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