Skip to content

Commit 812664a

Browse files
committed
Improve platform checks
1 parent a890901 commit 812664a

9 files changed

+51
-12
lines changed

src/BluetoothA2DPCommon.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
#include "BluetoothA2DPCommon.h"
1717

18+
#if IS_VALID_PLATFORM
19+
20+
1821
BluetoothA2DPCommon* actual_bluetooth_a2dp_common = nullptr;
1922

2023
extern "C" void ccall_bt_app_task_handler(void* arg) {
@@ -596,3 +599,5 @@ unsigned long BluetoothA2DPCommon::get_millis() {
596599
return (unsigned long)(esp_timer_get_time() / 1000ULL);
597600
#endif
598601
}
602+
603+
#endif // platform

src/BluetoothA2DPCommon.h

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,27 @@
2222
*/
2323

2424
#pragma once
25+
26+
// Compile only for ESP32
27+
#ifdef ARDUINO_ARCH_ESP32
28+
# include "sdkconfig.h"
29+
#endif
30+
#if defined(CONFIG_IDF_TARGET_ESP32)
31+
# define IS_VALID_PLATFORM true
32+
#else
33+
# error "Please read the Wiki about the supported Platforms!"
34+
# define IS_VALID_PLATFORM false
35+
#endif
36+
37+
// Continue only for ESP32
38+
#if IS_VALID_PLATFORM
39+
2540
#include "config.h"
2641
// If you use #include "I2S.h" the i2s functionality is hidden in a namespace
2742
// this hack prevents any error messages
2843
#ifdef _I2S_H_INCLUDED
2944
using namespace esp_i2s;
3045
#endif
31-
// Compile only for ESP32
32-
#if defined(CONFIG_IDF_TARGET_ESP32C2) || \
33-
defined(CONFIG_IDF_TARGET_ESP32C3) || \
34-
defined(CONFIG_IDF_TARGET_ESP32C5) || \
35-
defined(CONFIG_IDF_TARGET_ESP32C6) || \
36-
defined(CONFIG_IDF_TARGET_ESP32S2) || \
37-
defined(CONFIG_IDF_TARGET_ESP32S3) || \
38-
defined(CONFIG_IDF_TARGET_ESP32H2) || \
39-
defined(CONFIG_IDF_TARGET_ESP32P4)
40-
#error "ESP32C3, ESP32S2, ESP32S3... do not support A2DP"
41-
#endif
4246

4347
#include <math.h>
4448
#include <stdbool.h>
@@ -438,4 +442,6 @@ class BluetoothA2DPCommon {
438442

439443
};
440444

441-
extern BluetoothA2DPCommon *actual_bluetooth_a2dp_common;
445+
extern BluetoothA2DPCommon *actual_bluetooth_a2dp_common;
446+
447+
#endif // platform

src/BluetoothA2DPOutput.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "BluetoothA2DPOutput.h"
22

3+
#if IS_VALID_PLATFORM
4+
35
BluetoothA2DPOutputLegacy::BluetoothA2DPOutputLegacy() {
46
#if A2DP_LEGACY_I2S_SUPPORT
57
// default i2s port is 0
@@ -259,3 +261,4 @@ void BluetoothA2DPOutputAudioTools::set_output_active(bool active) {
259261
#endif
260262
}
261263

264+
#endif

src/BluetoothA2DPSink.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "BluetoothA2DPSink.h"
1717

18+
#if IS_VALID_PLATFORM
19+
1820
// to support static callback functions
1921
BluetoothA2DPSink *actual_bluetooth_a2dp_sink;
2022

@@ -1422,3 +1424,5 @@ void BluetoothA2DPSink::av_hdl_avrc_tg_evt(uint16_t event, void *p_param) {
14221424
}
14231425

14241426
#endif
1427+
1428+
#endif // platform

src/BluetoothA2DPSink.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#pragma once
1717
#include "BluetoothA2DPCommon.h"
18+
#if IS_VALID_PLATFORM
19+
1820
#include "BluetoothA2DPOutput.h"
1921
#include "freertos/ringbuf.h"
2022

@@ -536,3 +538,5 @@ class BluetoothA2DPSink : public BluetoothA2DPCommon {
536538
virtual bool isSource() { return false; }
537539

538540
};
541+
542+
#endif // platform

src/BluetoothA2DPSinkQueued.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
#include "BluetoothA2DPSinkQueued.h"
33

4+
#if IS_VALID_PLATFORM
5+
46
void BluetoothA2DPSinkQueued::bt_i2s_task_start_up(void) {
57
ESP_LOGI(BT_APP_TAG, "ringbuffer data empty! mode changed: RINGBUFFER_MODE_PREFETCHING");
68
ringbuffer_mode = RINGBUFFER_MODE_PREFETCHING;
@@ -135,3 +137,5 @@ size_t BluetoothA2DPSinkQueued::write_audio(const uint8_t *data, size_t size)
135137

136138
return done ? size : 0;
137139
}
140+
141+
#endif // platform

src/BluetoothA2DPSinkQueued.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "BluetoothA2DPSink.h"
44

5+
#if IS_VALID_PLATFORM
6+
57
#define RINGBUF_HIGHEST_WATER_LEVEL (32 * 1024)
68
#define RINGBUF_PREFETCH_PERCENT 65
79

@@ -98,3 +100,5 @@ class BluetoothA2DPSinkQueued : public BluetoothA2DPSink {
98100
return (bytes / 4 * 4);
99101
}
100102
};
103+
104+
#endif // platform

src/BluetoothA2DPSource.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "BluetoothA2DPSource.h"
1818

19+
#if IS_VALID_PLATFORM
20+
1921
#define APP_RC_CT_TL_RN_VOLUME_CHANGE (1)
2022
#define BT_APP_HEART_BEAT_EVT (0xff00)
2123

@@ -1101,3 +1103,5 @@ void BluetoothA2DPSource::av_hdl_avrc_tg_evt(uint16_t event, void *p_param) {
11011103
}
11021104

11031105
#endif
1106+
1107+
#endif // platform

src/BluetoothA2DPSource.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include "BluetoothA2DPCommon.h"
2525

26+
#if IS_VALID_PLATFORM
27+
2628
#ifdef ARDUINO
2729
#include "Stream.h"
2830
#endif
@@ -333,3 +335,6 @@ class BluetoothA2DPSource : public BluetoothA2DPCommon {
333335

334336
#endif
335337
};
338+
339+
340+
#endif // platform

0 commit comments

Comments
 (0)