Skip to content

Display and control your Android device

Make audio buffering independant of output buffer

Romain Vimont62776fb2617a
diff --git a/app/src/audio_player.c b/app/src/audio_player.c
index d72dac25..9e856181 100644
--- a/app/src/audio_player.c
+++ b/app/src/audio_player.c
@@ -220,14 +220,14 @@ sc_audio_player_frame_sink_push(struct sc_frame_sink *sink,
underflow = atomic_exchange_explicit(&ap->underflow, 0,
memory_order_relaxed);
- max_buffered_samples = ap->target_buffering
- + 12 * ap->output_buffer
- + ap->target_buffering / 10;
+ max_buffered_samples = ap->target_buffering * 11 / 10
+ + 60 * ap->sample_rate / 1000 /* 60 ms */;
} else {
// SDL playback not started yet, do not accumulate more than
// max_initial_buffering samples, this would cause unnecessary delay
// (and glitches to compensate) on start.
- max_buffered_samples = ap->target_buffering + 2 * ap->output_buffer;
+ max_buffered_samples = ap->target_buffering
+ + 10 * ap->sample_rate / 1000 /* 10 ms */;
}
uint32_t can_read = sc_audiobuf_can_read(&ap->buf);
@@ -363,7 +363,6 @@ sc_audio_player_frame_sink_open(struct sc_frame_sink *sink,
uint64_t aout_samples = ap->output_buffer_duration * ap->sample_rate
/ SC_TICK_FREQ;
assert(aout_samples <= 0xFFFF);
- ap->output_buffer = (uint16_t) aout_samples;
SDL_AudioSpec desired = {
.freq = ctx->sample_rate,
diff --git a/app/src/audio_player.h b/app/src/audio_player.h
index c02a0d20..4ad40306 100644
--- a/app/src/audio_player.h
+++ b/app/src/audio_player.h
@@ -32,7 +32,6 @@ struct sc_audio_player {
// SDL audio output buffer size.
sc_tick output_buffer_duration;
- uint16_t output_buffer;
// Audio buffer to communicate between the receiver and the SDL audio
// callback