Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / chrome / renderer / media / cast_receiver_audio_valve.h
blob4ac8a93b433a726fdf86d19e50277085fbce171e
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_
6 #define CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_
8 #include "base/synchronization/lock.h"
9 #include "media/base/audio_capturer_source.h"
11 namespace media {
12 class AudioBus;
15 // Forwards calls to |cb| until Stop is called.
16 // Thread-safe.
17 // All functions may block depending on contention.
18 class CastReceiverAudioValve :
19 public media::AudioCapturerSource::CaptureCallback,
20 public base::RefCountedThreadSafe<CastReceiverAudioValve> {
21 public:
22 explicit CastReceiverAudioValve(
23 media::AudioCapturerSource::CaptureCallback* cb);
25 // AudioCapturerSource::CaptureCallback implementation.
26 void Capture(const media::AudioBus* audio_source,
27 int audio_delay_milliseconds,
28 double volume,
29 bool key_pressed) override;
30 void OnCaptureError() override;
32 // When this returns, no more calls will be forwarded to |cb|.
33 void Stop();
35 private:
36 friend class base::RefCountedThreadSafe<CastReceiverAudioValve>;
37 ~CastReceiverAudioValve() override;
38 media::AudioCapturerSource::CaptureCallback* cb_;
39 base::Lock lock_;
42 #endif // CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_