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

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

Issue 2763383002: Switching AudioInputDeviceManager from using AudioManager interface to AudioSystem one. (Closed)
Patch Set: review comments addressed Created 3 years, 8 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
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.h" 5 #include "media/audio/audio_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // because the destructor runs on the audio thread. We want to always change 247 // because the destructor runs on the audio thread. We want to always change
248 // g_last_created from the main thread. 248 // g_last_created from the main thread.
249 if (g_last_created == instance) { 249 if (g_last_created == instance) {
250 g_last_created = nullptr; 250 g_last_created = nullptr;
251 } else { 251 } else {
252 // We create multiple instances of AudioManager only when testing. 252 // We create multiple instances of AudioManager only when testing.
253 // We should not encounter this case in production. 253 // We should not encounter this case in production.
254 LOG(WARNING) << "Multiple instances of AudioManager detected"; 254 LOG(WARNING) << "Multiple instances of AudioManager detected";
255 } 255 }
256 256
257 #if defined(OS_MACOSX)
258 // If we are on Mac, tasks after this point are not executed, hence this is 257 // If we are on Mac, tasks after this point are not executed, hence this is
Guido Urdaneta 2017/04/06 14:26:41 The code is no longer Mac specific. Update the com
DaleCurtis 2017/04/06 18:37:17 Comment needs to change. Did you mean to leave thi
o1ka 2017/04/07 12:22:17 Done.
o1ka 2017/04/07 12:22:17 Done.
259 // the only chance to delete the audio manager (which on Mac lives on the 258 // the only chance to delete the audio manager (which on Mac lives on the
260 // main browser thread instead of a dedicated audio thread). If we don't 259 // main browser thread instead of a dedicated audio thread). If we don't
261 // delete here, the CoreAudio thread can keep providing callbacks, which 260 // delete here, the CoreAudio thread can keep providing callbacks, which
262 // uses a state that is destroyed in ~BrowserMainLoop(). 261 // uses a state that is destroyed in ~BrowserMainLoop().
263 // See http://crbug.com/623703 for more details. 262 // See http://crbug.com/623703 for more details.
264 DCHECK(instance->GetTaskRunner()->BelongsToCurrentThread()); 263 if (instance->GetTaskRunner()->BelongsToCurrentThread()) {
265 delete instance; 264 delete instance;
266 #else 265 return;
266 }
267
267 // AudioManager must be destroyed on the audio thread. 268 // AudioManager must be destroyed on the audio thread.
268 if (!instance->GetTaskRunner()->DeleteSoon(FROM_HERE, instance)) { 269 if (!instance->GetTaskRunner()->DeleteSoon(FROM_HERE, instance))
269 LOG(WARNING) << "Failed to delete AudioManager instance."; 270 LOG(WARNING) << "Failed to delete AudioManager instance.";
270 }
271 #endif
272 } 271 }
273 272
274 // Forward declaration of the platform specific AudioManager factory function. 273 // Forward declaration of the platform specific AudioManager factory function.
275 ScopedAudioManagerPtr CreateAudioManager( 274 ScopedAudioManagerPtr CreateAudioManager(
276 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 275 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
277 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 276 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
278 AudioLogFactory* audio_log_factory); 277 AudioLogFactory* audio_log_factory);
279 278
280 void AudioManager::SetMaxStreamCountForTesting(int max_input, int max_output) { 279 void AudioManager::SetMaxStreamCountForTesting(int max_input, int max_output) {
281 NOTREACHED(); 280 NOTREACHED();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return GetHelper()->app_name(); 352 return GetHelper()->app_name();
354 } 353 }
355 #endif 354 #endif
356 355
357 // static 356 // static
358 AudioManager* AudioManager::Get() { 357 AudioManager* AudioManager::Get() {
359 return g_last_created; 358 return g_last_created;
360 } 359 }
361 360
362 } // namespace media 361 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698