added helper functions for buffer<->framerate<->duration conversions
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3645 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "MixerUtils.h"
|
#include "MixerUtils.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@@ -159,3 +160,31 @@ CopySamples(float *_dst, int32 _dst_sample_offset,
|
|||||||
dst += dst_sample_offset;
|
dst += dst_sample_offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64
|
||||||
|
frames_for_duration(double framerate, bigtime_t duration)
|
||||||
|
{
|
||||||
|
return (int64) ceil(framerate * double(duration) / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bigtime_t
|
||||||
|
duration_for_frames(double framerate, int64 frames)
|
||||||
|
{
|
||||||
|
return (bigtime_t)((1000000.0 * frames) / framerate);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
bytes_per_frame(const media_multi_audio_format & format)
|
||||||
|
{
|
||||||
|
return format.channel_count * (format.format & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
frames_per_buffer(const media_multi_audio_format & format)
|
||||||
|
{
|
||||||
|
int frames = 0;
|
||||||
|
if (bytes_per_frame(format) > 0) {
|
||||||
|
frames = format.buffer_size / bytes_per_frame(format);
|
||||||
|
}
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include <math.h>
|
|
||||||
|
|
||||||
void string_for_channel_mask(char *str, uint32 mask);
|
void string_for_channel_mask(char *str, uint32 mask);
|
||||||
void fix_multiaudio_format(media_multi_audio_format *format);
|
void fix_multiaudio_format(media_multi_audio_format *format);
|
||||||
@@ -13,13 +12,11 @@ void CopySamples(float *_dst, int32 _dst_sample_offset,
|
|||||||
const float *_src, int32 _src_sample_offset,
|
const float *_src, int32 _src_sample_offset,
|
||||||
int32 _sample_count);
|
int32 _sample_count);
|
||||||
|
|
||||||
|
int bytes_per_frame(const media_multi_audio_format & format);
|
||||||
|
int frames_per_buffer(const media_multi_audio_format & format);
|
||||||
|
|
||||||
int64 frames_for_duration(double framerate, bigtime_t duration);
|
int64 frames_for_duration(double framerate, bigtime_t duration);
|
||||||
|
bigtime_t duration_for_frames(double framerate, int64 frames);
|
||||||
inline int64 frames_for_duration(double framerate, bigtime_t duration)
|
|
||||||
{
|
|
||||||
return (int64) ceil(framerate * double(duration) / 1000000.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ChannelMaskToChannelType(uint32 mask);
|
int ChannelMaskToChannelType(uint32 mask);
|
||||||
uint32 ChannelTypeToChannelMask(int type);
|
uint32 ChannelTypeToChannelMask(int type);
|
||||||
|
|||||||
Reference in New Issue
Block a user