Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / media / base / fake_audio_renderer_sink.h
blob1982ba3d37363c4fd1a50d9a7e1f5a5a3d03d47e
1 // Copyright 2013 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 MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_
6 #define MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_
8 #include <string>
10 #include "media/audio/audio_parameters.h"
11 #include "media/base/audio_renderer_sink.h"
13 namespace media {
15 class FakeAudioRendererSink : public AudioRendererSink {
16 public:
17 enum State {
18 kUninitialized,
19 kInitialized,
20 kStarted,
21 kPaused,
22 kPlaying,
23 kStopped
26 FakeAudioRendererSink();
28 void Initialize(const AudioParameters& params,
29 RenderCallback* callback) override;
30 void Start() override;
31 void Stop() override;
32 void Pause() override;
33 void Play() override;
34 bool SetVolume(double volume) override;
35 void SwitchOutputDevice(const std::string& device_id,
36 const GURL& security_origin,
37 const SwitchOutputDeviceCB& callback) override;
39 // Attempts to call Render() on the callback provided to
40 // Initialize() with |dest| and |audio_delay_milliseconds|.
41 // Returns true and sets |frames_written| to the return value of the
42 // Render() call.
43 // Returns false if this object is in a state where calling Render()
44 // should not occur. (i.e., in the kPaused or kStopped state.) The
45 // value of |frames_written| is undefined if false is returned.
46 bool Render(AudioBus* dest, int audio_delay_milliseconds,
47 int* frames_written);
48 void OnRenderError();
50 State state() const { return state_; }
52 protected:
53 ~FakeAudioRendererSink() override;
55 private:
56 void ChangeState(State new_state);
58 State state_;
59 RenderCallback* callback_;
61 DISALLOW_COPY_AND_ASSIGN(FakeAudioRendererSink);
64 } // namespace media
66 #endif // MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_