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 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ |
6 #define CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ | 6 #define CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 virtual ~AudioMessageFilter(); | 58 virtual ~AudioMessageFilter(); |
59 | 59 |
60 private: | 60 private: |
61 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Basic); | 61 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Basic); |
62 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Delegates); | 62 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Delegates); |
63 | 63 |
64 // Implementation of media::AudioOutputIPC which augments IPC calls with | 64 // Implementation of media::AudioOutputIPC which augments IPC calls with |
65 // stream_id and the source render_view_id. | 65 // stream_id and the source render_view_id. |
66 class AudioOutputIPCImpl; | 66 class AudioOutputIPCImpl; |
67 | 67 |
68 // Sends an IPC message using |channel_|. | 68 // Sends an IPC message using |sender_|. |
69 void Send(IPC::Message* message); | 69 void Send(IPC::Message* message); |
70 | 70 |
71 // IPC::MessageFilter override. Called on |io_message_loop|. | 71 // IPC::MessageFilter override. Called on |io_message_loop|. |
72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
73 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; | 73 virtual void OnFilterAdded(IPC::Sender* sender) OVERRIDE; |
74 virtual void OnFilterRemoved() OVERRIDE; | 74 virtual void OnFilterRemoved() OVERRIDE; |
75 virtual void OnChannelClosing() OVERRIDE; | 75 virtual void OnChannelClosing() OVERRIDE; |
76 | 76 |
77 // Received when browser process has created an audio output stream. | 77 // Received when browser process has created an audio output stream. |
78 void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle, | 78 void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle, |
79 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
80 base::SyncSocket::Handle socket_handle, | 80 base::SyncSocket::Handle socket_handle, |
81 #else | 81 #else |
82 base::FileDescriptor socket_descriptor, | 82 base::FileDescriptor socket_descriptor, |
83 #endif | 83 #endif |
84 uint32 length); | 84 uint32 length); |
85 | 85 |
86 // Received when internal state of browser process' audio output device has | 86 // Received when internal state of browser process' audio output device has |
87 // changed. | 87 // changed. |
88 void OnStreamStateChanged(int stream_id, | 88 void OnStreamStateChanged(int stream_id, |
89 media::AudioOutputIPCDelegate::State state); | 89 media::AudioOutputIPCDelegate::State state); |
90 | 90 |
91 // Received when the browser process detects an output device change. | 91 // Received when the browser process detects an output device change. |
92 void OnOutputDeviceChanged(int stream_id, int new_buffer_size, | 92 void OnOutputDeviceChanged(int stream_id, int new_buffer_size, |
93 int new_sample_rate); | 93 int new_sample_rate); |
94 | 94 |
95 // IPC channel for Send(); must only be accesed on |io_message_loop_|. | 95 // IPC sender for Send(); must only be accesed on |io_message_loop_|. |
96 IPC::Channel* channel_; | 96 IPC::Sender* sender_; |
97 | 97 |
98 // A map of stream ids to delegates; must only be accessed on | 98 // A map of stream ids to delegates; must only be accessed on |
99 // |io_message_loop_|. | 99 // |io_message_loop_|. |
100 IDMap<media::AudioOutputIPCDelegate> delegates_; | 100 IDMap<media::AudioOutputIPCDelegate> delegates_; |
101 | 101 |
102 // Audio hardware configuration to update when OnOutputDeviceChanged() fires. | 102 // Audio hardware configuration to update when OnOutputDeviceChanged() fires. |
103 // Access is guarded by |lock_|. | 103 // Access is guarded by |lock_|. |
104 base::Lock lock_; | 104 base::Lock lock_; |
105 media::AudioHardwareConfig* audio_hardware_config_; | 105 media::AudioHardwareConfig* audio_hardware_config_; |
106 | 106 |
107 // Message loop on which IPC calls are driven. | 107 // Message loop on which IPC calls are driven. |
108 const scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 108 const scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
109 | 109 |
110 // The singleton instance for this filter. | 110 // The singleton instance for this filter. |
111 static AudioMessageFilter* g_filter; | 111 static AudioMessageFilter* g_filter; |
112 | 112 |
113 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); | 113 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); |
114 }; | 114 }; |
115 | 115 |
116 } // namespace content | 116 } // namespace content |
117 | 117 |
118 #endif // CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ | 118 #endif // CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ |
OLD | NEW |