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

Side by Side 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: Rebase Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread_checker.h"
12 #include "media/base/audio_converter.h" 14 #include "media/base/audio_converter.h"
13 #include "media/base/audio_renderer_sink.h" 15 #include "media/base/audio_renderer_sink.h"
14 #include "media/base/output_device.h" 16 #include "media/base/output_device.h"
15 #include "url/origin.h" 17 #include "url/origin.h"
16 18
17 namespace media { 19 namespace media {
18 20
19 class AudioRendererMixer; 21 class AudioRendererMixer;
20 22
21 class MEDIA_EXPORT AudioRendererMixerInput 23 class MEDIA_EXPORT AudioRendererMixerInput
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 64
63 // Called by AudioRendererMixer when an error occurs. 65 // Called by AudioRendererMixer when an error occurs.
64 void OnRenderError(); 66 void OnRenderError();
65 67
66 protected: 68 protected:
67 ~AudioRendererMixerInput() override; 69 ~AudioRendererMixerInput() override;
68 70
69 private: 71 private:
70 friend class AudioRendererMixerInputTest; 72 friend class AudioRendererMixerInputTest;
71 73
74 // Used to DCHECK that control methods (Start/Stop/Switch...) are called from
75 // the same thread.
76 base::ThreadChecker thread_checker_;
77
78 // Protect |volume_|, accessed by separate threads in ProvideInput() and
79 // SetVolume().
80 base::Lock volume_lock_;
81
72 bool started_; 82 bool started_;
73 bool playing_; 83 bool playing_;
74 double volume_; 84 double volume_;
75 85
76 // AudioConverter::InputCallback implementation. 86 // AudioConverter::InputCallback implementation.
77 double ProvideInput(AudioBus* audio_bus, 87 double ProvideInput(AudioBus* audio_bus,
78 base::TimeDelta buffer_delay) override; 88 base::TimeDelta buffer_delay) override;
79 89
80 // Callbacks provided during construction which allow AudioRendererMixerInput 90 // Callbacks provided during construction which allow AudioRendererMixerInput
81 // to retrieve a mixer during Initialize() and notify when it's done with it. 91 // to retrieve a mixer during Initialize() and notify when it's done with it.
(...skipping 26 matching lines...) Expand all
108 SwitchOutputDeviceCB pending_switch_callback_; 118 SwitchOutputDeviceCB pending_switch_callback_;
109 std::string pending_switch_device_id_; 119 std::string pending_switch_device_id_;
110 url::Origin pending_switch_security_origin_; 120 url::Origin pending_switch_security_origin_;
111 121
112 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); 122 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput);
113 }; 123 };
114 124
115 } // namespace media 125 } // namespace media
116 126
117 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 127 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
OLDNEW
« 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