Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMECAST_PUBLIC_MEDIA_AUDIO_POST_PROCESSOR_SHLIB_H_ | |
| 6 #define CHROMECAST_PUBLIC_MEDIA_AUDIO_POST_PROCESSOR_SHLIB_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "chromecast_export.h" | |
| 12 | |
| 13 namespace chromecast { | |
| 14 namespace media { | |
| 15 class AudioPostProcessor; | |
| 16 } // namespace media | |
| 17 } // namespace chromecast | |
| 18 | |
| 19 // Creates an AudioPostProcessor. | |
| 20 // This is applicable only to Alsa CMA backend. | |
| 21 // Please refer to | |
| 22 // chromecast/media/cma/backend/alsa/post_processors/governor_shlib.cc | |
| 23 // as an example, but OEM's implementations should not have any | |
| 24 // Chromium dependencies. | |
| 25 // Called from StreamMixerAlsa when shared objects are listed in | |
| 26 // /etc/cast_audio.json | |
| 27 extern "C" CHROMECAST_EXPORT | |
| 28 std::unique_ptr<chromecast::media::AudioPostProcessor> | |
|
kmackay
2017/03/24 04:47:57
I guess if we don't want to deal with suppressing
bshaya
2017/03/24 18:55:10
Done.
| |
| 29 AudioPostProcessorShlib_Create(const std::string& config, int channels); | |
| 30 | |
| 31 namespace chromecast { | |
| 32 namespace media { | |
| 33 | |
| 34 // Interface for AudioPostProcessors used for applying DSP in StreamMixerAlsa. | |
| 35 class AudioPostProcessor { | |
| 36 public: | |
| 37 // Updates the sample rate of the processor. | |
| 38 // Returns |false| if the processor cannot support |sample_rate| | |
| 39 // Returning false will result in crashing cast_shell. | |
| 40 virtual bool SetSampleRate(int sample_rate) = 0; | |
| 41 | |
| 42 // Processes audio frames from |data|, overwriting contents. | |
| 43 // |data| will always be 32-bit interleaved float. | |
| 44 // Always provides |frames| frames of data back (may output 0’s) | |
| 45 // |volume| is the current attenuation level of the stream. | |
| 46 // AudioPostProcessor should assume that it has already been applied. | |
| 47 // Returns the current rendering delay of the filter in frames, | |
| 48 // or negative if an error occurred during processing. | |
| 49 // If an error occurred during processing, |data| should be unchanged. | |
| 50 virtual int ProcessFrames(uint8_t* data, int frames, float volume) = 0; | |
| 51 | |
| 52 // Returns the number of frames of silence it will take for the | |
| 53 // processor to come to rest. | |
| 54 // This may be the actual number of frames stored, | |
| 55 // or may be calculated from internal resonators or similar. | |
| 56 // When inputs are paused, at least this |GetRingingTimeInFrames()| of | |
| 57 // silence will be passed through the processor. | |
| 58 // This is not expected to be real-time; | |
| 59 // It should only change when SetSampleRate is called. | |
| 60 virtual int GetRingingTimeInFrames() = 0; | |
| 61 | |
| 62 virtual ~AudioPostProcessor() = default; | |
| 63 }; | |
| 64 | |
| 65 } // namespace media | |
| 66 } // namespace chromecast | |
| 67 | |
| 68 #endif // CHROMECAST_PUBLIC_MEDIA_AUDIO_POST_PROCESSOR_SHLIB_H_ | |
| OLD | NEW |