| Index: ppapi/shared_impl/ppb_audio_shared.cc
|
| diff --git a/ppapi/shared_impl/ppb_audio_shared.cc b/ppapi/shared_impl/ppb_audio_shared.cc
|
| index ced11466970c6e2ba26eb9d87fb3f1c94d49993b..70c739ca961e795ae2287151f017cb4bbf59d72b 100644
|
| --- a/ppapi/shared_impl/ppb_audio_shared.cc
|
| +++ b/ppapi/shared_impl/ppb_audio_shared.cc
|
| @@ -73,7 +73,7 @@ void PPB_Audio_Shared::SetCallback(const AudioCallbackCombined& callback,
|
| user_data_ = user_data;
|
| }
|
|
|
| -void PPB_Audio_Shared::SetStartPlaybackState() {
|
| +bool PPB_Audio_Shared::SetStartPlaybackState() {
|
| DCHECK(!playing_);
|
| #if !defined(OS_NACL)
|
| DCHECK(!audio_thread_.get());
|
| @@ -86,7 +86,9 @@ void PPB_Audio_Shared::SetStartPlaybackState() {
|
| // flag and the playback will automatically start when that data is available
|
| // in SetStreamInfo.
|
| playing_ = true;
|
| - StartThread();
|
| + if (!StartThread())
|
| + playing_ = false;
|
| + return playing_;
|
| }
|
|
|
| void PPB_Audio_Shared::SetStopPlaybackState() {
|
| @@ -127,12 +129,21 @@ void PPB_Audio_Shared::SetStreamInfo(
|
| StartThread();
|
| }
|
|
|
| -void PPB_Audio_Shared::StartThread() {
|
| +bool PPB_Audio_Shared::StartThread() {
|
| +#if defined(OS_NACL)
|
| + // Use NaCl's special API for IRT code that creates threads that call back
|
| + // into user code.
|
| + if (NULL == thread_functions.thread_create ||
|
| + NULL == thread_functions.thread_join)
|
| + return false;
|
| +#endif
|
| +
|
| // Don't start the thread unless all our state is set up correctly.
|
| if (!playing_ || !callback_.IsValid() || !socket_.get() ||
|
| !shared_memory_->memory() || !audio_bus_.get() || !client_buffer_.get() ||
|
| bytes_per_second_ == 0)
|
| - return;
|
| + return true;
|
| +
|
| // Clear contents of shm buffer before starting audio thread. This will
|
| // prevent a burst of static if for some reason the audio thread doesn't
|
| // start up quickly enough.
|
| @@ -144,16 +155,12 @@ void PPB_Audio_Shared::StartThread() {
|
| new base::DelegateSimpleThread(this, "plugin_audio_thread"));
|
| audio_thread_->Start();
|
| #else
|
| - // Use NaCl's special API for IRT code that creates threads that call back
|
| - // into user code.
|
| - if (NULL == thread_functions.thread_create ||
|
| - NULL == thread_functions.thread_join)
|
| - return;
|
| -
|
| + DCHECK(!thread_active_);
|
| int result = thread_functions.thread_create(&thread_id_, CallRun, this);
|
| DCHECK_EQ(result, 0);
|
| thread_active_ = true;
|
| #endif
|
| + return true;
|
| }
|
|
|
| void PPB_Audio_Shared::StopThread() {
|
| @@ -183,8 +190,8 @@ void PPB_Audio_Shared::StopThread() {
|
| // static
|
| void PPB_Audio_Shared::SetThreadFunctions(
|
| const struct PP_ThreadFunctions* functions) {
|
| - DCHECK(thread_functions.thread_create == NULL);
|
| - DCHECK(thread_functions.thread_join == NULL);
|
| + // DCHECK(thread_functions.thread_create == NULL);
|
| + // DCHECK(thread_functions.thread_join == NULL);
|
| thread_functions = *functions;
|
| }
|
|
|
|
|