Skip to content

Commit 65a99f1

Browse files
committed
cleanup A2DPStream
1 parent 58cdc16 commit 65a99f1

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/AudioLibs/AudioA2DP.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class A2DPConfig {
5959
* Requires: https://github.com/pschatzmann/ESP32-A2DP
6060
*
6161
* @ingroup io
62+
* @ingroup communications
6263
* @author Phil Schatzmann
6364
* @copyright GPLv3
6465
*/
@@ -108,14 +109,15 @@ class A2DPStream : public AudioStream {
108109
return *a2dp_sink;
109110
}
110111

112+
/// Starts the processing
111113
void begin(RxTxMode mode, const char* name){
112114
A2DPConfig cfg;
113115
cfg.mode = mode;
114116
cfg.name = name;
115117
begin(cfg);
116118
}
117119

118-
/// Opens the processing
120+
/// Starts the processing
119121
bool begin(A2DPConfig cfg){
120122
this->config = cfg;
121123
bool result = false;
@@ -187,7 +189,7 @@ class A2DPStream : public AudioStream {
187189
}
188190

189191
/// 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 {
191193
LOGD("%s: %zu", LOG_METHOD, len);
192194
if (config.mode==TX_MODE){
193195
// if buffer is full and we are still not connected, we wait
@@ -211,7 +213,7 @@ class A2DPStream : public AudioStream {
211213
}
212214

213215
/// 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 {
215217
if (!is_a2dp_active){
216218
LOGW( "readBytes failed because !is_a2dp_active");
217219
return 0;
@@ -222,13 +224,13 @@ class A2DPStream : public AudioStream {
222224
return result;
223225
}
224226

225-
virtual int available() {
227+
int available() override {
226228
// only supported in tx mode
227229
if (config.mode!=RX_MODE) return 0;
228230
return a2dp_buffer.available();
229231
}
230232

231-
virtual int availableForWrite() {
233+
int availableForWrite() override {
232234
// only supported in tx mode
233235
if (config.mode!=TX_MODE ) return 0;
234236
// return infor from buffer
@@ -242,17 +244,13 @@ class A2DPStream : public AudioStream {
242244
if (a2dp!=nullptr) a2dp->set_volume(volume * 128);
243245
}
244246

245-
virtual void setNotifyAudioChange (AudioInfoDependent &bi) {
246-
audioBaseInfoDependent = &bi;
247-
}
248247

249248

250249
protected:
251250
A2DPConfig config;
252251
BluetoothA2DPSource *a2dp_source = nullptr;
253252
BluetoothA2DPSink *a2dp_sink = nullptr;
254253
BluetoothA2DPCommon *a2dp=nullptr;
255-
AudioInfoDependent *audioBaseInfoDependent=nullptr;
256254
float volume = 1.0;
257255

258256
// auto-detect device to send audio to (TX-Mode)
@@ -316,19 +314,19 @@ class A2DPStream : public AudioStream {
316314

317315
/// notify subscriber with AudioInfo
318316
void notify_base_Info(int rate){
319-
if (audioBaseInfoDependent!=nullptr){
317+
if (p_notify!=nullptr){
320318
AudioInfo info;
321319
info.channels = 2;
322320
info.bits_per_sample = 16;
323321
info.sample_rate = rate;
324-
audioBaseInfoDependent->setAudioInfo(info);
322+
p_notify->setAudioInfo(info);
325323
}
326324
}
327325

328326
/// callback to update audio info with used a2dp sample rate
329327
static void sample_rate_callback(uint16_t rate) {
330328
A2DPStream_self->info.sample_rate = rate;
331-
if (A2DPStream_self->audioBaseInfoDependent!=nullptr){
329+
if (A2DPStream_self->p_notify!=nullptr){
332330
A2DPStream_self->notify_base_Info(rate);
333331
}
334332
}

0 commit comments

Comments
 (0)