diff options
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; |