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

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: fix unittests 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(bool repeat_transition,
124 const float* src,
125 int frames,
126 float* dest) override;
123 void AfterWriteFrames(const MediaPipelineBackendAlsa::RenderingDelay& 127 void AfterWriteFrames(const MediaPipelineBackendAlsa::RenderingDelay&
124 mixer_rendering_delay) override; 128 mixer_rendering_delay) override;
125 void SignalError(StreamMixerAlsaInput::MixerError error) override; 129 void SignalError(StreamMixerAlsaInput::MixerError error) override;
126 void PrepareToDelete(const OnReadyToDeleteCb& delete_cb) override; 130 void PrepareToDelete(const OnReadyToDeleteCb& delete_cb) override;
127 131
128 // Tells the mixer to delete |this|. Makes sure not to call |delete_cb_| more 132 // Tells the mixer to delete |this|. Makes sure not to call |delete_cb_| more
129 // than once for |this|. 133 // than once for |this|.
130 void DeleteThis(); 134 void DeleteThis();
131 MediaPipelineBackendAlsa::RenderingDelay QueueData( 135 MediaPipelineBackendAlsa::RenderingDelay QueueData(
132 const scoped_refptr<DecoderBufferBase>& data); 136 const scoped_refptr<DecoderBufferBase>& data);
133 void PostPcmCallback(const MediaPipelineBackendAlsa::RenderingDelay& delay); 137 void PostPcmCallback(const MediaPipelineBackendAlsa::RenderingDelay& delay);
134 void DidQueueData(bool end_of_stream); 138 void DidQueueData(bool end_of_stream);
135 void ReadCB(int frame_delay, ::media::AudioBus* output); 139 void ReadCB(int frame_delay, ::media::AudioBus* output);
136 void FillFrames(int frame_delay, ::media::AudioBus* output, int frames); 140 void FillFrames(int frame_delay, ::media::AudioBus* output, int frames);
137 int NormalFadeFrames(); 141 int NormalFadeFrames();
138 void FadeIn(::media::AudioBus* dest, int frames); 142 void FadeIn(::media::AudioBus* dest, int frames);
139 void FadeOut(::media::AudioBus* dest, int frames); 143 void FadeOut(::media::AudioBus* dest, int frames);
140 void PostError(StreamMixerAlsaInput::MixerError error); 144 void PostError(StreamMixerAlsaInput::MixerError error);
141 145
142 StreamMixerAlsaInput::Delegate* const delegate_; 146 StreamMixerAlsaInput::Delegate* const delegate_;
143 const int input_samples_per_second_; 147 const int input_samples_per_second_;
144 const bool primary_; 148 const bool primary_;
145 StreamMixerAlsa* const mixer_; 149 StreamMixerAlsa* const mixer_;
146 const scoped_refptr<base::SingleThreadTaskRunner> mixer_task_runner_; 150 const scoped_refptr<base::SingleThreadTaskRunner> mixer_task_runner_;
147 const scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 151 const scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
148 152
149 double resample_ratio_; 153 double resample_ratio_;
150 154
151 State state_; 155 State state_;
152 float volume_multiplier_; 156 SlewVolume slew_volume_;
153 157
154 base::Lock queue_lock_; // Lock for the following queue-related members. 158 base::Lock queue_lock_; // Lock for the following queue-related members.
155 scoped_refptr<DecoderBufferBase> pending_data_; 159 scoped_refptr<DecoderBufferBase> pending_data_;
156 std::deque<scoped_refptr<DecoderBufferBase>> queue_; 160 std::deque<scoped_refptr<DecoderBufferBase>> queue_;
157 int queued_frames_; 161 int queued_frames_;
158 double queued_frames_including_resampler_; 162 double queued_frames_including_resampler_;
159 MediaPipelineBackendAlsa::RenderingDelay mixer_rendering_delay_; 163 MediaPipelineBackendAlsa::RenderingDelay mixer_rendering_delay_;
160 // End of members that queue_lock_ controls access for. 164 // End of members that queue_lock_ controls access for.
161 165
162 int current_buffer_offset_; 166 int current_buffer_offset_;
163 int max_queued_frames_; 167 int max_queued_frames_;
164 int fade_frames_remaining_; 168 int fade_frames_remaining_;
165 int fade_out_frames_total_; 169 int fade_out_frames_total_;
166 int zeroed_frames_; // current count of consecutive 0-filled frames 170 int zeroed_frames_; // current count of consecutive 0-filled frames
167 171
168 OnReadyToDeleteCb delete_cb_; 172 OnReadyToDeleteCb delete_cb_;
169 173
170 std::unique_ptr<::media::MultiChannelResampler> resampler_; 174 std::unique_ptr<::media::MultiChannelResampler> resampler_;
171 175
172 base::WeakPtr<StreamMixerAlsaInputImpl> weak_this_; 176 base::WeakPtr<StreamMixerAlsaInputImpl> weak_this_;
173 base::WeakPtrFactory<StreamMixerAlsaInputImpl> weak_factory_; 177 base::WeakPtrFactory<StreamMixerAlsaInputImpl> weak_factory_;
174 178
175 DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsaInputImpl); 179 DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsaInputImpl);
176 }; 180 };
177 181
178 } // namespace media 182 } // namespace media
179 } // namespace chromecast 183 } // namespace chromecast
180 184
181 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_ 185 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698