Skip to content

Commit

Permalink
Use block writes for BT audio consumers (#2204)
Browse files Browse the repository at this point in the history
Around 2x the performance, and every bit is needed w/BT SBC compression
and decompression.
  • Loading branch information
earlephilhower committed Jun 5, 2024
1 parent 0ec12aa commit 0f05ad1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions libraries/BluetoothAudio/src/BluetoothAudioConsumerI2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ void BluetoothAudioConsumerI2S::fill() {
_a2dpSink->playback_handler((int16_t *) buff, 32);
num_samples -= 64;
for (int i = 0; i < 64; i++) {
int32_t tmp = buff[i];
tmp *= _gain;
tmp >>= 8;
_i2s->write((int16_t)tmp);
buff[i] = (((int32_t)buff[i]) * _gain) >> 8;
}
_i2s->write((uint8_t *)buff, 64 * 2);
}
}
6 changes: 2 additions & 4 deletions libraries/BluetoothAudio/src/BluetoothAudioConsumerPWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ void BluetoothAudioConsumerPWM::fill() {
_a2dpSink->playback_handler((int16_t *) buff, 32);
num_samples -= 64;
for (int i = 0; i < 64; i++) {
int32_t tmp = buff[i];
tmp *= _gain;
tmp >>= 8;
_pwm->write((int16_t)tmp);
buff[i] = (((int32_t)buff[i]) * _gain) >> 8;
}
_pwm->write((uint8_t *)buff, 64 * 2);
}
}

0 comments on commit 0f05ad1

Please sign in to comment.