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

Unified Diff: media/audio/audio_device_thread.cc

Issue 22886005: Switch audio synchronization from sleep() based to select() based. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/audio_device_thread.cc
diff --git a/media/audio/audio_device_thread.cc b/media/audio/audio_device_thread.cc
index d5c1bbcebdc652b8d0cf1fd7ac222a1458af2ba7..59e701c885a132b4d5d43c587b1e52d0b1955875 100644
--- a/media/audio/audio_device_thread.cc
+++ b/media/audio/audio_device_thread.cc
@@ -157,6 +157,7 @@ void AudioDeviceThread::Thread::ThreadMain() {
}
void AudioDeviceThread::Thread::Run() {
+ uint32_t buffer_index = 0;
while (true) {
int pending_data = 0;
size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data));
@@ -165,9 +166,16 @@ void AudioDeviceThread::Thread::Run() {
break;
}
- base::AutoLock auto_lock(callback_lock_);
- if (callback_)
- callback_->Process(pending_data);
+ {
+ base::AutoLock auto_lock(callback_lock_);
+ if (callback_)
+ callback_->Process(pending_data);
+ }
+
+ // Let AudioSyncReader know which buffer we just filled.
+ buffer_index++;
henrika (OOO until Aug 14) 2013/08/20 07:50:30 Perhaps I am missing something here but isn't new
tommi (sloooow) - chröme 2013/08/20 10:55:57 nit: ++buffer_index;
DaleCurtis 2013/09/11 01:16:03 This is handled in the new WaitTilDataReady().
DaleCurtis 2013/09/11 01:16:03 Done.
+ CHECK_EQ(socket_.Send(&buffer_index, sizeof(buffer_index)),
+ sizeof(buffer_index));
}
}

Powered by Google App Engine
This is Rietveld 408576698