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 // 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 (secondary thread of render process) it intercepts audio messages | 7 // IO thread (secondary 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_MEDIA_AUDIO_MESSAGE_FILTER_H_ | 10 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ |
(...skipping 21 matching lines...) Expand all Loading... |
32 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 32 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
33 base::SyncSocket::Handle socket_handle, | 33 base::SyncSocket::Handle socket_handle, |
34 uint32 length) = 0; | 34 uint32 length) = 0; |
35 | 35 |
36 protected: | 36 protected: |
37 virtual ~Delegate() {} | 37 virtual ~Delegate() {} |
38 }; | 38 }; |
39 | 39 |
40 AudioMessageFilter(); | 40 AudioMessageFilter(); |
41 | 41 |
| 42 // Getter for the one AudioMessageFilter object. |
| 43 static AudioMessageFilter* Get(); |
| 44 |
42 // Add a delegate to the map and return id of the entry. | 45 // Add a delegate to the map and return id of the entry. |
43 int32 AddDelegate(Delegate* delegate); | 46 int32 AddDelegate(Delegate* delegate); |
44 | 47 |
45 // Remove a delegate referenced by |id| from the map. | 48 // Remove a delegate referenced by |id| from the map. |
46 void RemoveDelegate(int32 id); | 49 void RemoveDelegate(int32 id); |
47 | 50 |
48 // Sends an IPC message using |channel_|. | 51 // Sends an IPC message using |channel_|. |
49 bool Send(IPC::Message* message); | 52 bool Send(IPC::Message* message); |
50 | 53 |
51 // IPC::ChannelProxy::MessageFilter override. Called on IO thread. | 54 // IPC::ChannelProxy::MessageFilter override. Called on IO thread. |
(...skipping 16 matching lines...) Expand all Loading... |
68 #else | 71 #else |
69 base::FileDescriptor socket_descriptor, | 72 base::FileDescriptor socket_descriptor, |
70 #endif | 73 #endif |
71 uint32 length); | 74 uint32 length); |
72 | 75 |
73 | 76 |
74 // Received when internal state of browser process' audio output device has | 77 // Received when internal state of browser process' audio output device has |
75 // changed. | 78 // changed. |
76 void OnStreamStateChanged(int stream_id, AudioStreamState state); | 79 void OnStreamStateChanged(int stream_id, AudioStreamState state); |
77 | 80 |
| 81 // The singleton instance for this filter. |
| 82 static AudioMessageFilter* filter_; |
| 83 |
78 // A map of stream ids to delegates. | 84 // A map of stream ids to delegates. |
79 IDMap<Delegate> delegates_; | 85 IDMap<Delegate> delegates_; |
80 | 86 |
81 IPC::Channel* channel_; | 87 IPC::Channel* channel_; |
82 | 88 |
83 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); | 89 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); |
84 }; | 90 }; |
85 | 91 |
86 #endif // CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ | 92 #endif // CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ |
OLD | NEW |