X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fomnplay.cpp;h=d54f78df9bb8583be6ec1d12448a60060b584336;hb=e9b0f5d6d408984b64793383616db7ef7c137e0b;hp=28e2cdc9e342856fbc9306dc0943050a02abdca2;hpb=9357149b3f7d105e03c93439cced8dcd12aa9dba;p=omnplay diff --git a/src/omnplay.cpp b/src/omnplay.cpp index 28e2cdc..d54f78d 100644 --- a/src/omnplay.cpp +++ b/src/omnplay.cpp @@ -224,13 +224,15 @@ static void* omnplay_thread_proc(void* data) OmPlrStatus st_curr, st_prev; omnplay_player_t* player = (omnplay_player_t*)data; + g_warning("omnplay_thread_proc\n"); + /* connect */ pthread_mutex_lock(&player->app->players.lock); r = OmPlrOpen(player->host, player->name, (OmPlrHandle*)&player->handle); pthread_mutex_unlock(&player->app->players.lock); if(r) { - fprintf(stderr, "ERROR: OmPlrOpen(%s, %s) failed with 0x%.8X\n", + g_warning("ERROR: OmPlrOpen(%s, %s) failed with 0x%.8X\n", player->host, player->name, r); return (void*)r; @@ -250,7 +252,7 @@ static void* omnplay_thread_proc(void* data) if(r) { - fprintf(stderr, "ERROR: OmPlrClipSetDirectory(%s) failed with 0x%.8X\n", + g_warning("ERROR: OmPlrClipSetDirectory(%s) failed with 0x%.8X\n", player->app->players.path, r); pthread_mutex_lock(&player->app->players.lock); @@ -265,7 +267,11 @@ static void* omnplay_thread_proc(void* data) for(r = 0 ; !player->app->f_exit && !r;) { /* sleep */ +#ifdef _WIN32 + Sleep(100); +#else usleep(100000); +#endif /* get status */ pthread_mutex_lock(&player->app->players.lock); @@ -274,7 +280,7 @@ static void* omnplay_thread_proc(void* data) pthread_mutex_unlock(&player->app->players.lock); if(r) - fprintf(stderr, "ERROR: OmPlrGetPlayerStatus failed with 0x%.8X\n", r); + g_warning("ERROR: OmPlrGetPlayerStatus failed with 0x%.8X\n", r); else if(memcmp(&st_curr, &st_prev, sizeof(OmPlrStatus))) omnplay_update_status(player, &st_prev , &st_curr); @@ -402,7 +408,7 @@ static void omnplay_playlist_block(omnplay_instance_t* app, control_buttons_t bu }; /* update border items */ - if(!start && !(app->playlist.item[start - 1].type & OMNPLAY_PLAYLIST_BLOCK_END)) + if(start && !(app->playlist.item[start - 1].type & OMNPLAY_PLAYLIST_BLOCK_END)) { app->playlist.item[start - 1].type = (playlist_item_type_t)(OMNPLAY_PLAYLIST_BLOCK_END | app->playlist.item[start - 1].type); @@ -416,7 +422,7 @@ static void omnplay_playlist_block(omnplay_instance_t* app, control_buttons_t bu }; } else - fprintf(stderr, "omnplay_playlist_block: range [%d %d] do OVERLAP player\n", + g_warning("omnplay_playlist_block: range [%d %d] do OVERLAP player\n", start, stop); pthread_mutex_unlock(&app->players.lock); @@ -447,7 +453,7 @@ static int get_playlist_block(omnplay_instance_t* app, int idx, int* start_ptr, if(app->playlist.item[stop].type & OMNPLAY_PLAYLIST_BLOCK_END) break; - fprintf(stderr, "get_playlist_block: range %d -> %d\n", start, stop); + g_warning("get_playlist_block: range %d -> %d\n", start, stop); /* check block range */ if(start >= 0 && stop < app->playlist.count) @@ -482,12 +488,16 @@ static void omnplay_playlist_delete_items(omnplay_instance_t* app, int* idxs, in idx = idxs[j] - j; /* fix block types */ - if(idx) - app->playlist.item[idx - 1].type = (playlist_item_type_t)(app->playlist.item[idx - 1].type | - OMNPLAY_PLAYLIST_BLOCK_END); - if(idx + 1 < app->playlist.count) - app->playlist.item[idx + 1].type = (playlist_item_type_t)(app->playlist.item[idx + 1].type | - OMNPLAY_PLAYLIST_BLOCK_BEGIN); + if( app->playlist.item[idx].type != OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY && + app->playlist.item[idx].type != OMNPLAY_PLAYLIST_ITEM_LOOP_BODY) + { + if(idx) + app->playlist.item[idx - 1].type = (playlist_item_type_t)(app->playlist.item[idx - 1].type | + OMNPLAY_PLAYLIST_BLOCK_END); + if(idx + 1 < app->playlist.count) + app->playlist.item[idx + 1].type = (playlist_item_type_t)(app->playlist.item[idx + 1].type | + OMNPLAY_PLAYLIST_BLOCK_BEGIN); + }; /* shift playlist items */ memmove @@ -636,7 +646,7 @@ static void omnplay_playlist_item_add(omnplay_instance_t* app, int after) if(!omnplay_playlist_insert_check(app, idx, &t)) return; - fprintf(stderr, "allowed insert into idx=%d\n", idx); + g_warning("allowed insert into idx=%d\n", idx); /* clear item */ memset(&item, 0, sizeof(playlist_item_t)); @@ -689,7 +699,7 @@ static void omnplay_ctl(omnplay_instance_t* app, control_buttons_t button) return; }; - fprintf(stderr, "cue: selected item is %d\n", idx); + g_warning("cue: selected item is %d\n", idx); if(get_playlist_block(app, idx, &start, &stop) < 0) { @@ -697,7 +707,7 @@ static void omnplay_ctl(omnplay_instance_t* app, control_buttons_t button) return; }; - fprintf(stderr, "cue: range %d -> %d\n", start, stop); + g_warning("cue: range %d -> %d\n", start, stop); player = get_player_at_pos(app, start); @@ -737,7 +747,7 @@ static void omnplay_ctl(omnplay_instance_t* app, control_buttons_t button) { unsigned int l; - fprintf(stderr, "OmPlrClipGetInfo(%s): firstFrame=%d, lastFrame=%d\n", + g_warning("OmPlrClipGetInfo(%s): firstFrame=%d, lastFrame=%d\n", app->playlist.item[i].id, clip.firstFrame, clip.lastFrame); /* should we fix playlist clip timings */ @@ -746,7 +756,7 @@ static void omnplay_ctl(omnplay_instance_t* app, control_buttons_t button) app->playlist.item[i].in + app->playlist.item[i].dur <= clip.lastFrame) || !app->playlist.item[i].dur) { - fprintf(stderr, "cue: item [%s] will be updated [%d;%d]->[%d;%d]\n", + g_warning("cue: item [%s] will be updated [%d;%d]->[%d;%d]\n", app->playlist.item[i].id, app->playlist.item[i].in, app->playlist.item[i].dur, clip.firstFrame, clip.lastFrame - clip.firstFrame); @@ -765,7 +775,7 @@ static void omnplay_ctl(omnplay_instance_t* app, control_buttons_t button) if(r) { - fprintf(stderr, "cue: failed with %d, %s\n", r, OmPlrGetErrorString((OmPlrError)r)); + g_warning("cue: failed with %d, %s\n", r, OmPlrGetErrorString((OmPlrError)r)); app->playlist.item[i].omn_idx = -1; app->playlist.item[i].omn_offset = -1; app->playlist.item[i].error |= PLAYLIST_ITEM_ERROR_CUE; @@ -1135,7 +1145,7 @@ static gboolean on_library_grid_key(GtkWidget *widget, GdkEventKey *event, gpoin case GDK_v: if(event->state & GDK_CONTROL_MASK) { - fprintf(stderr, "CTRL+v\n"); + g_warning("CTRL+v\n"); return TRUE; }; break; @@ -1143,7 +1153,7 @@ static gboolean on_library_grid_key(GtkWidget *widget, GdkEventKey *event, gpoin case GDK_x: if(event->state & GDK_CONTROL_MASK) { - fprintf(stderr, "CTRL+x\n"); + g_warning("CTRL+x\n"); return TRUE; }; break; @@ -1152,11 +1162,34 @@ static gboolean on_library_grid_key(GtkWidget *widget, GdkEventKey *event, gpoin return FALSE; }; +static gboolean on_library_grid_button(GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + if(event->button==1 && event->type==GDK_2BUTTON_PRESS) + { + omnplay_library_add((omnplay_instance_t* )data, 0); + return TRUE; + }; + + return FALSE; +}; + +static gboolean on_playlist_grid_button(GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + if(event->button==1 && event->type==GDK_2BUTTON_PRESS) + { + omnplay_ctl((omnplay_instance_t* )data, BUTTON_PLAYER_CUE); + return TRUE; + }; + + return FALSE; +}; + void omnplay_init(omnplay_instance_t* app) { int i; pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); gtk_signal_connect( GTK_OBJECT( app->window ), "delete-event", @@ -1173,6 +1206,12 @@ void omnplay_init(omnplay_instance_t* app) gtk_signal_connect(GTK_OBJECT(app->library_grid), "key-press-event", GTK_SIGNAL_FUNC(on_library_grid_key), app); + gtk_signal_connect(GTK_OBJECT(app->playlist_grid), "button-press-event", + GTK_SIGNAL_FUNC(on_playlist_grid_button), app); + + gtk_signal_connect(GTK_OBJECT(app->library_grid), "button-press-event", + GTK_SIGNAL_FUNC(on_library_grid_button), app); + /* create lock */ pthread_mutex_init(&app->players.lock, &attr); @@ -1181,6 +1220,7 @@ void omnplay_init(omnplay_instance_t* app) pthread_create(&app->players.item[i].thread, NULL, omnplay_thread_proc, &app->players.item[i]); + /* create lock */ pthread_mutex_init(&app->playlist.lock, &attr); @@ -1194,6 +1234,8 @@ void omnplay_init(omnplay_instance_t* app) /* load library */ omnplay_library_load(app); + + pthread_mutexattr_destroy(&attr); }; void omnplay_release(omnplay_instance_t* app)