[xiph-commits] r2918 - liboggplay/trunk/plugin
shans at svn.annodex.net
shans at svn.annodex.net
Wed Jun 13 18:24:39 PDT 2007
Author: shans
Date: 2007-06-13 18:24:39 -0700 (Wed, 13 Jun 2007)
New Revision: 2918
Modified:
liboggplay/trunk/plugin/plugin_oggplay.c
Log:
added handling of timeout on oggplay_step_decoding
reintroduced waiting for oggplay decode thread to shut down gracefully
Modified: liboggplay/trunk/plugin/plugin_oggplay.c
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-14 01:21:39 UTC (rev 2917)
+++ liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-14 01:24:39 UTC (rev 2918)
@@ -114,7 +114,6 @@
int video_track = -1;
int audio_track = -1;
- printf("oggplay thread: started\n"); fflush(stdout);
player = oggplay_new_with_reader(reader, pointers->location);
pointers->shutdown_oggplay = 0;
@@ -130,7 +129,6 @@
oggplay_use_buffer(player, LIBOGGPLAY_BUFFER_SIZE);
SEM_CREATE(pointers->sem, LIBOGGPLAY_BUFFER_SIZE);
- printf("oggplay thread: signalling readiness\n"); fflush(stdout);
SEM_SIGNAL(pointers->start_stop_sem);
/*
@@ -146,7 +144,6 @@
break;
}
if (pointers->shutdown_oggplay) {
- printf("oggplay thread: shutdown during startup\n"); fflush(stdout);
goto thread_shutdown;
}
if (res == E_OGGPLAY_TIMEOUT) {
@@ -154,15 +151,12 @@
continue;
}
}
- printf("oggplay thread: failed to initialise oggplay; error %d\n", res);
- fflush(stdout);
while (!pointers->shutdown_oggplay) {
oggplay_millisleep(10);
}
goto thread_shutdown;
}
- printf("oggplay thread: completed startup\n"); fflush(stdout);
for (i = 0; i < oggplay_get_num_tracks(player); i++) {
if (oggplay_get_track_type(player, i) == OGGZ_CONTENT_THEORA) {
@@ -195,7 +189,6 @@
#ifdef USE_AUDIO
if (video_track == -1) {
int period = pointers->audio_rate / 25;
- printf("no video: syncing to audio track\n");
oggplay_set_callback_num_frames(player, audio_track, period);
NUM_DENOM_TO_16_16(period * 1000, pointers->audio_rate,
&(pointers->callback_period));
@@ -212,14 +205,15 @@
SEM_WAIT(pointers->sem);
- if (pointers->shutdown_oggplay) {
- printf("oggplay thread: shutdown during normal operation\n");
- fflush(stdout);
- break;
+
+ r = E_OGGPLAY_TIMEOUT;
+ while (r == E_OGGPLAY_TIMEOUT) {
+ if (pointers->shutdown_oggplay) {
+ goto thread_shutdown;
+ }
+ r = oggplay_step_decoding(pointers->player);
}
-
- r = oggplay_step_decoding(pointers->player);
- printf("oggplay thread: stepped\n");
+
if (r != E_OGGPLAY_CONTINUE && r != E_OGGPLAY_USER_INTERRUPT) {
break;
}
@@ -229,14 +223,10 @@
pointers->shutdown_oggplay = 0;
SEM_CLOSE(pointers->sem);
- printf("oggplay thread: closing oggplay\n"); fflush(stdout);
oggplay_close(pointers->player);
- printf("oggplay thread: closed\n"); fflush(stdout);
- free(pointers->location);
- free(pointers);
-
- printf("pointers freed\n");
+ SEM_SIGNAL(pointers->start_stop_sem);
+
#if defined(XP_UX) || defined(XP_MACOSX)
pthread_exit(NULL);
#elif defined(XP_WIN)
@@ -266,10 +256,7 @@
(LPVOID)pointers, 0, &dec_id);
#endif
- printf("waiting on oggplay startup\n"); fflush(stdout);
SEM_WAIT(pointers->start_stop_sem);
- SEM_CLOSE(pointers->start_stop_sem);
- printf("oggplay startup complete\n"); fflush(stdout);
return pointers;
}
@@ -279,7 +266,6 @@
PluginPointers * pointers = (PluginPointers *)handle;
- printf("signalling oggplay shutdown\n"); fflush(stdout);
pointers->shutdown_oggplay = 1;
/*
@@ -292,8 +278,14 @@
SEM_SIGNAL(pointers->sem);
/*
- * we don't actually need to wait for the oggplay object to shut itself down.
+ * wait for the oggplay object to shut itself down.
*/
+ SEM_WAIT(pointers->start_stop_sem);
+ SEM_CLOSE(pointers->start_stop_sem);
+
+ free(pointers->location);
+ free(pointers);
+
}
void
More information about the commits
mailing list