Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: media/audio/audio_io.h

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Pass target playout time to AudioSourceCallback::OnMoreData. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_AUDIO_AUDIO_IO_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_IO_H_
6 #define MEDIA_AUDIO_AUDIO_IO_H_ 6 #define MEDIA_AUDIO_AUDIO_IO_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/time/time.h"
10 #include "media/base/audio_bus.h" 11 #include "media/base/audio_bus.h"
11 12
12 // Low-level audio output support. To make sound there are 3 objects involved: 13 // Low-level audio output support. To make sound there are 3 objects involved:
13 // - AudioSource : produces audio samples on a pull model. Implements 14 // - AudioSource : produces audio samples on a pull model. Implements
14 // the AudioSourceCallback interface. 15 // the AudioSourceCallback interface.
15 // - AudioOutputStream : uses the AudioSource to render audio on a given 16 // - AudioOutputStream : uses the AudioSource to render audio on a given
16 // channel, format and sample frequency configuration. Data from the 17 // channel, format and sample frequency configuration. Data from the
17 // AudioSource is delivered in a 'pull' model. 18 // AudioSource is delivered in a 'pull' model.
18 // - AudioManager : factory for the AudioOutputStream objects, manager 19 // - AudioManager : factory for the AudioOutputStream objects, manager
19 // of the hardware resources and mixer control. 20 // of the hardware resources and mixer control.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 class MEDIA_EXPORT AudioOutputStream { 53 class MEDIA_EXPORT AudioOutputStream {
53 public: 54 public:
54 // Audio sources must implement AudioSourceCallback. This interface will be 55 // Audio sources must implement AudioSourceCallback. This interface will be
55 // called in a random thread which very likely is a high priority thread. Do 56 // called in a random thread which very likely is a high priority thread. Do
56 // not rely on using this thread TLS or make calls that alter the thread 57 // not rely on using this thread TLS or make calls that alter the thread
57 // itself such as creating Windows or initializing COM. 58 // itself such as creating Windows or initializing COM.
58 class MEDIA_EXPORT AudioSourceCallback { 59 class MEDIA_EXPORT AudioSourceCallback {
59 public: 60 public:
60 virtual ~AudioSourceCallback() {} 61 virtual ~AudioSourceCallback() {}
61 62
62 // Provide more data by fully filling |dest|. The source will return 63 // Provide more data by fully filling |dest|. The source will return the
63 // the number of frames it filled. |total_bytes_delay| contains current 64 // number of frames it filled. |target_playout_time| is the time when the
64 // number of bytes of delay buffered by the AudioOutputStream. 65 // first sample added to |dest| is expected to be played and should equal
65 // |frames_skipped| contains the number of frames skipped by the consumer. 66 // the audio output delay added to the time when it was calculated. It may
66 virtual int OnMoreData(AudioBus* dest, 67 // be used to determine when to make adjustments to keep audio output
67 uint32_t total_bytes_delay, 68 // synchronized, such as adjusting the media clock rate or adding or
68 uint32_t frames_skipped) = 0; 69 // dropping frames. The accuracy of |target_playout_time| may vary depending
70 // on the platform and implementation. |prior_frames_skipped| is the number
71 // of frames skipped by the consumer.
72 virtual int OnMoreData(base::TimeTicks target_playout_time,
73 int prior_frames_skipped,
74 AudioBus* dest) = 0;
69 75
70 // There was an error while playing a buffer. Audio source cannot be 76 // There was an error while playing a buffer. Audio source cannot be
71 // destroyed yet. No direct action needed by the AudioStream, but it is 77 // destroyed yet. No direct action needed by the AudioStream, but it is
72 // a good place to stop accumulating sound data since is is likely that 78 // a good place to stop accumulating sound data since is is likely that
73 // playback will not continue. 79 // playback will not continue.
74 virtual void OnError(AudioOutputStream* stream) = 0; 80 virtual void OnError(AudioOutputStream* stream) = 0;
75 }; 81 };
76 82
77 virtual ~AudioOutputStream() {} 83 virtual ~AudioOutputStream() {}
78 84
(...skipping 28 matching lines...) Expand all
107 public: 113 public:
108 class MEDIA_EXPORT AudioInputCallback { 114 class MEDIA_EXPORT AudioInputCallback {
109 public: 115 public:
110 // Called by the audio recorder when a full packet of audio data is 116 // Called by the audio recorder when a full packet of audio data is
111 // available. This is called from a special audio thread and the 117 // available. This is called from a special audio thread and the
112 // implementation should return as soon as possible. 118 // implementation should return as soon as possible.
113 // TODO(henrika): should be pure virtual when old OnData() is phased out. 119 // TODO(henrika): should be pure virtual when old OnData() is phased out.
114 virtual void OnData(AudioInputStream* stream, 120 virtual void OnData(AudioInputStream* stream,
115 const AudioBus* source, 121 const AudioBus* source,
116 uint32_t hardware_delay_bytes, 122 uint32_t hardware_delay_bytes,
117 double volume){}; 123 double volume) {}
118 124
119 // TODO(henrika): don't use; to be removed. 125 // TODO(henrika): don't use; to be removed.
120 virtual void OnData(AudioInputStream* stream, 126 virtual void OnData(AudioInputStream* stream,
121 const uint8_t* src, 127 const uint8_t* src,
122 uint32_t size, 128 uint32_t size,
123 uint32_t hardware_delay_bytes, 129 uint32_t hardware_delay_bytes,
124 double volume){}; 130 double volume) {}
125 131
126 // There was an error while recording audio. The audio sink cannot be 132 // There was an error while recording audio. The audio sink cannot be
127 // destroyed yet. No direct action needed by the AudioInputStream, but it 133 // destroyed yet. No direct action needed by the AudioInputStream, but it
128 // is a good place to stop accumulating sound data since is is likely that 134 // is a good place to stop accumulating sound data since is is likely that
129 // recording will not continue. 135 // recording will not continue.
130 virtual void OnError(AudioInputStream* stream) = 0; 136 virtual void OnError(AudioInputStream* stream) = 0;
131 137
132 protected: 138 protected:
133 virtual ~AudioInputCallback() {} 139 virtual ~AudioInputCallback() {}
134 }; 140 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // Returns the Automatic Gain Control (AGC) state. 174 // Returns the Automatic Gain Control (AGC) state.
169 virtual bool GetAutomaticGainControl() = 0; 175 virtual bool GetAutomaticGainControl() = 0;
170 176
171 // Returns the current muting state for the microphone. 177 // Returns the current muting state for the microphone.
172 virtual bool IsMuted() = 0; 178 virtual bool IsMuted() = 0;
173 }; 179 };
174 180
175 } // namespace media 181 } // namespace media
176 182
177 #endif // MEDIA_AUDIO_AUDIO_IO_H_ 183 #endif // MEDIA_AUDIO_AUDIO_IO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698