Chromium Code Reviews| Index: chromecast/media/cma/backend/alsa/filter_group.h |
| diff --git a/chromecast/media/cma/backend/alsa/filter_group.h b/chromecast/media/cma/backend/alsa/filter_group.h |
| index cf14fe2918e6da3c16ed888a9e9655f7e964f133..8ff013721a1d00a855f1b180a679151919086c0e 100644 |
| --- a/chromecast/media/cma/backend/alsa/filter_group.h |
| +++ b/chromecast/media/cma/backend/alsa/filter_group.h |
| @@ -26,25 +26,35 @@ namespace media { |
| class PostProcessingPipeline; |
| -// FilterGroup contains state for an AudioFilter. |
| -// It takes multiple StreamMixerAlsa::InputQueues, |
| -// mixes them, and processes them. |
| +// FilterGroup mixes StreamMixerAlsa::InputQueues and/or FilterGroups, |
| +// mixes their outputs, and applies DSP to them. |
| -// ActiveInputs are added with AddActiveInput(), then cleared when |
| +// FilterGroups are added at construction. These cannot be removed. |
| + |
| +// InputQueues are added with AddActiveInput(), then cleared when |
| // MixAndFilter() is called (they must be added each time data is queried). |
| class FilterGroup { |
| public: |
| // |input_types| is a set of strings that is used as a filter to determine |
| // if an input belongs to this group (InputQueue->name() must exactly match an |
| - // entry in |input_types| to be processed by this group. |
| - // |filter_type| is passed to AudioFilterFactory to create an AudioFilter. |
| - FilterGroup(const std::unordered_set<std::string>& input_types, |
| - AudioContentType content_type, |
| - int channels, |
| - const base::ListValue* filter_list); |
| - ~FilterGroup(); |
| + // entry in |input_types| to be processed by this group). |
|
kmackay
2017/04/28 00:31:42
Could you add comments about the other parameters?
bshaya
2017/04/28 01:37:37
Done.
|
| + FilterGroup(int channels, |
|
kmackay
2017/04/28 00:31:42
num_channels
bshaya
2017/04/28 01:37:36
Done.
|
| + const std::string& name, |
| + const base::ListValue* filter_list, |
| + const std::unordered_set<std::string>& input_types, |
| + const std::vector<FilterGroup*>& mixed_inputs); |
| + |
| + FilterGroup(int channels, |
| + const std::string& name, |
| + const base::ListValue* filter_list, |
| + const std::vector<FilterGroup*>& mixed_inputs); |
| + |
| + FilterGroup(int channels, |
| + const std::string& name, |
| + const base::ListValue* filter_list, |
| + const std::unordered_set<std::string>& input_types); |
|
kmackay
2017/04/28 00:31:42
The two extra constructors seem unneccessary; call
bshaya
2017/04/28 01:37:37
Done.
Although you do have to pass in std::vector
|
| - AudioContentType content_type() const { return content_type_; } |
| + ~FilterGroup(); |
| // Sets the sample rate of the post-processors. |
| void Initialize(int output_samples_per_second); |
| @@ -55,40 +65,44 @@ class FilterGroup { |
| // Adds |input| to |active_inputs_|. |
| void AddActiveInput(StreamMixerAlsa::InputQueue* input); |
| - // Retrieves a pointer to the output buffer |interleaved_|. |
| - std::vector<uint8_t>* GetInterleaved(); |
| - |
| // Mixes all active inputs and passes them through the audio filter. |
|
kmackay
2017/04/28 00:31:42
comment about return value
bshaya
2017/04/28 01:37:36
Done.
|
| - bool MixAndFilter(int chunk_size); |
| + float MixAndFilter(int chunk_size); |
| - // Overwrites |interleaved_| with 0's, ensuring at least |
| - // |chunk_size| bytes. |
| - void ClearInterleaved(int chunk_size); |
| + // Gets the current delay of this filter group's AudioPostProcessors. |
| + // (Not recursive). |
| + int64_t GetRenderingDelayMicroseconds(); |
| // Clear all |active_inputs_|. This should be called before AddActiveInputs |
| // on each mixing iteration. |
| void ClearActiveInputs(); |
| - // Resets the PostProcessingPipeline, removing all AudioPostProcessors. |
| - void DisablePostProcessingForTest(); |
| + // Retrieves a pointer to the output buffer. |
| + ::media::AudioBus* data() { return mixed_.get(); } |
| + |
| + // Get the last used volume. |
| + float last_volume() const { return last_volume_; } |
| + |
| + std::string name() const { return name_; } |
| private: |
| void ResizeBuffersIfNecessary(int chunk_size); |
| - int BytesPerOutputFormatSample(); |
| - const std::unordered_set<std::string> input_types_; |
| - const AudioContentType content_type_; |
| const int num_channels_; |
| + const std::string name_; |
| + const std::unordered_set<std::string> input_types_; |
| + std::vector<FilterGroup*> mixed_inputs_; |
| std::vector<StreamMixerAlsa::InputQueue*> active_inputs_; |
| int output_samples_per_second_; |
| + int frames_zeroed_ = 0; |
| + float last_volume_ = 0.0f; |
| + int64_t delay_frames_ = 0; |
| // Buffers that hold audio data while it is mixed. |
| // These are kept as members of this class to minimize copies and |
| // allocations. |
| std::unique_ptr<::media::AudioBus> temp_; |
| std::unique_ptr<::media::AudioBus> mixed_; |
| - std::vector<uint8_t> interleaved_; |
| std::vector<float*> channels_; |
| std::unique_ptr<PostProcessingPipeline> post_processing_pipeline_; |