OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_AUDIO_RENDERER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_H_ |
6 #define MEDIA_BASE_AUDIO_RENDERER_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "media/base/buffering_state.h" | 11 #include "media/base/buffering_state.h" |
12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
13 #include "media/base/pipeline_status.h" | 13 #include "media/base/pipeline_status.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 class DemuxerStream; | 17 class DemuxerStream; |
18 | 18 |
19 class MEDIA_EXPORT AudioRenderer { | 19 class MEDIA_EXPORT AudioRenderer { |
20 public: | 20 public: |
21 // First parameter is the current time that has been rendered. | 21 // First parameter is the current time that has been rendered. |
22 // Second parameter is the maximum time value that the clock cannot exceed. | 22 // Second parameter is the maximum time value that the clock cannot exceed. |
23 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; | 23 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; |
24 | 24 |
25 AudioRenderer(); | 25 AudioRenderer(); |
| 26 |
| 27 // Stop all operations and fire all pending callbacks. |
26 virtual ~AudioRenderer(); | 28 virtual ~AudioRenderer(); |
27 | 29 |
28 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon | 30 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon |
29 // completion. | 31 // completion. |
30 // | 32 // |
31 // |statistics_cb| is executed periodically with audio rendering stats. | 33 // |statistics_cb| is executed periodically with audio rendering stats. |
32 // | 34 // |
33 // |time_cb| is executed whenever time has advanced by way of audio rendering. | 35 // |time_cb| is executed whenever time has advanced by way of audio rendering. |
34 // | 36 // |
35 // |buffering_state_cb| is executed when audio rendering has either run out of | 37 // |buffering_state_cb| is executed when audio rendering has either run out of |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // | 70 // |
69 // Clients should expect |buffering_state_cb| to be called with | 71 // Clients should expect |buffering_state_cb| to be called with |
70 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 72 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
71 virtual void Flush(const base::Closure& callback) = 0; | 73 virtual void Flush(const base::Closure& callback) = 0; |
72 | 74 |
73 // Starts playback by reading from |stream| and decoding and rendering audio. | 75 // Starts playback by reading from |stream| and decoding and rendering audio. |
74 // | 76 // |
75 // Only valid to call after a successful Initialize() or Flush(). | 77 // Only valid to call after a successful Initialize() or Flush(). |
76 virtual void StartPlaying() = 0; | 78 virtual void StartPlaying() = 0; |
77 | 79 |
78 // Stop all operations in preparation for being deleted, executing |callback| | |
79 // when complete. | |
80 virtual void Stop(const base::Closure& callback) = 0; | |
81 | |
82 // Updates the current playback rate. | 80 // Updates the current playback rate. |
83 // | 81 // |
84 // TODO(scherkus): Fold into TimeSource API. | 82 // TODO(scherkus): Fold into TimeSource API. |
85 virtual void SetPlaybackRate(float playback_rate) = 0; | 83 virtual void SetPlaybackRate(float playback_rate) = 0; |
86 | 84 |
87 // Sets the output volume. | 85 // Sets the output volume. |
88 virtual void SetVolume(float volume) = 0; | 86 virtual void SetVolume(float volume) = 0; |
89 | 87 |
90 private: | 88 private: |
91 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); | 89 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); |
92 }; | 90 }; |
93 | 91 |
94 } // namespace media | 92 } // namespace media |
95 | 93 |
96 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ | 94 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ |
OLD | NEW |