| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/audio/audio_system.h" |
| 6 |
| 7 namespace media { |
| 8 |
| 9 static AudioSystem* g_last_created = nullptr; |
| 10 |
| 11 AudioSystem::~AudioSystem() {} |
| 12 |
| 13 AudioSystem* AudioSystem::Get() { |
| 14 return g_last_created; |
| 15 } |
| 16 |
| 17 void AudioSystem::SetInstance(AudioSystem* audio_system) { |
| 18 DCHECK(audio_system); |
| 19 if (g_last_created && audio_system) { |
| 20 // We create multiple instances of AudioSystem only when testing. |
| 21 // We should not encounter this case in production. |
| 22 LOG(WARNING) << "Multiple instances of AudioSystem detected"; |
| 23 } |
| 24 g_last_created = audio_system; |
| 25 } |
| 26 |
| 27 void AudioSystem::ClearInstance(const AudioSystem* audio_system) { |
| 28 DCHECK(audio_system); |
| 29 if (g_last_created != audio_system) { |
| 30 // We create multiple instances of AudioSystem only when testing. |
| 31 // We should not encounter this case in production. |
| 32 LOG(WARNING) << "Multiple instances of AudioSystem detected"; |
| 33 } else { |
| 34 g_last_created = nullptr; |
| 35 } |
| 36 } |
| 37 |
| 38 } // namespace media |
| OLD | NEW |