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

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

Issue 2060833002: Implementation of 'AudioContext.getOutputTimestamp' method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implementation of 'AudioContext.getOutputTimestamp' method Created 4 years, 6 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 "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Because we support more audio streams than physically available channels 42 // Because we support more audio streams than physically available channels
43 // a given AudioOutputStream might or might not talk directly to hardware. 43 // a given AudioOutputStream might or might not talk directly to hardware.
44 // An audio stream allocates several buffers for audio data and calls 44 // An audio stream allocates several buffers for audio data and calls
45 // AudioSourceCallback::OnMoreData() periodically to fill these buffers, 45 // AudioSourceCallback::OnMoreData() periodically to fill these buffers,
46 // as the data is written to the audio device. Size of each packet is determined 46 // as the data is written to the audio device. Size of each packet is determined
47 // by |samples_per_packet| specified in AudioParameters when the stream is 47 // by |samples_per_packet| specified in AudioParameters when the stream is
48 // created. 48 // created.
49 49
50 namespace media { 50 namespace media {
51 51
52 struct MEDIA_EXPORT AudioTimestamp {
53 int64_t frames;
54 int64_t ticks; // Obtained from base::TimeTicks::ToInternalValue().
55 };
56
57 // Used in unittests.
58 inline bool operator==(const AudioTimestamp& one, const AudioTimestamp& other) {
59 return one.ticks == other.ticks && one.frames == other.frames;
60 }
61
52 class MEDIA_EXPORT AudioOutputStream { 62 class MEDIA_EXPORT AudioOutputStream {
53 public: 63 public:
54 // Audio sources must implement AudioSourceCallback. This interface will be 64 // Audio sources must implement AudioSourceCallback. This interface will be
55 // called in a random thread which very likely is a high priority thread. Do 65 // 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 66 // not rely on using this thread TLS or make calls that alter the thread
57 // itself such as creating Windows or initializing COM. 67 // itself such as creating Windows or initializing COM.
58 class MEDIA_EXPORT AudioSourceCallback { 68 class MEDIA_EXPORT AudioSourceCallback {
59 public: 69 public:
60 virtual ~AudioSourceCallback() {} 70 virtual ~AudioSourceCallback() {}
61 71
62 // Provide more data by fully filling |dest|. The source will return 72 // Provide more data by fully filling |dest|. The source will return
63 // the number of frames it filled. |total_bytes_delay| contains current 73 // the number of frames it filled. |total_bytes_delay| contains current
64 // number of bytes of delay buffered by the AudioOutputStream. 74 // number of bytes of delay buffered by the AudioOutputStream.
65 // |frames_skipped| contains the number of frames skipped by the consumer. 75 // |frames_skipped| contains the number of frames skipped by the consumer.
76 // |timestamp| if provided, contains timestamp of the currently audible
77 // signal.
66 virtual int OnMoreData(AudioBus* dest, 78 virtual int OnMoreData(AudioBus* dest,
67 uint32_t total_bytes_delay, 79 uint32_t total_bytes_delay,
68 uint32_t frames_skipped) = 0; 80 uint32_t frames_skipped,
81 const AudioTimestamp& output_timestamp = {0, 0}) = 0;
69 82
70 // There was an error while playing a buffer. Audio source cannot be 83 // 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 84 // 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 85 // a good place to stop accumulating sound data since is is likely that
73 // playback will not continue. 86 // playback will not continue.
74 virtual void OnError(AudioOutputStream* stream) = 0; 87 virtual void OnError(AudioOutputStream* stream) = 0;
75 }; 88 };
76 89
77 virtual ~AudioOutputStream() {} 90 virtual ~AudioOutputStream() {}
78 91
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // Returns the Automatic Gain Control (AGC) state. 181 // Returns the Automatic Gain Control (AGC) state.
169 virtual bool GetAutomaticGainControl() = 0; 182 virtual bool GetAutomaticGainControl() = 0;
170 183
171 // Returns the current muting state for the microphone. 184 // Returns the current muting state for the microphone.
172 virtual bool IsMuted() = 0; 185 virtual bool IsMuted() = 0;
173 }; 186 };
174 187
175 } // namespace media 188 } // namespace media
176 189
177 #endif // MEDIA_AUDIO_AUDIO_IO_H_ 190 #endif // MEDIA_AUDIO_AUDIO_IO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698