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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host.h

Issue 9805001: Move media/audio files into media namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
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 // 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "base/message_loop_helpers.h" 46 #include "base/message_loop_helpers.h"
47 #include "base/process.h" 47 #include "base/process.h"
48 #include "base/shared_memory.h" 48 #include "base/shared_memory.h"
49 #include "content/common/content_export.h" 49 #include "content/common/content_export.h"
50 #include "content/public/browser/browser_message_filter.h" 50 #include "content/public/browser/browser_message_filter.h"
51 #include "content/public/browser/browser_thread.h" 51 #include "content/public/browser/browser_thread.h"
52 #include "media/audio/audio_io.h" 52 #include "media/audio/audio_io.h"
53 #include "media/audio/audio_output_controller.h" 53 #include "media/audio/audio_output_controller.h"
54 #include "media/audio/simple_sources.h" 54 #include "media/audio/simple_sources.h"
55 55
56 class AudioManager;
57 class AudioParameters;
58
59 namespace content { 56 namespace content {
60 class MediaObserver; 57 class MediaObserver;
61 class ResourceContext; 58 class ResourceContext;
62 } // namespace content 59 } // namespace content
63 60
61 namespace media {
62 class AudioManager;
63 class AudioParameters;
64 }
65
64 class CONTENT_EXPORT AudioRendererHost 66 class CONTENT_EXPORT AudioRendererHost
65 : public content::BrowserMessageFilter, 67 : public content::BrowserMessageFilter,
66 public media::AudioOutputController::EventHandler { 68 public media::AudioOutputController::EventHandler {
67 public: 69 public:
68 struct AudioEntry { 70 struct AudioEntry {
69 AudioEntry(); 71 AudioEntry();
70 ~AudioEntry(); 72 ~AudioEntry();
71 73
72 // The AudioOutputController that manages the audio stream. 74 // The AudioOutputController that manages the audio stream.
73 scoped_refptr<media::AudioOutputController> controller; 75 scoped_refptr<media::AudioOutputController> controller;
74 76
75 // The audio stream ID. 77 // The audio stream ID.
76 int stream_id; 78 int stream_id;
77 79
78 // Shared memory for transmission of the audio data. 80 // Shared memory for transmission of the audio data.
79 base::SharedMemory shared_memory; 81 base::SharedMemory shared_memory;
80 82
81 // The synchronous reader to be used by the controller. We have the 83 // The synchronous reader to be used by the controller. We have the
82 // ownership of the reader. 84 // ownership of the reader.
83 scoped_ptr<media::AudioOutputController::SyncReader> reader; 85 scoped_ptr<media::AudioOutputController::SyncReader> reader;
84 86
85 // Set to true after we called Close() for the controller. 87 // Set to true after we called Close() for the controller.
86 bool pending_close; 88 bool pending_close;
87 }; 89 };
88 90
89 typedef std::map<int, AudioEntry*> AudioEntryMap; 91 typedef std::map<int, AudioEntry*> AudioEntryMap;
90 92
91 // Called from UI thread from the owner of this object. 93 // Called from UI thread from the owner of this object.
92 AudioRendererHost(AudioManager* audio_manager, 94 AudioRendererHost(media::AudioManager* audio_manager,
93 content::MediaObserver* media_observer); 95 content::MediaObserver* media_observer);
94 96
95 // content::BrowserMessageFilter implementation. 97 // content::BrowserMessageFilter implementation.
96 virtual void OnChannelClosing() OVERRIDE; 98 virtual void OnChannelClosing() OVERRIDE;
97 virtual void OnDestruct() const OVERRIDE; 99 virtual void OnDestruct() const OVERRIDE;
98 virtual bool OnMessageReceived(const IPC::Message& message, 100 virtual bool OnMessageReceived(const IPC::Message& message,
99 bool* message_was_ok) OVERRIDE; 101 bool* message_was_ok) OVERRIDE;
100 102
101 // AudioOutputController::EventHandler implementations. 103 // AudioOutputController::EventHandler implementations.
102 virtual void OnCreated(media::AudioOutputController* controller) OVERRIDE; 104 virtual void OnCreated(media::AudioOutputController* controller) OVERRIDE;
(...skipping 11 matching lines...) Expand all
114 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); 116 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation);
115 117
116 virtual ~AudioRendererHost(); 118 virtual ~AudioRendererHost();
117 119
118 // Methods called on IO thread ---------------------------------------------- 120 // Methods called on IO thread ----------------------------------------------
119 121
120 // Audio related IPC message handlers. 122 // Audio related IPC message handlers.
121 // Creates an audio output stream with the specified format. If this call is 123 // Creates an audio output stream with the specified format. If this call is
122 // successful this object would keep an internal entry of the stream for the 124 // successful this object would keep an internal entry of the stream for the
123 // required properties. 125 // required properties.
124 void OnCreateStream(int stream_id, const AudioParameters& params); 126 void OnCreateStream(int stream_id, const media::AudioParameters& params);
125 127
126 // Play the audio stream referenced by |stream_id|. 128 // Play the audio stream referenced by |stream_id|.
127 void OnPlayStream(int stream_id); 129 void OnPlayStream(int stream_id);
128 130
129 // Pause the audio stream referenced by |stream_id|. 131 // Pause the audio stream referenced by |stream_id|.
130 void OnPauseStream(int stream_id); 132 void OnPauseStream(int stream_id);
131 133
132 // Discard all audio data in stream referenced by |stream_id|. 134 // Discard all audio data in stream referenced by |stream_id|.
133 void OnFlushStream(int stream_id); 135 void OnFlushStream(int stream_id);
134 136
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 AudioEntry* LookupById(int stream_id); 173 AudioEntry* LookupById(int stream_id);
172 174
173 // Search for a AudioEntry having the reference to |controller|. 175 // Search for a AudioEntry having the reference to |controller|.
174 // This method is used to look up an AudioEntry after a controller 176 // This method is used to look up an AudioEntry after a controller
175 // event is received. 177 // event is received.
176 AudioEntry* LookupByController(media::AudioOutputController* controller); 178 AudioEntry* LookupByController(media::AudioOutputController* controller);
177 179
178 // A map of stream IDs to audio sources. 180 // A map of stream IDs to audio sources.
179 AudioEntryMap audio_entries_; 181 AudioEntryMap audio_entries_;
180 182
181 AudioManager* audio_manager_; 183 media::AudioManager* audio_manager_;
182 content::MediaObserver* media_observer_; 184 content::MediaObserver* media_observer_;
183 185
184 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); 186 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost);
185 }; 187 };
186 188
187 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ 189 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698