diff options
author | sjl@google.com <sjl@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-01 17:47:27 +0000 |
---|---|---|
committer | sjl@google.com <sjl@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-01 17:47:27 +0000 |
commit | e55ad123ef3c6db8af401ea8ae52f6612c71bbbe (patch) | |
tree | 03e49b46fe92dc93ad0f262debe5fb703ca0e1d1 /media | |
parent | 9fd250ca267e0d477b3de557b8e8571eb9a901dd (diff) | |
download | chromium_src-e55ad123ef3c6db8af401ea8ae52f6612c71bbbe.zip chromium_src-e55ad123ef3c6db8af401ea8ae52f6612c71bbbe.tar.gz chromium_src-e55ad123ef3c6db8af401ea8ae52f6612c71bbbe.tar.bz2 |
Mac platform was not treating 8bit PCM audio as unsigned data.
If bits per channel is 8, open the stream as unsigned and use 128 as the silence value.
BUG=70730
TEST=media_unittests and manual testing of a bunch of audio files (8 bit and others).
Review URL: http://codereview.chromium.org/6689003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80181 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/mac/audio_output_mac.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc index ab96bd6..c940b5a 100644 --- a/media/audio/mac/audio_output_mac.cc +++ b/media/audio/mac/audio_output_mac.cc @@ -56,8 +56,7 @@ PCMQueueOutAudioOutputStream::PCMQueueOutAudioOutputStream( // packet is always one frame. format_.mSampleRate = params.sample_rate; format_.mFormatID = kAudioFormatLinearPCM; - format_.mFormatFlags = kLinearPCMFormatFlagIsPacked | - kLinearPCMFormatFlagIsSignedInteger; + format_.mFormatFlags = kLinearPCMFormatFlagIsPacked; format_.mBitsPerChannel = params.bits_per_sample; format_.mChannelsPerFrame = params.channels; format_.mFramesPerPacket = 1; @@ -66,6 +65,10 @@ PCMQueueOutAudioOutputStream::PCMQueueOutAudioOutputStream( packet_size_ = params.GetPacketSize(); + if (params.bits_per_sample > 8) { + format_.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; + } + // Silence buffer has a duration of 6ms to simulate the behavior of Windows. // This value is choosen by experiments and macs cannot keep up with // anything less than 6ms. @@ -219,7 +222,15 @@ void PCMQueueOutAudioOutputStream::RenderCallback(void* p_this, if (!filled) { CHECK(audio_stream->silence_bytes_ <= static_cast<int>(capacity)); filled = audio_stream->silence_bytes_; - memset(buffer->mAudioData, 0, filled); + + // Assume unsigned audio. + int silence_value = 128; + if (audio_stream->format_.mBitsPerChannel > 8) { + // When bits per channel is greater than 8, audio is signed. + silence_value = 0; + } + + memset(buffer->mAudioData, silence_value, filled); static_cast<AudioQueueUserData*>(buffer->mUserData)->empty_buffer = true; } else if (filled > capacity) { // User probably overran our buffer. @@ -242,7 +253,7 @@ void PCMQueueOutAudioOutputStream::RenderCallback(void* p_this, buffer->mAudioDataByteSize = filled; - // Incremnet bytes by amount filled into audio buffer if this is not a + // Increment bytes by amount filled into audio buffer if this is not a // silence buffer. if (!static_cast<AudioQueueUserData*>(buffer->mUserData)->empty_buffer) audio_stream->pending_bytes_ += filled; |