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

Unified Diff: content/renderer/media/audio_message_filter.h

Issue 12383016: Merge AssociateStreamWithProducer message into CreateStream message for both audio output and input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/audio_message_filter.h
diff --git a/content/renderer/media/audio_message_filter.h b/content/renderer/media/audio_message_filter.h
index 2d9f4a2662eeb94e7740c7c1eeb18bc4d0c7bf3d..08aab4ec0fa82d381337a11bc64c356780678303 100644
--- a/content/renderer/media/audio_message_filter.h
+++ b/content/renderer/media/audio_message_filter.h
@@ -6,8 +6,7 @@
#define CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_
#include "base/gtest_prod_util.h"
-#include "base/hash_tables.h"
-#include "base/message_loop_proxy.h"
+#include "base/id_map.h"
#include "base/shared_memory.h"
#include "base/sync_socket.h"
#include "base/synchronization/lock.h"
@@ -27,8 +26,7 @@ namespace content {
// IO thread (secondary thread of render process) it intercepts audio messages
// and process them on IO thread since these messages are time critical.
class CONTENT_EXPORT AudioMessageFilter
- : public IPC::ChannelProxy::MessageFilter,
- public NON_EXPORTED_BASE(media::AudioOutputIPC) {
+ : public IPC::ChannelProxy::MessageFilter {
public:
explicit AudioMessageFilter(
const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
@@ -36,27 +34,12 @@ class CONTENT_EXPORT AudioMessageFilter
// Getter for the one AudioMessageFilter object.
static AudioMessageFilter* Get();
- // Associates |render_view_id| as the source of audio rendered for a stream.
- void AssociateStreamWithProducer(int stream_id, int render_view_id);
-
- // media::AudioOutputIPC implementation.
- virtual int AddDelegate(media::AudioOutputIPCDelegate* delegate) OVERRIDE;
- virtual void RemoveDelegate(int id) OVERRIDE;
-
- // Methods below must be called on the provided |io_message_loop|.
- virtual void CreateStream(int stream_id,
- const media::AudioParameters& params) OVERRIDE;
- virtual void PlayStream(int stream_id) OVERRIDE;
- virtual void PauseStream(int stream_id) OVERRIDE;
- virtual void FlushStream(int stream_id) OVERRIDE;
- virtual void CloseStream(int stream_id) OVERRIDE;
- virtual void SetVolume(int stream_id, double volume) OVERRIDE;
-
- // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|.
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
- virtual void OnFilterRemoved() OVERRIDE;
- virtual void OnChannelClosing() OVERRIDE;
+ // Create an AudioOutputIPC for a delegate. |render_view_id| is the render
+ // view containing the entity producing the audio.
+ //
+ // The returned object is not thread-safe. Methods must be called on
+ // |io_message_loop|.
+ media::AudioOutputIPC* CreateAudioOutputIPC(int render_view_id);
// When set, AudioMessageFilter will update the AudioHardwareConfig with new
// configuration values as recieved by OnOutputDeviceChanged(). The provided
@@ -75,9 +58,19 @@ class CONTENT_EXPORT AudioMessageFilter
FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Basic);
FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Delegates);
+ // Implementation of media::AudioOutputIPC which augments IPC calls with
+ // stream_id and the source render_view_id.
+ class AudioOutputIPCImpl;
DaleCurtis 2013/03/01 00:27:52 What's the point of nesting this? Seems it should
miu 2013/03/02 00:24:16 I needed it to have access to private members (the
+
// Sends an IPC message using |channel_|.
void Send(IPC::Message* message);
+ // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
+ virtual void OnFilterRemoved() OVERRIDE;
+ virtual void OnChannelClosing() OVERRIDE;
+
// Received when browser process has created an audio output stream.
void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle,
#if defined(OS_WIN)
@@ -99,20 +92,16 @@ class CONTENT_EXPORT AudioMessageFilter
// The singleton instance for this filter.
static AudioMessageFilter* filter_;
- // IPC channel for Send(), must only be accesed on |io_message_loop_|.
+ // IPC channel for Send(); must only be accesed on |io_message_loop_|.
IPC::Channel* channel_;
- // Unique ID to use for next added delegate.
- int next_stream_id_;
-
- // Guards all variables below which are accessed from multiple threads.
- base::Lock lock_;
-
- // A map of stream ids to delegates.
- typedef base::hash_map<int, media::AudioOutputIPCDelegate*> DelegateMap;
- DelegateMap delegates_;
+ // A map of stream ids to delegates; must only be accessed on
+ // |io_message_loop_|.
+ IDMap<media::AudioOutputIPCDelegate> delegates_;
// Audio hardware configuration to update when OnOutputDeviceChanged() fires.
+ // Access is guarded by |lock_|.
+ base::Lock lock_;
media::AudioHardwareConfig* audio_hardware_config_;
// Message loop on which IPC calls are driven.

Powered by Google App Engine
This is Rietveld 408576698