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

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

Issue 1538563002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fix. git cl format. Rebase. Created 5 years 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_OUTPUT_CONTROLLER_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
7 7
8 #include "base/atomic_ref_count.h" 8 #include "base/atomic_ref_count.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/threading/thread_checker.h"
11 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "media/audio/audio_io.h" 14 #include "media/audio/audio_io.h"
14 #include "media/audio/audio_manager.h" 15 #include "media/audio/audio_manager.h"
15 #include "media/audio/audio_power_monitor.h" 16 #include "media/audio/audio_power_monitor.h"
16 #include "media/audio/audio_source_diverter.h" 17 #include "media/audio/audio_source_diverter.h"
17 #include "media/audio/simple_sources.h" 18 #include "media/audio/simple_sources.h"
18 #include "media/base/media_export.h" 19 #include "media/base/media_export.h"
19 20
20 // An AudioOutputController controls an AudioOutputStream and provides data 21 // An AudioOutputController controls an AudioOutputStream and provides data
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // A synchronous reader interface used by AudioOutputController for 76 // A synchronous reader interface used by AudioOutputController for
76 // synchronous reading. 77 // synchronous reading.
77 // TODO(crogers): find a better name for this class and the Read() method 78 // TODO(crogers): find a better name for this class and the Read() method
78 // now that it can handle synchronized I/O. 79 // now that it can handle synchronized I/O.
79 class SyncReader { 80 class SyncReader {
80 public: 81 public:
81 virtual ~SyncReader() {} 82 virtual ~SyncReader() {}
82 83
83 // Notify the synchronous reader the number of bytes in the 84 // Notify the synchronous reader the number of bytes in the
84 // AudioOutputController not yet played. This is used by SyncReader to 85 // AudioOutputController not yet played. This is used by SyncReader to
85 // prepare more data and perform synchronization. 86 // prepare more data and perform synchronization. Also inform about if any
86 virtual void UpdatePendingBytes(uint32 bytes) = 0; 87 // frames has been skipped by the renderer (typically the OS). The renderer
88 // source can handle this appropriately depending on the type of source. An
89 // ordinary file playout would ignore this.
90 virtual void UpdatePendingBytes(uint32_t bytes,
91 uint32_t frames_skipped) = 0;
87 92
88 // Attempts to completely fill |dest|, zeroing |dest| if the request can not 93 // Attempts to completely fill |dest|, zeroing |dest| if the request can not
89 // be fulfilled (due to timeout). 94 // be fulfilled (due to timeout).
90 virtual void Read(AudioBus* dest) = 0; 95 virtual void Read(AudioBus* dest) = 0;
91 96
92 // Close this synchronous reader. 97 // Close this synchronous reader.
93 virtual void Close() = 0; 98 virtual void Close() = 0;
94 }; 99 };
95 100
96 // Factory method for creating an AudioOutputController. 101 // Factory method for creating an AudioOutputController.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // 151 //
147 // Changing the output device causes the controller to go through 152 // Changing the output device causes the controller to go through
148 // the same state transition back to the current state as a call to 153 // the same state transition back to the current state as a call to
149 // OnDeviceChange (unless it is currently diverting, see 154 // OnDeviceChange (unless it is currently diverting, see
150 // Start/StopDiverting below, in which case the state transition 155 // Start/StopDiverting below, in which case the state transition
151 // will happen when StopDiverting is called). 156 // will happen when StopDiverting is called).
152 void SwitchOutputDevice(const std::string& output_device_id, 157 void SwitchOutputDevice(const std::string& output_device_id,
153 const base::Closure& callback); 158 const base::Closure& callback);
154 159
155 // AudioSourceCallback implementation. 160 // AudioSourceCallback implementation.
156 int OnMoreData(AudioBus* dest, uint32 total_bytes_delay) override; 161 int OnMoreData(AudioBus* dest,
162 uint32_t total_bytes_delay,
163 uint32_t frames_skipped) override;
157 void OnError(AudioOutputStream* stream) override; 164 void OnError(AudioOutputStream* stream) override;
158 165
159 // AudioDeviceListener implementation. When called AudioOutputController will 166 // AudioDeviceListener implementation. When called AudioOutputController will
160 // shutdown the existing |stream_|, transition to the kRecreating state, 167 // shutdown the existing |stream_|, transition to the kRecreating state,
161 // create a new stream, and then transition back to an equivalent state prior 168 // create a new stream, and then transition back to an equivalent state prior
162 // to being called. 169 // to being called.
163 void OnDeviceChange() override; 170 void OnDeviceChange() override;
164 171
165 // AudioSourceDiverter implementation. 172 // AudioSourceDiverter implementation.
166 const AudioParameters& GetAudioParameters() override; 173 const AudioParameters& GetAudioParameters() override;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // be accessed while |error_lock_| is held. 264 // be accessed while |error_lock_| is held.
258 bool ignore_errors_during_stop_close_; 265 bool ignore_errors_during_stop_close_;
259 base::Lock error_lock_; 266 base::Lock error_lock_;
260 267
261 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); 268 DISALLOW_COPY_AND_ASSIGN(AudioOutputController);
262 }; 269 };
263 270
264 } // namespace media 271 } // namespace media
265 272
266 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 273 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « media/audio/audio_low_latency_input_output_unittest.cc ('k') | media/audio/audio_output_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698