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

Side by Side Diff: media/audio/audio_manager_base.cc

Issue 16286010: Removed the IsRecordingInProcess check for speech since it is not needed (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
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/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 dispatcher_->output_params == dispatcher_in->output_params && 64 dispatcher_->output_params == dispatcher_in->output_params &&
65 (!dispatcher_->input_params.input_channels() || 65 (!dispatcher_->input_params.input_channels() ||
66 dispatcher_->input_device_id == dispatcher_in->input_device_id)); 66 dispatcher_->input_device_id == dispatcher_in->input_device_id));
67 } 67 }
68 68
69 private: 69 private:
70 const DispatcherParams* dispatcher_; 70 const DispatcherParams* dispatcher_;
71 }; 71 };
72 72
73 AudioManagerBase::AudioManagerBase() 73 AudioManagerBase::AudioManagerBase()
74 : num_active_input_streams_(0), 74 : max_num_output_streams_(kDefaultMaxOutputStreams),
75 max_num_output_streams_(kDefaultMaxOutputStreams),
76 max_num_input_streams_(kDefaultMaxInputStreams), 75 max_num_input_streams_(kDefaultMaxInputStreams),
77 num_output_streams_(0), 76 num_output_streams_(0),
78 num_input_streams_(0), 77 num_input_streams_(0),
79 output_listeners_( 78 output_listeners_(
80 ObserverList<AudioDeviceListener>::NOTIFY_EXISTING_ONLY), 79 ObserverList<AudioDeviceListener>::NOTIFY_EXISTING_ONLY),
81 audio_thread_(new base::Thread("AudioThread")) { 80 audio_thread_(new base::Thread("AudioThread")) {
82 #if defined(OS_WIN) 81 #if defined(OS_WIN)
83 audio_thread_->init_com_with_mta(true); 82 audio_thread_->init_com_with_mta(true);
84 #endif 83 #endif
85 #if defined(OS_MACOSX) 84 #if defined(OS_MACOSX)
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 delete stream; 284 delete stream;
286 } 285 }
287 286
288 void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) { 287 void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) {
289 DCHECK(stream); 288 DCHECK(stream);
290 // TODO(xians) : Have a clearer destruction path for the AudioInputStream. 289 // TODO(xians) : Have a clearer destruction path for the AudioInputStream.
291 --num_input_streams_; 290 --num_input_streams_;
292 delete stream; 291 delete stream;
293 } 292 }
294 293
295 void AudioManagerBase::IncreaseActiveInputStreamCount() {
296 base::AtomicRefCountInc(&num_active_input_streams_);
297 }
298
299 void AudioManagerBase::DecreaseActiveInputStreamCount() {
300 DCHECK(IsRecordingInProcess());
301 base::AtomicRefCountDec(&num_active_input_streams_);
302 }
303
304 bool AudioManagerBase::IsRecordingInProcess() {
305 return !base::AtomicRefCountIsZero(&num_active_input_streams_);
306 }
307
308 void AudioManagerBase::Shutdown() { 294 void AudioManagerBase::Shutdown() {
309 // To avoid running into deadlocks while we stop the thread, shut it down 295 // To avoid running into deadlocks while we stop the thread, shut it down
310 // via a local variable while not holding the audio thread lock. 296 // via a local variable while not holding the audio thread lock.
311 scoped_ptr<base::Thread> audio_thread; 297 scoped_ptr<base::Thread> audio_thread;
312 { 298 {
313 base::AutoLock lock(audio_thread_lock_); 299 base::AutoLock lock(audio_thread_lock_);
314 audio_thread_.swap(audio_thread); 300 audio_thread_.swap(audio_thread);
315 } 301 }
316 302
317 if (!audio_thread) 303 if (!audio_thread)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 return GetPreferredOutputStreamParameters(AudioParameters()); 365 return GetPreferredOutputStreamParameters(AudioParameters());
380 } 366 }
381 367
382 AudioParameters AudioManagerBase::GetInputStreamParameters( 368 AudioParameters AudioManagerBase::GetInputStreamParameters(
383 const std::string& device_id) { 369 const std::string& device_id) {
384 NOTREACHED(); 370 NOTREACHED();
385 return AudioParameters(); 371 return AudioParameters();
386 } 372 }
387 373
388 } // namespace media 374 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698