freepassport-c/src/player.h

44 lines
1.4 KiB
C
Raw Normal View History

2026-03-27 21:45:40 -04:00
#ifndef PLAYER_H
#define PLAYER_H
#include <SDL2/SDL.h>
#include <time.h>
#include "channel.h"
#include "frame_queue.h"
typedef struct Player {
FrameQueue frame_queue;
SDL_Thread *thread;
SDL_atomic_t stop_requested;
const ChannelList *channels;
int current_index;
time_t app_start_time;
Uint32 tuning_blackout_until;
SDL_AudioDeviceID audio_device;
SDL_AudioSpec audio_spec;
SDL_mutex *audio_mutex;
SDL_mutex *clock_mutex;
double latest_audio_end_pts;
int has_audio_stream;
int audio_started;
int preroll_ready;
Uint32 catchup_until;
char audio_driver[32];
2026-03-27 21:45:40 -04:00
SDL_mutex *error_mutex;
char last_error[256];
} Player;
int player_init(Player *player, const ChannelList *channels, time_t app_start_time);
void player_destroy(Player *player);
int player_tune(Player *player, int channel_index);
int player_consume_latest_frame(Player *player, FrameData *out);
int player_consume_synced_frame(Player *player, FrameData *out, double clock_seconds, double lead_tolerance);
2026-03-27 21:45:40 -04:00
double player_live_position(const Player *player, time_t now);
double player_get_sync_clock(Player *player, time_t now);
void player_set_catchup_until(Player *player, Uint32 tick);
2026-03-27 21:45:40 -04:00
int player_is_in_blackout(const Player *player);
void player_resume_audio(Player *player);
2026-03-27 21:45:40 -04:00
void player_get_error(Player *player, char *buffer, size_t buffer_size);
#endif