X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fomnplay.cpp;h=83e94f36ab8e266a25e1f5c3e4d3ef595a422733;hb=d36841f273ffe01ba67ae77a65ba2cd658339e64;hp=4a7542989fe8254fdfc10a720d58c88fcd29f671;hpb=9511cdf6b08b5a6657ecaee9441cf453d1e0baff;p=omnplay diff --git a/src/omnplay.cpp b/src/omnplay.cpp index 4a75429..83e94f3 100644 --- a/src/omnplay.cpp +++ b/src/omnplay.cpp @@ -113,9 +113,9 @@ static void* omnplay_thread_proc(void* data) omnplay_player_t* player = (omnplay_player_t*)data; /* connect */ - pthread_mutex_lock(&player->lock); + pthread_mutex_lock(&player->app->players.lock); r = OmPlrOpen(player->host, player->name, (OmPlrHandle*)&player->handle); - pthread_mutex_unlock(&player->lock); + pthread_mutex_unlock(&player->app->players.lock); if(r) { fprintf(stderr, "ERROR: OmPlrOpen(%s, %s) failed with 0x%.8X\n", @@ -125,25 +125,25 @@ static void* omnplay_thread_proc(void* data) }; /* setup to do not reconnect */ - pthread_mutex_lock(&player->lock); + pthread_mutex_lock(&player->app->players.lock); OmPlrSetRetryOpen((OmPlrHandle)player->handle, 0); - pthread_mutex_unlock(&player->lock); + pthread_mutex_unlock(&player->app->players.lock); /* setup directory */ if(player->app->players.path[0]) { - pthread_mutex_lock(&player->lock); + pthread_mutex_lock(&player->app->players.lock); // r = OmPlrClipSetDirectory((OmPlrHandle)player->handle, player->app->players.path); - pthread_mutex_unlock(&player->lock); + pthread_mutex_unlock(&player->app->players.lock); if(r) { fprintf(stderr, "ERROR: OmPlrClipSetDirectory(%s) failed with 0x%.8X\n", player->app->players.path, r); - pthread_mutex_lock(&player->lock); + pthread_mutex_lock(&player->app->players.lock); OmPlrClose((OmPlrHandle)player->handle); - pthread_mutex_unlock(&player->lock); + pthread_mutex_unlock(&player->app->players.lock); return (void*)r; }; @@ -156,10 +156,10 @@ static void* omnplay_thread_proc(void* data) usleep(100000); /* get status */ - pthread_mutex_lock(&player->lock); + pthread_mutex_lock(&player->app->players.lock); st_curr.size = sizeof(OmPlrStatus); r = OmPlrGetPlayerStatus((OmPlrHandle)player->handle, &st_curr); - pthread_mutex_unlock(&player->lock); + pthread_mutex_unlock(&player->app->players.lock); if(r) fprintf(stderr, "ERROR: OmPlrGetPlayerStatus failed with 0x%.8X\n", r); @@ -168,13 +168,67 @@ static void* omnplay_thread_proc(void* data) omnplay_update_status(player, &st_prev , &st_curr); }; - pthread_mutex_lock(&player->lock); + pthread_mutex_lock(&player->app->players.lock); OmPlrClose((OmPlrHandle)player->handle); - pthread_mutex_unlock(&player->lock); + pthread_mutex_unlock(&player->app->players.lock); return NULL; }; +static void omnplay_cue(omnplay_instance_t* app) +{ + int idx, start, stop; + GtkTreeIter iter; + GtkTreeModel *model; + GtkTreeSelection *selection; + omnplay_player_t *player; + + pthread_mutex_lock(&app->playlist.lock); + + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(app->playlist_grid)); + if(selection && gtk_tree_selection_get_selected(selection, &model, &iter)) + { + gtk_tree_model_get(model, &iter, 7, &idx, -1); + + fprintf(stderr, "cue: selected item is %d\n", idx); + + for(start = idx; start >= 0; start--) + if(app->playlist.item[start].type & OMNPLAY_PLAYLIST_BLOCK_BEGIN) + break; + + for(stop = idx; stop < app->playlist.count; stop++) + if(app->playlist.item[stop].type & OMNPLAY_PLAYLIST_BLOCK_END) + break; + + /* check block range */ + if(start >= 0 && stop < app->playlist.count) + { + fprintf(stderr, "cue: range %d -> %d\n", start, stop); + + /* check player range */ + if(app->playlist.item[start].player > -1 && app->playlist.item[start].player < player->app->players.count) + { + player = &app->players.item[app->playlist.item[start].player]; + + /* 1. stop */ + pthread_mutex_lock(&app->players.lock); + OmPlrStop((OmPlrHandle)player->handle); + pthread_mutex_unlock(&app->players.lock); + + /* 2. detach previous clips */ + pthread_mutex_lock(&app->players.lock); + OmPlrDetachAllClips((OmPlrHandle)player->handle); + pthread_mutex_unlock(&app->players.lock); + + // http://research.m1stereo.tv/viewvc-int/viewvc.cgi/Ingest2Srv/trunk/SrvPlayCtl.cpp?view=markup + }; + }; + }; + + pthread_mutex_unlock(&app->playlist.lock); + +}; + static gboolean omnplay_button_click(omnplay_instance_t* app, control_buttons_t button) { switch(button) @@ -193,6 +247,7 @@ static gboolean omnplay_button_click(omnplay_instance_t* app, control_buttons_t case BUTTON_PLAYLIST_ITEM_UP: case BUTTON_PLAYLIST_ITEM_DOWN: case BUTTON_PLAYER_CUE: + omnplay_cue(app); case BUTTON_PLAYER_PLAY: case BUTTON_PLAYER_PAUSE: case BUTTON_PLAYER_STOP: @@ -223,15 +278,13 @@ void omnplay_init(omnplay_instance_t* app) gtk_signal_connect( GTK_OBJECT( app->window ), "destroy", GTK_SIGNAL_FUNC(on_main_window_delete_event), app); - for(i = 0; i < app->players.count; i++) - { - /* create lock */ - pthread_mutex_init(&app->players.item[i].lock, NULL); + /* create lock */ + pthread_mutex_init(&app->players.lock, NULL); - /* create a omneon status thread */ + /* create a omneon status thread */ + for(i = 0; i < app->players.count; i++) pthread_create(&app->players.item[i].thread, NULL, omnplay_thread_proc, &app->players.item[i]); - }; /* create lock */ pthread_mutex_init(&app->playlist.lock, NULL); @@ -251,15 +304,12 @@ void omnplay_release(omnplay_instance_t* app) app->f_exit = 1; for(i = 0; i < app->players.count; i++) - { /* create a omneon status thread */ pthread_join(app->players.item[i].thread, &r); - /* create lock */ - pthread_mutex_destroy(&app->players.item[i].lock); + /* destroy lock */ + pthread_mutex_destroy(&app->players.lock); - }; - - /* create lock */ + /* destroy lock */ pthread_mutex_destroy(&app->playlist.lock); };