Add audio sample ring-buffer

Add a thin wrapper around bytebuf to handle samples instead of bytes.
This simplifies the audio player, which mostly handles samples.
This commit is contained in:
Romain Vimont
2023-03-11 10:13:00 +01:00
parent bb509d9317
commit 14f9d82fda
3 changed files with 148 additions and 76 deletions

View File

@@ -5,8 +5,8 @@
#include <stdbool.h>
#include "trait/frame_sink.h"
#include <util/audiobuf.h>
#include <util/average.h>
#include <util/bytebuf.h>
#include <util/thread.h>
#include <util/tick.h>
@@ -29,11 +29,11 @@ struct sc_audio_player {
// Audio buffer to communicate between the receiver and the SDL audio
// callback (protected by SDL_AudioDeviceLock())
struct sc_bytebuf buf;
struct sc_audiobuf buf;
// The previous number of bytes available in the buffer (only used by the
// receiver thread)
size_t previous_write_avail;
// The previous empty space in the buffer (only used by the receiver
// thread)
uint32_t previous_write_avail;
// Resampler (only used from the receiver thread)
struct SwrContext *swr_ctx;