OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_AUDIO_AUDIO_DEVICE_IPC_H_ | |
6 #define MEDIA_AUDIO_AUDIO_DEVICE_IPC_H_ | |
7 | |
8 #include "base/shared_memory.h" | |
9 #include "base/sync_socket.h" | |
10 #include "media/audio/audio_parameters.h" | |
11 #include "media/base/media_export.h" | |
12 | |
13 namespace media { | |
14 | |
15 // Contains IPC notifications for the state of the server side | |
16 // (AudioOutputController) audio state changes and when an AudioOutputController | |
17 // has been created. Implemented by AudioDevice. | |
18 class MEDIA_EXPORT AudioDeviceIPCDelegate { | |
19 public: | |
20 // Current status of the audio output stream in the browser process. Browser | |
21 // sends information about the current playback state and error to the | |
22 // renderer process using this type. | |
23 enum State { | |
24 kPlaying, | |
25 kPaused, | |
26 kError | |
27 }; | |
28 | |
29 // Called when state of an audio stream has changed. | |
30 virtual void OnStateChanged(State state) = 0; | |
31 | |
32 // Called when an audio stream has been created. | |
33 // The shared memory |handle| points to a memory section that's used to | |
34 // transfer audio buffers from the AudioDeviceIPCDelegate back to the | |
35 // AudioRendererHost. The implementation of OnStreamCreated takes ownership. | |
36 // The |socket_handle| is used by AudioRendererHost to signal requests for | |
37 // audio data to be written into the shared memory. The AudioDeviceIPCDelegate | |
38 // must read from this socket and provide audio whenever data (search for | |
39 // "pending_bytes") is received. | |
40 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | |
41 base::SyncSocket::Handle socket_handle, | |
42 int length) = 0; | |
43 | |
44 // Called when the AudioDeviceIPC object is going away and/or when the IPC | |
45 // channel has been closed and no more ipc requests can be made. | |
46 // Implementations must clear any references to the AudioDeviceIPC object | |
47 // at this point. | |
48 virtual void OnIPCClosed() = 0; | |
49 | |
50 protected: | |
51 virtual ~AudioDeviceIPCDelegate(); | |
52 }; | |
53 | |
54 // Provides IPC functionality for an AudioDevice. The implementation should | |
55 // asynchronously deliver the messages to an AudioOutputController object (or | |
56 // create one in the case of CreateStream()), that may live in a separate | |
57 // process. | |
58 class MEDIA_EXPORT AudioDeviceIPC { | |
scherkus (not reviewing)
2012/07/25 17:43:37
Shoot. I thought you were going to rename this Aud
tommi (sloooow) - chröme
2012/07/25 20:10:27
I must admit that the thought crossed my mind but
| |
59 public: | |
60 // Registers an AudioDeviceIPCDelegate and returns a |stream_id| that must | |
61 // be used with all other IPC functions in this interface. | |
62 virtual int AddDelegate(AudioDeviceIPCDelegate* 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 | |
69 // 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 | |
71 // audio |params|. Once the stream has been created, the implementation must | |
72 // generate a notification to the AudioDeviceIPCDelegate and call | |
73 // OnStreamCreated(). | |
74 virtual void CreateStream(int stream_id, const AudioParameters& params) = 0; | |
75 | |
76 // Starts playing the stream. This should generate a call to | |
77 // AudioOutputController::Play(). | |
78 virtual void PlayStream(int stream_id) = 0; | |
79 | |
80 // Pauses an audio stream. This should generate a call to | |
81 // AudioOutputController::Pause(). | |
82 virtual void PauseStream(int stream_id) = 0; | |
83 | |
84 // "Flushes" the audio device. This should generate a call to | |
85 // AudioOutputController::Flush(). | |
86 // TODO(tommi): This is currently neither implemented nor called. Remove? | |
87 virtual void FlushStream(int stream_id) = 0; | |
88 | |
89 // Closes the audio stream and deletes the matching AudioOutputController | |
90 // instance. Prior to deleting the AudioOutputController object, a call to | |
91 // AudioOutputController::Close must be made. | |
92 virtual void CloseStream(int stream_id) = 0; | |
93 | |
94 // Sets the volume of the audio stream. | |
95 virtual void SetVolume(int stream_id, double volume) = 0; | |
96 | |
97 protected: | |
98 virtual ~AudioDeviceIPC(); | |
99 }; | |
100 | |
101 } // namespace media | |
102 | |
103 #endif // MEDIA_AUDIO_AUDIO_DEVICE_IPC_H_ | |
OLD | NEW |