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

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: android test fix Created 4 years, 5 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
« no previous file with comments | « media/base/audio_renderer_mixer.cc ('k') | media/base/audio_renderer_mixer_input.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 28 matching lines...) Expand all
79 81
80 // AudioConverter::InputCallback implementation. 82 // AudioConverter::InputCallback implementation.
81 double ProvideInput(AudioBus* audio_bus, uint32_t frames_delayed) override; 83 double ProvideInput(AudioBus* audio_bus, uint32_t frames_delayed) override;
82 84
83 // AudioParameters received during Initialize(). 85 // AudioParameters received during Initialize().
84 AudioParameters params_; 86 AudioParameters params_;
85 87
86 const int owner_id_; 88 const int owner_id_;
87 std::string device_id_; // ID of hardware device to use 89 std::string device_id_; // ID of hardware device to use
88 url::Origin security_origin_; 90 url::Origin security_origin_;
91 const AudioLatency::LatencyType latency_;
89 92
90 // AudioRendererMixer obtained from mixer pool during Initialize(), 93 // AudioRendererMixer obtained from mixer pool during Initialize(),
91 // guaranteed to live (at least) until it is returned to the pool. 94 // guaranteed to live (at least) until it is returned to the pool.
92 AudioRendererMixer* mixer_; 95 AudioRendererMixer* mixer_;
93 96
94 // Source of audio data which is provided to the mixer. 97 // Source of audio data which is provided to the mixer.
95 AudioRendererSink::RenderCallback* callback_; 98 AudioRendererSink::RenderCallback* callback_;
96 99
97 // Error callback for handing to AudioRendererMixer. 100 // Error callback for handing to AudioRendererMixer.
98 const base::Closure error_cb_; 101 const base::Closure error_cb_;
99 102
100 // Pending switch-device callback, in case SwitchOutputDevice() is invoked 103 // Pending switch-device callback, in case SwitchOutputDevice() is invoked
101 // before Start() 104 // before Start()
102 OutputDeviceStatusCB pending_switch_callback_; 105 OutputDeviceStatusCB pending_switch_callback_;
103 std::string pending_switch_device_id_; 106 std::string pending_switch_device_id_;
104 url::Origin pending_switch_security_origin_; 107 url::Origin pending_switch_security_origin_;
105 108
106 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); 109 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput);
107 }; 110 };
108 111
109 } // namespace media 112 } // namespace media
110 113
111 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 114 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer.cc ('k') | media/base/audio_renderer_mixer_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698