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

Side by Side Diff: ppapi/shared_impl/audio_impl.h

Issue 8790004: Rename the shared impl files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged Created 9 years 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
« no previous file with comments | « ppapi/shared_impl/audio_config_impl.cc ('k') | ppapi/shared_impl/audio_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef PPAPI_SHARED_IMPL_AUDIO_IMPL_H_
6 #define PPAPI_SHARED_IMPL_AUDIO_IMPL_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/shared_memory.h"
10 #include "base/sync_socket.h"
11 #include "base/threading/simple_thread.h"
12 #include "ppapi/c/ppb_audio.h"
13 #include "ppapi/shared_impl/resource.h"
14 #include "ppapi/thunk/ppb_audio_api.h"
15
16 namespace ppapi {
17
18 // Implements the logic to map shared memory and run the audio thread signaled
19 // from the sync socket. Both the proxy and the renderer implementation use
20 // this code.
21 class PPAPI_SHARED_EXPORT AudioImpl
22 : public thunk::PPB_Audio_API,
23 public base::DelegateSimpleThread::Delegate {
24 public:
25 AudioImpl();
26 virtual ~AudioImpl();
27
28 bool playing() const { return playing_; }
29
30 // Sets the callback information that the background thread will use. This
31 // is optional. Without a callback, the thread will not be run. This
32 // non-callback mode is used in the renderer with the proxy, since the proxy
33 // handles the callback entirely within the plugin process.
34 void SetCallback(PPB_Audio_Callback callback, void* user_data);
35
36 // Configures the current state to be playing or not. The caller is
37 // responsible for ensuring the new state is the opposite of the current one.
38 //
39 // This is the implementation for PPB_Audio.Start/StopPlayback, except that
40 // it does not actually notify the audio system to stop playback, it just
41 // configures our object to stop generating callbacks. The actual stop
42 // playback request will be done in the derived classes and will be different
43 // from the proxy and the renderer.
44 void SetStartPlaybackState();
45 void SetStopPlaybackState();
46
47 // Sets the shared memory and socket handles. This will automatically start
48 // playback if we're currently set to play.
49 void SetStreamInfo(base::SharedMemoryHandle shared_memory_handle,
50 size_t shared_memory_size,
51 base::SyncSocket::Handle socket_handle);
52
53 private:
54 // Starts execution of the audio thread.
55 void StartThread();
56
57 // DelegateSimpleThread::Delegate implementation. Run on the audio thread.
58 virtual void Run();
59
60 // True if playing the stream.
61 bool playing_;
62
63 // Socket used to notify us when audio is ready to accept new samples. This
64 // pointer is created in StreamCreated().
65 scoped_ptr<base::SyncSocket> socket_;
66
67 // Sample buffer in shared memory. This pointer is created in
68 // StreamCreated(). The memory is only mapped when the audio thread is
69 // created.
70 scoped_ptr<base::SharedMemory> shared_memory_;
71
72 // The size of the sample buffer in bytes.
73 size_t shared_memory_size_;
74
75 // When the callback is set, this thread is spawned for calling it.
76 scoped_ptr<base::DelegateSimpleThread> audio_thread_;
77
78 // Callback to call when audio is ready to accept new samples.
79 PPB_Audio_Callback callback_;
80
81 // User data pointer passed verbatim to the callback function.
82 void* user_data_;
83 };
84
85 } // namespace ppapi
86
87 #endif // PPAPI_SHARED_IMPL_AUDIO_IMPL_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/audio_config_impl.cc ('k') | ppapi/shared_impl/audio_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698