#include "omnplay.h"
#include "ui.h"
#include "opts.h"
+#include "timecode.h"
#include "omplrclnt.h"
-static char* frames2tc( int f, float fps, char* buf )
-{
- int tc[4] = { 0, 0, 0, 0 };
- float d;
- int t;
-
- if ( fps && f >= 0)
- {
- d = f / fps;
- t = d;
-
- tc[0] = (d - t) * fps;
- tc[1] = t % 60; t /= 60;
- tc[2] = t % 60; t /= 60;
- tc[3] = t % 24;
- }
-
- sprintf(buf, "%.2d:%.2d:%.2d:%.2d", tc[3], tc[2], tc[1], tc[0]);
-
- return buf;
-}
-
-
static gboolean on_main_window_delete_event( GtkWidget *widget, GdkEvent *event, gpointer user_data )
{
gtk_exit(0);
return NULL;
};
+static gboolean omnplay_button_click(omnplay_instance_t* app, control_buttons_t button)
+{
+ switch(button)
+ {
+ case BUTTON_PLAYLIST_ITEM_ADD:
+ case BUTTON_PLAYLIST_ITEM_DEL:
+ case BUTTON_PLAYLIST_ITEM_EDIT:
+ case BUTTON_PLAYLIST_LOAD:
+ omnplay_playlist_load(app);
+ break;
+ case BUTTON_PLAYLIST_SAVE:
+ omnplay_playlist_save(app);
+ break;
+ case BUTTON_PLAYLIST_BLOCK_SINGLE:
+ case BUTTON_PLAYLIST_BLOCK_LOOP:
+ case BUTTON_PLAYLIST_ITEM_UP:
+ case BUTTON_PLAYLIST_ITEM_DOWN:
+ case BUTTON_PLAYER_CUE:
+ case BUTTON_PLAYER_PLAY:
+ case BUTTON_PLAYER_PAUSE:
+ case BUTTON_PLAYER_STOP:
+ case BUTTON_LIBRARY_ADD:
+ case BUTTON_LIBRARY_REFRESH:
+ break;
+ };
+
+ return TRUE;
+};
+
+static gboolean on_button_click(GtkWidget *button, gpointer user_data)
+{
+ int i;
+ omnplay_instance_t* app = (omnplay_instance_t*)user_data;
+
+ for(i = 1; i < BUTTON_LAST; i++)
+ if(app->buttons[i] == button)
+ return omnplay_button_click(app, (control_buttons_t)i);
+
+ return FALSE;
+};
+
void omnplay_init(omnplay_instance_t* app)
{
int 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);
+
+ /* attach buttons click */
+ for(i = 1; i < BUTTON_LAST; i++)
+ gtk_signal_connect(GTK_OBJECT(app->buttons[i]), "clicked",
+ GTK_SIGNAL_FUNC( on_button_click), app );
+
};
void omnplay_release(omnplay_instance_t* app)
pthread_mutex_destroy(&app->players.item[i].lock);
};
+
+ /* create lock */
+ pthread_mutex_destroy(&app->playlist.lock);
};