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

Unified Diff: media/audio/audio_output_device.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: media/audio/audio_output_device.cc
diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc
index 9924f76b83e5e4e435a6f0a5598a22a68acad809..0a4cd664556ffbd38242f06decb8a3acf5cf7a4c 100644
--- a/media/audio/audio_output_device.cc
+++ b/media/audio/audio_output_device.cc
@@ -28,12 +28,13 @@ class AudioOutputDevice::AudioThreadCallback
void MapSharedMemory() override;
// Called whenever we receive notifications about pending data.
- void Process(uint32 pending_data) override;
+ void Process(uint32_t pending_data) override;
private:
AudioRendererSink::RenderCallback* render_callback_;
scoped_ptr<AudioBus> output_bus_;
uint64 callback_num_;
+
DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
};
@@ -395,16 +396,19 @@ AudioOutputDevice::AudioThreadCallback::~AudioThreadCallback() {
void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
CHECK_EQ(total_segments_, 1);
CHECK(shared_memory_.Map(memory_length_));
- DCHECK_EQ(memory_length_, AudioBus::CalculateMemorySize(audio_parameters_));
+ DCHECK_EQ(memory_length_,
+ sizeof(AudioOutputBufferParameters) +
+ AudioBus::CalculateMemorySize(audio_parameters_));
- output_bus_ =
- AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory());
+ AudioOutputBuffer* buffer =
+ reinterpret_cast<AudioOutputBuffer*>(shared_memory_.memory());
+ output_bus_ = AudioBus::WrapMemory(audio_parameters_, buffer->audio);
}
// Called whenever we receive notifications about pending data.
-void AudioOutputDevice::AudioThreadCallback::Process(uint32 pending_data) {
+void AudioOutputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
// Convert the number of pending bytes in the render buffer into milliseconds.
- int audio_delay_milliseconds = pending_data / bytes_per_ms_;
+ uint32_t audio_delay_milliseconds = pending_data / bytes_per_ms_;
callback_num_++;
TRACE_EVENT1("audio", "AudioOutputDevice::FireRenderCallback",
@@ -417,10 +421,18 @@ void AudioOutputDevice::AudioThreadCallback::Process(uint32 pending_data) {
TRACE_EVENT_ASYNC_END0("audio", "StartingPlayback", this);
}
- // Update the audio-delay measurement then ask client to render audio. Since
- // |output_bus_| is wrapping the shared memory the Render() call is writing
- // directly into the shared memory.
- render_callback_->Render(output_bus_.get(), audio_delay_milliseconds);
+ // Read and reset the number of frames skipped.
+ AudioOutputBuffer* buffer =
+ reinterpret_cast<AudioOutputBuffer*>(shared_memory_.memory());
+ uint32_t frames_skipped = buffer->params.frames_skipped;
+ buffer->params.frames_skipped = 0;
tommi (sloooow) - chröme 2015/12/08 08:34:51 ah, so we reset the value here... is there a reaso
Henrik Grunell 2015/12/08 09:30:34 Yes, as my reply to the other comment, we can over
+
+ // Update the audio-delay measurement, inform about the number of skipped
+ // frames, and ask client to render audio. Since |output_bus_| is wrapping
+ // the shared memory the Render() call is writing directly into the shared
+ // memory.
+ render_callback_->Render(output_bus_.get(), audio_delay_milliseconds,
+ frames_skipped);
}
-} // namespace media.
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698