From: Darren S. <ds...@us...> - 2005-05-20 19:38:16
|
Update of /cvsroot/xine/gnome-xine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11369/src Modified Files: mediamarks.c player.c playlist.c playlist.h Log Message: Editing of the currently-played item makes a copy (outside the playlist). (This may later be used for clipboard-related purposes.) Playlist next/previous now wrap. Index: mediamarks.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/mediamarks.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- mediamarks.c 13 May 2005 18:19:10 -0000 1.47 +++ mediamarks.c 20 May 2005 19:38:07 -0000 1.48 @@ -525,9 +525,7 @@ char *dot; const char *title = xine_get_meta_info (stream, XINE_META_INFO_TITLE); - play_item = playlist_get_item (playlist_get_list_pos()); - play_item = play_item ? play_item_copy (play_item) - : play_item_new ("", "", 0); + play_item = playlist_get_current_item () ? : play_item_new ("", "", 0); /* default title? try to get title from meta-info */ dot = strrchr (play_item->mrl, '.'); @@ -546,6 +544,8 @@ if (play_item_edit (play_item, PLAY_ITEM_MEDIAMARK_NEW, title)) mm_add (play_item); + else + play_item_dispose (play_item); } void mm_add (play_item_t *play_item) Index: player.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/player.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- player.c 17 May 2005 22:39:49 -0000 1.39 +++ player.c 20 May 2005 19:38:07 -0000 1.40 @@ -917,14 +917,13 @@ pos_time = 0; playlist_play_from (item, pos, pos_time); + } + else + { + play_item_t *item = playlist_get_current_item (); - } else { - - play_item_t *item; - - item = playlist_get_item (playlist_get_list_pos()); - - if (item) { + if (item) + { switch (xine_get_status (stream)) { case XINE_STATUS_STOP: @@ -946,6 +945,7 @@ } break; } + play_item_dispose (item); } else printf (_("script_engine: error, no valid play item available\n")); } Index: playlist.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/playlist.c,v retrieving revision 1.121 retrieving revision 1.122 diff -u -r1.121 -r1.122 --- playlist.c 17 May 2005 22:35:45 -0000 1.121 +++ playlist.c 20 May 2005 19:38:07 -0000 1.122 @@ -64,9 +64,15 @@ static GtkWidget *repeat_button, *random_button; static char logo_mrl[1024]; static int logo_mode; + +static play_item_t *cur_item = NULL; static int cur_list_pos; static int ref_list_pos; +static pthread_mutex_t cur_item_lock = PTHREAD_MUTEX_INITIALIZER; +#define CUR_ITEM_LOCK() pthread_mutex_lock (&cur_item_lock) +#define CUR_ITEM_UNLOCK() pthread_mutex_unlock (&cur_item_lock) + #define unmark_play_item() set_mark_play_item (FALSE) #define mark_play_item() set_mark_play_item (TRUE) static void set_mark_play_item (gboolean state); @@ -79,6 +85,17 @@ *str = 0; } +static inline void cur_item_dispose (void) +{ + CUR_ITEM_LOCK (); + if (cur_item) + { + play_item_dispose (cur_item); + cur_item = NULL; + } + CUR_ITEM_UNLOCK (); +} + static int item_marked_current (GtkTreeIter *iter) { const char *p; @@ -189,21 +206,35 @@ if (gtk_tree_selection_get_selected (sel, NULL, &iter)) { GValue v; - play_item_t *play_item; + play_item_t *play_item, *item_copy; const char *title; memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (pl_store), &iter, 2, &v); play_item = g_value_peek_pointer (&v); + item_copy = play_item_copy (play_item); /* in case of edit */ + title = item_marked_current (&iter) ? xine_get_meta_info (stream, XINE_META_INFO_TITLE) : NULL; if (play_item_edit (play_item, PLAY_ITEM_LIST, title)) - /* FIXME: what if the MRL is changed? */ + { + if (item_marked_current (&iter)) + { + CUR_ITEM_LOCK (); + cur_item = item_copy; + CUR_ITEM_UNLOCK (); + } + else + play_item_dispose (item_copy); + gtk_list_store_set (pl_store, &iter, 0, play_item->title, 1, play_item->mrl, 2, play_item, -1); + } + else + play_item_dispose (item_copy); g_value_unset (&v); } @@ -211,12 +242,18 @@ static void playlist_next_cb (GtkWidget *widget, gpointer data) { - playlist_play (playlist_get_list_pos () + 1); + int pos = playlist_get_list_pos (); + int newpos = playlist_clip (pos + 1); + if (newpos != pos) + playlist_play (newpos); } static void playlist_prev_cb (GtkWidget *widget, gpointer data) { - playlist_play (playlist_get_list_pos () - 1); + int pos = playlist_get_list_pos (); + int newpos = playlist_clip (pos - 1); + if (newpos != pos) + playlist_play (newpos); } static int playlist_load (char *fname) @@ -366,12 +403,17 @@ playlist_save (filename); } +static int playlist_clip (int pos) +{ + int items = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (pl_store), NULL); + return (pos == -1) ? (items - 1) : (pos < 0 || pos >= items) ? 0 : pos; +} + play_item_t *playlist_get_item (int pos) { GtkTreeIter iter; - if (pos<0) - pos = 0; + pos = playlist_clip (pos); if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (pl_store), &iter, NULL, pos)) { @@ -394,6 +436,15 @@ return cur_list_pos; } +play_item_t *playlist_get_current_item (void) +{ + play_item_t *i; + CUR_ITEM_LOCK (); + i = play_item_copy (cur_item ? : playlist_get_item (cur_list_pos)); + CUR_ITEM_UNLOCK (); + return i; +} + int playlist_size (void) { return gtk_tree_model_iter_n_children (GTK_TREE_MODEL (pl_store), NULL); } @@ -1052,13 +1103,9 @@ return ret; } -void playlist_play (int list_pos) { - play_item_t *item; - - if (list_pos<0) - list_pos = 0; - - item = playlist_get_item (list_pos); +void playlist_play (int list_pos) +{ + play_item_t *item = playlist_get_item (list_pos); if (!item) { playlist_logo (); return; @@ -1078,13 +1125,11 @@ } } -void playlist_logo (void) { - - /* int err; */ - +void playlist_logo (void) +{ unmark_play_item (); + cur_item_dispose (); logo_mode = 1; - player_launch (NULL, logo_mrl, 0, 0); } @@ -1336,6 +1381,15 @@ gtk_list_store_set (pl_store, &iter, 0, play_item->title, -1); } + CUR_ITEM_LOCK (); + if (cur_item && cur_item->untitled) + { + free (cur_item->title); + cur_item->title = strdup (title); + cur_item->untitled = FALSE; + } + CUR_ITEM_UNLOCK (); + g_value_unset (&v); } } @@ -1479,9 +1533,6 @@ JS_ValueToInt32 (cx, argv[0], &item); - if (item<0) - item = 0; - playlist_play (item); return JS_TRUE; @@ -1508,11 +1559,10 @@ logo_mode = 0; - if (list_pos<0) - list_pos = 0; - unmark_play_item (); + cur_item_dispose (); + list_pos = playlist_clip (list_pos); play_item = playlist_get_item (list_pos); if (!play_item) { @@ -1531,8 +1581,6 @@ cur_list_pos = list_pos; mark_play_item (); - - } void playlist_init (void) { Index: playlist.h =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/playlist.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- playlist.h 28 Jan 2005 02:16:27 -0000 1.12 +++ playlist.h 20 May 2005 19:38:07 -0000 1.13 @@ -45,6 +45,7 @@ play_item_t *playlist_get_item (int list_pos); int playlist_get_list_pos (void); /*of currently played entry*/ +play_item_t *playlist_get_current_item (void); /* current entry, unedited */ int playlist_size (void); |