| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
| 6 #define MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
| 7 |
| 8 #include <vector> |
| 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "media/audio/audio_parameters.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 // AudioRendererSink is an interface representing the end-point for |
| 17 // rendered audio. An implementation is expected to |
| 18 // periodically call Render() on a callback object. |
| 19 |
| 20 class AudioRendererSink |
| 21 : public base::RefCountedThreadSafe<media::AudioRendererSink> { |
| 22 public: |
| 23 class RenderCallback { |
| 24 public: |
| 25 // Fills entire buffer of length |number_of_frames| but returns actual |
| 26 // number of frames it got from its source (|number_of_frames| in case of |
| 27 // continuous stream). That actual number of frames is passed to host |
| 28 // together with PCM audio data and host is free to use or ignore it. |
| 29 // TODO(crogers): use base:Callback instead. |
| 30 virtual size_t Render(const std::vector<float*>& audio_data, |
| 31 size_t number_of_frames, |
| 32 size_t audio_delay_milliseconds) = 0; |
| 33 |
| 34 protected: |
| 35 virtual ~RenderCallback() {} |
| 36 }; |
| 37 |
| 38 virtual ~AudioRendererSink() {} |
| 39 |
| 40 // Sets important information about the audio stream format. |
| 41 // It must be called before any of the other methods. |
| 42 virtual void Initialize(size_t buffer_size, |
| 43 int channels, |
| 44 double sample_rate, |
| 45 AudioParameters::Format latency_format, |
| 46 RenderCallback* callback) = 0; |
| 47 |
| 48 // Starts audio playback. |
| 49 virtual void Start() = 0; |
| 50 |
| 51 // Stops audio playback. |
| 52 virtual void Stop() = 0; |
| 53 |
| 54 // Pauses playback. |
| 55 virtual void Pause(bool flush) = 0; |
| 56 |
| 57 // Resumes playback after calling Pause(). |
| 58 virtual void Play() = 0; |
| 59 |
| 60 // Sets the playback volume, with range [0.0, 1.0] inclusive. |
| 61 // Returns |true| on success. |
| 62 virtual bool SetVolume(double volume) = 0; |
| 63 |
| 64 // Gets the playback volume, with range [0.0, 1.0] inclusive. |
| 65 virtual void GetVolume(double* volume) = 0; |
| 66 }; |
| 67 |
| 68 } // namespace media |
| 69 |
| 70 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
| OLD | NEW |