Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: media/audio/audio_output_ipc.h

Issue 1323403005: Allow AudioOutputDevice objects to be initialized with a specific hardware output device and store … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert DCHECK in destructor Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 13 matching lines...) Expand all
24 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED, 24 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED,
25 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR, 25 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR,
26 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR 26 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR
27 }; 27 };
28 28
29 // Contains IPC notifications for the state of the server side 29 // Contains IPC notifications for the state of the server side
30 // (AudioOutputController) audio state changes and when an AudioOutputController 30 // (AudioOutputController) audio state changes and when an AudioOutputController
31 // has been created. Implemented by AudioOutputDevice. 31 // has been created. Implemented by AudioOutputDevice.
32 class MEDIA_EXPORT AudioOutputIPCDelegate { 32 class MEDIA_EXPORT AudioOutputIPCDelegate {
33 public: 33 public:
34
35 // Called when state of an audio stream has changed. 34 // Called when state of an audio stream has changed.
36 virtual void OnStateChanged(AudioOutputIPCDelegateState state) = 0; 35 virtual void OnStateChanged(AudioOutputIPCDelegateState state) = 0;
37 36
37 // Called when an authorization request for an output device has been
38 // completed
39 virtual void OnDeviceAuthorized(
40 bool success,
41 const media::AudioParameters& output_params) = 0;
42
38 // Called when an audio stream has been created. 43 // Called when an audio stream has been created.
39 // The shared memory |handle| points to a memory section that's used to 44 // The shared memory |handle| points to a memory section that's used to
40 // transfer audio buffers from the AudioOutputIPCDelegate back to the 45 // transfer audio buffers from the AudioOutputIPCDelegate back to the
41 // AudioRendererHost. The implementation of OnStreamCreated takes ownership. 46 // AudioRendererHost. The implementation of OnStreamCreated takes ownership.
42 // The |socket_handle| is used by AudioRendererHost to signal requests for 47 // The |socket_handle| is used by AudioRendererHost to signal requests for
43 // audio data to be written into the shared memory. The AudioOutputIPCDelegate 48 // audio data to be written into the shared memory. The AudioOutputIPCDelegate
44 // must read from this socket and provide audio whenever data (search for 49 // must read from this socket and provide audio whenever data (search for
45 // "pending_bytes") is received. 50 // "pending_bytes") is received.
46 virtual void OnStreamCreated(base::SharedMemoryHandle handle, 51 virtual void OnStreamCreated(base::SharedMemoryHandle handle,
47 base::SyncSocket::Handle socket_handle, 52 base::SyncSocket::Handle socket_handle,
48 int length) = 0; 53 int length) = 0;
49 54
50 // Called when an attempt to switch the output device has been completed 55 // Called when an attempt to switch the output device has been completed
51 virtual void OnOutputDeviceSwitched(int request_id, 56 virtual void OnOutputDeviceSwitched(SwitchOutputDeviceResult result) = 0;
52 SwitchOutputDeviceResult result) = 0;
53 57
54 // Called when the AudioOutputIPC object is going away and/or when the IPC 58 // Called when the AudioOutputIPC object is going away and/or when the IPC
55 // channel has been closed and no more ipc requests can be made. 59 // channel has been closed and no more ipc requests can be made.
56 // Implementations should delete their owned AudioOutputIPC instance 60 // Implementations should delete their owned AudioOutputIPC instance
57 // immediately. 61 // immediately.
58 virtual void OnIPCClosed() = 0; 62 virtual void OnIPCClosed() = 0;
59 63
60 protected: 64 protected:
61 virtual ~AudioOutputIPCDelegate(); 65 virtual ~AudioOutputIPCDelegate();
62 }; 66 };
63 67
64 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an 68 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an
65 // AudioOutputDevice). The implementation should asynchronously deliver the 69 // AudioOutputDevice). The implementation should asynchronously deliver the
66 // messages to an AudioOutputController object (or create one in the case of 70 // messages to an AudioOutputController object (or create one in the case of
67 // CreateStream()), that may live in a separate process. 71 // CreateStream()), that may live in a separate process.
68 class MEDIA_EXPORT AudioOutputIPC { 72 class MEDIA_EXPORT AudioOutputIPC {
69 public: 73 public:
70 virtual ~AudioOutputIPC(); 74 virtual ~AudioOutputIPC();
71 75
76 // Sends a request to authorize the use of a specific audio output device
77 // in the peer process.
78 // If |session_id| is nonzero, the browser selects the output device
79 // associated with an opened input device indicated by |session_id|. If no
80 // such device is found, the browser attempts to select the device indicated
81 // by |device_id|. If |device_id| is the empty string, the default
82 // audio output device will be selected.
83 // Once the authorization process is complete, the implementation will
84 // notify |delegate| by calling OnDeviceAuthorized().
85 virtual void RequestDeviceAuthorization(AudioOutputIPCDelegate* delegate,
86 int session_id,
87 const std::string& device_id,
88 const GURL& security_origin) = 0;
89
72 // Sends a request to create an AudioOutputController object in the peer 90 // Sends a request to create an AudioOutputController object in the peer
73 // process and configures it to use the specified audio |params| including 91 // process and configures it to use the specified audio |params| including
74 // number of synchronized input channels.|session_id| is used by the browser 92 // number of synchronized input channels.
75 // to select the correct input device if the input channel in |params| is 93 // Once the stream has been created, the implementation will notify
76 // valid, otherwise it will be ignored. Once the stream has been created, 94 // |delegate| by calling OnStreamCreated().
77 // the implementation will notify |delegate| by calling OnStreamCreated().
78 virtual void CreateStream(AudioOutputIPCDelegate* delegate, 95 virtual void CreateStream(AudioOutputIPCDelegate* delegate,
79 const AudioParameters& params, 96 const AudioParameters& params) = 0;
80 int session_id) = 0;
81 97
82 // Starts playing the stream. This should generate a call to 98 // Starts playing the stream. This should generate a call to
83 // AudioOutputController::Play(). 99 // AudioOutputController::Play().
84 virtual void PlayStream() = 0; 100 virtual void PlayStream() = 0;
85 101
86 // Pauses an audio stream. This should generate a call to 102 // Pauses an audio stream. This should generate a call to
87 // AudioOutputController::Pause(). 103 // AudioOutputController::Pause().
88 virtual void PauseStream() = 0; 104 virtual void PauseStream() = 0;
89 105
90 // Closes the audio stream which should shut down the corresponding 106 // Closes the audio stream which should shut down the corresponding
91 // AudioOutputController in the peer process. 107 // AudioOutputController in the peer process.
92 virtual void CloseStream() = 0; 108 virtual void CloseStream() = 0;
93 109
94 // Sets the volume of the audio stream. 110 // Sets the volume of the audio stream.
95 virtual void SetVolume(double volume) = 0; 111 virtual void SetVolume(double volume) = 0;
96 112
97 // Switches the output device of the audio stream. 113 // Switches the output device of the audio stream.
98 virtual void SwitchOutputDevice(const std::string& device_id, 114 virtual void SwitchOutputDevice(const std::string& device_id,
99 const GURL& security_origin, 115 const GURL& security_origin) = 0;
100 int request_id) = 0;
101 }; 116 };
102 117
103 } // namespace media 118 } // namespace media
104 119
105 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ 120 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698