]> git.sesse.net Git - vlc/blobdiff - plugins/macosx/vout_macosx.c
* Fixed the BeOS compile typo.
[vlc] / plugins / macosx / vout_macosx.c
index 96239ec339ad9973367247ae5bc341b2a5b241fe..ac171ae7cb36958cfd32e46d0281a41af47b15ef 100644 (file)
@@ -4,7 +4,6 @@
  * Copyright (C) 2001 VideoLAN
  *
  * Authors: Colin Delacroix <colin@zoy.org>
- *          Eugenio Jarosiewicz <ej0@cise.ufl.edu>
  *
  * 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
 #include "mtime.h"
 #include "tests.h"
 
-#include "video.h"
-#include "video_output.h"
-
 #include "intf_msg.h"
 
-#include "main.h"
+#include "video.h"
+#include "video_output.h"
 
 #include "modules.h"
+#include "main.h"
 
-#ifndef __CARBONPREFIX__
-    #define __CARBONPREFIX__
-
-    // Needed for carbonization
-    #define TARGET_API_MAC_CARBON 1
+#include "macosx_common.h"
 
-    // For the pascal to C or C to pascal string conversions in carbon
-    #define OLDP2C 1
-#endif
 
-#include <Carbon/Carbon.h>
+/*****************************************************************************
+ * Constants & more
+ *****************************************************************************/
 
 // Initial Window Constants
 enum
@@ -75,32 +68,6 @@ enum
     kInSystem
 };
 
-/*****************************************************************************
- * vout_sys_t: MacOS X video output method descriptor
- *****************************************************************************
- * This structure is part of the video output thread descriptor.
- * It describes the MacOS X specific properties of an output thread.
- *****************************************************************************/
-typedef struct vout_sys_s
-{
-    /* MacOS X video memory */
-    byte_t *                    p_video;                      /* base adress */
-    size_t                      i_page_size;                    /* page size */
-    
-    Rect       wrect;
-    WindowRef  p_window;
-    short gwLocOffscreen;
-    GWorldPtr p_gw[ 2 ];
-    Boolean gNewNewGWorld;      /* can we allocate in VRAm or AGP memory ? */
-    
-    // Boolean gDone;
-    // SInt32 gSleepTime;
-    
-    GDHandle  theGDList;
-    Ptr                                theBase;
-    int                                theRow;
-    int                                theDepth;
-} vout_sys_t;
 
 /*****************************************************************************
  * Local prototypes
@@ -175,8 +142,6 @@ static int vout_Create( vout_thread_t *p_vout )
     p_vout->p_sys->p_window       = NULL;
     p_vout->p_sys->p_gw[ 0 ]      = NULL;
     p_vout->p_sys->p_gw[ 1 ]      = NULL;
-    p_vout->p_sys->i_page_size    = p_vout->i_width * p_vout->i_height
-                                  * p_vout->i_bytes_per_pixel;
     
     if ( CreateDisplay( p_vout ) )
     {
@@ -190,22 +155,6 @@ static int vout_Create( vout_thread_t *p_vout )
     intf_ErrMsg( "vout p_vout->i_height %d" , p_vout->i_height);
     intf_ErrMsg( "vout p_vout->i_bytes_per_pixel %d" , p_vout->i_bytes_per_pixel);
     intf_ErrMsg( "vout p_vout->i_screen_depth %d" , p_vout->i_screen_depth);
-    intf_ErrMsg( "vout p_vout->p_sys->i_page_size %d" , p_vout->p_sys->i_page_size);
-#endif
-
-#if 0
-    /* Map two framebuffers a the very beginning of the fb */
-    p_vout->p_sys->p_video = malloc( 2 * p_vout->p_sys->i_page_size );
-    if( p_vout->p_sys->p_video == NULL )
-    {
-        intf_ErrMsg( "vout error: can't map video memory (%s)",
-                     strerror(errno) );
-        free( p_vout->p_sys );
-        return( 1 );
-    }
-    /* Set and initialize buffers */
-    vout_SetBuffers( p_vout, p_vout->p_sys->p_video,
-                    p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );
 #endif
 
     return( 0 );
@@ -236,12 +185,9 @@ void FindBestMemoryLocation( vout_thread_t *p_vout )
 
         intf_ErrMsg( "FindBestMemoryLocation : gNewNewGWorld = false !" );
 #if 0
-//EJ added
         p_vout->i_screen_depth = wPixDepth;
         p_vout->i_bytes_per_pixel = wPixDepth;
-        p_vout->i_bytes_per_line   = p_vout->i_width * p_vout->i_bytes_per_pixel;
-        p_vout->p_sys->i_page_size = p_vout->i_width * p_vout->i_height * p_vout->i_bytes_per_pixel;
-//p_vout->i_bytes_per_line = (**(**hgdWindow).gdPMap).rowBytes & 0x3FFF ;
+        p_vout->i_bytes_per_line = (**(**hgdWindow).gdPMap).rowBytes & 0x3FFF ;
 #endif
         if(    ( noErr == NewGWorld( &pgwTest, wPixDepth, &rectTest, NULL, hgdWindow,
                                      noNewDevice | useDistantHdwrMem ) ) 
@@ -283,10 +229,8 @@ static int CreateDisplay( vout_thread_t *p_vout )
         return( 1 );
     }
 
+//FIXME ? - lock this down until the end...
     hPixmap0 = GetGWorldPixMap( p_vout->p_sys->p_gw[0] );
-//FIXME BIGTIME - in SDL they just lock this down until the end...KLUDGE
-//but alas sounds good to me to try it.
-//well fuck a duck it works.
     LockPixels(hPixmap0);
     hPixmap1 = GetGWorldPixMap( p_vout->p_sys->p_gw[1] );
     LockPixels(hPixmap1);
@@ -310,9 +254,9 @@ static int CreateDisplay( vout_thread_t *p_vout )
         return( 1 );
     }
 
-//FIXME TODO - if I ever dispose of the Gworlds and recreate them, i'll have a new address
+//FIXME - if I ever dispose of the Gworlds and recreate them, i'll have a new address
 //and I'll need to tell vout about them...  dunno what problems vout might have if we just updateGworld  
-    vout_SetBuffers( p_vout, hPixmapBaseAddr0, hPixmapBaseAddr1 );
+    p_vout->pf_setbuffers( p_vout, hPixmapBaseAddr0, hPixmapBaseAddr1 );
 
     return 0;
 }
@@ -326,6 +270,7 @@ static int MakeWindow( vout_thread_t *p_vout )
     int top = 0;
     int bottom = p_vout->i_height;
     int right = p_vout->i_width;
+    ProcessSerialNumber PSN;
 
     WindowAttributes windowAttr = kWindowStandardDocumentAttributes | 
                                     kWindowStandardHandlerAttribute |
@@ -343,20 +288,20 @@ static int MakeWindow( vout_thread_t *p_vout )
     InstallStandardEventHandler(GetWindowEventTarget(p_vout->p_sys->p_window));
     SetPort( GetWindowPort( p_vout->p_sys->p_window ) );
     SetWindowTitleWithCFString( p_vout->p_sys->p_window, CFSTR("VLC") );
-//    ShowWindow( p_vout->p_sys->p_window );
-    TransitionWindow( p_vout->p_sys->p_window, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL);
-    BringToFront(  p_vout->p_sys->p_window );
+    ShowWindow( p_vout->p_sys->p_window );
+    SelectWindow( p_vout->p_sys->p_window );
+
+    //in case we are run from the command line, bring us to front instead of Terminal
+    GetCurrentProcess(&PSN);
+    SetFrontProcess(&PSN);
 
 {
     short wPixDepth = (**(GetPortPixMap( GetWindowPort( p_vout->p_sys->p_window ) ))).pixelSize;
     p_vout->i_screen_depth = wPixDepth;
     p_vout->i_bytes_per_pixel = p_vout->i_screen_depth / 8;
     p_vout->i_bytes_per_line   = p_vout->i_width * p_vout->i_bytes_per_pixel;
-    p_vout->p_sys->i_page_size = p_vout->i_width * p_vout->i_height * p_vout->i_bytes_per_pixel;
 
-//EJ added
-#if 1
-p_vout->i_bytes_per_line = (**(**GetWindowDevice( p_vout )).gdPMap).rowBytes & 0x3FFF ;
+    p_vout->i_bytes_per_line = (**(**GetWindowDevice( p_vout )).gdPMap).rowBytes & 0x3FFF ;
 
     switch ( p_vout->i_screen_depth )
     {
@@ -375,9 +320,8 @@ p_vout->i_bytes_per_line = (**(**GetWindowDevice( p_vout )).gdPMap).rowBytes & 0
         default:
             break;
     }
-#endif
+}
 
-//EJ - not sure about these...
 #if 0
     p_vout->i_red_lshift = 0x10;
     p_vout->i_red_rshift = 0x0;
@@ -391,13 +335,13 @@ p_vout->i_bytes_per_line = (**(**GetWindowDevice( p_vout )).gdPMap).rowBytes & 0
     p_vout->i_gray_pixel = 0x808080;
     p_vout->i_blue_pixel = 0x32;
 #endif
-}
 
     return( 0 );
 }
 
 /*****************************************************************************
- * AllocBuffer: forces offscreen allocation (if different than current) in memory type specified
+ * AllocBuffer: forces offscreen allocation (if different than current) in
+ * memory type specified
  *****************************************************************************/
 static int AllocBuffer ( vout_thread_t *p_vout, short index )
 {
@@ -467,18 +411,13 @@ static void vout_Destroy( vout_thread_t *p_vout )
 {
     //intf_ErrMsg( "vout_Destroy()" );
 
-//FIXME KLUDGE to lock pixels
-#if 1
-{
+//FIXME Big Lock around Gworlds
     PixMapHandle hPixmap0, hPixmap1;
     hPixmap0 = GetGWorldPixMap( p_vout->p_sys->p_gw[0] );
     hPixmap1 = GetGWorldPixMap( p_vout->p_sys->p_gw[1] );
     UnlockPixels(hPixmap0);
     UnlockPixels(hPixmap1);
-}
-#endif
 
-#if 1
     if ( p_vout->p_sys->p_gw[0] )
     {
         DisposeGWorld( p_vout->p_sys->p_gw[0] );
@@ -491,8 +430,7 @@ static void vout_Destroy( vout_thread_t *p_vout )
     {
         DisposeWindow( p_vout->p_sys->p_window );
     }
-#endif
-    free( p_vout->p_sys->p_video );
+
     free( p_vout->p_sys );
 }
 
@@ -518,13 +456,15 @@ static void vout_Display( vout_thread_t *p_vout )
 {
 //    intf_ErrMsg( "vout_Display()" );
 
-    BlitToWindow ( p_vout, p_vout->i_buffer_index );
+//we should not be called if we set the status to paused or stopped via the interface
+//    if ( p_vout->p_sys->playback_status != PAUSED &&  p_vout->p_sys->playback_status != STOPPED )
+        BlitToWindow ( p_vout, p_vout->i_buffer_index );
 }
 
 
 /*****************************************************************************
  * flushQD: flushes buffered window area
 *****************************************************************************/
+ *****************************************************************************/
 void flushQD( vout_thread_t *p_vout )
 {
     CGrafPtr thePort;
@@ -553,7 +493,7 @@ void flushQD( vout_thread_t *p_vout )
 
 /*****************************************************************************
  * BlitToWindow: checks offscreen and blits it to the front
 *****************************************************************************/
+ *****************************************************************************/
 
 void BlitToWindow( vout_thread_t *p_vout, short index )
 {
@@ -570,19 +510,20 @@ void BlitToWindow( vout_thread_t *p_vout, short index )
 //FIXME have global lock - kinda bad but oh well 
 //    if ( LockPixels( GetGWorldPixMap( p_vout->p_sys->p_gw[index] ) ) )
 //    {
+
+//LockPortBits(GetWindowPort( p_vout->p_sys->p_window ));
+//NoPurgePixels( GetGWorldPixMap( p_vout->p_sys->p_gw[index] ) );
+
         CopyBits( GetPortBitMapForCopyBits( p_vout->p_sys->p_gw[index] ), 
                     GetPortBitMapForCopyBits( GetWindowPort( p_vout->p_sys->p_window ) ), 
                     &rectSource, &rectDest, srcCopy, NULL);
+
+//UnlockPortBits(GetWindowPort( p_vout->p_sys->p_window ));
+//AllowPurgePixels( GetGWorldPixMap( p_vout->p_sys->p_gw[index] ) );
+
 //        UnlockPixels( GetGWorldPixMap( p_vout->p_sys->p_gw[index] ) );
-//EJ
         //flushQD( p_vout );
-/*
-    }
-    else
-    {
-        intf_ErrMsg( "error: Could not LockPixels" );
-    }
-*/
+//    }
     SetPort ( pCGrafSave );
 }