| 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 // AudioRendererHost serves audio related requests from AudioRenderer which | 5 // AudioRendererHost serves audio related requests from AudioRenderer which |
| 6 // lives inside the render process and provide access to audio hardware. | 6 // lives inside the render process and provide access to audio hardware. |
| 7 // | 7 // |
| 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI | 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI |
| 9 // thread, but all other operations and method calls happen on IO thread, so we | 9 // thread, but all other operations and method calls happen on IO thread, so we |
| 10 // need to be extra careful about the lifetime of this object. AudioManager is a | 10 // need to be extra careful about the lifetime of this object. AudioManager is a |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // | CloseStream > | | 32 // | CloseStream > | |
| 33 // v v | 33 // v v |
| 34 | 34 |
| 35 // A SyncSocket pair is used to signal buffer readiness between processes. | 35 // A SyncSocket pair is used to signal buffer readiness between processes. |
| 36 | 36 |
| 37 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 37 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
| 38 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 38 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
| 39 | 39 |
| 40 #include <map> | 40 #include <map> |
| 41 | 41 |
| 42 #include "base/atomic_ref_count.h" |
| 42 #include "base/gtest_prod_util.h" | 43 #include "base/gtest_prod_util.h" |
| 43 #include "base/memory/ref_counted.h" | 44 #include "base/memory/ref_counted.h" |
| 44 #include "base/memory/scoped_ptr.h" | 45 #include "base/memory/scoped_ptr.h" |
| 45 #include "base/process/process.h" | 46 #include "base/process/process.h" |
| 46 #include "base/sequenced_task_runner_helpers.h" | 47 #include "base/sequenced_task_runner_helpers.h" |
| 47 #include "content/common/content_export.h" | 48 #include "content/common/content_export.h" |
| 48 #include "content/public/browser/browser_message_filter.h" | 49 #include "content/public/browser/browser_message_filter.h" |
| 49 #include "content/public/browser/browser_thread.h" | 50 #include "content/public/browser/browser_thread.h" |
| 50 #include "content/public/browser/render_view_host.h" | 51 #include "content/public/browser/render_view_host.h" |
| 51 #include "media/audio/audio_io.h" | 52 #include "media/audio/audio_io.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 77 // Calls |callback| with the list of AudioOutputControllers for this object. | 78 // Calls |callback| with the list of AudioOutputControllers for this object. |
| 78 void GetOutputControllers( | 79 void GetOutputControllers( |
| 79 int render_view_id, | 80 int render_view_id, |
| 80 const RenderViewHost::GetAudioOutputControllersCallback& callback) const; | 81 const RenderViewHost::GetAudioOutputControllersCallback& callback) const; |
| 81 | 82 |
| 82 // BrowserMessageFilter implementation. | 83 // BrowserMessageFilter implementation. |
| 83 virtual void OnChannelClosing() OVERRIDE; | 84 virtual void OnChannelClosing() OVERRIDE; |
| 84 virtual void OnDestruct() const OVERRIDE; | 85 virtual void OnDestruct() const OVERRIDE; |
| 85 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 86 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 86 | 87 |
| 88 // Returns true if any streams managed by this host are actively playing. Can |
| 89 // be called from any thread. |
| 90 bool HasActiveAudio(); |
| 91 |
| 87 private: | 92 private: |
| 88 friend class AudioRendererHostTest; | 93 friend class AudioRendererHostTest; |
| 89 friend class BrowserThread; | 94 friend class BrowserThread; |
| 90 friend class base::DeleteHelper<AudioRendererHost>; | 95 friend class base::DeleteHelper<AudioRendererHost>; |
| 91 friend class MockAudioRendererHost; | 96 friend class MockAudioRendererHost; |
| 92 friend class TestAudioRendererHost; | 97 friend class TestAudioRendererHost; |
| 93 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); | 98 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); |
| 94 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); | 99 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); |
| 95 | 100 |
| 96 class AudioEntry; | 101 class AudioEntry; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 media::AudioManager* const audio_manager_; | 163 media::AudioManager* const audio_manager_; |
| 159 AudioMirroringManager* const mirroring_manager_; | 164 AudioMirroringManager* const mirroring_manager_; |
| 160 scoped_ptr<media::AudioLog> audio_log_; | 165 scoped_ptr<media::AudioLog> audio_log_; |
| 161 | 166 |
| 162 // Used to access to AudioInputDeviceManager. | 167 // Used to access to AudioInputDeviceManager. |
| 163 MediaStreamManager* media_stream_manager_; | 168 MediaStreamManager* media_stream_manager_; |
| 164 | 169 |
| 165 // A map of stream IDs to audio sources. | 170 // A map of stream IDs to audio sources. |
| 166 AudioEntryMap audio_entries_; | 171 AudioEntryMap audio_entries_; |
| 167 | 172 |
| 173 // The number of streams in the playing state. |
| 174 base::AtomicRefCount num_playing_streams_; |
| 175 |
| 168 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 176 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
| 169 }; | 177 }; |
| 170 | 178 |
| 171 } // namespace content | 179 } // namespace content |
| 172 | 180 |
| 173 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 181 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
| OLD | NEW |