@@ -59,6 +59,7 @@ class A2DPConfig {
59
59
* Requires: https://github.com/pschatzmann/ESP32-A2DP
60
60
*
61
61
* @ingroup io
62
+ * @ingroup communications
62
63
* @author Phil Schatzmann
63
64
* @copyright GPLv3
64
65
*/
@@ -108,14 +109,15 @@ class A2DPStream : public AudioStream {
108
109
return *a2dp_sink;
109
110
}
110
111
112
+ // / Starts the processing
111
113
void begin (RxTxMode mode, const char * name){
112
114
A2DPConfig cfg;
113
115
cfg.mode = mode;
114
116
cfg.name = name;
115
117
begin (cfg);
116
118
}
117
119
118
- // / Opens the processing
120
+ // / Starts the processing
119
121
bool begin (A2DPConfig cfg){
120
122
this ->config = cfg;
121
123
bool result = false ;
@@ -187,7 +189,7 @@ class A2DPStream : public AudioStream {
187
189
}
188
190
189
191
// / Writes the data into a temporary send buffer - where it can be picked up by the callback
190
- virtual size_t write (const uint8_t * data, size_t len) {
192
+ size_t write (const uint8_t * data, size_t len) override {
191
193
LOGD (" %s: %zu" , LOG_METHOD, len);
192
194
if (config.mode ==TX_MODE){
193
195
// if buffer is full and we are still not connected, we wait
@@ -211,7 +213,7 @@ class A2DPStream : public AudioStream {
211
213
}
212
214
213
215
// / Reads the data from the temporary buffer
214
- virtual size_t readBytes (uint8_t *data, size_t len) {
216
+ size_t readBytes (uint8_t *data, size_t len) override {
215
217
if (!is_a2dp_active){
216
218
LOGW ( " readBytes failed because !is_a2dp_active" );
217
219
return 0 ;
@@ -222,13 +224,13 @@ class A2DPStream : public AudioStream {
222
224
return result;
223
225
}
224
226
225
- virtual int available () {
227
+ int available () override {
226
228
// only supported in tx mode
227
229
if (config.mode !=RX_MODE) return 0 ;
228
230
return a2dp_buffer.available ();
229
231
}
230
232
231
- virtual int availableForWrite () {
233
+ int availableForWrite () override {
232
234
// only supported in tx mode
233
235
if (config.mode !=TX_MODE ) return 0 ;
234
236
// return infor from buffer
@@ -242,17 +244,13 @@ class A2DPStream : public AudioStream {
242
244
if (a2dp!=nullptr ) a2dp->set_volume (volume * 128 );
243
245
}
244
246
245
- virtual void setNotifyAudioChange (AudioInfoDependent &bi) {
246
- audioBaseInfoDependent = &bi;
247
- }
248
247
249
248
250
249
protected:
251
250
A2DPConfig config;
252
251
BluetoothA2DPSource *a2dp_source = nullptr ;
253
252
BluetoothA2DPSink *a2dp_sink = nullptr ;
254
253
BluetoothA2DPCommon *a2dp=nullptr ;
255
- AudioInfoDependent *audioBaseInfoDependent=nullptr ;
256
254
float volume = 1.0 ;
257
255
258
256
// auto-detect device to send audio to (TX-Mode)
@@ -316,19 +314,19 @@ class A2DPStream : public AudioStream {
316
314
317
315
// / notify subscriber with AudioInfo
318
316
void notify_base_Info (int rate){
319
- if (audioBaseInfoDependent !=nullptr ){
317
+ if (p_notify !=nullptr ){
320
318
AudioInfo info;
321
319
info.channels = 2 ;
322
320
info.bits_per_sample = 16 ;
323
321
info.sample_rate = rate;
324
- audioBaseInfoDependent ->setAudioInfo (info);
322
+ p_notify ->setAudioInfo (info);
325
323
}
326
324
}
327
325
328
326
// / callback to update audio info with used a2dp sample rate
329
327
static void sample_rate_callback (uint16_t rate) {
330
328
A2DPStream_self->info .sample_rate = rate;
331
- if (A2DPStream_self->audioBaseInfoDependent !=nullptr ){
329
+ if (A2DPStream_self->p_notify !=nullptr ){
332
330
A2DPStream_self->notify_base_Info (rate);
333
331
}
334
332
}
0 commit comments