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

Unified Diff: media/base/audio_renderer_mixer_input.h

Issue 1748183006: Add lock to fix race in AudioRendererMixerInput. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | media/base/audio_renderer_mixer_input.cc » ('j') | media/base/audio_renderer_mixer_input.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_renderer_mixer_input.h
diff --git a/media/base/audio_renderer_mixer_input.h b/media/base/audio_renderer_mixer_input.h
index 34f37c5ee00a3c0d0803ef4f807992942bbf8401..4a0165781918bf2c7eec902236123d69d94eb688 100644
--- a/media/base/audio_renderer_mixer_input.h
+++ b/media/base/audio_renderer_mixer_input.h
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "base/synchronization/lock.h"
#include "media/base/audio_converter.h"
#include "media/base/audio_renderer_sink.h"
#include "media/base/output_device.h"
@@ -69,13 +70,30 @@ class MEDIA_EXPORT AudioRendererMixerInput
private:
friend class AudioRendererMixerInputTest;
+ // AudioConverter::InputCallback implementation.
+ double ProvideInput(AudioBus* audio_bus,
+ base::TimeDelta buffer_delay) override;
+
+ // The implementation for these methods is split out to avoid re-entrant
+ // locking when called by multiple internal callers. Re-entrant locking is
+ // not supported with base::Lock.
+ void Stop_Locked();
+ void Play_Locked();
+ void Pause_Locked();
+ void SwitchOutputDevice_Locked(const std::string& device_id,
+ const url::Origin& security_origin,
+ const SwitchOutputDeviceCB& callback);
+
+ // This class is used by both media thread (e.g. SetVolume) and audio device
+ // thread (e.g. ProvideInput).
+ base::Lock lock_;
+
+ // ---------------[ All variables below protected by |lock_| ]---------------
+
bool started_;
bool playing_;
double volume_;
- // AudioConverter::InputCallback implementation.
- double ProvideInput(AudioBus* audio_bus,
- base::TimeDelta buffer_delay) override;
// Callbacks provided during construction which allow AudioRendererMixerInput
// to retrieve a mixer during Initialize() and notify when it's done with it.
« no previous file with comments | « no previous file | media/base/audio_renderer_mixer_input.cc » ('j') | media/base/audio_renderer_mixer_input.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698