* Actually use the client suggested buffer size.

* When the client didn't suggest it, take the sample
   size into account.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38494 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-09-01 14:51:37 +00:00
parent 2c1e15255e
commit b4a9b7c236

View File

@ -373,18 +373,25 @@ AVCodecDecoder::_NegotiateAudioOutputFormat(media_format* inOutFormat)
outputAudioFormat.channel_count
= fInputFormat.u.encoded_audio.output.channel_count;
outputAudioFormat.format = fInputFormat.u.encoded_audio.output.format;
outputAudioFormat.buffer_size
= inOutFormat->u.raw_audio.buffer_size;
// Check that format is not still a wild card!
if (outputAudioFormat.format == 0) {
TRACE(" format still a wild-card, assuming B_AUDIO_SHORT.\n");
outputAudioFormat.format = media_raw_audio_format::B_AUDIO_SHORT;
}
size_t sampleSize = outputAudioFormat.format
& media_raw_audio_format::B_AUDIO_SIZE_MASK;
// Check that channel count is not still a wild card!
if (outputAudioFormat.channel_count == 0) {
TRACE(" channel_count still a wild-card, assuming stereo.\n");
outputAudioFormat.channel_count = 2;
}
outputAudioFormat.buffer_size = 1024 * outputAudioFormat.channel_count;
if (outputAudioFormat.buffer_size == 0) {
outputAudioFormat.buffer_size = 512
* sampleSize * outputAudioFormat.channel_count;
}
inOutFormat->type = B_MEDIA_RAW_AUDIO;
inOutFormat->u.raw_audio = outputAudioFormat;
@ -423,8 +430,6 @@ AVCodecDecoder::_NegotiateAudioOutputFormat(media_format* inOutFormat)
fCodecInitDone = (result >= 0);
fStartTime = 0;
size_t sampleSize = outputAudioFormat.format
& media_raw_audio_format::B_AUDIO_SIZE_MASK;
fOutputFrameSize = sampleSize * outputAudioFormat.channel_count;
fOutputFrameCount = outputAudioFormat.buffer_size / fOutputFrameSize;
fOutputFrameRate = outputAudioFormat.frame_rate;