cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / media / audio / audio_output_ipc.h
blob3353735b0853c8c796fa5aa5ca6aa53b16bdb914
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.
5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_
8 #include "base/memory/shared_memory.h"
9 #include "base/sync_socket.h"
10 #include "media/audio/audio_parameters.h"
11 #include "media/base/media_export.h"
13 namespace media {
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 AudioOutputDevice.
18 class MEDIA_EXPORT AudioOutputIPCDelegate {
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
29 // Called when state of an audio stream has changed.
30 virtual void OnStateChanged(State state) = 0;
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 AudioOutputIPCDelegate 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 AudioOutputIPCDelegate
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;
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.
46 // Implementations should delete their owned AudioOutputIPC instance
47 // immediately.
48 virtual void OnIPCClosed() = 0;
50 protected:
51 virtual ~AudioOutputIPCDelegate();
54 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an
55 // AudioOutputDevice). The implementation should asynchronously deliver the
56 // messages to an AudioOutputController object (or create one in the case of
57 // CreateStream()), that may live in a separate process.
58 class MEDIA_EXPORT AudioOutputIPC {
59 public:
60 virtual ~AudioOutputIPC();
62 // Sends a request to create an AudioOutputController object in the peer
63 // process and configures it to use the specified audio |params| including
64 // number of synchronized input channels.|session_id| is used by the browser
65 // to select the correct input device if the input channel in |params| is
66 // valid, otherwise it will be ignored. Once the stream has been created,
67 // the implementation will notify |delegate| by calling OnStreamCreated().
68 virtual void CreateStream(AudioOutputIPCDelegate* delegate,
69 const AudioParameters& params,
70 int session_id) = 0;
72 // Starts playing the stream. This should generate a call to
73 // AudioOutputController::Play().
74 virtual void PlayStream() = 0;
76 // Pauses an audio stream. This should generate a call to
77 // AudioOutputController::Pause().
78 virtual void PauseStream() = 0;
80 // Closes the audio stream which should shut down the corresponding
81 // AudioOutputController in the peer process.
82 virtual void CloseStream() = 0;
84 // Sets the volume of the audio stream.
85 virtual void SetVolume(double volume) = 0;
88 } // namespace media
90 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_