X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fomnplay.cpp;h=b961c4b5d598ed101aa00e7731e778c3a9b1d706;hb=6a0af0e7bba391e04e5aac228b6b2743894c60e5;hp=699f16e728b7ab670bd7f6abb88cd577e62aedbc;hpb=b71b52f8fa19073fc9c01c143d9e5585421450ce;p=omnplay diff --git a/src/omnplay.cpp b/src/omnplay.cpp index 699f16e..b961c4b 100644 --- a/src/omnplay.cpp +++ b/src/omnplay.cpp @@ -233,20 +233,71 @@ static void* omnplay_thread_proc(void* data) return NULL; }; -static int get_first_selected_item_playlist(omnplay_instance_t* app) +void get_selected_items_playlist_proc(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { - int idx; - GtkTreeIter iter; - GtkTreeModel *model; + int idx, *list = (int*)data; + gtk_tree_model_get(model, iter, 7, &idx, -1); + list[list[0] + 1] = idx; + list[0] = list[0] + 1; +}; + +static int* get_selected_items_playlist(omnplay_instance_t* app) +{ + int* list = NULL; GtkTreeSelection *selection; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(app->playlist_grid)); - if(selection && gtk_tree_selection_get_selected(selection, &model, &iter)) + if(selection) { - gtk_tree_model_get(model, &iter, 7, &idx, -1); - return idx; + list = (int*)malloc(sizeof(int) * (MAX_PLAYLIST_ITEMS + 1)); + memset(list, 0, sizeof(int) * (MAX_PLAYLIST_ITEMS + 1)); + + gtk_tree_selection_selected_foreach( + selection, + get_selected_items_playlist_proc, + list); + + if(!list[0]) + { + free(list); + list = NULL; + }; }; - return -1; + + return list; +}; + +static void omnplay_playlist_block(omnplay_instance_t* app, control_buttons_t button) +{ + int start, stop; + int* list = get_selected_items_playlist(app); + + if(!list) + return; + + pthread_mutex_lock(&app->playlist.lock); + pthread_mutex_lock(&app->players.lock); + + start = list[1]; + stop = list[list[0]]; + + fprintf(stderr, "omnplay_playlist_block: [%d %d]\n", + start, stop); + + pthread_mutex_unlock(&app->players.lock); + pthread_mutex_unlock(&app->playlist.lock); + + free(list); +}; + +static int get_first_selected_item_playlist(omnplay_instance_t* app) +{ + int idx; + int* list = get_selected_items_playlist(app); + if(!list) return -1; + idx = list[1]; + free(list); + return idx; }; static int get_playlist_block(omnplay_instance_t* app, int idx, int* start_ptr, int* stop_ptr) @@ -325,8 +376,7 @@ static void omnplay_ctl(omnplay_instance_t* app, control_buttons_t button) OmPlrStop((OmPlrHandle)player->handle); /* detach previous clips */ -// player->playlist_start = -1; -// player->playlist_count = -1; + player->playlist_length = -1; OmPlrDetachAllClips((OmPlrHandle)player->handle); }; @@ -412,10 +462,10 @@ static void omnplay_ctl(omnplay_instance_t* app, control_buttons_t button) OmPlrLoop((OmPlrHandle)player->handle, hs.minPos, hs.maxPos); player->playlist_start = start; + player->playlist_length = stop - start + 1; /* Cue */ OmPlrCuePlay((OmPlrHandle)player->handle, 0.0); - OmPlrPlay((OmPlrHandle)player->handle, 0.0); }; }; @@ -450,6 +500,7 @@ static gboolean omnplay_button_click(omnplay_instance_t* app, control_buttons_t break; case BUTTON_PLAYLIST_BLOCK_SINGLE: case BUTTON_PLAYLIST_BLOCK_LOOP: + omnplay_playlist_block(app, button); break; case BUTTON_PLAYLIST_ITEM_UP: case BUTTON_PLAYLIST_ITEM_DOWN: