diff options
author | annacc@chromium.org <annacc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-01 22:01:56 +0000 |
---|---|---|
committer | annacc@chromium.org <annacc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-01 22:01:56 +0000 |
commit | 028e790790fd0fe16db630732a5d37628fb943bd (patch) | |
tree | 4e6db6e532dba7b9d520bcd7d9e6d54530ac8c20 | |
parent | 087e552e12e474e93cd0b18c98806a46e431c4d8 (diff) | |
download | chromium_src-028e790790fd0fe16db630732a5d37628fb943bd.zip chromium_src-028e790790fd0fe16db630732a5d37628fb943bd.tar.gz chromium_src-028e790790fd0fe16db630732a5d37628fb943bd.tar.bz2 |
Better memory management for audio channel swizzle code.
This patch fixes some of the errors created by: http://codereview.chromium.org/7047020/
To see memory issue suppressions, see http://codereview.chromium.org/7077020/ and http://codereview.chromium.org/7085020/
BUG=84142
TEST=tools/valgrind/chrome_tests.sh -t media --gtest_filter=MacAudioTest.*
Review URL: http://codereview.chromium.org/7094007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87535 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | media/audio/mac/audio_output_mac.cc | 26 | ||||
-rw-r--r-- | tools/valgrind/memcheck/suppressions_mac.txt | 22 |
2 files changed, 16 insertions, 32 deletions
diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc index b8e2938..cbc4f9e 100644 --- a/media/audio/mac/audio_output_mac.cc +++ b/media/audio/mac/audio_output_mac.cc @@ -42,14 +42,18 @@ enum { PCMQueueOutAudioOutputStream::PCMQueueOutAudioOutputStream( AudioManagerMac* manager, AudioParameters params) - : format_(), - audio_queue_(NULL), - buffer_(), + : audio_queue_(NULL), source_(NULL), manager_(manager), + packet_size_(params.GetPacketSize()), silence_bytes_(0), volume_(1), - pending_bytes_(0) { + pending_bytes_(0), + num_source_channels_(params.channels), + source_layout_(params.channel_layout), + num_core_channels_(0), + should_swizzle_(false), + should_down_mix_(false) { // We must have a manager. DCHECK(manager_); // A frame is one sample across all channels. In interleaved audio the per @@ -64,9 +68,8 @@ PCMQueueOutAudioOutputStream::PCMQueueOutAudioOutputStream( format_.mBytesPerPacket = (format_.mBitsPerChannel * params.channels) / 8; format_.mBytesPerFrame = format_.mBytesPerPacket; - packet_size_ = params.GetPacketSize(); - num_source_channels_ = params.channels; - source_layout_ = params.channel_layout; + memset(core_channel_orderings_, 0, sizeof(core_channel_orderings_)); + memset(channel_remap_, 0, sizeof(channel_remap_)); if (params.bits_per_sample > 8) { format_.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; @@ -116,10 +119,12 @@ bool PCMQueueOutAudioOutputStream::Open() { HandleError(err); return false; } - // Get the device's channel layout. - scoped_ptr<AudioChannelLayout> core_channel_layout; + // Get the device's channel layout. This layout may vary in sized based on + // the number of channels. Use |core_layout_size| to allocate memory. + scoped_ptr_malloc<AudioChannelLayout> core_channel_layout; core_channel_layout.reset( - reinterpret_cast<AudioChannelLayout*>(new char[core_layout_size])); + reinterpret_cast<AudioChannelLayout*>(malloc(core_layout_size))); + memset(core_channel_layout.get(), 0, core_layout_size); err = AudioDeviceGetProperty(device_id, 0, false, kAudioDevicePropertyPreferredChannelLayout, &core_layout_size, core_channel_layout.get()); @@ -217,6 +222,7 @@ bool PCMQueueOutAudioOutputStream::Open() { break; default: DLOG(WARNING) << "Channel label not supported"; + channel_remap_[i] = kEmptyChannel; break; } } diff --git a/tools/valgrind/memcheck/suppressions_mac.txt b/tools/valgrind/memcheck/suppressions_mac.txt index 0bdc4f57..1dba713 100644 --- a/tools/valgrind/memcheck/suppressions_mac.txt +++ b/tools/valgrind/memcheck/suppressions_mac.txt @@ -665,8 +665,6 @@ fun:AudioObjectGetPropertyData fun:*16HasAudioHardwareEm fun:_ZN15AudioManagerMac21HasAudioOutputDevicesEv - fun:_ZN5mediaL21HasAudioOutputDevicesEv - fun:_ZN5media45AudioOutputControllerTest_CreateAndClose_Test8TestBodyEv } { bug_46186_e @@ -1701,26 +1699,6 @@ fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc } { - bug_84142_a - Memcheck:Cond - fun:_ZN28PCMQueueOutAudioOutputStream13SwizzleLayoutIsEEvPT_j - fun:_ZN28PCMQueueOutAudioOutputStream14RenderCallbackEPvP16OpaqueAudioQueueP16AudioQueueBuffer -} -{ - bug_84142_b - Memcheck:Value4 - fun:_ZN28PCMQueueOutAudioOutputStream13SwizzleLayoutIsEEvPT_j - fun:_ZN28PCMQueueOutAudioOutputStream14RenderCallbackEPvP16OpaqueAudioQueueP16AudioQueueBuffer -} -{ - bug_84142_c - Memcheck:Free - fun:_ZdlPv - fun:_ZN10scoped_ptrI18AudioChannelLayoutED2Ev - fun:_ZN10scoped_ptrI18AudioChannelLayoutED1Ev - fun:_ZN28PCMQueueOutAudioOutputStream4OpenEv -} -{ bug_84329 Memcheck:Addr4 fun:_ZN3WTF17ChromiumThreading16callOnMainThreadEPFvPvES1_ |