| 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 #include <string> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 16 #include "chromecast/media/cma/backend/alsa/media_pipeline_backend_alsa.h" | 17 #include "chromecast/media/cma/backend/alsa/media_pipeline_backend_alsa.h" |
| 17 #include "chromecast/media/cma/backend/alsa/slew_volume.h" | 18 #include "chromecast/media/cma/backend/alsa/slew_volume.h" |
| 18 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa.h" | 19 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa.h" |
| 19 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input.h" | 20 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 kStatePaused, // Currently paused. | 84 kStatePaused, // Currently paused. |
| 84 kStateGotEos, // Got the end-of-stream buffer (normal playback). | 85 kStateGotEos, // Got the end-of-stream buffer (normal playback). |
| 85 kStateFinalFade, // Fading out to a deleted state. | 86 kStateFinalFade, // Fading out to a deleted state. |
| 86 kStateDeleted, // Told the mixer to delete this. | 87 kStateDeleted, // Told the mixer to delete this. |
| 87 kStateError, // A mixer error occurred, this is unusable now. | 88 kStateError, // A mixer error occurred, this is unusable now. |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 StreamMixerAlsaInputImpl(StreamMixerAlsaInput::Delegate* delegate, | 91 StreamMixerAlsaInputImpl(StreamMixerAlsaInput::Delegate* delegate, |
| 91 int input_samples_per_second, | 92 int input_samples_per_second, |
| 92 bool primary, | 93 bool primary, |
| 94 std::string name, |
| 93 StreamMixerAlsa* mixer); | 95 StreamMixerAlsa* mixer); |
| 94 | 96 |
| 95 ~StreamMixerAlsaInputImpl() override; | 97 ~StreamMixerAlsaInputImpl() override; |
| 96 | 98 |
| 97 // Queues some PCM data to be mixed. |data| must be in planar float format. | 99 // Queues some PCM data to be mixed. |data| must be in planar float format. |
| 98 void WritePcm(const scoped_refptr<DecoderBufferBase>& data); | 100 void WritePcm(const scoped_refptr<DecoderBufferBase>& data); |
| 99 | 101 |
| 100 // Sets the pause state of this stream. | 102 // Sets the pause state of this stream. |
| 101 void SetPaused(bool paused); | 103 void SetPaused(bool paused); |
| 102 | 104 |
| 103 // Sets the volume multiplier for this stream. If |multiplier| < 0, sets the | 105 // Sets the volume multiplier for this stream. If |multiplier| < 0, sets the |
| 104 // volume multiplier to 0. If |multiplier| > 1, sets the volume multiplier | 106 // volume multiplier to 0. If |multiplier| > 1, sets the volume multiplier |
| 105 // to 1. | 107 // to 1. |
| 106 void SetVolumeMultiplier(float multiplier); | 108 void SetVolumeMultiplier(float multiplier); |
| 107 | 109 |
| 108 // Prevents any further calls to the delegate (ie, called when the delegate | 110 // Prevents any further calls to the delegate (ie, called when the delegate |
| 109 // is being destroyed). | 111 // is being destroyed). |
| 110 void PreventDelegateCalls(); | 112 void PreventDelegateCalls(); |
| 111 | 113 |
| 112 State state() const { return state_; } | 114 State state() const { return state_; } |
| 113 | 115 |
| 114 private: | 116 private: |
| 115 // StreamMixerAlsa::InputQueue implementation: | 117 // StreamMixerAlsa::InputQueue implementation: |
| 116 int input_samples_per_second() const override; | 118 int input_samples_per_second() const override; |
| 117 bool primary() const override; | 119 bool primary() const override; |
| 120 std::string name() const override; |
| 118 bool IsDeleting() const override; | 121 bool IsDeleting() const override; |
| 119 void Initialize(const MediaPipelineBackendAlsa::RenderingDelay& | 122 void Initialize(const MediaPipelineBackendAlsa::RenderingDelay& |
| 120 mixer_rendering_delay) override; | 123 mixer_rendering_delay) override; |
| 121 int MaxReadSize() override; | 124 int MaxReadSize() override; |
| 122 void GetResampledData(::media::AudioBus* dest, int frames) override; | 125 void GetResampledData(::media::AudioBus* dest, int frames) override; |
| 123 void OnSkipped() override; | 126 void OnSkipped() override; |
| 124 void VolumeScaleAccumulate(bool repeat_transition, | 127 void VolumeScaleAccumulate(bool repeat_transition, |
| 125 const float* src, | 128 const float* src, |
| 126 int frames, | 129 int frames, |
| 127 float* dest) override; | 130 float* dest) override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 140 void ReadCB(int frame_delay, ::media::AudioBus* output); | 143 void ReadCB(int frame_delay, ::media::AudioBus* output); |
| 141 void FillFrames(int frame_delay, ::media::AudioBus* output, int frames); | 144 void FillFrames(int frame_delay, ::media::AudioBus* output, int frames); |
| 142 int NormalFadeFrames(); | 145 int NormalFadeFrames(); |
| 143 void FadeIn(::media::AudioBus* dest, int frames); | 146 void FadeIn(::media::AudioBus* dest, int frames); |
| 144 void FadeOut(::media::AudioBus* dest, int frames); | 147 void FadeOut(::media::AudioBus* dest, int frames); |
| 145 void PostError(StreamMixerAlsaInput::MixerError error); | 148 void PostError(StreamMixerAlsaInput::MixerError error); |
| 146 | 149 |
| 147 StreamMixerAlsaInput::Delegate* const delegate_; | 150 StreamMixerAlsaInput::Delegate* const delegate_; |
| 148 const int input_samples_per_second_; | 151 const int input_samples_per_second_; |
| 149 const bool primary_; | 152 const bool primary_; |
| 153 std::string name_; |
| 150 StreamMixerAlsa* const mixer_; | 154 StreamMixerAlsa* const mixer_; |
| 151 const scoped_refptr<base::SingleThreadTaskRunner> mixer_task_runner_; | 155 const scoped_refptr<base::SingleThreadTaskRunner> mixer_task_runner_; |
| 152 const scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 156 const scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
| 153 | 157 |
| 154 double resample_ratio_; | 158 double resample_ratio_; |
| 155 | 159 |
| 156 State state_; | 160 State state_; |
| 157 SlewVolume slew_volume_; | 161 SlewVolume slew_volume_; |
| 158 | 162 |
| 159 base::Lock queue_lock_; // Lock for the following queue-related members. | 163 base::Lock queue_lock_; // Lock for the following queue-related members. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 178 base::WeakPtr<StreamMixerAlsaInputImpl> weak_this_; | 182 base::WeakPtr<StreamMixerAlsaInputImpl> weak_this_; |
| 179 base::WeakPtrFactory<StreamMixerAlsaInputImpl> weak_factory_; | 183 base::WeakPtrFactory<StreamMixerAlsaInputImpl> weak_factory_; |
| 180 | 184 |
| 181 DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsaInputImpl); | 185 DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsaInputImpl); |
| 182 }; | 186 }; |
| 183 | 187 |
| 184 } // namespace media | 188 } // namespace media |
| 185 } // namespace chromecast | 189 } // namespace chromecast |
| 186 | 190 |
| 187 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_ | 191 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_STREAM_MIXER_ALSA_INPUT_IMPL_H_ |
| OLD | NEW |