From: Rafal R. <di...@us...> - 2004-08-12 14:54:41
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/MVEPlayer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30267/gemrb/plugins/MVEPlayer Modified Files: mve_play.cpp Log Message: frame dropping in movies Index: mve_play.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/MVEPlayer/mve_play.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** mve_play.cpp 7 Aug 2004 15:41:52 -0000 1.6 --- mve_play.cpp 12 Aug 2004 14:54:17 -0000 1.7 *************** *** 68,71 **** --- 68,73 ---- static int g_spdFactorDenom = 10; static int g_frameUpdated = 0; + static int g_framesToDrop = 0; + static int g_framesDropped = 0; static short get_short(unsigned char* data) *************** *** 216,223 **** gettimeofday( &tv, NULL ); ! if (tv.tv_sec > timer_expire.tv_sec) { ! goto end; ! } else if (tv.tv_sec == timer_expire.tv_sec && ! tv.tv_usec >= timer_expire.tv_usec) { goto end; } --- 218,224 ---- gettimeofday( &tv, NULL ); ! if ((tv.tv_sec > timer_expire.tv_sec) || (tv.tv_sec == timer_expire.tv_sec && ! tv.tv_usec >= timer_expire.tv_usec)) { ! ++ g_framesToDrop; // we are late, so we have to catch up to audio not to lose synchro goto end; } *************** *** 259,262 **** --- 260,264 ---- static int mve_audio_enabled = 1; static short * mve_audio_memory = 0; + static int mve_audio_underruns = 0; #endif *************** *** 334,344 **** alSourcef( mve_audio_source, AL_GAIN, 1.0f ); alSourcefv( mve_audio_source, AL_POSITION, SourcePos ); - alSourcei( mve_audio_source, AL_SOURCE_RELATIVE, 1 ); alSourcefv( mve_audio_source, AL_VELOCITY, SourceVel ); alSourcei( mve_audio_source, AL_LOOPING, 0 ); } fprintf( stderr, " success\n" ); mve_audio_canplay = 1; #endif --- 336,348 ---- alSourcef( mve_audio_source, AL_GAIN, 1.0f ); alSourcefv( mve_audio_source, AL_POSITION, SourcePos ); alSourcefv( mve_audio_source, AL_VELOCITY, SourceVel ); alSourcei( mve_audio_source, AL_LOOPING, 0 ); + alSourcei( mve_audio_source, AL_SOURCE_RELATIVE, 1 ); } fprintf( stderr, " success\n" ); mve_audio_canplay = 1; + + mve_audio_underruns = 0; #endif *************** *** 397,402 **** data += 8; ! alBufferData( buffer, mve_audio_format, ! data, nsamp, mve_audio_samplerate ); } } else { --- 401,405 ---- data += 8; ! alBufferData( buffer, mve_audio_format, data, nsamp, mve_audio_samplerate ); } } else { *************** *** 407,417 **** ALenum state; ! alGetSourcei( mve_audio_source, AL_SOURCE_STATE, &state ! ); if (AL_STOPPED == state) { // it seems we have a buffer underrun; press play to continue... alSourcePlay( mve_audio_source ); } } } --- 410,426 ---- ALenum state; ! alGetSourcei( mve_audio_source, AL_SOURCE_STATE, &state ); if (AL_STOPPED == state) { // it seems we have a buffer underrun; press play to continue... + mve_audio_underruns ++; + fprintf( stderr, "\nbuffer underrun\n" ); alSourcePlay( mve_audio_source ); } + ALint queued, processed; + alGetSourcei( mve_audio_source, AL_BUFFERS_QUEUED, &queued ); + alGetSourcei( mve_audio_source, AL_BUFFERS_PROCESSED, &processed ); + fprintf(stderr, "audio buffers: %d queued, %d processed\r", queued, processed); + } } *************** *** 503,508 **** } ! mve_showframe( ( unsigned char * ) g_vBackBuf1, g_width, g_height, 0, 0, ! g_width, g_height, g_destX, g_destY ); g_frameUpdated = 1; --- 512,522 ---- } ! if (0 == g_framesToDrop) { // this is the most expensive operation, so we want to drop frames here ! mve_showframe( ( unsigned char * ) g_vBackBuf1, g_width, g_height, 0, 0, ! g_width, g_height, g_destX, g_destY ); ! } else { ! -- g_framesToDrop; ! ++ g_framesDropped; ! } g_frameUpdated = 1; *************** *** 667,670 **** --- 681,687 ---- mve_play_next_chunk( mve ); /* audio initialization chunk */ + g_framesToDrop = 0; + g_framesDropped = 0; + return 0; } *************** *** 736,739 **** --- 753,758 ---- mve_audio_compressed = 0; audiobuf_created = 0; + + fprintf( stderr, "\ntotal buffer underruns: %d\n", mve_audio_underruns ); #endif *************** *** 745,748 **** --- 764,769 ---- video_initialized = 0; + fprintf( stderr, "dropped frames: %d\n", g_framesDropped ); + mve_close( mve ); mve = NULL; |