From 95380177529f2411ce2462c61ac7d85a1f2c467b Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Sat, 24 Aug 2024 07:12:07 +0200 Subject: [PATCH] IS_I2S_IMPLEMENTED and make SPDIFOutput optional --- .../a2dp/streams-a2dp-spdif/streams-a2dp-spdif.ino | 1 + .../streams-generator-spdif/streams-generator-spdif.ino | 2 +- src/AudioI2S/I2SESP32.h | 4 +++- src/AudioI2S/I2SESP32V1.h | 3 +++ src/AudioI2S/I2SESP8266.h | 2 ++ src/AudioI2S/I2SNanoSenseBLE.h | 2 ++ src/AudioI2S/I2SRP2040-MBED.h | 2 ++ src/AudioI2S/I2SRP2040.h | 2 ++ src/AudioI2S/I2SSAMD.h | 3 ++- src/AudioI2S/I2SSTM32.h | 4 ++++ src/AudioI2S/I2SStream.h | 3 +++ src/{AudioTools/AudioSPDIF.h => AudioLibs/SPDIFOutput.h} | 0 src/AudioTools.h | 4 ---- 13 files changed, 25 insertions(+), 7 deletions(-) rename src/{AudioTools/AudioSPDIF.h => AudioLibs/SPDIFOutput.h} (100%) diff --git a/examples/examples-communication/a2dp/streams-a2dp-spdif/streams-a2dp-spdif.ino b/examples/examples-communication/a2dp/streams-a2dp-spdif/streams-a2dp-spdif.ino index e2b62329ab..85a7cbb201 100644 --- a/examples/examples-communication/a2dp/streams-a2dp-spdif/streams-a2dp-spdif.ino +++ b/examples/examples-communication/a2dp/streams-a2dp-spdif/streams-a2dp-spdif.ino @@ -6,6 +6,7 @@ * @copyright GPLv3 */ #include "AudioTools.h" +#include "AudioLibs/SPDIFOutput.h" #include "BluetoothA2DPSink.h" AudioInfo info(44100, 2, 16); diff --git a/examples/examples-stream/streams-generator-spdif/streams-generator-spdif.ino b/examples/examples-stream/streams-generator-spdif/streams-generator-spdif.ino index e5c5057de6..c78dbc99f2 100644 --- a/examples/examples-stream/streams-generator-spdif/streams-generator-spdif.ino +++ b/examples/examples-stream/streams-generator-spdif/streams-generator-spdif.ino @@ -7,7 +7,7 @@ */ #include "AudioTools.h" - +#include "AudioLibs/SPDIFOutput.h" AudioInfo info(44100, 2, 16); SineWaveGenerator sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000 diff --git a/src/AudioI2S/I2SESP32.h b/src/AudioI2S/I2SESP32.h index 023d12aa8e..dc1d064a88 100644 --- a/src/AudioI2S/I2SESP32.h +++ b/src/AudioI2S/I2SESP32.h @@ -10,9 +10,11 @@ #include "esp_system.h" #ifndef I2S_MCLK_MULTIPLE_DEFAULT -#define I2S_MCLK_MULTIPLE_DEFAULT ((i2s_mclk_multiple_t)0) +# define I2S_MCLK_MULTIPLE_DEFAULT ((i2s_mclk_multiple_t)0) #endif +#define IS_I2S_IMPLEMENTED + namespace audio_tools { /** diff --git a/src/AudioI2S/I2SESP32V1.h b/src/AudioI2S/I2SESP32V1.h index 06ebce7bf6..39b640f478 100644 --- a/src/AudioI2S/I2SESP32V1.h +++ b/src/AudioI2S/I2SESP32V1.h @@ -11,6 +11,9 @@ #include "driver/i2s_tdm.h" #include "esp_system.h" +#define IS_I2S_IMPLEMENTED + + namespace audio_tools { /** diff --git a/src/AudioI2S/I2SESP8266.h b/src/AudioI2S/I2SESP8266.h index 0b4aec89bc..80121dc034 100644 --- a/src/AudioI2S/I2SESP8266.h +++ b/src/AudioI2S/I2SESP8266.h @@ -6,6 +6,8 @@ #include "AudioI2S/I2SConfig.h" #include "AudioTools/AudioLogger.h" +#define IS_I2S_IMPLEMENTED + namespace audio_tools { /** diff --git a/src/AudioI2S/I2SNanoSenseBLE.h b/src/AudioI2S/I2SNanoSenseBLE.h index 71c4f59197..13d5191e59 100644 --- a/src/AudioI2S/I2SNanoSenseBLE.h +++ b/src/AudioI2S/I2SNanoSenseBLE.h @@ -9,6 +9,8 @@ #include "AudioTools/AudioTypes.h" #include "AudioTools/Buffers.h" +#define IS_I2S_IMPLEMENTED + namespace audio_tools { static int i2s_buffer_size = 0; diff --git a/src/AudioI2S/I2SRP2040-MBED.h b/src/AudioI2S/I2SRP2040-MBED.h index c351c9de70..056e85924e 100644 --- a/src/AudioI2S/I2SRP2040-MBED.h +++ b/src/AudioI2S/I2SRP2040-MBED.h @@ -4,6 +4,8 @@ #if defined(RP2040_MBED) #include "RP2040-I2S.h" +#define IS_I2S_IMPLEMENTED + namespace audio_tools { #if !defined(ARDUINO_ARCH_MBED_RP2040) diff --git a/src/AudioI2S/I2SRP2040.h b/src/AudioI2S/I2SRP2040.h index a4efabfe29..061ea8ccb7 100644 --- a/src/AudioI2S/I2SRP2040.h +++ b/src/AudioI2S/I2SRP2040.h @@ -4,6 +4,8 @@ #if defined(RP2040_HOWER) #include +#define IS_I2S_IMPLEMENTED + namespace audio_tools { /** diff --git a/src/AudioI2S/I2SSAMD.h b/src/AudioI2S/I2SSAMD.h index 82157bd507..837b086112 100644 --- a/src/AudioI2S/I2SSAMD.h +++ b/src/AudioI2S/I2SSAMD.h @@ -2,9 +2,10 @@ #if defined(ARDUINO_ARCH_SAMD) #include - #include "AudioI2S/I2SConfig.h" +#define IS_I2S_IMPLEMENTED + namespace audio_tools { /** diff --git a/src/AudioI2S/I2SSTM32.h b/src/AudioI2S/I2SSTM32.h index c9a8efff86..f1e36cf120 100644 --- a/src/AudioI2S/I2SSTM32.h +++ b/src/AudioI2S/I2SSTM32.h @@ -4,6 +4,9 @@ #include "AudioI2S/I2SConfig.h" #include "stm32-i2s.h" +#ifdef STM_I2S_PINS +#define IS_I2S_IMPLEMENTED + namespace audio_tools { /** @@ -415,3 +418,4 @@ using I2SDriver = I2SDriverSTM32; } // namespace audio_tools #endif +#endif diff --git a/src/AudioI2S/I2SStream.h b/src/AudioI2S/I2SStream.h index 7b7eb8cbe8..0e38a7813f 100644 --- a/src/AudioI2S/I2SStream.h +++ b/src/AudioI2S/I2SStream.h @@ -17,6 +17,8 @@ #include "AudioTools/AudioStreams.h" #include "AudioTools/AudioTypes.h" +#if defined(IS_I2S_IMPLEMENTED) + namespace audio_tools { /** @@ -150,3 +152,4 @@ class I2SStream : public AudioStream { } // namespace audio_tools #endif +#endif diff --git a/src/AudioTools/AudioSPDIF.h b/src/AudioLibs/SPDIFOutput.h similarity index 100% rename from src/AudioTools/AudioSPDIF.h rename to src/AudioLibs/SPDIFOutput.h diff --git a/src/AudioTools.h b/src/AudioTools.h index 04a7516eef..314c9b97d3 100644 --- a/src/AudioTools.h +++ b/src/AudioTools.h @@ -108,10 +108,6 @@ # include "AudioEffects/Synthesizer.h" #endif -#if defined(USE_I2S) -# include "AudioTools/AudioSPDIF.h" -#endif - /** * -------------------------------------------------------------------------