Minor cleanup

This commit is contained in:
Sam Lantinga 2024-10-31 15:44:41 -07:00
parent 68cc173d92
commit 77a0411dde

View file

@ -101,7 +101,6 @@ struct SwsContextContainer
struct SwsContext *context; struct SwsContext *context;
}; };
static const char *SWS_CONTEXT_CONTAINER_PROPERTY = "SWS_CONTEXT_CONTAINER"; static const char *SWS_CONTEXT_CONTAINER_PROPERTY = "SWS_CONTEXT_CONTAINER";
static int done;
static bool verbose; static bool verbose;
static bool CreateWindowAndRenderer(SDL_WindowFlags window_flags, const char *driver) static bool CreateWindowAndRenderer(SDL_WindowFlags window_flags, const char *driver)
@ -1111,9 +1110,8 @@ static void HandleVideoFrame(AVFrame *frame, double pts)
video_start = SDL_GetTicks(); video_start = SDL_GetTicks();
} }
double now = (double)(SDL_GetTicks() - video_start) / 1000.0; double now = (double)(SDL_GetTicks() - video_start) / 1000.0;
while (now < pts - 0.001) { if (now < pts) {
SDL_Delay(1); SDL_DelayPrecise((Uint64)((pts - now) * SDL_NS_PER_SECOND));
now = (double)(SDL_GetTicks() - video_start) / 1000.0;
} }
if (BeginFrameRendering(frame) < 0) { if (BeginFrameRendering(frame) < 0) {
@ -1173,7 +1171,7 @@ static AVCodecContext *OpenAudioStream(AVFormatContext *ic, int stream, const AV
return context; return context;
} }
static SDL_AudioFormat GetAudioFormat(enum AVSampleFormat format) static SDL_AudioFormat GetAudioFormat(int format)
{ {
switch (format) { switch (format) {
case AV_SAMPLE_FMT_U8: case AV_SAMPLE_FMT_U8:
@ -1190,11 +1188,11 @@ static SDL_AudioFormat GetAudioFormat(enum AVSampleFormat format)
return SDL_AUDIO_F32; return SDL_AUDIO_F32;
default: default:
/* Unsupported */ /* Unsupported */
return 0; return SDL_AUDIO_UNKNOWN;
} }
} }
static bool IsPlanarAudioFormat(enum AVSampleFormat format) static bool IsPlanarAudioFormat(int format)
{ {
switch (format) { switch (format) {
case AV_SAMPLE_FMT_U8P: case AV_SAMPLE_FMT_U8P:
@ -1313,6 +1311,7 @@ int main(int argc, char *argv[])
SDL_WindowFlags window_flags; SDL_WindowFlags window_flags;
bool flushing = false; bool flushing = false;
bool decoded = false; bool decoded = false;
bool done = false;
SDLTest_CommonState *state; SDLTest_CommonState *state;
/* Initialize test framework */ /* Initialize test framework */
@ -1497,8 +1496,6 @@ int main(int argc, char *argv[])
SDL_ShowWindow(window); SDL_ShowWindow(window);
/* Main render loop */ /* Main render loop */
done = 0;
while (!done) { while (!done) {
SDL_Event event; SDL_Event event;
@ -1506,7 +1503,7 @@ int main(int argc, char *argv[])
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
if (event.type == SDL_EVENT_QUIT || if (event.type == SDL_EVENT_QUIT ||
(event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_ESCAPE)) { (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_ESCAPE)) {
done = 1; done = true;
} }
} }
@ -1572,7 +1569,7 @@ int main(int argc, char *argv[])
/* Wait a little bit for the audio to finish */ /* Wait a little bit for the audio to finish */
SDL_Delay(10); SDL_Delay(10);
} else { } else {
done = 1; done = true;
} }
} }
} }