OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // MessageFilter that handles audio messages and delegates them to audio | 5 // MessageFilter that handles audio messages and delegates them to audio |
6 // renderers. Created on render thread, AudioMessageFilter is operated on | 6 // renderers. Created on render thread, AudioMessageFilter is operated on |
7 // IO thread (main thread of render process), it intercepts audio messages | 7 // IO thread (main thread of render process), it intercepts audio messages |
8 // and process them on IO thread since these messages are time critical. | 8 // and process them on IO thread since these messages are time critical. |
9 | 9 |
10 #ifndef CONTENT_RENDERER_AUDIO_MESSAGE_FILTER_H_ | 10 #ifndef CONTENT_RENDERER_AUDIO_MESSAGE_FILTER_H_ |
11 #define CONTENT_RENDERER_AUDIO_MESSAGE_FILTER_H_ | 11 #define CONTENT_RENDERER_AUDIO_MESSAGE_FILTER_H_ |
12 #pragma once | 12 #pragma once |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/id_map.h" | 15 #include "base/id_map.h" |
16 #include "base/shared_memory.h" | 16 #include "base/shared_memory.h" |
17 #include "base/sync_socket.h" | 17 #include "base/sync_socket.h" |
| 18 #include "content/common/audio_stream_state.h" |
18 #include "ipc/ipc_channel_proxy.h" | 19 #include "ipc/ipc_channel_proxy.h" |
19 #include "media/audio/audio_buffers_state.h" | 20 #include "media/audio/audio_buffers_state.h" |
20 | 21 |
21 struct ViewMsg_AudioStreamState_Params; | |
22 | |
23 namespace base { | 22 namespace base { |
24 class Time; | 23 class Time; |
25 } | 24 } |
26 | 25 |
27 class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter { | 26 class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter { |
28 public: | 27 public: |
29 class Delegate { | 28 class Delegate { |
30 public: | 29 public: |
31 // Called when an audio packet is requested from the browser process. | 30 // Called when an audio packet is requested from the browser process. |
32 virtual void OnRequestPacket(AudioBuffersState buffers_state) = 0; | 31 virtual void OnRequestPacket(AudioBuffersState buffers_state) = 0; |
33 | 32 |
34 // Called when state of an audio stream has changed in the browser process. | 33 // Called when state of an audio stream has changed in the browser process. |
35 virtual void OnStateChanged( | 34 virtual void OnStateChanged(AudioStreamState state) = 0; |
36 const ViewMsg_AudioStreamState_Params& state) = 0; | |
37 | 35 |
38 // Called when an audio stream has been created in the browser process. | 36 // Called when an audio stream has been created in the browser process. |
39 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length) = 0; | 37 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length) = 0; |
40 | 38 |
41 // Called when a low-latency audio stream has been created in the browser | 39 // Called when a low-latency audio stream has been created in the browser |
42 // process. | 40 // process. |
43 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 41 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
44 base::SyncSocket::Handle socket_handle, | 42 base::SyncSocket::Handle socket_handle, |
45 uint32 length) = 0; | 43 uint32 length) = 0; |
46 | 44 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
94 base::SyncSocket::Handle socket_handle, | 92 base::SyncSocket::Handle socket_handle, |
95 #else | 93 #else |
96 base::FileDescriptor socket_descriptor, | 94 base::FileDescriptor socket_descriptor, |
97 #endif | 95 #endif |
98 uint32 length); | 96 uint32 length); |
99 | 97 |
100 | 98 |
101 // Received when internal state of browser process' audio output device has | 99 // Received when internal state of browser process' audio output device has |
102 // changed. | 100 // changed. |
103 void OnStreamStateChanged(int stream_id, | 101 void OnStreamStateChanged(int stream_id, AudioStreamState state); |
104 const ViewMsg_AudioStreamState_Params& state); | |
105 | 102 |
106 // Notification of volume property of an audio output stream. | 103 // Notification of volume property of an audio output stream. |
107 void OnStreamVolume(int stream_id, double volume); | 104 void OnStreamVolume(int stream_id, double volume); |
108 | 105 |
109 // A map of stream ids to delegates. | 106 // A map of stream ids to delegates. |
110 IDMap<Delegate> delegates_; | 107 IDMap<Delegate> delegates_; |
111 | 108 |
112 IPC::Channel* channel_; | 109 IPC::Channel* channel_; |
113 | 110 |
114 int32 route_id_; | 111 int32 route_id_; |
115 | 112 |
116 MessageLoop* message_loop_; | 113 MessageLoop* message_loop_; |
117 | 114 |
118 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); | 115 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); |
119 }; | 116 }; |
120 | 117 |
121 #endif // CONTENT_RENDERER_AUDIO_MESSAGE_FILTER_H_ | 118 #endif // CONTENT_RENDERER_AUDIO_MESSAGE_FILTER_H_ |
OLD | NEW |