| OLD | NEW |
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 float volume_multiplier() const override; |
| 117 bool primary() const override; | 118 bool primary() const override; |
| 118 bool IsDeleting() const override; | 119 bool IsDeleting() const override; |
| 119 void Initialize(const MediaPipelineBackendAlsa::RenderingDelay& | 120 void Initialize(const MediaPipelineBackendAlsa::RenderingDelay& |
| 120 mixer_rendering_delay) override; | 121 mixer_rendering_delay) override; |
| 121 int MaxReadSize() override; | 122 int MaxReadSize() override; |
| 122 void GetResampledData(::media::AudioBus* dest, int frames) override; | 123 void GetResampledData(::media::AudioBus* dest, int frames) override; |
| 124 bool VolumeScaleAccumulate(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_; |
| 156 SlewVolume slew_volume_; |
| 152 float volume_multiplier_; | 157 float volume_multiplier_; |
| 153 | 158 |
| 154 base::Lock queue_lock_; // Lock for the following queue-related members. | 159 base::Lock queue_lock_; // Lock for the following queue-related members. |
| 155 scoped_refptr<DecoderBufferBase> pending_data_; | 160 scoped_refptr<DecoderBufferBase> pending_data_; |
| 156 std::deque<scoped_refptr<DecoderBufferBase>> queue_; | 161 std::deque<scoped_refptr<DecoderBufferBase>> queue_; |
| 157 int queued_frames_; | 162 int queued_frames_; |
| 158 double queued_frames_including_resampler_; | 163 double queued_frames_including_resampler_; |
| 159 MediaPipelineBackendAlsa::RenderingDelay mixer_rendering_delay_; | 164 MediaPipelineBackendAlsa::RenderingDelay mixer_rendering_delay_; |
| 160 // End of members that queue_lock_ controls access for. | 165 // End of members that queue_lock_ controls access for. |
| 161 | 166 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 172 base::WeakPtr<StreamMixerAlsaInputImpl> weak_this_; | 177 base::WeakPtr<StreamMixerAlsaInputImpl> weak_this_; |
| 173 base::WeakPtrFactory<StreamMixerAlsaInputImpl> weak_factory_; | 178 base::WeakPtrFactory<StreamMixerAlsaInputImpl> weak_factory_; |
| 174 | 179 |
| 175 DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsaInputImpl); | 180 DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsaInputImpl); |
| 176 }; | 181 }; |
| 177 | 182 |
| 178 } // namespace media | 183 } // namespace media |
| 179 } // namespace chromecast | 184 } // namespace chromecast |
| 180 | 185 |
| 181 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_ | 186 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_ |
| OLD | NEW |