--- /dev/null
+/*
+ * player.h -- GTK+ 2 melted gui
+ * Copyright (C) 2012 Maksym Veremeyenko <verem@m1stereo.tv>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+#include <pthread.h>
+
+#include <mvcp/mvcp.h>
+#include <mvcp/mvcp_remote.h>
+
+#include "player.h"
+
+static void* player_thread_proc(void* data)
+{
+ int r;
+ int playlist_start_prev = 0;
+// OmPlrStatus st_curr, st_prev;
+ player_t* player = (player_t*)data;
+
+ g_warning("omnplay_thread_proc\n");
+
+// memset(&st_curr, 0, sizeof(OmPlrStatus));
+// memset(&st_prev, 0, sizeof(OmPlrStatus));
+
+ /* 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)
+ {
+// g_warning("ERROR: OmPlrOpen(%s, %s) failed with 0x%.8X\n",
+// player->host, player->name, r);
+
+ return (void*)r;
+ };
+
+ /* setup to do not reconnect */
+ pthread_mutex_lock(&player->app->players.lock);
+// OmPlrSetRetryOpen((OmPlrHandle)player->handle, 0);
+ pthread_mutex_unlock(&player->app->players.lock);
+
+ /* setup directory */
+// if(player->app->players.path[0])
+ {
+ pthread_mutex_lock(&player->app->players.lock);
+// r = OmPlrClipSetDirectory((OmPlrHandle)player->handle, player->app->players.path);
+ pthread_mutex_unlock(&player->app->players.lock);
+
+ if(r)
+ {
+// g_warning("ERROR: OmPlrClipSetDirectory(%s) failed with 0x%.8X\n",
+// player->app->players.path, r);
+
+ pthread_mutex_lock(&player->app->players.lock);
+// OmPlrClose((OmPlrHandle)player->handle);
+ pthread_mutex_unlock(&player->app->players.lock);
+
+ return (void*)r;
+ };
+ };
+
+ /* endless loop */
+ 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);
+// st_curr.size = sizeof(OmPlrStatus);
+// r = OmPlrGetPlayerStatus((OmPlrHandle)player->handle, &st_curr);
+ pthread_mutex_unlock(&player->app->players.lock);
+
+ if(r)
+ g_warning("ERROR: OmPlrGetPlayerStatus failed with 0x%.8X\n", r);
+ else
+ {
+// omnplay_update_status(player, &st_prev , &st_curr, &playlist_start_prev);
+// playlist_start_prev = player->playlist_start;
+// memcmp(&st_curr, &st_prev, sizeof(OmPlrStatus));
+ };
+ };
+
+ pthread_mutex_lock(&player->app->players.lock);
+// OmPlrClose((OmPlrHandle)player->handle);
+ pthread_mutex_unlock(&player->app->players.lock);
+
+ return NULL;
+};
+
+
+void player_run(instance_t* app, int idx)
+{
+ mvcp_parser parser = mvcp_parser_init_remote(app->players.host, 5250);
+ mvcp command = mvcp_init(parser);
+
+ app->players.item[idx].thread = g_thread_create(
+ player_thread_proc, &app->players.item[idx], TRUE, NULL);
+};
+
+void player_stop(instance_t* app, int idx)
+{
+ g_thread_join(app->players.item[idx].thread);
+};