suggest buffer size of 50 ms
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6098 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,6 +14,12 @@
|
|||||||
|
|
||||||
#define DECODE_BUFFER_SIZE (32 * 1024)
|
#define DECODE_BUFFER_SIZE (32 * 1024)
|
||||||
|
|
||||||
|
inline size_t
|
||||||
|
AudioBufferSize(int32 channel_count, uint32 sample_format, float frame_rate, bigtime_t buffer_duration = 50000 /* 50 ms */)
|
||||||
|
{
|
||||||
|
return (sample_format & 0xf) * channel_count * (size_t)((frame_rate * buffer_duration) / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
// bit_rate_table[mpeg_version_index][layer_index][bitrate_index]
|
// bit_rate_table[mpeg_version_index][layer_index][bitrate_index]
|
||||||
static const int bit_rate_table[4][4][16] =
|
static const int bit_rate_table[4][4][16] =
|
||||||
{
|
{
|
||||||
@@ -117,7 +123,7 @@ mp3Decoder::NegotiateOutputFormat(media_format *ioDecodedFormat)
|
|||||||
ioDecodedFormat->u.raw_audio.format = media_raw_audio_format::B_AUDIO_SHORT; // XXX should support other formats, too
|
ioDecodedFormat->u.raw_audio.format = media_raw_audio_format::B_AUDIO_SHORT; // XXX should support other formats, too
|
||||||
ioDecodedFormat->u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN; // XXX should support other endain, too
|
ioDecodedFormat->u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN; // XXX should support other endain, too
|
||||||
if (ioDecodedFormat->u.raw_audio.buffer_size < 512 || ioDecodedFormat->u.raw_audio.buffer_size > 65536)
|
if (ioDecodedFormat->u.raw_audio.buffer_size < 512 || ioDecodedFormat->u.raw_audio.buffer_size > 65536)
|
||||||
ioDecodedFormat->u.raw_audio.buffer_size = BMediaRoster::Roster()->AudioBufferSizeFor(
|
ioDecodedFormat->u.raw_audio.buffer_size = AudioBufferSize(
|
||||||
fChannelCount,
|
fChannelCount,
|
||||||
ioDecodedFormat->u.raw_audio.format,
|
ioDecodedFormat->u.raw_audio.format,
|
||||||
fFrameRate);
|
fFrameRate);
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
#define TRACE(a...)
|
#define TRACE(a...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline size_t
|
||||||
|
AudioBufferSize(int32 channel_count, uint32 sample_format, float frame_rate, bigtime_t buffer_duration = 50000 /* 50 ms */)
|
||||||
|
{
|
||||||
|
return (sample_format & 0xf) * channel_count * (size_t)((frame_rate * buffer_duration) / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
RawDecoder::Setup(media_format *ioEncodedFormat,
|
RawDecoder::Setup(media_format *ioEncodedFormat,
|
||||||
@@ -63,6 +68,13 @@ RawDecoder::Setup(media_format *ioEncodedFormat,
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// since we can translate to a different buffer size,
|
||||||
|
// suggest something nicer than delivered by the
|
||||||
|
// file reader (perhaps we should even report wildcard?)
|
||||||
|
ioEncodedFormat->u.raw_audio.buffer_size = AudioBufferSize(
|
||||||
|
ioEncodedFormat->u.raw_audio.channel_count,
|
||||||
|
ioEncodedFormat->u.raw_audio.format,
|
||||||
|
ioEncodedFormat->u.raw_audio.frame_rate);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +160,7 @@ RawDecoder::NegotiateAudioOutputFormat(media_format *ioDecodedFormat)
|
|||||||
ioDecodedFormat->u.raw_audio.matrix_mask = 0;
|
ioDecodedFormat->u.raw_audio.matrix_mask = 0;
|
||||||
|
|
||||||
if (ioDecodedFormat->u.raw_audio.buffer_size < 128 || ioDecodedFormat->u.raw_audio.buffer_size > 65536) {
|
if (ioDecodedFormat->u.raw_audio.buffer_size < 128 || ioDecodedFormat->u.raw_audio.buffer_size > 65536) {
|
||||||
ioDecodedFormat->u.raw_audio.buffer_size = BMediaRoster::Roster()->AudioBufferSizeFor(
|
ioDecodedFormat->u.raw_audio.buffer_size = AudioBufferSize(
|
||||||
ioDecodedFormat->u.raw_audio.channel_count,
|
ioDecodedFormat->u.raw_audio.channel_count,
|
||||||
ioDecodedFormat->u.raw_audio.format,
|
ioDecodedFormat->u.raw_audio.format,
|
||||||
ioDecodedFormat->u.raw_audio.frame_rate);
|
ioDecodedFormat->u.raw_audio.frame_rate);
|
||||||
|
|||||||
@@ -15,6 +15,12 @@
|
|||||||
|
|
||||||
#define DECODE_BUFFER_SIZE (32 * 1024)
|
#define DECODE_BUFFER_SIZE (32 * 1024)
|
||||||
|
|
||||||
|
inline size_t
|
||||||
|
AudioBufferSize(int32 channel_count, uint32 sample_format, float frame_rate, bigtime_t buffer_duration = 50000 /* 50 ms */)
|
||||||
|
{
|
||||||
|
return (sample_format & 0xf) * channel_count * (size_t)((frame_rate * buffer_duration) / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
vorbisDecoder::vorbisDecoder()
|
vorbisDecoder::vorbisDecoder()
|
||||||
{
|
{
|
||||||
TRACE("vorbisDecoder::vorbisDecoder\n");
|
TRACE("vorbisDecoder::vorbisDecoder\n");
|
||||||
@@ -103,9 +109,7 @@ void vorbisDecoder::CopyInfoToDecodedFormat(media_raw_audio_format * raf) {
|
|||||||
raf->byte_order = B_MEDIA_HOST_ENDIAN; // XXX should support other endain, too
|
raf->byte_order = B_MEDIA_HOST_ENDIAN; // XXX should support other endain, too
|
||||||
|
|
||||||
if (raf->buffer_size < 512 || raf->buffer_size > 65536) {
|
if (raf->buffer_size < 512 || raf->buffer_size > 65536) {
|
||||||
BMediaRoster * roster = BMediaRoster::Roster();
|
raf->buffer_size = AudioBufferSize(raf->channel_count,raf->format,raf->frame_rate);
|
||||||
raf->buffer_size
|
|
||||||
= roster->AudioBufferSizeFor(raf->channel_count,raf->format,raf->frame_rate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user