[xiph-commits] r3045 - in liboggplay/trunk: plugin src/liboggplay

laser13 at svn.annodex.net laser13 at svn.annodex.net
Mon Jun 25 05:10:37 PDT 2007


Author: laser13
Date: 2007-06-25 05:10:37 -0700 (Mon, 25 Jun 2007)
New Revision: 3045

Modified:
   liboggplay/trunk/plugin/plugin_gui_win32.c
   liboggplay/trunk/plugin/plugin_oggplay.c
   liboggplay/trunk/src/liboggplay/std_semaphore.h
Log:
Minor fixes for Win32: correct return codes, proper defines, etc.

Modified: liboggplay/trunk/plugin/plugin_gui_win32.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_win32.c	2007-06-25 11:05:31 UTC (rev 3044)
+++ liboggplay/trunk/plugin/plugin_gui_win32.c	2007-06-25 12:10:37 UTC (rev 3045)
@@ -75,27 +75,31 @@
 static BOOL 
 switch_oggplays(PluginWindowInfo *info) {
 
+  BOOL rv = FALSE;
   void * old_ogg_handle;
-  
+        
   if (info->new_oggplay_handle != NULL) {    
     SEM_WAIT(info->oggplay_replace_sem);
+    printf("Switch oggplay before!!!\n");      
     old_ogg_handle = info->ogg_handle;
     info->ogg_handle = (void *)info->new_oggplay_handle;
-    info->new_oggplay_handle = NULL;
-    SEM_SIGNAL(info->oggplay_replace_sem); 
-    shut_oggplay(old_ogg_handle);
-    return TRUE;
-  }
-  return FALSE;
+    info->new_oggplay_handle = NULL;      
+    printf("Switch oggplay after!!!\n");
+    SEM_SIGNAL(info->oggplay_replace_sem);     
+    shut_oggplay(old_ogg_handle);      
+    rv = TRUE; 
+  }    
+  return rv;
 }
+
+
 /**
  * \brief display_thread - main loop do the tread responsible for display 
  * \param [in] _info - PluginWindowInfo stucture 
  */
 DWORD WINAPI display_thread(void *_info) {  
   HWND                hWnd;  
-  RECT                r;
-  BOOL                has_cmml;
+  RECT                r;  
   PluginWindowInfo *  info = (PluginWindowInfo*)_info;    
   
 
@@ -105,17 +109,19 @@
   SEM_SIGNAL(info->start_stop_sem);  
 
   while (1) {    
-    // check if we should pause display
+    
+    // fall through once so we can display first 
+    // frame of a new video
     if (info->playback_state == PAUSED) {      
-      SEM_WAIT(info->playback_sem);
-    }
+      SEM_WAIT(info->playback_sem);     
+    }        
 
     // check if plugin hasn't been shut down
     if (info->shutdown_gui) {        
       info->shutdown_gui = 0;        
       ExitThread(0);
     }
-        
+     
     /*
      * Do not send WM_PAINT messages while waiting for GUI to shutdown.
      * This is asynchronous call so all calls to plugin_oggplay functions are
@@ -125,18 +131,16 @@
       // force refresh    
       GetClientRect(hWnd, &r);      
       InvalidateRect(hWnd, &r, FALSE);     
-      UpdateWindow(hWnd); 
-      has_cmml = ((info->frame_data->cmml_strings != NULL) && (info->frame_data->cmml_size > 0)) ? TRUE : FALSE;
-      if (has_cmml == TRUE) {
-        onCMMLData(info->plugin_instance, info->frame_data->cmml_strings, info->frame_data->cmml_size);      
-      }
-      free_oggplay_frame(info->ogg_handle, info->frame_data); 
-      SEM_WAIT(info->synch_sem);
+      UpdateWindow(hWnd);             
+      SEM_WAIT(info->synch_sem); 
+      // check if we should pause display      
     }      
     
-    Sleep(40);    
+    Sleep(40);            
+
     /* try switching oggplays */
-    switch_oggplays(info);       
+    switch_oggplays(info);           
+    
   }
   
   return 0;
@@ -239,7 +243,7 @@
   SEM_CLOSE(info->playback_sem);  
 
   if (info->frame_data != NULL) {
-    free(info->frame_data);  
+    //free(info->frame_data);  
   }  
   free(info);
   
@@ -333,7 +337,8 @@
   
   // filter early and random *broken* WM_PAINT messages  
   if (info == NULL) {
-      return;  
+    SEM_SIGNAL(info->synch_sem);
+    return;  
   }
 
   get_oggplay_frame(info->ogg_handle, info->frame_data);    
@@ -344,25 +349,25 @@
   has_cmml = ((info->frame_data->cmml_strings != NULL) && (info->frame_data->cmml_size > 0)) ? TRUE : FALSE;
   
   /* if there is need to update plugin GUI then go to next frame */
-  if ((has_video == TRUE) && (has_audio == TRUE)
+  if ((has_video == FALSE) && (has_audio == FALSE)
     /* && (has_cmml) */
   ) {
-    SEM_SIGNAL(info->synch_sem);
-    return;
-    //goto cleanup;    
+    //SEM_SIGNAL(info->synch_sem);
+    //return;    
+    goto cleanup;    
   }
   /* display frame */
   update_frame(info);
 
-  /* call CMML data callback using plugin's main thread call 
-  if (has_cmml == true) {    
+  /* call CMML data callback using plugin's main thread call */
+  if (has_cmml == TRUE) {    
     onCMMLData(info->plugin_instance, info->frame_data->cmml_strings, info->frame_data->cmml_size);      
-  }*/
+  }
 
-//cleanup:
+cleanup:
   SEM_SIGNAL(info->synch_sem);
   // progress with decoding  
-  //free_oggplay_frame(info->ogg_handle, info->frame_data);  
+  free_oggplay_frame(info->ogg_handle, info->frame_data);  
   return;
 }
 
@@ -404,7 +409,7 @@
     printf("early shutting aborted oggplay at %p\n", info->new_oggplay_handle);
     shut_oggplay(info->new_oggplay_handle);
   }
-  info->new_oggplay_handle = oggplay_handle;
+  info->new_oggplay_handle = oggplay_handle; 
   printf("update_gui_with_new_oggplay new handle passed\n");
   SEM_SIGNAL(info->oggplay_replace_sem); 
   
@@ -436,7 +441,7 @@
       break;
     case FINISHED: 
       state = 2;    
-      break;
+      break;    
     default:
       /* error state: should never be returned */
       state = -1;

Modified: liboggplay/trunk/plugin/plugin_oggplay.c
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.c	2007-06-25 11:05:31 UTC (rev 3044)
+++ liboggplay/trunk/plugin/plugin_oggplay.c	2007-06-25 12:10:37 UTC (rev 3045)
@@ -124,7 +124,7 @@
 #if defined(XP_UX) || defined(XP_MACOSX)
     return NULL;
 #elif defined(XP_WIN)
-    return;
+    return 0;
 #endif
   }
   
@@ -235,6 +235,7 @@
   pthread_exit(NULL);
 #elif defined(XP_WIN)  
   ExitThread(0);
+  return 0;
 #endif
 }
 

Modified: liboggplay/trunk/src/liboggplay/std_semaphore.h
===================================================================
--- liboggplay/trunk/src/liboggplay/std_semaphore.h	2007-06-25 11:05:31 UTC (rev 3044)
+++ liboggplay/trunk/src/liboggplay/std_semaphore.h	2007-06-25 12:10:37 UTC (rev 3045)
@@ -41,7 +41,7 @@
 #define SEM_WAIT(p)     sem_wait(&(p))
 #define SEM_CLOSE(p)    sem_destroy(&(p))
 typedef sem_t           semaphore;
-#elif defined(XP_WIN)
+#elif defined(WIN32)
 #include <windows.h>
 #define SEM_CREATE(p,s) p = CreateSemaphore(NULL, (long)(s), (long)(s), NULL)
 #define SEM_SIGNAL(p)   ReleaseSemaphore(p, 1, NULL)



More information about the commits mailing list