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