| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ | 5 #ifndef MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ |
| 6 #define MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ | 6 #define MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "media/audio/audio_parameters.h" | 13 #include "media/audio/audio_parameters.h" |
| 14 #include "media/base/audio_renderer_sink.h" | 14 #include "media/base/audio_renderer_sink.h" |
| 15 #include "media/base/output_device_info.h" |
| 15 | 16 |
| 16 namespace media { | 17 namespace media { |
| 17 | 18 |
| 18 class FakeOutputDevice; | |
| 19 | |
| 20 class FakeAudioRendererSink : public AudioRendererSink { | 19 class FakeAudioRendererSink : public AudioRendererSink { |
| 21 public: | 20 public: |
| 22 enum State { | 21 enum State { |
| 23 kUninitialized, | 22 kUninitialized, |
| 24 kInitialized, | 23 kInitialized, |
| 25 kStarted, | 24 kStarted, |
| 26 kPaused, | 25 kPaused, |
| 27 kPlaying, | 26 kPlaying, |
| 28 kStopped | 27 kStopped |
| 29 }; | 28 }; |
| 30 | 29 |
| 31 FakeAudioRendererSink(); | 30 FakeAudioRendererSink(); |
| 32 | 31 |
| 33 void Initialize(const AudioParameters& params, | 32 void Initialize(const AudioParameters& params, |
| 34 RenderCallback* callback) override; | 33 RenderCallback* callback) override; |
| 35 void Start() override; | 34 void Start() override; |
| 36 void Stop() override; | 35 void Stop() override; |
| 37 void Pause() override; | 36 void Pause() override; |
| 38 void Play() override; | 37 void Play() override; |
| 39 bool SetVolume(double volume) override; | 38 bool SetVolume(double volume) override; |
| 40 OutputDevice* GetOutputDevice() override; | 39 OutputDeviceInfo GetOutputDeviceInfo() override; |
| 41 | 40 |
| 42 // Attempts to call Render() on the callback provided to | 41 // Attempts to call Render() on the callback provided to |
| 43 // Initialize() with |dest| and |audio_delay_milliseconds|. | 42 // Initialize() with |dest| and |audio_delay_milliseconds|. |
| 44 // Returns true and sets |frames_written| to the return value of the | 43 // Returns true and sets |frames_written| to the return value of the |
| 45 // Render() call. | 44 // Render() call. |
| 46 // Returns false if this object is in a state where calling Render() | 45 // Returns false if this object is in a state where calling Render() |
| 47 // should not occur. (i.e., in the kPaused or kStopped state.) The | 46 // should not occur. (i.e., in the kPaused or kStopped state.) The |
| 48 // value of |frames_written| is undefined if false is returned. | 47 // value of |frames_written| is undefined if false is returned. |
| 49 bool Render(AudioBus* dest, | 48 bool Render(AudioBus* dest, |
| 50 uint32_t audio_delay_milliseconds, | 49 uint32_t audio_delay_milliseconds, |
| 51 int* frames_written); | 50 int* frames_written); |
| 52 void OnRenderError(); | 51 void OnRenderError(); |
| 53 | 52 |
| 54 State state() const { return state_; } | 53 State state() const { return state_; } |
| 55 | 54 |
| 56 protected: | 55 protected: |
| 57 ~FakeAudioRendererSink() override; | 56 ~FakeAudioRendererSink() override; |
| 58 | 57 |
| 59 private: | 58 private: |
| 60 void ChangeState(State new_state); | 59 void ChangeState(State new_state); |
| 61 | 60 |
| 62 State state_; | 61 State state_; |
| 63 RenderCallback* callback_; | 62 RenderCallback* callback_; |
| 64 scoped_ptr<FakeOutputDevice> output_device_; | 63 OutputDeviceInfo output_device_info_; |
| 65 | 64 |
| 66 DISALLOW_COPY_AND_ASSIGN(FakeAudioRendererSink); | 65 DISALLOW_COPY_AND_ASSIGN(FakeAudioRendererSink); |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 } // namespace media | 68 } // namespace media |
| 70 | 69 |
| 71 #endif // MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ | 70 #endif // MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ |
| OLD | NEW |