8000 Use block writes for BT audio consumers (#2204) · 12a318/arduino-pico@0f05ad1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f05ad1

Browse files
Use block writes for BT audio consumers (earlephilhower#2204)
Around 2x the performance, and every bit is needed w/BT SBC compression and decompression.
1 parent 0ec12aa commit 0f05ad1

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

libraries/BluetoothAudio/src/BluetoothAudioConsumerI2S.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ void BluetoothAudioConsumerI2S::fill() {
7575
_a2dpSink->playback_handler((int16_t *) buff, 32);
7676
num_samples -= 64;
7777
for (int i = 0; i < 64; i++) {
78-
int32_t tmp = buff[i];
79-
tmp *= _gain;
80-
tmp >>= 8;
81-
_i2s->write((int16_t)tmp);
78+
buff[i] = (((int32_t)buff[i]) * _gain) >> 8;
8279
}
80+
_i2s->write((uint8_t *)buff, 64 * 2);
8381
}
8482
}

libraries/BluetoothAudio/src/BluetoothAudioConsumerPWM.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ void BluetoothAudioConsumerPWM::fill() {
7676
_a2dpSink->playback_handler((int16_t *) buff, 32);
7777
num_samples -= 64;
7878
for (int i = 0; i < 64; i++) {
79-
int32_t tmp = buff[i];
80-
tmp *= _gain;
81-
tmp >>= 8;
82-
_pwm->write((int16_t)tmp);
79+
buff[i] = (((int32_t)buff[i]) * _gain) >> 8;
8380
}
81+
_pwm->write((uint8_t *)buff, 64 * 2);
8482
}
8583
}

0 commit comments

Comments
 (0)
0