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

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

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

Powered by Google App Engine
This is Rietveld 408576698