minimal mingw32 compilation fixes
authorMaksym Veremeyenko <verem@m1stereo.tv>
Fri, 24 Jun 2011 08:19:42 +0000 (11:19 +0300)
committerMaksym Veremeyenko <verem@m1stereo.tv>
Fri, 24 Jun 2011 08:19:42 +0000 (11:19 +0300)
README
src/Makefile.am
src/main.c
src/omnplay.cpp
src/omnplay.h

diff --git a/README b/README
index 8f2a5c5..593e95c 100644 (file)
--- a/README
+++ b/README
@@ -2,7 +2,9 @@
     ./autogen
 
 2. configure for win32
-    ./configure --host=i686-pc-mingw32
+    ./configure --host=i686-pc-mingw32 \
+        --with-ommedia=/usr/local/omneon/ommedia-win32-6.3.0.1.20110519 \
+        --with-omplrlib=/usr/local/omneon/omplrlib-win32-6.3.0.1.20110519
 
 3. preparation of library files cross-compiling
 
index c0c6e8a..9f3edd4 100644 (file)
@@ -19,4 +19,4 @@ omnplay_SOURCES = \
        timecode.c timecode.h \
        omnplay.cpp omnplay.h
 
-omnplay_LDADD = @GTHREAD_LIBS@ @GTK_LIBS@ @OM_LIBS@ @CURL_LIBS@
+omnplay_LDADD = @GTHREAD_LIBS@ @GTK_LIBS@ @OM_LIBS@ @CURL_LIBS@ -lpthread
index 41d770f..a6ce43d 100644 (file)
 #include "omnplay.h"
 #include "support.h"
 
+#ifdef _WIN32
+#include <ctype.h>
+#include <windows.h>
+
+char *strcasestr(char *haystack, char *needle)
+{
+    char *p, *startn = 0, *np = 0;
+
+    for (p = haystack; *p; p++) {
+        if (np) {
+            if (toupper(*p) == toupper(*np)) {
+                if (!*++np)
+                    return startn;
+            } else
+                np = 0;
+        } else if (toupper(*p) == toupper(*needle)) {
+            np = needle + 1;
+            startn = p;
+        }
+    }
+
+    return 0;
+};
+#endif /* _WIN32 */
+
 int main(int argc, char **argv)
 {
     char path[ 512 ], *buf;
@@ -50,16 +75,23 @@ int main(int argc, char **argv)
     gtk_set_locale();
     gtk_init(&argc, &argv);
 
+    memset(path, 0, sizeof(path));
 #ifdef _WIN32
+    GetModuleFileName(NULL, path, sizeof(path));
+//    g_warning("GetModuleFileName [%s]\n", path);
+    if((buf = strstr(path, "\\bin\\omnplay.exe")))
+    {
+        buf[0] = 0;
+        strcat(path, "\\share\\omnplay\\pixmaps");
+    }
 #else
     // Linux hack to determine path of the executable
-    memset(path, 0, sizeof(path));
     readlink( "/proc/self/exe", path, sizeof(path));
     g_warning ("path=(%s)\n", path);
     if((buf = strstr(path, "/bin/omnplay")))
     {
         buf[0] = 0;
-        strcat(path, "/share/rugen/pixmaps");
+        strcat(path, "/share/omnplay/pixmaps");
     }
     else if((buf = strstr(path, "/src/omnplay")))
     {
@@ -68,12 +100,11 @@ int main(int argc, char **argv)
     }
     else
         snprintf(path, sizeof(path), "%s/%s/pixmaps", PACKAGE_DATA_DIR, PACKAGE);
+#endif /* _WIN32 */
 
     add_pixmap_directory( path );
     g_warning ("add_pixmap_directory(%s)\n", path);
 
-#endif /* _WIN32 */
-
     app = omnplay_create(argc, argv);
 
     if(app->window)
index 5858d1d..faae20d 100644 (file)
@@ -224,6 +224,8 @@ 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);
@@ -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);
@@ -1183,6 +1189,7 @@ 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",
@@ -1213,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);
 
@@ -1226,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)
index 71db9d4..e92196e 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef OMNPLAY_H
 #define OMNPLAY_H
 
+#include <pthread.h>
+
 #ifdef __cplusplus
 extern "C"
 {