[xiph-commits] r3019 - liboggplay/trunk/plugin

laser13 at svn.annodex.net laser13 at svn.annodex.net
Thu Jun 21 03:45:59 PDT 2007


Author: laser13
Date: 2007-06-21 03:45:59 -0700 (Thu, 21 Jun 2007)
New Revision: 3019

Modified:
   liboggplay/trunk/plugin/plugin_gui_win32.c
Log:
Small changes to the Win32 plugin code to allow for proper clean up.

Modified: liboggplay/trunk/plugin/plugin_gui_win32.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_win32.c	2007-06-21 10:15:43 UTC (rev 3018)
+++ liboggplay/trunk/plugin/plugin_gui_win32.c	2007-06-21 10:45:59 UTC (rev 3019)
@@ -52,6 +52,7 @@
   // video frame
   PluginOggFrame*     frame_data;
   HWND                window;
+  HWND                parent_window;
   WNDPROC             old_wnd_proc;
   HANDLE              thread;
   int                 shutdown_gui;
@@ -59,6 +60,7 @@
   semaphore           oggplay_replace_sem;
   semaphore           start_stop_sem;
   semaphore           playback_sem;
+  semaphore           synch_sem;
   PluginPlaybackState   playback_state;
   void            *   new_oggplay_handle;
 #ifdef USE_AUDIO
@@ -114,13 +116,15 @@
         
     /*
      * Do not send WM_PAINT messages while waiting for GUI to shutdown.
-     * This is asynchronous call and can hang or crash web browser.
+     * This is asynchronous call so all calls to plugin_oggplay functions are
+     * in the GUI message processing callback.
      */
     if (!info->shutdown_gui) {             
       // force refresh    
       GetClientRect(hWnd, &r);      
       InvalidateRect(hWnd, &r, FALSE);     
-      UpdateWindow(hWnd);                   
+      UpdateWindow(hWnd);      
+      SEM_WAIT(info->synch_sem);
     }      
     
     Sleep(40);    
@@ -139,7 +143,7 @@
  * Comments: Fuction notifies the display
  * */
 void *
-initialise_gui(nsPluginInstance *instance, NPWindow *np_window, 
+initialise_gui(HWND parent_window, nsPluginInstance *instance, NPWindow *np_window, 
                 void *oggplay_handle) {
   
   DWORD                 disp_id;
@@ -167,14 +171,14 @@
    * create semaphore to lock replacement of oggplay object
    */
   SEM_CREATE(info->oggplay_replace_sem, 1);
-
+  
   // subclass window so we can intercept window messages and
   // do our drawing to it
   info->old_wnd_proc = SubclassWindow(hWnd, (WNDPROC)(PluginWinProc));
   
   // associate window with our PliuginWindowInfo so we can access 
   // it in the window procedure
-  SetWindowLongPtr((HWND)hWnd, GWL_USERDATA, (LONG)info);    
+  SetWindowLongPtr((HWND)hWnd, GWL_USERDATA, (LONG)info);     
   
   /*
    * create semaphore to use for startup / shutdown synchronisation
@@ -187,6 +191,9 @@
   SEM_CREATE(info->playback_sem, 1);
   SEM_WAIT(info->playback_sem);
 
+  SEM_CREATE(info->synch_sem, 1);
+  SEM_WAIT(info->synch_sem);
+
   info->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)display_thread, 
           (LPVOID)info, 0, &disp_id);    
     
@@ -206,9 +213,9 @@
 shut_gui(void *handle) {
 
   PluginWindowInfo  * info = (PluginWindowInfo *)handle;
-  
+    
   // subclass it back
-  SubclassWindow((HWND)(info->window), (WNDPROC)(info->old_wnd_proc));  
+  SubclassWindow((HWND)(info->window), (WNDPROC)(info->old_wnd_proc));    
 
   info->shutdown_gui = 1;  
   if (info->playback_state == PAUSED) {
@@ -313,7 +320,7 @@
 
 static void
 process_frame_data(PluginWindowInfo * info) {
-  
+    
   BOOL          has_audio = FALSE;
   BOOL          has_video = FALSE;
   BOOL          has_cmml = FALSE;
@@ -334,18 +341,20 @@
   if ((has_video == FALSE) && (has_audio == FALSE)
     /* && (has_cmml) */
   ) {
-    //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) {
+  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);  
   return;



More information about the commits mailing list