-
Notifications
You must be signed in to change notification settings - Fork 0
/
audiosourceprovider_impl.h
63 lines (50 loc) · 2.06 KB
/
audiosourceprovider_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
//
#ifndef CHROMIUM_MEDIA_LIB_AUDIOSOURCE_PROVIDER_IMPL_H_
#define CHROMIUM_MEDIA_LIB_AUDIOSOURCE_PROVIDER_IMPL_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
#include "media/base/audio_renderer_sink.h"
namespace media {
class MediaLog;
class MEDIA_EXPORT AudioSourceProviderImpl
: public SwitchableAudioRendererSink {
public:
using CopyAudioCB = base::Callback<void(std::unique_ptr<AudioBus>,
uint32_t frames_delayed,
int sample_rate)>;
AudioSourceProviderImpl(scoped_refptr<SwitchableAudioRendererSink> sink,
MediaLog* media_log);
// RestartableAudioRendererSink implementation.
void Initialize(const AudioParameters& params,
RenderCallback* callback) override;
void Start() override;
void Stop() override;
void Play() override;
void Pause() override;
bool SetVolume(double volume) override;
OutputDeviceInfo GetOutputDeviceInfo() override;
bool IsOptimizedForHardwareParameters() override;
bool CurrentThreadIsRenderingThread() override;
void SwitchOutputDevice(const std::string& device_id,
const url::Origin& security_origin,
const OutputDeviceStatusCB& callback) override;
protected:
scoped_refptr<SwitchableAudioRendererSink> CreateFallbackSink();
~AudioSourceProviderImpl() override;
private:
double volume_;
base::Lock sink_lock_;
scoped_refptr<SwitchableAudioRendererSink> sink_;
class TeeFilter;
const std::unique_ptr<TeeFilter> tee_filter_;
MediaLog* const media_log_;
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<AudioSourceProviderImpl> weak_factory_;
DISALLOW_IMPLICIT_CONSTRUCTORS(AudioSourceProviderImpl);
};
}
#endif // CHROMIUM_MEDIA_LIB_AUDIOSOURCE_PROVIDER_IMPL_H_