Skip to content

Commit 77a0411

Browse files
committed
Minor cleanup
1 parent 68cc173 commit 77a0411

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/testffmpeg.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ struct SwsContextContainer
101101
struct SwsContext *context;
102102
};
103103
static const char *SWS_CONTEXT_CONTAINER_PROPERTY = "SWS_CONTEXT_CONTAINER";
104-
static int done;
105104
static bool verbose;
106105

107106
static bool CreateWindowAndRenderer(SDL_WindowFlags window_flags, const char *driver)
@@ -1111,9 +1110,8 @@ static void HandleVideoFrame(AVFrame *frame, double pts)
11111110
video_start = SDL_GetTicks();
11121111
}
11131112
double now = (double)(SDL_GetTicks() - video_start) / 1000.0;
1114-
while (now < pts - 0.001) {
1115-
SDL_Delay(1);
1116-
now = (double)(SDL_GetTicks() - video_start) / 1000.0;
1113+
if (now < pts) {
1114+
SDL_DelayPrecise((Uint64)((pts - now) * SDL_NS_PER_SECOND));
11171115
}
11181116

11191117
if (BeginFrameRendering(frame) < 0) {
@@ -1173,7 +1171,7 @@ static AVCodecContext *OpenAudioStream(AVFormatContext *ic, int stream, const AV
11731171
return context;
11741172
}
11751173

1176-
static SDL_AudioFormat GetAudioFormat(enum AVSampleFormat format)
1174+
static SDL_AudioFormat GetAudioFormat(int format)
11771175
{
11781176
switch (format) {
11791177
case AV_SAMPLE_FMT_U8:
@@ -1190,11 +1188,11 @@ static SDL_AudioFormat GetAudioFormat(enum AVSampleFormat format)
11901188
return SDL_AUDIO_F32;
11911189
default:
11921190
/* Unsupported */
1193-
return 0;
1191+
return SDL_AUDIO_UNKNOWN;
11941192
}
11951193
}
11961194

1197-
static bool IsPlanarAudioFormat(enum AVSampleFormat format)
1195+
static bool IsPlanarAudioFormat(int format)
11981196
{
11991197
switch (format) {
12001198
case AV_SAMPLE_FMT_U8P:
@@ -1313,6 +1311,7 @@ int main(int argc, char *argv[])
13131311
SDL_WindowFlags window_flags;
13141312
bool flushing = false;
13151313
bool decoded = false;
1314+
bool done = false;
13161315
SDLTest_CommonState *state;
13171316

13181317
/* Initialize test framework */
@@ -1497,16 +1496,14 @@ int main(int argc, char *argv[])
14971496
SDL_ShowWindow(window);
14981497

14991498
/* Main render loop */
1500-
done = 0;
1501-
15021499
while (!done) {
15031500
SDL_Event event;
15041501

15051502
/* Check for events */
15061503
while (SDL_PollEvent(&event)) {
15071504
if (event.type == SDL_EVENT_QUIT ||
15081505
(event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_ESCAPE)) {
1509-
done = 1;
1506+
done = true;
15101507
}
15111508
}
15121509

@@ -1572,7 +1569,7 @@ int main(int argc, char *argv[])
15721569
/* Wait a little bit for the audio to finish */
15731570
SDL_Delay(10);
15741571
} else {
1575-
done = 1;
1572+
done = true;
15761573
}
15771574
}
15781575
}

0 commit comments

Comments
 (0)