OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sounds/sounds_manager.h" | 5 #include "media/audio/sounds/sounds_manager.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "media/audio/audio_manager.h" | 12 #include "media/audio/audio_manager.h" |
13 #include "media/audio/sounds/audio_stream_handler.h" | 13 #include "media/audio/sounds/audio_stream_handler.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 SoundsManager* g_instance = NULL; | 19 SoundsManager* g_instance = NULL; |
20 bool g_initialized_for_testing = false; | 20 bool g_initialized_for_testing = false; |
21 | 21 |
22 // SoundsManagerImpl --------------------------------------------------- | 22 // SoundsManagerImpl --------------------------------------------------- |
23 | 23 |
24 class SoundsManagerImpl : public SoundsManager { | 24 class SoundsManagerImpl : public SoundsManager { |
25 public: | 25 public: |
26 SoundsManagerImpl(); | 26 SoundsManagerImpl(); |
27 virtual ~SoundsManagerImpl(); | 27 ~SoundsManagerImpl() override; |
28 | 28 |
29 // SoundsManager implementation: | 29 // SoundsManager implementation: |
30 virtual bool Initialize(SoundKey key, | 30 bool Initialize(SoundKey key, const base::StringPiece& data) override; |
31 const base::StringPiece& data) override; | 31 bool Play(SoundKey key) override; |
32 virtual bool Play(SoundKey key) override; | 32 base::TimeDelta GetDuration(SoundKey key) override; |
33 virtual base::TimeDelta GetDuration(SoundKey key) override; | |
34 | 33 |
35 private: | 34 private: |
36 base::hash_map<SoundKey, linked_ptr<AudioStreamHandler> > handlers_; | 35 base::hash_map<SoundKey, linked_ptr<AudioStreamHandler> > handlers_; |
37 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 36 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
38 | 37 |
39 DISALLOW_COPY_AND_ASSIGN(SoundsManagerImpl); | 38 DISALLOW_COPY_AND_ASSIGN(SoundsManagerImpl); |
40 }; | 39 }; |
41 | 40 |
42 SoundsManagerImpl::SoundsManagerImpl() | 41 SoundsManagerImpl::SoundsManagerImpl() |
43 : task_runner_(AudioManager::Get()->GetTaskRunner()) { | 42 : task_runner_(AudioManager::Get()->GetTaskRunner()) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 107 |
109 // static | 108 // static |
110 void SoundsManager::InitializeForTesting(SoundsManager* manager) { | 109 void SoundsManager::InitializeForTesting(SoundsManager* manager) { |
111 CHECK(!g_instance) << "SoundsManager is already initialized."; | 110 CHECK(!g_instance) << "SoundsManager is already initialized."; |
112 CHECK(manager); | 111 CHECK(manager); |
113 g_instance = manager; | 112 g_instance = manager; |
114 g_initialized_for_testing = true; | 113 g_initialized_for_testing = true; |
115 } | 114 } |
116 | 115 |
117 } // namespace media | 116 } // namespace media |
OLD | NEW |