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

Unified Diff: content/browser/renderer_host/media/audio_sync_reader.cc

Issue 1487983002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Writing skipped frames to shared memory. Created 5 years 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: content/browser/renderer_host/media/audio_sync_reader.cc
diff --git a/content/browser/renderer_host/media/audio_sync_reader.cc b/content/browser/renderer_host/media/audio_sync_reader.cc
index f6b3d6cef3f7db4a593402a2b355381fc8180f6a..5cdccd70f2988400e7bd1cf99a466cf2290991aa 100644
--- a/content/browser/renderer_host/media/audio_sync_reader.cc
+++ b/content/browser/renderer_host/media/audio_sync_reader.cc
@@ -51,8 +51,11 @@ AudioSyncReader::AudioSyncReader(base::SharedMemory* shared_memory,
maximum_wait_time_(base::TimeDelta::FromMilliseconds(20)),
#endif
buffer_index_(0) {
- DCHECK_EQ(packet_size_, AudioBus::CalculateMemorySize(params));
- output_bus_ = AudioBus::WrapMemory(params, shared_memory->memory());
+ DCHECK_EQ(packet_size_, sizeof(AudioOutputBufferParameters) +
+ AudioBus::CalculateMemorySize(params));
+ AudioOutputBuffer* buffer =
+ reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory());
+ output_bus_ = AudioBus::WrapMemory(params, buffer->audio);
output_bus_->Zero();
}
@@ -81,10 +84,19 @@ AudioSyncReader::~AudioSyncReader() {
}
// media::AudioOutputController::SyncReader implementations.
-void AudioSyncReader::UpdatePendingBytes(uint32 bytes) {
+void AudioSyncReader::UpdatePendingBytes(uint32_t bytes,
+ uint32_t frames_skipped) {
+ // Increase the number of skipped frames stored in shared memory. We don't
tommi (sloooow) - chröme 2015/12/08 08:34:51 why do we increase the number of skipped frames? I
Henrik Grunell 2015/12/08 09:30:34 Afaict, there is a possibility that we write more
tommi (sloooow) - chröme 2015/12/08 10:08:09 Do we still overwrite in that case? I thought we w
Henrik Grunell 2015/12/08 11:12:32 If Wait...() times out, we'll give the OS an empty
tommi (sloooow) - chröme 2015/12/08 11:43:02 I think I'm out of brain power... can you help me
tommi (sloooow) - chröme 2015/12/08 12:27:39 Got some brain power back :) I realize now that I
Henrik Grunell 2015/12/08 12:56:10 :) I'm glad you could.
+ // send it over the socket since sending more than 4 bytes might lead to being
+ // descheduled. The reading side will zero it when consumed.
+ AudioOutputBuffer* buffer =
+ reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory());
+ buffer->params.frames_skipped += frames_skipped;
+
// Zero out the entire output buffer to avoid stuttering/repeating-buffers
// in the anomalous case if the renderer is unable to keep up with real-time.
output_bus_->Zero();
+
socket_->Send(&bytes, sizeof(bytes));
++buffer_index_;
}

Powered by Google App Engine
This is Rietveld 408576698