@@ -101,7 +101,6 @@ struct SwsContextContainer
101
101
struct SwsContext * context ;
102
102
};
103
103
static const char * SWS_CONTEXT_CONTAINER_PROPERTY = "SWS_CONTEXT_CONTAINER" ;
104
- static int done ;
105
104
static bool verbose ;
106
105
107
106
static bool CreateWindowAndRenderer (SDL_WindowFlags window_flags , const char * driver )
@@ -1111,9 +1110,8 @@ static void HandleVideoFrame(AVFrame *frame, double pts)
1111
1110
video_start = SDL_GetTicks ();
1112
1111
}
1113
1112
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 ));
1117
1115
}
1118
1116
1119
1117
if (BeginFrameRendering (frame ) < 0 ) {
@@ -1173,7 +1171,7 @@ static AVCodecContext *OpenAudioStream(AVFormatContext *ic, int stream, const AV
1173
1171
return context ;
1174
1172
}
1175
1173
1176
- static SDL_AudioFormat GetAudioFormat (enum AVSampleFormat format )
1174
+ static SDL_AudioFormat GetAudioFormat (int format )
1177
1175
{
1178
1176
switch (format ) {
1179
1177
case AV_SAMPLE_FMT_U8 :
@@ -1190,11 +1188,11 @@ static SDL_AudioFormat GetAudioFormat(enum AVSampleFormat format)
1190
1188
return SDL_AUDIO_F32 ;
1191
1189
default :
1192
1190
/* Unsupported */
1193
- return 0 ;
1191
+ return SDL_AUDIO_UNKNOWN ;
1194
1192
}
1195
1193
}
1196
1194
1197
- static bool IsPlanarAudioFormat (enum AVSampleFormat format )
1195
+ static bool IsPlanarAudioFormat (int format )
1198
1196
{
1199
1197
switch (format ) {
1200
1198
case AV_SAMPLE_FMT_U8P :
@@ -1313,6 +1311,7 @@ int main(int argc, char *argv[])
1313
1311
SDL_WindowFlags window_flags ;
1314
1312
bool flushing = false;
1315
1313
bool decoded = false;
1314
+ bool done = false;
1316
1315
SDLTest_CommonState * state ;
1317
1316
1318
1317
/* Initialize test framework */
@@ -1497,16 +1496,14 @@ int main(int argc, char *argv[])
1497
1496
SDL_ShowWindow (window );
1498
1497
1499
1498
/* Main render loop */
1500
- done = 0 ;
1501
-
1502
1499
while (!done ) {
1503
1500
SDL_Event event ;
1504
1501
1505
1502
/* Check for events */
1506
1503
while (SDL_PollEvent (& event )) {
1507
1504
if (event .type == SDL_EVENT_QUIT ||
1508
1505
(event .type == SDL_EVENT_KEY_DOWN && event .key .key == SDLK_ESCAPE )) {
1509
- done = 1 ;
1506
+ done = true ;
1510
1507
}
1511
1508
}
1512
1509
@@ -1572,7 +1569,7 @@ int main(int argc, char *argv[])
1572
1569
/* Wait a little bit for the audio to finish */
1573
1570
SDL_Delay (10 );
1574
1571
} else {
1575
- done = 1 ;
1572
+ done = true ;
1576
1573
}
1577
1574
}
1578
1575
}
0 commit comments