[Rhythmbox-devel] monkey-media xine backend fixes
- From: Bastien Nocera <hadess hadess net>
- To: Rhythmbox Devel <rhythmbox-devel gnome org>
- Subject: [Rhythmbox-devel] monkey-media xine backend fixes
- Date: 30 Jul 2003 15:59:42 +0100
Heya,
Another patch, fixes the xine backend to have buffering_end and
buffering_start signals.
Cheers
--
/Bastien Nocera
http://hadess.net
#2 0x4205a2cc in printf ("Oh my %s\n", preferred_deity) from
/lib/i686/libc.so.6 printf ("Oh my %s\n", preferred_deity);
Segmentation fault
Index: src/monkey-media-player-xine.c
===================================================================
RCS file: /cvs/gnome/monkey-media/src/monkey-media-player-xine.c,v
retrieving revision 1.7
diff -u -r1.7 monkey-media-player-xine.c
--- src/monkey-media-player-xine.c 30 Jan 2003 17:57:41 -0000 1.7
+++ src/monkey-media-player-xine.c 30 Jul 2003 14:49:28 -0000
@@ -55,12 +55,19 @@
long timer_add;
guint tick_timeout_id;
+ GAsyncQueue *queue;
};
+typedef struct {
+ int signal;
+} signal_data;
+
enum
{
EOS,
INFO,
+ BUFFERING_BEGIN,
+ BUFFERING_END,
ERROR,
TICK,
LAST_SIGNAL
@@ -126,6 +133,24 @@
2,
MONKEY_MEDIA_TYPE_STREAM_INFO_FIELD,
G_TYPE_POINTER);
+ monkey_media_player_signals[BUFFERING_BEGIN] =
+ g_signal_new ("buffering_begin",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (MonkeyMediaPlayerClass, buffering_begin),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ monkey_media_player_signals[BUFFERING_END] =
+ g_signal_new ("buffering_end",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (MonkeyMediaPlayerClass, buffering_end),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
monkey_media_player_signals[ERROR] =
g_signal_new ("error",
G_OBJECT_CLASS_TYPE (object_class),
@@ -211,21 +236,59 @@
static gboolean
signal_idle (MonkeyMediaPlayer *mp)
{
- g_signal_emit (G_OBJECT (mp), monkey_media_player_signals[EOS], 0);
+ int queue_length;
+ signal_data *data;
+
+ data = g_async_queue_try_pop (mp->priv->queue);
+ if (data == NULL)
+ return FALSE;
+
+ switch (data->signal) {
+ case EOS:
+ g_signal_emit (G_OBJECT (mp), monkey_media_player_signals[EOS], 0);
+ break;
+ case BUFFERING_BEGIN:
+ g_signal_emit (G_OBJECT (mp), monkey_media_player_signals[BUFFERING_BEGIN], 0);
+ break;
+ case BUFFERING_END:
+ g_signal_emit (G_OBJECT (mp), monkey_media_player_signals[BUFFERING_END], 0);
+ break;
+ }
g_object_unref (G_OBJECT (mp));
+ g_free (data);
+ queue_length = g_async_queue_length (mp->priv->queue);
- return FALSE;
+ return (queue_length > 0);
}
static void
xine_event (MonkeyMediaPlayer *mp,
const xine_event_t *event)
{
- if (event->type == XINE_EVENT_UI_PLAYBACK_FINISHED) {
- g_object_ref (G_OBJECT (mp));
+ signal_data *data;
+ xine_progress_data_t* prg;
+ switch (event->type) {
+ case XINE_EVENT_UI_PLAYBACK_FINISHED:
+ g_object_ref (G_OBJECT (mp));
+ data = g_new0 (signal_data, 1);
+ data->signal = EOS;
+ g_async_queue_push (mp->priv->queue, data);
g_idle_add ((GSourceFunc) signal_idle, mp);
+ break;
+ case XINE_EVENT_PROGRESS:
+ prg = event->data;
+
+ if (prg->percent == 0 || prg->percent == 100)
+ {
+ g_object_ref (G_OBJECT (mp));
+ data = g_new0 (signal_data, 1);
+ data->signal = prg->percent ?
+ BUFFERING_END : BUFFERING_BEGIN;
+ g_idle_add ((GSourceFunc) signal_idle, mp);
+ break;
+ }
}
}
@@ -274,6 +337,7 @@
mp->priv->audio_driver,
mp->priv->video_driver);
mp->priv->event_queue = xine_event_new_queue (mp->priv->stream);
+ mp->priv->queue = g_async_queue_new ();
xine_event_create_listener_thread (mp->priv->event_queue,
(xine_event_listener_cb_t) xine_event, mp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]