Chromium Code Reviews| Index: chromecast/media/cma/backend/alsa/stream_mixer_alsa.h |
| diff --git a/chromecast/media/cma/backend/alsa/stream_mixer_alsa.h b/chromecast/media/cma/backend/alsa/stream_mixer_alsa.h |
| index 53a48911f72ae92fe6fed42b1db7703d52aab2fd..44525f9ab3dfcbecf29598cdc3a7f1a53b2b676a 100644 |
| --- a/chromecast/media/cma/backend/alsa/stream_mixer_alsa.h |
| +++ b/chromecast/media/cma/backend/alsa/stream_mixer_alsa.h |
| @@ -29,6 +29,8 @@ namespace chromecast { |
| namespace media { |
| class AlsaWrapper; |
| +const int kNumFilterGroups = 2; |
| + |
| // Mixer implementation. The mixer has one or more input queues; these can be |
| // added/removed at any time. When an input source pushes frames to an input |
| // queue, the queue should call StreamMixerAlsa::WriteFrames(); this causes |
| @@ -67,6 +69,11 @@ class StreamMixerAlsa { |
| // precedence for sample rates and will dictate when data is polled. |
| virtual bool primary() const = 0; |
| + // Returns a string describing the content type class. |
| + // Should be from chromecast/public/media/audio_device_ids.h |
| + // or media/audio/audio_device_description.h |
| + virtual std::string name() const = 0; |
| + |
| // Returns true if PrepareToDelete() has been called. |
| virtual bool IsDeleting() const = 0; |
| @@ -195,10 +202,20 @@ class StreamMixerAlsa { |
| void WriteFrames(); |
| bool TryWriteFrames(); |
| - void WriteMixedPcm(const ::media::AudioBus& mixed, int frames, |
| - bool is_silence); |
| + |
| + // Mixes |acitve_inputs| and processes the resulting buffer |
|
kmackay
2017/02/17 06:11:25
active_inputs
bshaya
2017/02/17 18:26:54
Done.
|
| + // with pre_loopback_filter_[|filter|]. |
| + // If |accumulate| is false, |interleaved_| will be overwritten |
| + // (rather than summed). |
| + // Returns |true| if non-zero data was written to |interleaved_|. |
| + bool MixAndFilterGroup(const std::vector<InputQueue*>& active_inputs, |
| + int filter, |
| + int frames, |
| + bool accumulate); |
| + void WriteMixedPcm(int frames, bool filter_frames); |
| void UpdateRenderingDelay(int newly_pushed_frames); |
| ssize_t BytesPerOutputFormatSample(); |
| + void ResizeBuffersIfNecessary(int chunk_size); |
| static bool single_threaded_for_test_; |
| @@ -229,6 +246,9 @@ class StreamMixerAlsa { |
| std::vector<std::unique_ptr<InputQueue>> inputs_; |
| std::vector<std::unique_ptr<InputQueue>> ignored_inputs_; |
| MediaPipelineBackendAlsa::RenderingDelay rendering_delay_; |
| + // Buffer to write interleaved data for each stream type before |
| + // writing to |interleaved_|. |
|
kmackay
2017/02/17 06:11:25
Could you clarify the comment a bit? Something abo
bshaya
2017/02/17 18:26:54
Done.
|
| + std::vector<uint8_t> interleaved_intermediate_; |
| // Buffer to write final interleaved data before sending to snd_pcm_writei(). |
| std::vector<uint8_t> interleaved_; |
| @@ -245,9 +265,9 @@ class StreamMixerAlsa { |
| std::vector<CastMediaShlib::LoopbackAudioObserver*> loopback_observers_; |
| - std::unique_ptr<AudioFilterInterface> pre_loopback_filter_; |
| + std::unique_ptr<AudioFilterInterface> pre_loopback_filter_[kNumFilterGroups]; |
| std::unique_ptr<AudioFilterInterface> post_loopback_filter_; |
| - int silence_frames_filtered_ = 0; |
| + int silence_frames_filtered_[kNumFilterGroups]; |
| DISALLOW_COPY_AND_ASSIGN(StreamMixerAlsa); |
| }; |