summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-21 23:43:57 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-21 23:43:57 +0000
commit38244d9bed99ff00c33235a27b80b28368c21cf3 (patch)
treeb68e34ac9121cf548f384391fd8a303d5f2819fb /ppapi/shared_impl
parent72bbaccaa082a3ad6fff9bbc1cf70d01dabd79e8 (diff)
downloadchromium_src-38244d9bed99ff00c33235a27b80b28368c21cf3.zip
chromium_src-38244d9bed99ff00c33235a27b80b28368c21cf3.tar.gz
chromium_src-38244d9bed99ff00c33235a27b80b28368c21cf3.tar.bz2
PepperPlatformAudioInputImpl: support audio input device selection.
BUG=None TEST=ppapi/examples/audio_input Review URL: http://codereview.chromium.org/9705056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r--ppapi/shared_impl/ppb_audio_input_shared.cc37
1 files changed, 25 insertions, 12 deletions
diff --git a/ppapi/shared_impl/ppb_audio_input_shared.cc b/ppapi/shared_impl/ppb_audio_input_shared.cc
index 3028894..9af25a9 100644
--- a/ppapi/shared_impl/ppb_audio_input_shared.cc
+++ b/ppapi/shared_impl/ppb_audio_input_shared.cc
@@ -91,17 +91,30 @@ PP_Bool PPB_AudioInput_Shared::StartCapture() {
if (capturing_)
return PP_TRUE;
+ // If the audio input device hasn't been opened, set |capturing_| to true and
+ // return directly. Capturing will be started once the open operation is
+ // completed.
+ if (open_state_ == BEFORE_OPEN) {
+ capturing_ = true;
+ return PP_TRUE;
+ }
+
return InternalStartCapture();
}
PP_Bool PPB_AudioInput_Shared::StopCapture() {
- if (open_state_ == CLOSED || (open_state_ == BEFORE_OPEN &&
- !TrackedCallback::IsPending(open_callback_))) {
+ if (open_state_ == CLOSED)
return PP_FALSE;
- }
if (!capturing_)
return PP_TRUE;
+ // If the audio input device hasn't been opened, set |capturing_| to false and
+ // return directly.
+ if (open_state_ == BEFORE_OPEN) {
+ capturing_ = false;
+ return PP_TRUE;
+ }
+
return InternalStopCapture();
}
@@ -150,6 +163,7 @@ void PPB_AudioInput_Shared::OnOpenComplete(
// Clean up the handles.
base::SyncSocket temp_socket(socket_handle);
base::SharedMemory temp_mem(shared_memory_handle, false);
+ capturing_ = false;
}
// The callback may have been aborted by Close().
@@ -166,11 +180,6 @@ void PPB_AudioInput_Shared::SetStartCaptureState() {
DCHECK(!capturing_);
DCHECK(!audio_input_thread_.get());
- // If the socket doesn't exist, that means that the plugin has started before
- // the browser has had a chance to create all the shared memory info and
- // notify us. This is a common case. In this case, we just set the capturing_
- // flag and the capture will automatically start when that data is available
- // in SetStreamInfo.
if (audio_input_callback_ && socket_.get())
StartThread();
capturing_ = true;
@@ -194,12 +203,16 @@ void PPB_AudioInput_Shared::SetStreamInfo(
shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false));
shared_memory_size_ = shared_memory_size;
- if (audio_input_callback_) {
+ if (audio_input_callback_)
shared_memory_->Map(shared_memory_size_);
- // StartCapture() may be called before SetSreamInfo().
- if (capturing_)
- StartThread();
+ // There is a pending capture request before SetStreamInfo().
+ if (capturing_) {
+ // Set |capturing_| to false so that the state looks consistent to
+ // InternalStartCapture(). It will be reset to true by
+ // SetStartCaptureState().
+ capturing_ = false;
+ InternalStartCapture();
}
}