2023-03-03 00:43:20 +01:00
|
|
|
#ifndef SC_AUDIO_PLAYER_H
|
|
|
|
#define SC_AUDIO_PLAYER_H
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
2024-01-01 19:22:55 +01:00
|
|
|
#include <stdatomic.h>
|
2023-03-03 00:43:20 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
|
2024-09-23 23:58:02 +02:00
|
|
|
#include "audio_regulator.h"
|
2024-01-02 10:22:06 +01:00
|
|
|
#include "trait/frame_sink.h"
|
|
|
|
#include "util/tick.h"
|
|
|
|
|
2023-03-03 00:43:20 +01:00
|
|
|
struct sc_audio_player {
|
|
|
|
struct sc_frame_sink frame_sink;
|
|
|
|
|
|
|
|
// The target buffering between the producer and the consumer. This value
|
|
|
|
// is directly use for compensation.
|
|
|
|
// Since audio capture and/or encoding on the device typically produce
|
|
|
|
// blocks of 960 samples (20ms) or 1024 samples (~21.3ms), this target
|
|
|
|
// value should be higher.
|
|
|
|
sc_tick target_buffering_delay;
|
|
|
|
|
2024-09-23 23:58:02 +02:00
|
|
|
// SDL audio output buffer size
|
2023-03-13 09:23:02 +01:00
|
|
|
sc_tick output_buffer_duration;
|
|
|
|
|
2024-09-23 23:58:02 +02:00
|
|
|
SDL_AudioDeviceID device;
|
|
|
|
struct sc_audio_regulator audioreg;
|
2023-03-03 00:43:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2023-03-13 09:23:02 +01:00
|
|
|
sc_audio_player_init(struct sc_audio_player *ap, sc_tick target_buffering,
|
|
|
|
sc_tick audio_output_buffer);
|
2023-03-03 00:43:20 +01:00
|
|
|
|
|
|
|
#endif
|