Make 'Google Smart Lock' a hyperlink in the password infobar on Mac.
[chromium-blink-merge.git] / media / audio / audio_output_ipc.h
blob9af1df44efe8aa76992a7063b2422aff83328ddf
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 <string>
10 #include "base/memory/shared_memory.h"
11 #include "base/sync_socket.h"
12 #include "media/audio/audio_parameters.h"
13 #include "media/base/media_export.h"
14 #include "url/gurl.h"
16 namespace media {
18 // Result of an audio output device switch operation
19 enum SwitchOutputDeviceResult {
20 SWITCH_OUTPUT_DEVICE_RESULT_SUCCESS = 0,
21 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_FOUND,
22 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_AUTHORIZED,
23 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_OBSOLETE,
24 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED,
25 SWITCH_OUTPUT_DEVICE_RESULT_LAST =
26 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED,
29 // Current status of the audio output stream in the browser process. Browser
30 // sends information about the current playback state and error to the
31 // renderer process using this type.
32 enum AudioOutputIPCDelegateState {
33 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PLAYING,
34 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED,
35 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR,
36 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR
39 // Contains IPC notifications for the state of the server side
40 // (AudioOutputController) audio state changes and when an AudioOutputController
41 // has been created. Implemented by AudioOutputDevice.
42 class MEDIA_EXPORT AudioOutputIPCDelegate {
43 public:
45 // Called when state of an audio stream has changed.
46 virtual void OnStateChanged(AudioOutputIPCDelegateState state) = 0;
48 // Called when an audio stream has been created.
49 // The shared memory |handle| points to a memory section that's used to
50 // transfer audio buffers from the AudioOutputIPCDelegate back to the
51 // AudioRendererHost. The implementation of OnStreamCreated takes ownership.
52 // The |socket_handle| is used by AudioRendererHost to signal requests for
53 // audio data to be written into the shared memory. The AudioOutputIPCDelegate
54 // must read from this socket and provide audio whenever data (search for
55 // "pending_bytes") is received.
56 virtual void OnStreamCreated(base::SharedMemoryHandle handle,
57 base::SyncSocket::Handle socket_handle,
58 int length) = 0;
60 // Called when the AudioOutputIPC object is going away and/or when the IPC
61 // channel has been closed and no more ipc requests can be made.
62 // Implementations should delete their owned AudioOutputIPC instance
63 // immediately.
64 virtual void OnIPCClosed() = 0;
66 protected:
67 virtual ~AudioOutputIPCDelegate();
70 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an
71 // AudioOutputDevice). The implementation should asynchronously deliver the
72 // messages to an AudioOutputController object (or create one in the case of
73 // CreateStream()), that may live in a separate process.
74 class MEDIA_EXPORT AudioOutputIPC {
75 public:
76 virtual ~AudioOutputIPC();
78 // Sends a request to create an AudioOutputController object in the peer
79 // process and configures it to use the specified audio |params| including
80 // number of synchronized input channels.|session_id| is used by the browser
81 // to select the correct input device if the input channel in |params| is
82 // valid, otherwise it will be ignored. Once the stream has been created,
83 // the implementation will notify |delegate| by calling OnStreamCreated().
84 virtual void CreateStream(AudioOutputIPCDelegate* delegate,
85 const AudioParameters& params,
86 int session_id) = 0;
88 // Starts playing the stream. This should generate a call to
89 // AudioOutputController::Play().
90 virtual void PlayStream() = 0;
92 // Pauses an audio stream. This should generate a call to
93 // AudioOutputController::Pause().
94 virtual void PauseStream() = 0;
96 // Closes the audio stream which should shut down the corresponding
97 // AudioOutputController in the peer process.
98 virtual void CloseStream() = 0;
100 // Sets the volume of the audio stream.
101 virtual void SetVolume(double volume) = 0;
104 } // namespace media
106 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_