Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(701)

Side by Side Diff: media/audio/win/audio_unified_win.cc

Issue 17377004: Resolves crash in media::ChannelMixer::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/win/audio_unified_win.h" 5 #include "media/audio/win/audio_unified_win.h"
6 6
7 #include <Functiondiscoverykeys_devpkey.h> 7 #include <Functiondiscoverykeys_devpkey.h>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #ifndef NDEBUG 10 #ifndef NDEBUG
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 SetIOFormats(hw_input_params, params_); 273 SetIOFormats(hw_input_params, params_);
274 274
275 // Create the input and output busses. 275 // Create the input and output busses.
276 input_bus_ = AudioBus::Create( 276 input_bus_ = AudioBus::Create(
277 hw_input_params.channels(), input_buffer_size_frames_); 277 hw_input_params.channels(), input_buffer_size_frames_);
278 output_bus_ = AudioBus::Create(params_); 278 output_bus_ = AudioBus::Create(params_);
279 279
280 // One extra bus is needed for the input channel mixing case. 280 // One extra bus is needed for the input channel mixing case.
281 if (channel_mixer_) { 281 if (channel_mixer_) {
282 DCHECK_LT(hw_input_params.channels(), input_channels_); 282 DCHECK_LT(hw_input_params.channels(), input_channels_);
283 channel_bus_ = AudioBus::Create(input_channels_, input_bus_->frames()); 283 // The size of the |channel_bus_| must be the same as the size of the
284 // output bus to ensure that the channel manager can deal with both
285 // resampled and non-resampled data as input.
286 channel_bus_ = AudioBus::Create(
287 input_channels_, params_.frames_per_buffer());
284 } 288 }
285 289
286 // Check if FIFO and resampling is required to match the input rate to the 290 // Check if FIFO and resampling is required to match the input rate to the
287 // output rate. If so, a special thread loop, optimized for this case, will 291 // output rate. If so, a special thread loop, optimized for this case, will
288 // be used. This mode is also called varispeed mode. 292 // be used. This mode is also called varispeed mode.
289 // Note that we can also use this mode when input and output rates are the 293 // Note that we can also use this mode when input and output rates are the
290 // same but native buffer sizes differ (can happen if two different audio 294 // same but native buffer sizes differ (can happen if two different audio
291 // devices are used). For this case, the resampler uses a target ratio of 295 // devices are used). For this case, the resampler uses a target ratio of
292 // 1.0 but SetRatio is called to compensate for clock-drift. The FIFO is 296 // 1.0 but SetRatio is called to compensate for clock-drift. The FIFO is
293 // required to compensate for the difference in buffer sizes. 297 // required to compensate for the difference in buffer sizes.
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 update_output_delay_ = false; 909 update_output_delay_ = false;
906 } 910 }
907 911
908 // Select source depending on if varispeed is utilized or not. 912 // Select source depending on if varispeed is utilized or not.
909 // Also, the source might be the output of a channel mixer if channel mixing 913 // Also, the source might be the output of a channel mixer if channel mixing
910 // is required to match the native input channels to the number of input 914 // is required to match the native input channels to the number of input
911 // channels used by the client (given by |input_channels_| in this case). 915 // channels used by the client (given by |input_channels_| in this case).
912 AudioBus* input_bus = VarispeedMode() ? 916 AudioBus* input_bus = VarispeedMode() ?
913 resampled_bus_.get() : input_bus_.get(); 917 resampled_bus_.get() : input_bus_.get();
914 if (channel_mixer_) { 918 if (channel_mixer_) {
919 DCHECK_EQ(input_bus->frames(), channel_bus_->frames());
915 // Most common case is 1->2 channel upmixing. 920 // Most common case is 1->2 channel upmixing.
916 channel_mixer_->Transform(input_bus, channel_bus_.get()); 921 channel_mixer_->Transform(input_bus, channel_bus_.get());
917 // Use the output from the channel mixer as new input bus. 922 // Use the output from the channel mixer as new input bus.
918 input_bus = channel_bus_.get(); 923 input_bus = channel_bus_.get();
919 } 924 }
920 925
921 // Prepare for rendering by calling OnMoreIOData(). 926 // Prepare for rendering by calling OnMoreIOData().
922 int frames_filled = source_->OnMoreIOData( 927 int frames_filled = source_->OnMoreIOData(
923 input_bus, 928 input_bus,
924 output_bus_.get(), 929 output_bus_.get(),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 void WASAPIUnifiedStream::StopAndJoinThread(HRESULT err) { 978 void WASAPIUnifiedStream::StopAndJoinThread(HRESULT err) {
974 CHECK(GetCurrentThreadId() == creating_thread_id_); 979 CHECK(GetCurrentThreadId() == creating_thread_id_);
975 DCHECK(audio_io_thread_.get()); 980 DCHECK(audio_io_thread_.get());
976 SetEvent(stop_streaming_event_.Get()); 981 SetEvent(stop_streaming_event_.Get());
977 audio_io_thread_->Join(); 982 audio_io_thread_->Join();
978 audio_io_thread_.reset(); 983 audio_io_thread_.reset();
979 HandleError(err); 984 HandleError(err);
980 } 985 }
981 986
982 } // namespace media 987 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698