Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> | |
|
Max Morin
2017/02/16 15:10:51
Linter wanted it for move.
| |
| 10 | |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 12 #include "base/debug/alias.h" | 14 #include "base/debug/alias.h" |
| 13 #include "base/debug/crash_logging.h" | 15 #include "base/debug/crash_logging.h" |
| 14 #include "base/debug/dump_without_crashing.h" | 16 #include "base/debug/dump_without_crashing.h" |
| 15 #include "base/logging.h" | 17 #include "base/logging.h" |
| 16 #include "base/macros.h" | 18 #include "base/macros.h" |
| 17 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 18 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 } | 282 } |
| 281 | 283 |
| 282 #if defined(OS_MACOSX) | 284 #if defined(OS_MACOSX) |
| 283 // If we are on Mac, tasks after this point are not executed, hence this is | 285 // If we are on Mac, tasks after this point are not executed, hence this is |
| 284 // the only chance to delete the audio manager (which on Mac lives on the | 286 // the only chance to delete the audio manager (which on Mac lives on the |
| 285 // main browser thread instead of a dedicated audio thread). If we don't | 287 // main browser thread instead of a dedicated audio thread). If we don't |
| 286 // delete here, the CoreAudio thread can keep providing callbacks, which | 288 // delete here, the CoreAudio thread can keep providing callbacks, which |
| 287 // uses a state that is destroyed in ~BrowserMainLoop(). | 289 // uses a state that is destroyed in ~BrowserMainLoop(). |
| 288 // See http://crbug.com/623703 for more details. | 290 // See http://crbug.com/623703 for more details. |
| 289 DCHECK(instance->GetTaskRunner()->BelongsToCurrentThread()); | 291 DCHECK(instance->GetTaskRunner()->BelongsToCurrentThread()); |
| 290 AudioManagerMac* mac_instance = | 292 delete instance; |
| 291 static_cast<AudioManagerMac*>(const_cast<AudioManager*>(instance)); | |
| 292 delete mac_instance; | |
| 293 #else | 293 #else |
| 294 // AudioManager must be destroyed on the audio thread. | 294 // AudioManager must be destroyed on the audio thread. |
| 295 if (!instance->GetTaskRunner()->DeleteSoon(FROM_HERE, instance)) { | 295 if (!instance->GetTaskRunner()->DeleteSoon(FROM_HERE, instance)) { |
| 296 LOG(WARNING) << "Failed to delete AudioManager instance."; | 296 LOG(WARNING) << "Failed to delete AudioManager instance."; |
| 297 } | 297 } |
| 298 #endif | 298 #endif |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Forward declaration of the platform specific AudioManager factory function. | 301 // Forward declaration of the platform specific AudioManager factory function. |
| 302 ScopedAudioManagerPtr CreateAudioManager( | 302 ScopedAudioManagerPtr CreateAudioManager( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 return GetHelper()->app_name(); | 380 return GetHelper()->app_name(); |
| 381 } | 381 } |
| 382 #endif | 382 #endif |
| 383 | 383 |
| 384 // static | 384 // static |
| 385 AudioManager* AudioManager::Get() { | 385 AudioManager* AudioManager::Get() { |
| 386 return g_last_created; | 386 return g_last_created; |
| 387 } | 387 } |
| 388 | 388 |
| 389 } // namespace media | 389 } // namespace media |
| OLD | NEW |