Improve back button behavior.
[chromium-blink-merge.git] / media / base / audio_renderer_sink.h
blob2d1b0aae4c0fa5e397646c0ee2775d3970675d66
1 // Copyright (c) 2012 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_AUDIO_RENDERER_SINK_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_SINK_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h"
15 #include "media/audio/audio_output_ipc.h"
16 #include "media/audio/audio_parameters.h"
17 #include "media/base/audio_bus.h"
18 #include "media/base/media_export.h"
19 #include "media/base/output_device.h"
20 #include "url/gurl.h"
22 namespace base {
23 class SingleThreadTaskRunner;
26 namespace media {
28 // AudioRendererSink is an interface representing the end-point for
29 // rendered audio. An implementation is expected to
30 // periodically call Render() on a callback object.
32 class AudioRendererSink
33 : public base::RefCountedThreadSafe<media::AudioRendererSink> {
34 public:
35 class RenderCallback {
36 public:
37 // Attempts to completely fill all channels of |dest|, returns actual
38 // number of frames filled.
39 virtual int Render(AudioBus* dest, int audio_delay_milliseconds) = 0;
41 // Signals an error has occurred.
42 virtual void OnRenderError() = 0;
44 protected:
45 virtual ~RenderCallback() {}
48 // Sets important information about the audio stream format.
49 // It must be called before any of the other methods.
50 virtual void Initialize(const AudioParameters& params,
51 RenderCallback* callback) = 0;
53 // Starts audio playback.
54 virtual void Start() = 0;
56 // Stops audio playback.
57 virtual void Stop() = 0;
59 // Pauses playback.
60 virtual void Pause() = 0;
62 // Resumes playback after calling Pause().
63 virtual void Play() = 0;
65 // Sets the playback volume, with range [0.0, 1.0] inclusive.
66 // Returns |true| on success.
67 virtual bool SetVolume(double volume) = 0;
69 // Returns a pointer to the internal output device.
70 // This pointer is not to be owned by the caller and is valid only during
71 // the lifetime of the AudioRendererSink.
72 // It can be null, which means that access to the output device is not
73 // supported.
74 virtual OutputDevice* GetOutputDevice() = 0;
76 protected:
77 friend class base::RefCountedThreadSafe<AudioRendererSink>;
78 virtual ~AudioRendererSink() {}
81 } // namespace media
83 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_