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

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

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated TestURLLoader to test blocking callbacks. Created 8 years, 8 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 PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ 5 #ifndef PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ 6 #define PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 23 matching lines...) Expand all
34 // Used by the impl. 34 // Used by the impl.
35 explicit PPB_AudioInput_Shared(PP_Instance instance); 35 explicit PPB_AudioInput_Shared(PP_Instance instance);
36 virtual ~PPB_AudioInput_Shared(); 36 virtual ~PPB_AudioInput_Shared();
37 37
38 // Resource overrides. 38 // Resource overrides.
39 virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE; 39 virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE;
40 40
41 // Implementation of PPB_AudioInput_API non-trusted methods. 41 // Implementation of PPB_AudioInput_API non-trusted methods.
42 virtual int32_t EnumerateDevices( 42 virtual int32_t EnumerateDevices(
43 PP_Resource* devices, 43 PP_Resource* devices,
44 const PP_CompletionCallback& callback) OVERRIDE; 44 ApiCallbackType callback) OVERRIDE;
45 virtual int32_t Open(const std::string& device_id, 45 virtual int32_t Open(const std::string& device_id,
46 PP_Resource config, 46 PP_Resource config,
47 PPB_AudioInput_Callback audio_input_callback, 47 PPB_AudioInput_Callback audio_input_callback,
48 void* user_data, 48 void* user_data,
49 const PP_CompletionCallback& callback) OVERRIDE; 49 ApiCallbackType callback) OVERRIDE;
50 virtual PP_Resource GetCurrentConfig() OVERRIDE; 50 virtual PP_Resource GetCurrentConfig() OVERRIDE;
51 virtual PP_Bool StartCapture() OVERRIDE; 51 virtual PP_Bool StartCapture() OVERRIDE;
52 virtual PP_Bool StopCapture() OVERRIDE; 52 virtual PP_Bool StopCapture() OVERRIDE;
53 virtual void Close() OVERRIDE; 53 virtual void Close() OVERRIDE;
54 54
55 void OnEnumerateDevicesComplete(int32_t result, 55 void OnEnumerateDevicesComplete(int32_t result,
56 const std::vector<DeviceRefData>& devices); 56 const std::vector<DeviceRefData>& devices);
57 void OnOpenComplete(int32_t result, 57 void OnOpenComplete(int32_t result,
58 base::SharedMemoryHandle shared_memory_handle, 58 base::SharedMemoryHandle shared_memory_handle,
59 size_t shared_memory_size, 59 size_t shared_memory_size,
60 base::SyncSocket::Handle socket_handle); 60 base::SyncSocket::Handle socket_handle);
61 61
62 static PP_CompletionCallback MakeIgnoredCompletionCallback(); 62 static ApiCallbackType MakeIgnoredCompletionCallback(Resource* resource);
63 63
64 protected: 64 protected:
65 enum OpenState { 65 enum OpenState {
66 BEFORE_OPEN, 66 BEFORE_OPEN,
67 OPENED, 67 OPENED,
68 CLOSED 68 CLOSED
69 }; 69 };
70 70
71 // Subclasses should implement these methods to do impl- and proxy-specific 71 // Subclasses should implement these methods to do impl- and proxy-specific
72 // work. 72 // work.
73 virtual int32_t InternalEnumerateDevices(PP_Resource* devices, 73 virtual int32_t InternalEnumerateDevices(PP_Resource* devices,
74 PP_CompletionCallback callback) = 0; 74 ApiCallbackType callback) = 0;
75 virtual int32_t InternalOpen(const std::string& device_id, 75 virtual int32_t InternalOpen(const std::string& device_id,
76 PP_AudioSampleRate sample_rate, 76 PP_AudioSampleRate sample_rate,
77 uint32_t sample_frame_count, 77 uint32_t sample_frame_count,
78 PP_CompletionCallback callback) = 0; 78 ApiCallbackType callback) = 0;
79 virtual PP_Bool InternalStartCapture() = 0; 79 virtual PP_Bool InternalStartCapture() = 0;
80 virtual PP_Bool InternalStopCapture() = 0; 80 virtual PP_Bool InternalStopCapture() = 0;
81 virtual void InternalClose() = 0; 81 virtual void InternalClose() = 0;
82 82
83 // Configures the current state to be capturing or not. The caller is 83 // Configures the current state to be capturing or not. The caller is
84 // responsible for ensuring the new state is the opposite of the current one. 84 // responsible for ensuring the new state is the opposite of the current one.
85 // 85 //
86 // This is the implementation for PPB_AudioInput.Start/StopCapture, except 86 // This is the implementation for PPB_AudioInput.Start/StopCapture, except
87 // that it does not actually notify the audio system to stop capture, it just 87 // that it does not actually notify the audio system to stop capture, it just
88 // configures our object to stop generating callbacks. The actual stop 88 // configures our object to stop generating callbacks. The actual stop
(...skipping 18 matching lines...) Expand all
107 // The common implementation of OpenTrusted() and Open(). It will call 107 // The common implementation of OpenTrusted() and Open(). It will call
108 // InternalOpen() to do impl- and proxy-specific work. 108 // InternalOpen() to do impl- and proxy-specific work.
109 // OpenTrusted() will call this methods with a NULL |audio_input_callback|, 109 // OpenTrusted() will call this methods with a NULL |audio_input_callback|,
110 // in this case, the thread will not be run. This non-callback mode is used in 110 // in this case, the thread will not be run. This non-callback mode is used in
111 // the renderer with the proxy, since the proxy handles the callback entirely 111 // the renderer with the proxy, since the proxy handles the callback entirely
112 // within the plugin process. 112 // within the plugin process.
113 int32_t CommonOpen(const std::string& device_id, 113 int32_t CommonOpen(const std::string& device_id,
114 PP_Resource config, 114 PP_Resource config,
115 PPB_AudioInput_Callback audio_input_callback, 115 PPB_AudioInput_Callback audio_input_callback,
116 void* user_data, 116 void* user_data,
117 PP_CompletionCallback callback); 117 ApiCallbackType callback);
118 118
119 OpenState open_state_; 119 OpenState open_state_;
120 120
121 // True if capturing the stream. 121 // True if capturing the stream.
122 bool capturing_; 122 bool capturing_;
123 123
124 // Socket used to notify us when new samples are available. This pointer is 124 // Socket used to notify us when new samples are available. This pointer is
125 // created in SetStreamInfo(). 125 // created in SetStreamInfo().
126 scoped_ptr<base::SyncSocket> socket_; 126 scoped_ptr<base::SyncSocket> socket_;
127 127
(...skipping 26 matching lines...) Expand all
154 PP_Resource* devices_; 154 PP_Resource* devices_;
155 155
156 ResourceObjectType resource_object_type_; 156 ResourceObjectType resource_object_type_;
157 157
158 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Shared); 158 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Shared);
159 }; 159 };
160 160
161 } // namespace ppapi 161 } // namespace ppapi
162 162
163 #endif // PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ 163 #endif // PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698