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

Unified Diff: chromecast/media/cma/backend/alsa/audio_decoder_alsa.h

Issue 2557513002: [Chromecast] Add support for different playback rates to ALSA backend (Closed)
Patch Set: use CreateEmptyBuffer Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/media/cma/backend/alsa/DEPS ('k') | chromecast/media/cma/backend/alsa/audio_decoder_alsa.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a0084ee17131aa85b6532f653a6669c35bde5aed 100644
--- a/chromecast/media/cma/backend/alsa/audio_decoder_alsa.h
+++ b/chromecast/media/cma/backend/alsa/audio_decoder_alsa.h
@@ -5,6 +5,9 @@
#ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_AUDIO_DECODER_ALSA_H_
#define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_AUDIO_DECODER_ALSA_H_
+#include <deque>
+#include <memory>
+
#include "base/bind.h"
#include "base/location.h"
#include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input.h"
@@ -17,6 +20,11 @@ namespace base {
class SingleThreadTaskRunner;
} // namespace base
+namespace media {
+class AudioBus;
+class AudioRendererAlgorithm;
+} // namespace media
+
namespace chromecast {
namespace media {
class DecoderBufferBase;
@@ -35,6 +43,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 +57,14 @@ class AudioDecoderAlsa : public MediaPipelineBackend::AudioDecoder,
RenderingDelay GetRenderingDelay() override;
private:
+ struct RateShifterInfo {
+ explicit RateShifterInfo(float playback_rate);
+
+ double rate;
+ double input_frames;
+ int64_t output_frames;
+ };
+
// StreamMixerAlsaInput::Delegate implementation:
void OnWritePcmCompletion(BufferStatus status,
const RenderingDelay& delay) override;
@@ -55,10 +72,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 +89,24 @@ class AudioDecoderAlsa : public MediaPipelineBackend::AudioDecoder,
MediaPipelineBackend::Decoder::Delegate* delegate_;
Statistics stats_;
- bool is_eos_;
- bool error_;
+
+ bool pending_buffer_complete_;
+ bool got_eos_;
+ bool pushed_eos_;
+ bool mixer_error_;
AudioConfig config_;
std::unique_ptr<CastAudioDecoder> decoder_;
+ std::unique_ptr<::media::AudioRendererAlgorithm> rate_shifter_;
+ 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_;
+ RenderingDelay last_mixer_delay_;
+ int64_t pending_output_frames_;
float volume_multiplier_;
base::WeakPtrFactory<AudioDecoderAlsa> weak_factory_;
« no previous file with comments | « chromecast/media/cma/backend/alsa/DEPS ('k') | chromecast/media/cma/backend/alsa/audio_decoder_alsa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698