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

Side by Side Diff: chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h

Issue 2341783004: [chromecast] Slew stream volume changes in StreamMixerAlsa. (Closed)
Patch Set: address comments Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_ 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_
6 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_ 6 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "chromecast/media/cma/backend/alsa/media_pipeline_backend_alsa.h" 16 #include "chromecast/media/cma/backend/alsa/media_pipeline_backend_alsa.h"
17 #include "chromecast/media/cma/backend/alsa/slew_volume.h"
17 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa.h" 18 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa.h"
18 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input.h" 19 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input.h"
19 20
20 namespace base { 21 namespace base {
21 class SingleThreadTaskRunner; 22 class SingleThreadTaskRunner;
22 } // namespace base 23 } // namespace base
23 24
24 namespace media { 25 namespace media {
25 class AudioBus; 26 class AudioBus;
26 class MultiChannelResampler; 27 class MultiChannelResampler;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 107
107 // Prevents any further calls to the delegate (ie, called when the delegate 108 // Prevents any further calls to the delegate (ie, called when the delegate
108 // is being destroyed). 109 // is being destroyed).
109 void PreventDelegateCalls(); 110 void PreventDelegateCalls();
110 111
111 State state() const { return state_; } 112 State state() const { return state_; }
112 113
113 private: 114 private:
114 // StreamMixerAlsa::InputQueue implementation: 115 // StreamMixerAlsa::InputQueue implementation:
115 int input_samples_per_second() const override; 116 int input_samples_per_second() const override;
116 float volume_multiplier() const override;
117 bool primary() const override; 117 bool primary() const override;
118 bool IsDeleting() const override; 118 bool IsDeleting() const override;
119 void Initialize(const MediaPipelineBackendAlsa::RenderingDelay& 119 void Initialize(const MediaPipelineBackendAlsa::RenderingDelay&
120 mixer_rendering_delay) override; 120 mixer_rendering_delay) override;
121 int MaxReadSize() override; 121 int MaxReadSize() override;
122 void GetResampledData(::media::AudioBus* dest, int frames) override; 122 void GetResampledData(::media::AudioBus* dest, int frames) override;
123 void VolumeScaleAccumulate(const float* src,
124 int frames,
125 float* dest) override;
123 void AfterWriteFrames(const MediaPipelineBackendAlsa::RenderingDelay& 126 void AfterWriteFrames(const MediaPipelineBackendAlsa::RenderingDelay&
124 mixer_rendering_delay) override; 127 mixer_rendering_delay) override;
125 void SignalError(StreamMixerAlsaInput::MixerError error) override; 128 void SignalError(StreamMixerAlsaInput::MixerError error) override;
126 void PrepareToDelete(const OnReadyToDeleteCb& delete_cb) override; 129 void PrepareToDelete(const OnReadyToDeleteCb& delete_cb) override;
127 130
128 // Tells the mixer to delete |this|. Makes sure not to call |delete_cb_| more 131 // Tells the mixer to delete |this|. Makes sure not to call |delete_cb_| more
129 // than once for |this|. 132 // than once for |this|.
130 void DeleteThis(); 133 void DeleteThis();
131 MediaPipelineBackendAlsa::RenderingDelay QueueData( 134 MediaPipelineBackendAlsa::RenderingDelay QueueData(
132 const scoped_refptr<DecoderBufferBase>& data); 135 const scoped_refptr<DecoderBufferBase>& data);
133 void PostPcmCallback(const MediaPipelineBackendAlsa::RenderingDelay& delay); 136 void PostPcmCallback(const MediaPipelineBackendAlsa::RenderingDelay& delay);
134 void DidQueueData(bool end_of_stream); 137 void DidQueueData(bool end_of_stream);
135 void ReadCB(int frame_delay, ::media::AudioBus* output); 138 void ReadCB(int frame_delay, ::media::AudioBus* output);
136 void FillFrames(int frame_delay, ::media::AudioBus* output, int frames); 139 void FillFrames(int frame_delay, ::media::AudioBus* output, int frames);
137 int NormalFadeFrames(); 140 int NormalFadeFrames();
138 void FadeIn(::media::AudioBus* dest, int frames); 141 void FadeIn(::media::AudioBus* dest, int frames);
139 void FadeOut(::media::AudioBus* dest, int frames); 142 void FadeOut(::media::AudioBus* dest, int frames);
140 void PostError(StreamMixerAlsaInput::MixerError error); 143 void PostError(StreamMixerAlsaInput::MixerError error);
141 144
142 StreamMixerAlsaInput::Delegate* const delegate_; 145 StreamMixerAlsaInput::Delegate* const delegate_;
143 const int input_samples_per_second_; 146 const int input_samples_per_second_;
144 const bool primary_; 147 const bool primary_;
145 StreamMixerAlsa* const mixer_; 148 StreamMixerAlsa* const mixer_;
146 const scoped_refptr<base::SingleThreadTaskRunner> mixer_task_runner_; 149 const scoped_refptr<base::SingleThreadTaskRunner> mixer_task_runner_;
147 const scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 150 const scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
148 151
149 double resample_ratio_; 152 double resample_ratio_;
150 153
151 State state_; 154 State state_;
152 float volume_multiplier_; 155 SlewVolume slew_volume_;
153 156
154 base::Lock queue_lock_; // Lock for the following queue-related members. 157 base::Lock queue_lock_; // Lock for the following queue-related members.
155 scoped_refptr<DecoderBufferBase> pending_data_; 158 scoped_refptr<DecoderBufferBase> pending_data_;
156 std::deque<scoped_refptr<DecoderBufferBase>> queue_; 159 std::deque<scoped_refptr<DecoderBufferBase>> queue_;
157 int queued_frames_; 160 int queued_frames_;
158 double queued_frames_including_resampler_; 161 double queued_frames_including_resampler_;
159 MediaPipelineBackendAlsa::RenderingDelay mixer_rendering_delay_; 162 MediaPipelineBackendAlsa::RenderingDelay mixer_rendering_delay_;
160 // End of members that queue_lock_ controls access for. 163 // End of members that queue_lock_ controls access for.
161 164
162 int current_buffer_offset_; 165 int current_buffer_offset_;
163 int max_queued_frames_; 166 int max_queued_frames_;
164 int fade_frames_remaining_; 167 int fade_frames_remaining_;
165 int fade_out_frames_total_; 168 int fade_out_frames_total_;
166 int zeroed_frames_; // current count of consecutive 0-filled frames 169 int zeroed_frames_; // current count of consecutive 0-filled frames
167 170
168 OnReadyToDeleteCb delete_cb_; 171 OnReadyToDeleteCb delete_cb_;
169 172
170 std::unique_ptr<::media::MultiChannelResampler> resampler_; 173 std::unique_ptr<::media::MultiChannelResampler> resampler_;
171 174
172 base::WeakPtr<StreamMixerAlsaInputImpl> weak_this_; 175 base::WeakPtr<StreamMixerAlsaInputImpl> weak_this_;
173 base::WeakPtrFactory<StreamMixerAlsaInputImpl> weak_factory_; 176 base::WeakPtrFactory<StreamMixerAlsaInputImpl> weak_factory_;
174 177
175 DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsaInputImpl); 178 DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsaInputImpl);
176 }; 179 };
177 180
178 } // namespace media 181 } // namespace media
179 } // namespace chromecast 182 } // namespace chromecast
180 183
181 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_ 184 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698