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

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

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

Powered by Google App Engine
This is Rietveld 408576698