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

Unified Diff: media/audio/audio_output_device.cc

Issue 1538563002: 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: Code review fix. git cl format. Rebase. 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
« no previous file with comments | « media/audio/audio_output_controller_unittest.cc ('k') | media/audio/audio_output_device_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cc0804b7079b00cf1ac97f653739dc94efd252d4 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(static_cast<size_t>(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;
+
+ // 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
« no previous file with comments | « media/audio/audio_output_controller_unittest.cc ('k') | media/audio/audio_output_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698