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

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: 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..cdc9334180ed14f81abbce7f37fe51e5c3652566 100644
--- a/media/audio/audio_output_device.cc
+++ b/media/audio/audio_output_device.cc
@@ -28,12 +28,19 @@ 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;
+
+ void FramesSkipped(uint32_t frames_skipped) override;
private:
AudioRendererSink::RenderCallback* render_callback_;
scoped_ptr<AudioBus> output_bus_;
uint64 callback_num_;
+
+ // Stores the number of frames skipped by the consumer. Used and cleared in
+ // Process().
tommi (sloooow) - chröme 2015/12/01 13:34:26 nit: and modified in FramesSkipped
Henrik Grunell 2015/12/03 17:01:07 Done.
+ uint32_t frames_skipped_;
+
DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
};
@@ -354,7 +361,7 @@ void AudioOutputDevice::OnStreamCreated(
audio_callback_.reset(new AudioOutputDevice::AudioThreadCallback(
audio_parameters_, handle, length, callback_));
audio_thread_.Start(audio_callback_.get(), socket_handle,
- "AudioOutputDevice", true);
+ "AudioOutputDevice", true, false);
state_ = PAUSED;
// We handle the case where Play() and/or Pause() may have been called
@@ -387,7 +394,8 @@ AudioOutputDevice::AudioThreadCallback::AudioThreadCallback(
AudioRendererSink::RenderCallback* render_callback)
: AudioDeviceThread::Callback(audio_parameters, memory, memory_length, 1),
render_callback_(render_callback),
- callback_num_(0) {}
+ callback_num_(0),
+ frames_skipped_(0) {}
AudioOutputDevice::AudioThreadCallback::~AudioThreadCallback() {
}
@@ -402,7 +410,7 @@ void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
}
// 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_;
@@ -417,10 +425,21 @@ void AudioOutputDevice::AudioThreadCallback::Process(uint32 pending_data) {
TRACE_EVENT_ASYNC_END0("audio", "StartingPlayback", this);
}
+ // Inform about skipped frames if any.
+ if (frames_skipped_ > 0) {
+ render_callback_->OnFramesSkipped(frames_skipped_);
+ frames_skipped_ = 0;
+ }
+
// 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);
}
+void AudioOutputDevice::AudioThreadCallback::FramesSkipped(
tommi (sloooow) - chröme 2015/12/01 13:34:25 thread check (must be on the same thread as Proces
Henrik Grunell 2015/12/03 17:01:07 The contract with AudioDeviceThread is that all ca
+ uint32_t frames_skipped) {
+ frames_skipped_ += frames_skipped;
+}
+
} // namespace media.

Powered by Google App Engine
This is Rietveld 408576698