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

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

Issue 11166002: Plumb render view ID from audio-related code in renderer through IPCs to AudioRendererHost in brows… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add plumbing for input side as well. Created 8 years, 2 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_OUTPUT_IMPL_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
10 #include "media/audio/audio_output_ipc.h" 11 #include "media/audio/audio_output_ipc.h"
11 #include "webkit/plugins/ppapi/plugin_delegate.h" 12 #include "webkit/plugins/ppapi/plugin_delegate.h"
12 13
13 namespace media { 14 namespace media {
14 class AudioParameters; 15 class AudioParameters;
15 } 16 }
16 17
17 namespace base { 18 namespace base {
18 class MessageLoopProxy; 19 class MessageLoopProxy;
19 } 20 }
20 21
21 namespace content { 22 namespace content {
22 23
23 class PepperPlatformAudioOutputImpl 24 class PepperPlatformAudioOutputImpl
24 : public webkit::ppapi::PluginDelegate::PlatformAudioOutput, 25 : public webkit::ppapi::PluginDelegate::PlatformAudioOutput,
25 public media::AudioOutputIPCDelegate, 26 public media::AudioOutputIPCDelegate,
26 public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> { 27 public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> {
27 public: 28 public:
28 // Factory function, returns NULL on failure. StreamCreated() will be called 29 // Factory function, returns NULL on failure. StreamCreated() will be called
29 // when the stream is created. 30 // when the stream is created.
30 static PepperPlatformAudioOutputImpl* Create( 31 static PepperPlatformAudioOutputImpl* Create(
32 int render_view_id,
31 int sample_rate, 33 int sample_rate,
32 int frames_per_buffer, 34 int frames_per_buffer,
33 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client); 35 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client);
34 36
35 // PlatformAudioOutput implementation (called on main thread). 37 // PlatformAudioOutput implementation (called on main thread).
36 virtual bool StartPlayback() OVERRIDE; 38 virtual bool StartPlayback() OVERRIDE;
37 virtual bool StopPlayback() OVERRIDE; 39 virtual bool StopPlayback() OVERRIDE;
38 virtual void ShutDown() OVERRIDE; 40 virtual void ShutDown() OVERRIDE;
39 41
40 // media::AudioOutputIPCDelegate implementation. 42 // media::AudioOutputIPCDelegate implementation.
41 virtual void OnStateChanged( 43 virtual void OnStateChanged(
42 media::AudioOutputIPCDelegate::State state) OVERRIDE; 44 media::AudioOutputIPCDelegate::State state) OVERRIDE;
43 virtual void OnStreamCreated(base::SharedMemoryHandle handle, 45 virtual void OnStreamCreated(base::SharedMemoryHandle handle,
44 base::SyncSocket::Handle socket_handle, 46 base::SyncSocket::Handle socket_handle,
45 int length) OVERRIDE; 47 int length) OVERRIDE;
46 virtual void OnIPCClosed() OVERRIDE; 48 virtual void OnIPCClosed() OVERRIDE;
47 49
48 protected: 50 protected:
49 virtual ~PepperPlatformAudioOutputImpl(); 51 virtual ~PepperPlatformAudioOutputImpl();
50 52
51 private: 53 private:
52 friend class base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl>; 54 friend class base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl>;
53 55
54 PepperPlatformAudioOutputImpl(); 56 explicit PepperPlatformAudioOutputImpl(int render_view_id);
55 57
56 bool Initialize( 58 bool Initialize(
57 int sample_rate, 59 int sample_rate,
58 int frames_per_buffer, 60 int frames_per_buffer,
59 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client); 61 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client);
60 62
61 // I/O thread backends to above functions. 63 // I/O thread backends to above functions.
62 void InitializeOnIOThread(const media::AudioParameters& params); 64 void InitializeOnIOThread(const media::AudioParameters& params);
63 void StartPlaybackOnIOThread(); 65 void StartPlaybackOnIOThread();
64 void StopPlaybackOnIOThread(); 66 void StopPlaybackOnIOThread();
65 void ShutDownOnIOThread(); 67 void ShutDownOnIOThread();
66 68
67 // The client to notify when the stream is created. THIS MUST ONLY BE 69 // The client to notify when the stream is created. THIS MUST ONLY BE
68 // ACCESSED ON THE MAIN THREAD. 70 // ACCESSED ON THE MAIN THREAD.
69 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client_; 71 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client_;
70 72
71 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE 73 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE
72 // I/O thread except to send messages and get the message loop. 74 // I/O thread except to send messages and get the message loop.
73 media::AudioOutputIPC* ipc_; 75 scoped_ptr<media::AudioOutputIPC> ipc_;
74 76
75 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD 77 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD
76 // or else you could race with the initialize function which sets it. 78 // or else you could race with the initialize function which sets it.
77 int32 stream_id_; 79 int32 stream_id_;
78 80
79 base::MessageLoopProxy* main_message_loop_proxy_; 81 base::MessageLoopProxy* main_message_loop_proxy_;
80 82
81 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioOutputImpl); 83 DISALLOW_IMPLICIT_CONSTRUCTORS(PepperPlatformAudioOutputImpl);
82 }; 84 };
83 85
84 } // namespace content 86 } // namespace content
85 87
86 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ 88 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698