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 MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ |
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ |
7 | 7 |
8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
9 #include "base/sync_socket.h" | 9 #include "base/sync_socket.h" |
10 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // The |socket_handle| is used by AudioRendererHost to signal requests for | 36 // The |socket_handle| is used by AudioRendererHost to signal requests for |
37 // audio data to be written into the shared memory. The AudioOutputIPCDelegate | 37 // audio data to be written into the shared memory. The AudioOutputIPCDelegate |
38 // must read from this socket and provide audio whenever data (search for | 38 // must read from this socket and provide audio whenever data (search for |
39 // "pending_bytes") is received. | 39 // "pending_bytes") is received. |
40 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 40 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
41 base::SyncSocket::Handle socket_handle, | 41 base::SyncSocket::Handle socket_handle, |
42 int length) = 0; | 42 int length) = 0; |
43 | 43 |
44 // Called when the AudioOutputIPC object is going away and/or when the IPC | 44 // Called when the AudioOutputIPC object is going away and/or when the IPC |
45 // channel has been closed and no more ipc requests can be made. | 45 // channel has been closed and no more ipc requests can be made. |
46 // Implementations must clear any references to the AudioOutputIPC object | 46 // Implementations should delete their owned AudioOutputIPC instance |
47 // at this point. | 47 // immediately. |
48 virtual void OnIPCClosed() = 0; | 48 virtual void OnIPCClosed() = 0; |
49 | 49 |
50 protected: | 50 protected: |
51 virtual ~AudioOutputIPCDelegate(); | 51 virtual ~AudioOutputIPCDelegate(); |
52 }; | 52 }; |
53 | 53 |
54 // Provides IPC functionality for an AudioOutputDevice. The implementation | 54 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an |
55 // should asynchronously deliver the messages to an AudioOutputController object | 55 // AudioOutputDevice). The implementation should asynchronously deliver the |
56 // (or create one in the case of CreateStream()), that may live in a separate | 56 // messages to an AudioOutputController object (or create one in the case of |
57 // process. | 57 // CreateStream()), that may live in a separate process. |
58 class MEDIA_EXPORT AudioOutputIPC { | 58 class MEDIA_EXPORT AudioOutputIPC { |
59 public: | 59 public: |
60 // Registers an AudioOutputIPCDelegate and returns a |stream_id| that must | 60 virtual ~AudioOutputIPC(); |
61 // be used with all other IPC functions in this interface. | |
62 virtual int AddDelegate(AudioOutputIPCDelegate* delegate) = 0; | |
63 | |
64 // Unregisters a delegate that was previously registered via a call to | |
65 // AddDelegate(). The audio stream should be in a closed state prior to | |
66 // calling this function. | |
67 virtual void RemoveDelegate(int stream_id) = 0; | |
68 | 61 |
69 // Sends a request to create an AudioOutputController object in the peer | 62 // Sends a request to create an AudioOutputController object in the peer |
70 // process, identify it by |stream_id| and configure it to use the specified | 63 // process and configures it to use the specified audio |params| including |
71 // audio |params| including number of synchronized input channels. | 64 // number of synchronized input channels. Once the stream has been created, |
72 // Once the stream has been created, the implementation must | 65 // the implementation will notify |delegate| by calling OnStreamCreated(). |
73 // generate a notification to the AudioOutputIPCDelegate and call | 66 virtual void CreateStream(AudioOutputIPCDelegate* delegate, |
74 // OnStreamCreated(). | |
75 virtual void CreateStream(int stream_id, | |
76 const AudioParameters& params) = 0; | 67 const AudioParameters& params) = 0; |
77 | 68 |
78 // Starts playing the stream. This should generate a call to | 69 // Starts playing the stream. This should generate a call to |
79 // AudioOutputController::Play(). | 70 // AudioOutputController::Play(). |
80 virtual void PlayStream(int stream_id) = 0; | 71 virtual void PlayStream() = 0; |
81 | 72 |
82 // Pauses an audio stream. This should generate a call to | 73 // Pauses an audio stream. This should generate a call to |
83 // AudioOutputController::Pause(). | 74 // AudioOutputController::Pause(). |
84 virtual void PauseStream(int stream_id) = 0; | 75 virtual void PauseStream() = 0; |
85 | 76 |
86 // Closes the audio stream and deletes the matching AudioOutputController | 77 // Closes the audio stream which should shut down the corresponding |
87 // instance. Prior to deleting the AudioOutputController object, a call to | 78 // AudioOutputController in the peer process. |
88 // AudioOutputController::Close must be made. | 79 virtual void CloseStream() = 0; |
89 virtual void CloseStream(int stream_id) = 0; | |
90 | 80 |
91 // Sets the volume of the audio stream. | 81 // Sets the volume of the audio stream. |
92 virtual void SetVolume(int stream_id, double volume) = 0; | 82 virtual void SetVolume(double volume) = 0; |
93 | |
94 protected: | |
95 virtual ~AudioOutputIPC(); | |
96 }; | 83 }; |
97 | 84 |
98 } // namespace media | 85 } // namespace media |
99 | 86 |
100 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ | 87 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ |
OLD | NEW |