Index: content/renderer/media/audio_input_device.cc |
=================================================================== |
--- content/renderer/media/audio_input_device.cc (revision 111890) |
+++ content/renderer/media/audio_input_device.cc (working copy) |
@@ -25,7 +25,8 @@ |
volume_(1.0), |
stream_id_(0), |
session_id_(0), |
- pending_device_ready_(false) { |
+ pending_device_ready_(false), |
+ audio_event_(true, false) { |
filter_ = RenderThreadImpl::current()->audio_input_message_filter(); |
audio_data_.reserve(channels); |
#if defined(OS_MACOSX) |
@@ -90,8 +91,8 @@ |
// function call. |
if (completion.TimedWait(kMaxTimeOut)) { |
if (audio_thread_.get()) { |
- // Terminate the main thread function in the audio thread. |
- socket_->Close(); |
+ // Signal the |audio_event_| to terminate the main thread function. |
+ audio_event_.Signal(); |
// Wait for the audio thread to exit. |
audio_thread_->Join(); |
// Ensures that we can call Stop() multiple times. |
@@ -199,6 +200,7 @@ |
socket_.reset(new base::SyncSocket(socket_handle)); |
+ audio_event_.Reset(); |
audio_thread_.reset( |
new base::DelegateSimpleThread(this, "RendererAudioInputThread")); |
audio_thread_->Start(); |
@@ -287,7 +289,8 @@ |
const int bytes_per_ms = audio_parameters_.channels * |
(audio_parameters_.bits_per_sample / 8) * samples_per_ms; |
- while (sizeof(pending_data) == socket_->Receive(&pending_data, |
+ while (!audio_event_.IsSignaled() && |
Ami GONE FROM CHROMIUM
2011/11/29 17:48:32
I'm not super-familiar with the audio codebase, bu
tommi (sloooow) - chröme
2011/11/29 20:11:32
Hey Ami,
A couple of questions inline:
On 2011/1
Ami GONE FROM CHROMIUM
2011/11/29 20:38:16
The problem is with the other case; IsSignaled() m
no longer working on chromium
2011/11/30 17:02:55
Event is thread safe. In the case you mentioned ab
|
+ sizeof(pending_data) == socket_->Receive(&pending_data, |
sizeof(pending_data)) && |
pending_data >= 0) { |
// TODO(henrika): investigate the provided |pending_data| value |
@@ -299,6 +302,9 @@ |
FireCaptureCallback(); |
} |
+ |
+ // Close the socket. |
+ socket_->Close(); |
} |
void AudioInputDevice::FireCaptureCallback() { |