From a7521ccc5f3a99282d1001efb4b811faf70f608c Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Sun, 18 Sep 2022 17:49:30 +0200 Subject: [PATCH] Added functions to setup, release and check compatibility of audio paths to audio.h --- openrtx/include/interfaces/audio.h | 45 ++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/openrtx/include/interfaces/audio.h b/openrtx/include/interfaces/audio.h index 6c6b4ea8..ad56118a 100644 --- a/openrtx/include/interfaces/audio.h +++ b/openrtx/include/interfaces/audio.h @@ -21,6 +21,9 @@ #ifndef AUDIO_H #define AUDIO_H +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -32,16 +35,16 @@ extern "C" { enum AudioSource { - SOURCE_MIC, ///< Receive audio signal from the microphone - SOURCE_RTX, ///< Receive audio signal from the transceiver - SOURCE_MCU ///< Receive audio signal from a memory buffer + SOURCE_MIC = 0, ///< Receive audio signal from the microphone + SOURCE_RTX = 1, ///< Receive audio signal from the transceiver + SOURCE_MCU = 2 ///< Receive audio signal from a memory buffer }; enum AudioSink { - SINK_SPK, ///< Send audio signal to the speaker - SINK_RTX, ///< Send audio signal to the transceiver - SINK_MCU ///< Send audio signal to a memory buffer + SINK_SPK = 0, ///< Send audio signal to the speaker + SINK_RTX = 1, ///< Send audio signal to the transceiver + SINK_MCU = 2 ///< Send audio signal to a memory buffer }; enum AudioPriority @@ -62,6 +65,36 @@ void audio_init(); */ void audio_terminate(); +/** + * Connect an audio source to an audio sink. + * + * @param source: identifier of the input audio peripheral. + * @param sink: identifier of the output audio peripheral. + */ +void audio_connect(const enum AudioSource source, const enum AudioSink sink); + +/** + * Disconnect an audio source from an audio sink. + * + * @param source: identifier of the input audio peripheral. + * @param sink: identifier of the output audio peripheral. + */ +void audio_disconnect(const enum AudioSource source, const enum AudioSink sink); + +/** + * Check if two audio paths are compatible that is, if they can be open at the + * same time. + * + * @param p1Source: identifier of the input audio peripheral of the first path. + * @param p1Sink: identifier of the output audio peripheral of the first path. + * @param p2Source: identifier of the input audio peripheral of the second path. + * @param p2Sink: identifier of the output audio peripheral of the second path. + */ +bool audio_checkPathCompatibility(const enum AudioSource p1Source, + const enum AudioSink p1Sink, + const enum AudioSource p2Source, + const enum AudioSink p2Sink); + /** * Enable microphone. */