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

Side by Side Diff: media/base/audio_renderer_mixer.h

Issue 1687213002: Express audio delay more precisely in frames rather than milliseconds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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_BASE_AUDIO_RENDERER_MIXER_H_ 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // parameters of the new device and the output parameters with which the 51 // parameters of the new device and the output parameters with which the
52 // mixer was initialized. See crbug.com/506507 52 // mixer was initialized. See crbug.com/506507
53 OutputDevice* GetOutputDevice(); 53 OutputDevice* GetOutputDevice();
54 54
55 private: 55 private:
56 // Maps input sample rate to the dedicated converter. 56 // Maps input sample rate to the dedicated converter.
57 typedef std::map<int, scoped_ptr<LoopbackAudioConverter>> AudioConvertersMap; 57 typedef std::map<int, scoped_ptr<LoopbackAudioConverter>> AudioConvertersMap;
58 58
59 // AudioRendererSink::RenderCallback implementation. 59 // AudioRendererSink::RenderCallback implementation.
60 int Render(AudioBus* audio_bus, 60 int Render(AudioBus* audio_bus,
61 uint32_t audio_delay_milliseconds, 61 uint32_t frames_delayed,
62 uint32_t frames_skipped) override; 62 uint32_t frames_skipped) override;
63 void OnRenderError() override; 63 void OnRenderError() override;
64 64
65 bool is_master_sample_rate(int sample_rate) { 65 bool is_master_sample_rate(int sample_rate) {
66 return sample_rate == output_params_.sample_rate(); 66 return sample_rate == output_params_.sample_rate();
67 } 67 }
68 68
69 // Output sink for this mixer. 69 // Output sink for this mixer.
70 scoped_refptr<AudioRendererSink> audio_sink_; 70 scoped_refptr<AudioRendererSink> audio_sink_;
71 71
72 // Output parameters for this mixer. 72 // Output parameters for this mixer.
73 AudioParameters output_params_; 73 AudioParameters output_params_;
74 double microseconds_per_frame_;
74 75
75 // ---------------[ All variables below protected by |lock_| ]--------------- 76 // ---------------[ All variables below protected by |lock_| ]---------------
76 base::Lock lock_; 77 base::Lock lock_;
77 78
78 // List of error callbacks used by this mixer. 79 // List of error callbacks used by this mixer.
79 typedef std::list<base::Closure> ErrorCallbackList; 80 typedef std::list<base::Closure> ErrorCallbackList;
80 ErrorCallbackList error_callbacks_; 81 ErrorCallbackList error_callbacks_;
81 82
82 // Each of these converters mixes inputs with a given sample rate and 83 // Each of these converters mixes inputs with a given sample rate and
83 // resamples them to the output sample rate. Inputs not reqiuring resampling 84 // resamples them to the output sample rate. Inputs not reqiuring resampling
84 // go directly to |master_converter_|. 85 // go directly to |master_converter_|.
85 AudioConvertersMap converters_; 86 AudioConvertersMap converters_;
86 87
87 // Master converter which mixes all the outputs from |converters_| as well as 88 // Master converter which mixes all the outputs from |converters_| as well as
88 // mixer inputs that are in the output sample rate. 89 // mixer inputs that are in the output sample rate.
89 AudioConverter master_converter_; 90 AudioConverter master_converter_;
90 91
91 // Handles physical stream pause when no inputs are playing. For latency 92 // Handles physical stream pause when no inputs are playing. For latency
92 // reasons we don't want to immediately pause the physical stream. 93 // reasons we don't want to immediately pause the physical stream.
93 base::TimeDelta pause_delay_; 94 base::TimeDelta pause_delay_;
94 base::TimeTicks last_play_time_; 95 base::TimeTicks last_play_time_;
95 bool playing_; 96 bool playing_;
96 97
97 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer); 98 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer);
98 }; 99 };
99 100
100 } // namespace media 101 } // namespace media
101 102
102 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 103 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698