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

Side by Side Diff: content/renderer/pepper/pepper_platform_audio_input_impl.h

Issue 10790121: First step towards moving AudioDevice from content/ to media/audio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: relaxing the notreached back to log(error) since nacl tests will otherwise fail Created 8 years, 5 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 | Annotate | Revision Log
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 CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace content { 22 namespace content {
23 23
24 class PepperPluginDelegateImpl; 24 class PepperPluginDelegateImpl;
25 25
26 // PepperPlatformAudioInputImpl is operated on two threads: the main thread (the 26 // PepperPlatformAudioInputImpl is operated on two threads: the main thread (the
27 // thread on which objects are created) and the I/O thread. All public methods, 27 // thread on which objects are created) and the I/O thread. All public methods,
28 // except the destructor, must be called on the main thread. The notifications 28 // except the destructor, must be called on the main thread. The notifications
29 // to the users of this class (via the PlatformAudioInputClient interface) are 29 // to the users of this class (via the PlatformAudioInputClient interface) are
30 // also sent on the main thread. Internally, this class sends audio input IPC 30 // also sent on the main thread. Internally, this class sends audio input IPC
31 // messages and receives AudioInputMessageFilter::Delegate notifications on the 31 // messages and receives media::AudioInputDeviceIPCDelegate notifications on the
32 // I/O thread. 32 // I/O thread.
33 33
34 class PepperPlatformAudioInputImpl 34 class PepperPlatformAudioInputImpl
35 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, 35 : public webkit::ppapi::PluginDelegate::PlatformAudioInput,
36 public AudioInputMessageFilter::Delegate, 36 public media::AudioInputDeviceIPCDelegate,
37 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { 37 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> {
38 public: 38 public:
39 // Factory function, returns NULL on failure. StreamCreated() will be called 39 // Factory function, returns NULL on failure. StreamCreated() will be called
40 // when the stream is created. 40 // when the stream is created.
41 static PepperPlatformAudioInputImpl* Create( 41 static PepperPlatformAudioInputImpl* Create(
42 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, 42 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
43 const std::string& device_id, 43 const std::string& device_id,
44 int sample_rate, 44 int sample_rate,
45 int frames_per_buffer, 45 int frames_per_buffer,
46 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); 46 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client);
47 47
48 // PlatformAudioInput implementation (called on main thread). 48 // PlatformAudioInput implementation (called on main thread).
49 virtual void StartCapture() OVERRIDE; 49 virtual void StartCapture() OVERRIDE;
50 virtual void StopCapture() OVERRIDE; 50 virtual void StopCapture() OVERRIDE;
51 virtual void ShutDown() OVERRIDE; 51 virtual void ShutDown() OVERRIDE;
52 52
53 // AudioInputMessageFilter::Delegate. 53 // media::AudioInputDeviceIPCDelegate.
54 virtual void OnStreamCreated(base::SharedMemoryHandle handle, 54 virtual void OnStreamCreated(base::SharedMemoryHandle handle,
55 base::SyncSocket::Handle socket_handle, 55 base::SyncSocket::Handle socket_handle,
56 uint32 length) OVERRIDE; 56 uint32 length) OVERRIDE;
57 virtual void OnVolume(double volume) OVERRIDE; 57 virtual void OnVolume(double volume) OVERRIDE;
58 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; 58 virtual void OnStateChanged(
59 media::AudioInputDeviceIPCDelegate::State state) OVERRIDE;
59 virtual void OnDeviceReady(const std::string&) OVERRIDE; 60 virtual void OnDeviceReady(const std::string&) OVERRIDE;
61 virtual void OnIPCClosed() OVERRIDE;
60 62
61 protected: 63 protected:
62 virtual ~PepperPlatformAudioInputImpl(); 64 virtual ~PepperPlatformAudioInputImpl();
63 65
64 private: 66 private:
65 friend class base::RefCountedThreadSafe<PepperPlatformAudioInputImpl>; 67 friend class base::RefCountedThreadSafe<PepperPlatformAudioInputImpl>;
66 68
67 PepperPlatformAudioInputImpl(); 69 PepperPlatformAudioInputImpl();
68 70
69 bool Initialize( 71 bool Initialize(
(...skipping 12 matching lines...) Expand all
82 void OnDeviceOpened(int request_id, 84 void OnDeviceOpened(int request_id,
83 bool succeeded, 85 bool succeeded,
84 const std::string& label); 86 const std::string& label);
85 void CloseDevice(); 87 void CloseDevice();
86 void NotifyStreamCreationFailed(); 88 void NotifyStreamCreationFailed();
87 89
88 // The client to notify when the stream is created. THIS MUST ONLY BE 90 // The client to notify when the stream is created. THIS MUST ONLY BE
89 // ACCESSED ON THE MAIN THREAD. 91 // ACCESSED ON THE MAIN THREAD.
90 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_; 92 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_;
91 93
92 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE 94 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE
93 // I/O thread except to send messages and get the message loop. 95 // I/O thread except to send messages and get the message loop.
94 scoped_refptr<AudioInputMessageFilter> filter_; 96 media::AudioInputDeviceIPC* ipc_;
95 97
96 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD 98 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD
97 // or else you could race with the initialize function which sets it. 99 // or else you could race with the initialize function which sets it.
98 int32 stream_id_; 100 int32 stream_id_;
99 101
100 base::MessageLoopProxy* main_message_loop_proxy_; 102 base::MessageLoopProxy* main_message_loop_proxy_;
101 103
102 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. 104 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD.
103 base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_; 105 base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_;
104 106
105 // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON 107 // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON
106 // THE MAIN THREAD. 108 // THE MAIN THREAD.
107 std::string label_; 109 std::string label_;
108 110
109 // Whether ShutDownOnIOThread() has been called. THIS MUST ONLY BE ACCESSED ON 111 // Whether ShutDownOnIOThread() has been called. THIS MUST ONLY BE ACCESSED ON
110 // THE I/O THREAD. 112 // THE I/O THREAD.
111 bool shutdown_called_; 113 bool shutdown_called_;
112 114
113 // Initialized on the main thread and accessed on the I/O thread afterwards. 115 // Initialized on the main thread and accessed on the I/O thread afterwards.
114 media::AudioParameters params_; 116 media::AudioParameters params_;
115 117
116 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); 118 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl);
117 }; 119 };
118 120
119 } // namespace content 121 } // namespace content
120 122
121 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ 123 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698