Skip to content

Commit 847d553

Browse files
committed
a2dp-spdif example - explicit config
1 parent ebb018c commit 847d553

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

examples/sandbox/basic-a2dp-spdif/basic-a2dp-spdif.ino

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
* @copyright GPLv3
77
*/
88

9+
/**
10+
* @file basic-a2dp-audiospdif.ino
11+
* @brief A2DP Sink with output to SPDIFStream
12+
*
13+
* @author Phil Schatzmann
14+
* @copyright GPLv3
15+
*/
16+
917
#define USE_A2DP
1018
#include "AudioTools.h"
1119
#include "AudioExperiments/AudioSPDIF.h"
@@ -22,15 +30,20 @@ void read_data_stream(const uint8_t *data, uint32_t length) {
2230
void setup() {
2331
Serial.begin(115200);
2432
AudioLogger::instance().begin(Serial, AudioLogger::Info);
33+
34+
// register callback
35+
a2dp_sink.set_auto_reconnect(false);
36+
a2dp_sink.set_stream_reader(read_data_stream, false);
37+
a2dp_sink.start("a2dp-spdif");
2538

2639
// setup output
2740
auto cfg = spdif.defaultConfig();
28-
cfg.pin_data = 22;
41+
cfg.pin_data = 23;
42+
cfg.sample_rate = a2dp_sink.sample_rate();
43+
cfg.channels = 2;
44+
cfg.bits_per_sample = 16;
2945
spdif.begin(cfg);
3046

31-
// register callback
32-
a2dp_sink.set_stream_reader(read_data_stream, false);
33-
a2dp_sink.start("a2dp-spdif");
3447
}
3548

3649
void loop() {

0 commit comments

Comments
 (0)