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

Side by Side Diff: media/base/audio_renderer_mixer_input.h

Issue 2067863003: Mixing audio with different latency requirements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mixing inputs of the same latency Created 4 years, 6 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 // THREAD SAFETY 5 // THREAD SAFETY
6 // 6 //
7 // This class is generally not thread safe. Callers should ensure thread safety. 7 // This class is generally not thread safe. Callers should ensure thread safety.
8 // For instance, the |sink_lock_| in WebAudioSourceProvider synchronizes access 8 // For instance, the |sink_lock_| in WebAudioSourceProvider synchronizes access
9 // to this object across the main thread (for WebAudio APIs) and the 9 // to this object across the main thread (for WebAudio APIs) and the
10 // media thread (for HTMLMediaElement APIs). 10 // media thread (for HTMLMediaElement APIs).
11 // 11 //
12 // The one exception is protection for |volume_| via |volume_lock_|. This lock 12 // The one exception is protection for |volume_| via |volume_lock_|. This lock
13 // prevents races between SetVolume() (called on any thread) and ProvideInput 13 // prevents races between SetVolume() (called on any thread) and ProvideInput
14 // (called on audio device thread). See http://crbug.com/588992. 14 // (called on audio device thread). See http://crbug.com/588992.
15 15
16 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 16 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
17 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 17 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
18 18
19 #include <string> 19 #include <string>
20 20
21 #include "base/callback.h" 21 #include "base/callback.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/synchronization/lock.h" 23 #include "base/synchronization/lock.h"
24 #include "media/base/audio_converter.h" 24 #include "media/base/audio_converter.h"
25 #include "media/base/audio_latency.h"
25 #include "media/base/audio_renderer_sink.h" 26 #include "media/base/audio_renderer_sink.h"
26 #include "url/origin.h" 27 #include "url/origin.h"
27 28
28 namespace media { 29 namespace media {
29 30
30 class AudioRendererMixerPool; 31 class AudioRendererMixerPool;
31 class AudioRendererMixer; 32 class AudioRendererMixer;
32 33
33 class MEDIA_EXPORT AudioRendererMixerInput 34 class MEDIA_EXPORT AudioRendererMixerInput
34 : NON_EXPORTED_BASE(public SwitchableAudioRendererSink), 35 : NON_EXPORTED_BASE(public SwitchableAudioRendererSink),
35 public AudioConverter::InputCallback { 36 public AudioConverter::InputCallback {
36 public: 37 public:
37 AudioRendererMixerInput(AudioRendererMixerPool* mixer_pool, 38 AudioRendererMixerInput(AudioRendererMixerPool* mixer_pool,
38 int owner_id, 39 int owner_id,
39 const std::string& device_id, 40 const std::string& device_id,
40 const url::Origin& security_origin); 41 const url::Origin& security_origin,
42 AudioLatency::LatencyType latency);
41 43
42 // SwitchableAudioRendererSink implementation. 44 // SwitchableAudioRendererSink implementation.
43 void Start() override; 45 void Start() override;
44 void Stop() override; 46 void Stop() override;
45 void Play() override; 47 void Play() override;
46 void Pause() override; 48 void Pause() override;
47 bool SetVolume(double volume) override; 49 bool SetVolume(double volume) override;
48 OutputDeviceInfo GetOutputDeviceInfo() override; 50 OutputDeviceInfo GetOutputDeviceInfo() override;
49 void Initialize(const AudioParameters& params, 51 void Initialize(const AudioParameters& params,
50 AudioRendererSink::RenderCallback* renderer) override; 52 AudioRendererSink::RenderCallback* renderer) override;
(...skipping 24 matching lines...) Expand all
75 77
76 // AudioConverter::InputCallback implementation. 78 // AudioConverter::InputCallback implementation.
77 double ProvideInput(AudioBus* audio_bus, uint32_t frames_delayed) override; 79 double ProvideInput(AudioBus* audio_bus, uint32_t frames_delayed) override;
78 80
79 // AudioParameters received during Initialize(). 81 // AudioParameters received during Initialize().
80 AudioParameters params_; 82 AudioParameters params_;
81 83
82 const int owner_id_; 84 const int owner_id_;
83 std::string device_id_; // ID of hardware device to use 85 std::string device_id_; // ID of hardware device to use
84 url::Origin security_origin_; 86 url::Origin security_origin_;
87 const AudioLatency::LatencyType latency_;
85 88
86 // AudioRendererMixer obtained from mixer pool during Initialize(), 89 // AudioRendererMixer obtained from mixer pool during Initialize(),
87 // guaranteed to live (at least) until it is returned to the pool. 90 // guaranteed to live (at least) until it is returned to the pool.
88 AudioRendererMixer* mixer_; 91 AudioRendererMixer* mixer_;
89 92
90 // Source of audio data which is provided to the mixer. 93 // Source of audio data which is provided to the mixer.
91 AudioRendererSink::RenderCallback* callback_; 94 AudioRendererSink::RenderCallback* callback_;
92 95
93 // Error callback for handing to AudioRendererMixer. 96 // Error callback for handing to AudioRendererMixer.
94 const base::Closure error_cb_; 97 const base::Closure error_cb_;
95 98
96 // Pending switch-device callback, in case SwitchOutputDevice() is invoked 99 // Pending switch-device callback, in case SwitchOutputDevice() is invoked
97 // before Start() 100 // before Start()
98 OutputDeviceStatusCB pending_switch_callback_; 101 OutputDeviceStatusCB pending_switch_callback_;
99 std::string pending_switch_device_id_; 102 std::string pending_switch_device_id_;
100 url::Origin pending_switch_security_origin_; 103 url::Origin pending_switch_security_origin_;
101 104
102 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); 105 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput);
103 }; 106 };
104 107
105 } // namespace media 108 } // namespace media
106 109
107 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 110 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698