Chromium Code Reviews| Index: chromecast/media/cma/backend/alsa/audio_decoder_alsa.h |
| diff --git a/chromecast/media/cma/backend/alsa/audio_decoder_alsa.h b/chromecast/media/cma/backend/alsa/audio_decoder_alsa.h |
| index 04c963f00603125c14fc093e83ccddb113b886b6..18d271c6b7aea7f5ff36ec198844f7d8c34b7364 100644 |
| --- a/chromecast/media/cma/backend/alsa/audio_decoder_alsa.h |
| +++ b/chromecast/media/cma/backend/alsa/audio_decoder_alsa.h |
| @@ -5,6 +5,8 @@ |
| #ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_AUDIO_DECODER_ALSA_H_ |
| #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_AUDIO_DECODER_ALSA_H_ |
| +#include <deque> |
| + |
| #include "base/bind.h" |
| #include "base/location.h" |
| #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input.h" |
| @@ -17,6 +19,11 @@ namespace base { |
| class SingleThreadTaskRunner; |
| } // namespace base |
| +namespace media { |
| +class AudioBus; |
| +class AudioRendererAlgorithm; |
| +} // namespace media |
| + |
| namespace chromecast { |
| namespace media { |
| class DecoderBufferBase; |
| @@ -35,6 +42,7 @@ class AudioDecoderAlsa : public MediaPipelineBackend::AudioDecoder, |
| void Stop(); |
| bool Pause(); |
| bool Resume(); |
| + bool SetPlaybackRate(float rate); |
| int64_t current_pts() const { return current_pts_; } |
| @@ -48,6 +56,14 @@ class AudioDecoderAlsa : public MediaPipelineBackend::AudioDecoder, |
| RenderingDelay GetRenderingDelay() override; |
| private: |
| + struct RateShifterInfo { |
| + RateShifterInfo(float playback_rate); |
|
slan
2016/12/07 00:22:27
nit: explicit
Also, can we do a default ctor here
kmackay
2016/12/07 22:59:58
Added explicit; I don't think a default constructo
slan
2016/12/09 00:05:31
Yeah, I'm silly.
|
| + |
| + double rate; |
| + double input_frames; |
| + int64_t output_frames; |
| + }; |
| + |
| // StreamMixerAlsaInput::Delegate implementation: |
| void OnWritePcmCompletion(BufferStatus status, |
| const RenderingDelay& delay) override; |
| @@ -55,10 +71,13 @@ class AudioDecoderAlsa : public MediaPipelineBackend::AudioDecoder, |
| void CleanUpPcm(); |
| void CreateDecoder(); |
| + void CreateRateShifter(int samples_per_second); |
| void OnDecoderInitialized(bool success); |
| void OnBufferDecoded(uint64_t input_bytes, |
| CastAudioDecoder::Status status, |
| const scoped_refptr<DecoderBufferBase>& decoded); |
| + void PushRateShifted(); |
| + void PushMorePcm(); |
| void RunEos(); |
| bool BypassDecoder() const; |
| bool ShouldStartClock() const; |
| @@ -69,17 +88,25 @@ class AudioDecoderAlsa : public MediaPipelineBackend::AudioDecoder, |
| MediaPipelineBackend::Decoder::Delegate* delegate_; |
| Statistics stats_; |
| - bool is_eos_; |
| + |
| + bool pending_write_pcm_; |
|
halliwell
2016/12/06 17:27:59
Seems like this is mostly redundant (corresponds t
slan
2016/12/07 00:22:27
Yes, after grepping for this value, it does seem t
kmackay
2016/12/07 22:59:58
input_frames can be 0 sometimes. I added a (negati
|
| + bool pending_buffer_complete_; |
| + bool got_eos_; |
| + bool pushed_eos_; |
| bool error_; |
| AudioConfig config_; |
| std::unique_ptr<CastAudioDecoder> decoder_; |
| + std::unique_ptr<::media::AudioRendererAlgorithm> rate_shifter_; |
|
halliwell
2016/12/06 17:27:59
nit, should be including <memory>
kmackay
2016/12/07 22:59:58
Done.
|
| + std::deque<RateShifterInfo> rate_shifter_info_; |
| + std::unique_ptr<::media::AudioBus> rate_shifter_output_; |
| + |
| int64_t current_pts_; |
| - int64_t last_buffer_pts_; |
| std::unique_ptr<StreamMixerAlsaInput> mixer_input_; |
| RenderingDelay last_known_delay_; |
| + int64_t pending_output_frames_; |
| float volume_multiplier_; |
| base::WeakPtrFactory<AudioDecoderAlsa> weak_factory_; |