diff src/psf2/plugin.c @ 2751:533d73cfa1ff

Finalize event loop for the playback thread; the plugin is now done except for seeking.
author William Pitcock <nenolod@atheme.org>
date Mon, 30 Jun 2008 23:50:51 -0500
parents 6319a15e7243
children cd2d2118fdee
line wrap: on
line diff
--- a/src/psf2/plugin.c	Mon Jun 30 23:39:49 2008 -0500
+++ b/src/psf2/plugin.c	Mon Jun 30 23:50:51 2008 -0500
@@ -69,6 +69,8 @@
 	return AO_SUCCESS;
 }
 
+static gint seek = 0;
+
 Tuple *psf2_tuple(gchar *filename)
 {
 	Tuple *t;
@@ -169,17 +171,29 @@
 
 	data->playing = TRUE;
 	data->set_pb_ready(data);
-	while (data->playing)
+
+	for (;;)
 	{
 		psf2_execute(data);
-	}	
 
-	psf2_stop();
+		if (seek)
+		{
+			seek = 0;
+			continue;
+		}
+
+		psf2_stop();
 
-	data->output->buffer_free();
-	data->output->buffer_free();
+		data->output->buffer_free();
+		data->output->buffer_free();
 
-	data->output->close_audio();
+		while (data->eof && data->output->buffer_playing())
+			g_usleep(10000);
+
+		data->output->close_audio();
+
+		break;
+	}	
 
 	g_free(buffer);
 	g_free(path);