Revert of Reland of crrev.com/1100173002 (Add a WinHeap dump provider to the memory...
[chromium-blink-merge.git] / media / base / fake_audio_renderer_sink.h
blobc3c313ae531c83b0ab793ac6cb24ab90b2a52e06
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 "media/audio/audio_parameters.h"
9 #include "media/base/audio_renderer_sink.h"
11 namespace media {
13 class FakeAudioRendererSink : public AudioRendererSink {
14 public:
15 enum State {
16 kUninitialized,
17 kInitialized,
18 kStarted,
19 kPaused,
20 kPlaying,
21 kStopped
24 FakeAudioRendererSink();
26 void Initialize(const AudioParameters& params,
27 RenderCallback* callback) override;
28 void Start() override;
29 void Stop() override;
30 void Pause() override;
31 void Play() override;
32 bool SetVolume(double volume) override;
34 // Attempts to call Render() on the callback provided to
35 // Initialize() with |dest| and |audio_delay_milliseconds|.
36 // Returns true and sets |frames_written| to the return value of the
37 // Render() call.
38 // Returns false if this object is in a state where calling Render()
39 // should not occur. (i.e., in the kPaused or kStopped state.) The
40 // value of |frames_written| is undefined if false is returned.
41 bool Render(AudioBus* dest, int audio_delay_milliseconds,
42 int* frames_written);
43 void OnRenderError();
45 State state() const { return state_; }
47 protected:
48 ~FakeAudioRendererSink() override;
50 private:
51 void ChangeState(State new_state);
53 State state_;
54 RenderCallback* callback_;
56 DISALLOW_COPY_AND_ASSIGN(FakeAudioRendererSink);
59 } // namespace media
61 #endif // MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_