Commit 4ebec617 authored by Eugenio Jarosiewicz's avatar Eugenio Jarosiewicz

Updated & cleaned up intf_macosx.c and vout_macosx.c - added Open menu

function support and a no-frills About box

Created macosx_common.h in plugins/macosx/ to hold , well, common stuff
(the way I see it, there is inherently a difficult separation of intf and
vout on Mac OS, if anyone has suggestions I'm open)

Cleaned up debug spew I left in modules.c and video_text.c

Hacked main.c to disregard argv[1] when compiled for OSX & run as a full
app (ie., double clicked and not launched from command line)... read the
file for more details.  UGLY.

Updated Makefile.in to make vlc.app by default on Mac OS X & Darwin, added
clean code for it as well
parent b69b9d33
...@@ -484,6 +484,7 @@ clean: ...@@ -484,6 +484,7 @@ clean:
rm -f plugins/*/*.o plugins/*/*.moc plugins/*/*.bak rm -f plugins/*/*.o plugins/*/*.moc plugins/*/*.bak
rm -f src/*/*.o extras/*/*.o rm -f src/*/*.o extras/*/*.o
rm -f lib/*.so vlc gnome-vlc gvlc kvlc qvlc rm -f lib/*.so vlc gnome-vlc gvlc kvlc qvlc
rm -rf vlc.app
distclean: clean distclean: clean
rm -f **/*.o **/*~ *.log rm -f **/*.o **/*~ *.log
...@@ -491,6 +492,7 @@ distclean: clean ...@@ -491,6 +492,7 @@ distclean: clean
rm -f config.status config.cache config.log rm -f config.status config.cache config.log
rm -f gmon.out core build-stamp rm -f gmon.out core build-stamp
rm -Rf .dep rm -Rf .dep
rm -f .gdb_history
install: install:
mkdir -p $(DESTDIR)$(bindir) mkdir -p $(DESTDIR)$(bindir)
...@@ -682,8 +684,6 @@ ifeq ($(SYS),beos) ...@@ -682,8 +684,6 @@ ifeq ($(SYS),beos)
rm -f ./plugins/_APP_ rm -f ./plugins/_APP_
ln -s ../vlc ./plugins/_APP_ ln -s ../vlc ./plugins/_APP_
endif endif
vlc.app: all
ifneq (,$(findstring darwin,$(SYS))) ifneq (,$(findstring darwin,$(SYS)))
mkdir -p vlc.app/Contents/MacOS mkdir -p vlc.app/Contents/MacOS
mkdir -p vlc.app/Contents/MacOS/lib mkdir -p vlc.app/Contents/MacOS/lib
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* *
* Authors: * Authors: Colin Delacroix <colin@zoy.org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "defs.h" #include "defs.h"
#include <stdlib.h> /* malloc(), free() */ #include <stdlib.h> /* malloc(), free() */
#include <sys/param.h> /* for MAXPATHLEN */
#include "config.h" #include "config.h"
#include "common.h" #include "common.h"
...@@ -36,29 +37,34 @@ ...@@ -36,29 +37,34 @@
#include "mtime.h" #include "mtime.h"
#include "tests.h" #include "tests.h"
#include "intf_msg.h"
#include "interface.h" #include "interface.h"
#include "intf_msg.h"
#include "modules.h" #include "intf_playlist.h"
#include "stream_control.h" #include "stream_control.h"
#include "input_ext-intf.h" #include "input_ext-intf.h"
#include "intf_playlist.h"
#include "audio_output.h" #include "audio_output.h"
#include "video.h"
#include "video_output.h"
#include "modules.h"
#include "main.h" #include "main.h"
#include <Carbon/Carbon.h> #include "macosx_common.h"
extern main_t *p_main;
/*****************************************************************************
* Constants & more
*****************************************************************************/
//how often to have callback to main loop. Target of 30fps then 30hz + maybe some more... //how often to have callback to main loop. Target of 30fps then 30hz + maybe some more...
//it doesn't really scale if we move to 2x the hz... something else is slowing us down... //it doesn't really scale if we move to 2x the hz... something else is slowing us down...
#define kMainLoopFrequency (kEventDurationSecond / 45) //45 for good measure #define kMainLoopFrequency (kEventDurationSecond / 45) //45 for good measure
#define PLAYING 0
#define PAUSED 1
// Menu defs // Menu defs
enum enum
{ {
...@@ -92,8 +98,8 @@ enum ...@@ -92,8 +98,8 @@ enum
*/ */
kMenuApple = 128, kMenuApple = 128,
kMenuFile = 129, kMenuFile,
kMenuControls = 130, kMenuControls,
kAppleAbout = 1, kAppleAbout = 1,
kAppleQuit = 8, //is this always the same? kAppleQuit = 8, //is this always the same?
...@@ -120,7 +126,6 @@ enum ...@@ -120,7 +126,6 @@ enum
kControlsEjectDiv, kControlsEjectDiv,
kControlsEject kControlsEject
#if 0 #if 0
//virtual key codes ; raw subtract 0x40 from these values //virtual key codes ; raw subtract 0x40 from these values
//http://devworld.apple.com/techpubs/mac/Text/Text-577.html#HEADING577-0 //http://devworld.apple.com/techpubs/mac/Text/Text-577.html#HEADING577-0
...@@ -137,13 +142,23 @@ enum ...@@ -137,13 +142,23 @@ enum
}; };
// Initial Window Constants
enum
{
kAboutWindowOffset = 200,
kAboutWindowWidth = 200, //400
kAboutWindowHeight = 50 //100
};
/***************************************************************************** /*****************************************************************************
* intf_sys_t: description and status of the interface * intf_sys_t: description and status of the interface
*****************************************************************************/ *****************************************************************************/
typedef struct intf_sys_s typedef struct intf_sys_s
{ {
EventLoopTimerRef manageTimer; EventLoopTimerRef manageTimer;
Rect aboutRect;
WindowRef p_aboutWindow;
} intf_sys_t; } intf_sys_t;
/***************************************************************************** /*****************************************************************************
...@@ -156,13 +171,22 @@ static void intf_Run ( intf_thread_t *p_intf ); ...@@ -156,13 +171,22 @@ static void intf_Run ( intf_thread_t *p_intf );
/* OS Specific */ /* OS Specific */
static int MakeAboutWindow ( intf_thread_t *p_intf );
void CarbonManageCallback ( EventLoopTimerRef inTimer, void *inUserData ); void CarbonManageCallback ( EventLoopTimerRef inTimer, void *inUserData );
OSErr MyOpenDocument(const FSSpecPtr defaultLocationfssPtr);
void playorpause ( intf_thread_t *p_intf );
void stop ( intf_thread_t *p_intf );
#ifndef CarbonEvents #ifndef CarbonEvents
void EventLoop( intf_thread_t *p_intf ); void EventLoop( intf_thread_t *p_intf );
void DoEvent( intf_thread_t *p_intf , EventRecord *event); void DoEvent( intf_thread_t *p_intf , EventRecord *event);
void DoMenuCommand( intf_thread_t *p_intf , long menuResult); void DoMenuCommand( intf_thread_t *p_intf , long menuResult);
void DrawWindow(WindowRef window); void DrawWindow(WindowRef window);
void DrawAboutWindow(WindowRef window);
#else #else
/* /*
pascal OSErr QuitEventHandler(const AppleEvent *theEvent, AppleEvent *theReply, SInt32 refCon); pascal OSErr QuitEventHandler(const AppleEvent *theEvent, AppleEvent *theReply, SInt32 refCon);
...@@ -287,10 +311,22 @@ static int intf_Open( intf_thread_t *p_intf ) ...@@ -287,10 +311,22 @@ static int intf_Open( intf_thread_t *p_intf )
InsertMenu( menu, 0 ); InsertMenu( menu, 0 );
//Hmm, eventually we might want more than one player window, but for now we assume one only (like OS 9 player)
//and since we start with a window open, we temporarily disable the 'new' menu
DisableMenuItem( GetMenuHandle(kMenuFile), kFileNew);
//FIXME - Disabled Menus which are not implemented yet
DisableMenuItem( GetMenuHandle(kMenuControls), kControlsDVDMenu);
DisableMenuItem( GetMenuHandle(kMenuControls), kControlsEject);
DrawMenuBar(); DrawMenuBar();
if( MakeAboutWindow( p_intf ) )
{
intf_ErrMsg( "vout error: can't make about window" );
return( 1 );
}
return( 0 ); return( 0 );
} }
...@@ -309,20 +345,17 @@ static void intf_Close( intf_thread_t *p_intf ) ...@@ -309,20 +345,17 @@ static void intf_Close( intf_thread_t *p_intf )
static void intf_Run( intf_thread_t *p_intf ) static void intf_Run( intf_thread_t *p_intf )
{ {
OSStatus err; OSStatus err;
EventLoopTimerUPP manageUPP; EventLoopTimerUPP manageUPP;
/* /*
Eventually we want to use Carbon events, or maybe even write this app in Cocoa Eventually we want to use Carbon events, or maybe even write this app in Cocoa
*/
// EventTypeSpec windowEventType = { kEventClassWindow, kEventWindowClose }; //kinda going out of bounds here... need to bring window creation to this file.
// EventHandlerUPP windowHandlerUPP; main_t *p_main;
//kinda going out of bounds here... need to bring window creation to this file. EventTypeSpec windowEventType = { kEventClassWindow, kEventWindowClose };
// main_t *p_main; EventHandlerUPP windowHandlerUPP;
/*
EventTypeSpec keyboardEventType = { kEventClassKeyboard, kEventRawKeyDown }; EventTypeSpec keyboardEventType = { kEventClassKeyboard, kEventRawKeyDown };
EventHandlerUPP keyboardHandlerUPP; EventHandlerUPP keyboardHandlerUPP;
*/ */
...@@ -332,7 +365,8 @@ Eventually we want to use Carbon events, or maybe even write this app in Cocoa ...@@ -332,7 +365,8 @@ Eventually we want to use Carbon events, or maybe even write this app in Cocoa
assert(err == noErr); assert(err == noErr);
DisposeEventLoopTimerUPP(manageUPP); DisposeEventLoopTimerUPP(manageUPP);
/* windowHandlerUPP = NewEventHandlerUPP ( MyWindowEventHandler ); /*
windowHandlerUPP = NewEventHandlerUPP ( MyWindowEventHandler );
err = InstallWindowEventHandler ( p_main->p_vout->p_sys->p_window , windowHandlerUPP, GetEventTypeCount(windowEventType), &windowEventType, (void *) p_intf, NULL ); err = InstallWindowEventHandler ( p_main->p_vout->p_sys->p_window , windowHandlerUPP, GetEventTypeCount(windowEventType), &windowEventType, (void *) p_intf, NULL );
assert(err == noErr); assert(err == noErr);
DisposeEventHandlerUPP(windowHandlerUPP); DisposeEventHandlerUPP(windowHandlerUPP);
...@@ -343,7 +377,6 @@ Eventually we want to use Carbon events, or maybe even write this app in Cocoa ...@@ -343,7 +377,6 @@ Eventually we want to use Carbon events, or maybe even write this app in Cocoa
//UGLY Event Loop! //UGLY Event Loop!
EventLoop( p_intf ); EventLoop( p_intf );
#else #else
//Our big event loop !-)
RunApplicationEventLoop(); RunApplicationEventLoop();
#endif #endif
err = RemoveEventLoopTimer(p_intf->p_sys->manageTimer); err = RemoveEventLoopTimer(p_intf->p_sys->manageTimer);
...@@ -351,6 +384,37 @@ Eventually we want to use Carbon events, or maybe even write this app in Cocoa ...@@ -351,6 +384,37 @@ Eventually we want to use Carbon events, or maybe even write this app in Cocoa
} }
/*****************************************************************************
* MakeAboutWindow: similar to MakeWindow in vout_macosx.c ;
* open and set-up a Mac OS window to be used for 'about' program...
* create it hidden and only show it when requested
*****************************************************************************/
static int MakeAboutWindow( intf_thread_t *p_intf )
{
int left = 0;
int top = 0;
int bottom = kAboutWindowHeight;
int right = kAboutWindowWidth;
WindowAttributes windowAttr = kWindowCloseBoxAttribute |
kWindowStandardHandlerAttribute |
kWindowInWindowMenuAttribute;
SetRect( &p_intf->p_sys->aboutRect, left, top, right, bottom );
OffsetRect( &p_intf->p_sys->aboutRect, kAboutWindowOffset, kAboutWindowOffset );
CreateNewWindow( kDocumentWindowClass, windowAttr, &p_intf->p_sys->aboutRect, &p_intf->p_sys->p_aboutWindow );
if ( p_intf->p_sys->p_aboutWindow == nil )
{
return( 1 );
}
InstallStandardEventHandler(GetWindowEventTarget(p_intf->p_sys->p_aboutWindow));
SetWindowTitleWithCFString( p_intf->p_sys->p_aboutWindow, CFSTR("About DVD.app & VLC") );
return( 0 );
}
void CarbonManageCallback ( EventLoopTimerRef inTimer, void *inUserData ) void CarbonManageCallback ( EventLoopTimerRef inTimer, void *inUserData )
{ {
...@@ -421,8 +485,6 @@ void DoEvent( intf_thread_t *p_intf , EventRecord *event) ...@@ -421,8 +485,6 @@ void DoEvent( intf_thread_t *p_intf , EventRecord *event)
case inGoAway: case inGoAway:
p_intf->b_die = true; p_intf->b_die = true;
return; return;
//DisposeWindow(whichWindow);
//ExitToShell();
break; break;
case inZoomIn: case inZoomIn:
...@@ -462,13 +524,59 @@ void DoEvent( intf_thread_t *p_intf , EventRecord *event) ...@@ -462,13 +524,59 @@ void DoEvent( intf_thread_t *p_intf , EventRecord *event)
} }
} }
//the code for playorpause and stop taken almost directly from the BeOS code
void playorpause ( intf_thread_t *p_intf )
{
// pause the playback
if (p_intf->p_input != NULL )
{
// mute the volume if currently playing
if (p_main->p_vout->p_sys->playback_status == PLAYING)
{
if (p_main->p_aout != NULL)
{
p_main->p_aout->vol = 0;
}
p_main->p_vout->p_sys->playback_status = PAUSED;
SetMenuItemText( GetMenuHandle(kMenuControls), kControlsPlayORPause, "\pPlay");
}
else
// restore the volume
{
if (p_main->p_aout != NULL)
{
p_main->p_aout->vol = p_main->p_vout->p_sys->vol_val;
}
p_main->p_vout->p_sys->playback_status = PLAYING;
SetMenuItemText( GetMenuHandle(kMenuControls), kControlsPlayORPause, "\pPause");
}
//snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_PAUSE);
}
}
void stop ( intf_thread_t *p_intf )
{
// this currently stops playback not nicely
if (p_intf->p_input != NULL )
{
// silence the sound, otherwise very horrible
if (p_main->p_aout != NULL)
{
p_main->p_aout->vol = 0;
}
//snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_END);
}
p_main->p_vout->p_sys->playback_status = STOPPED;
}
void DoMenuCommand( intf_thread_t *p_intf , long menuResult) void DoMenuCommand( intf_thread_t *p_intf , long menuResult)
{ {
short menuID; /* the resource ID of the selected menu */ short menuID; /* the resource ID of the selected menu */
short menuItem; /* the item number of the selected menu */ short menuItem; /* the item number of the selected menu */
static int vol_val; // remember the current volume
static int playback_status; // remember playback state
menuID = HiWord(menuResult); /* use macros to get item & menu number */ menuID = HiWord(menuResult); /* use macros to get item & menu number */
menuItem = LoWord(menuResult); menuItem = LoWord(menuResult);
...@@ -479,16 +587,15 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult) ...@@ -479,16 +587,15 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult)
switch (menuItem) switch (menuItem)
{ {
case kAppleAbout: case kAppleAbout:
//Fixme ShowWindow( p_intf->p_sys->p_aboutWindow );
SysBeep(30); SelectWindow( p_intf->p_sys->p_aboutWindow );
//DoAboutBox(); DrawAboutWindow( p_intf->p_sys->p_aboutWindow); //kludge
EnableMenuItem( GetMenuHandle(kMenuFile), kFileClose);
break; break;
case kAppleQuit: case kAppleQuit:
p_intf->b_die = true; p_intf->b_die = true;
//hrmm... //hrmm... don't know what is going on w/ the Quit item in the new application menu...documentation???
ExitToShell();
return;
break; break;
default: default:
...@@ -500,35 +607,33 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult) ...@@ -500,35 +607,33 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult)
switch (menuItem) switch (menuItem)
{ {
case kFileNew: case kFileNew:
//Fixme ShowWindow( p_main->p_vout->p_sys->p_window );
SysBeep(30); SelectWindow( p_main->p_vout->p_sys->p_window );
//DoAboutBox(); DisableMenuItem( GetMenuHandle(kMenuFile), kFileNew);
EnableMenuItem( GetMenuHandle(kMenuFile), kFileClose);
//hmm, can't say to play() right now because I don't know if a file is in playlist yet.
//need to see if I can tell this or eve if calling play() w/o a file is bad...not sure of either
break; break;
case kFileOpen: case kFileOpen:
//Fixme playorpause( p_intf );
/* MyOpenDocument(nil);
const char **device; // starts playing automatically on open? playorpause( p_intf );
char device_method_and_name[B_FILE_NAME_LENGTH + 4];
if(p_message->FindString("device", device) != B_ERROR)
{
sprintf(device_method_and_name, "dvd:%s", *device);
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, device_method_and_name );
}
*/
SysBeep(30);
//DoAboutBox();
break; break;
case kFileClose: case kFileClose:
HideWindow( FrontWindow() ); HideWindow( FrontWindow() );
//Fixme if ( ! IsWindowVisible( p_main->p_vout->p_sys->p_window ) && ! IsWindowVisible( p_intf->p_sys->p_aboutWindow ) )
SysBeep(30); {
//DoAboutBox(); //calling this even if no file open shouldn't be bad... not sure of opposite situation above
stop( p_intf );
EnableMenuItem( GetMenuHandle(kMenuFile), kFileNew);
DisableMenuItem( GetMenuHandle(kMenuFile), kFileClose);
}
break; break;
case kFileQuitHack: case kFileQuitHack:
stop( p_intf );
p_intf->b_die = true; p_intf->b_die = true;
break; break;
...@@ -541,44 +646,11 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult) ...@@ -541,44 +646,11 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult)
switch (menuItem) switch (menuItem)
{ {
case kControlsPlayORPause: case kControlsPlayORPause:
// pause the playback playorpause( p_intf );
if (p_intf->p_input != NULL )
{
// mute the volume if currently playing
if (playback_status == PLAYING)
{
if (p_main->p_aout != NULL)
{
p_main->p_aout->vol = 0;
}
playback_status = PAUSED;
}
else
// restore the volume
{
if (p_main->p_aout != NULL)
{
p_main->p_aout->vol = vol_val;
}
playback_status = PLAYING;
}
//snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_PAUSE);
}
break; break;
case kControlsStop: case kControlsStop:
// this currently stops playback not nicely stop( p_intf );
if (p_intf->p_input != NULL )
{
// silence the sound, otherwise very horrible
if (p_main->p_aout != NULL)
{
p_main->p_aout->vol = 0;
}
//snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_END);
}
break; break;
case kControlsForward: case kControlsForward:
...@@ -653,12 +725,12 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult) ...@@ -653,12 +725,12 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult)
if (p_main->p_aout->vol == 0) if (p_main->p_aout->vol == 0)
{ {
//p_vol->SetEnabled(true); //p_vol->SetEnabled(true);
p_main->p_aout->vol = vol_val; p_main->p_aout->vol = p_main->p_vout->p_sys->vol_val;
} }
else else
{ {
//p_vol->SetEnabled(false); //p_vol->SetEnabled(false);
vol_val = p_main->p_aout->vol; p_main->p_vout->p_sys->vol_val = p_main->p_aout->vol;
p_main->p_aout->vol = 0; p_main->p_aout->vol = 0;
} }
} }
...@@ -683,18 +755,30 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult) ...@@ -683,18 +755,30 @@ void DoMenuCommand( intf_thread_t *p_intf , long menuResult)
void DrawWindow(WindowRef window) void DrawWindow(WindowRef window)
{ {
Rect tempRect; Rect tempRect;
GrafPtr curPort; GrafPtr previousPort;
GetPort(&curPort); GetPort(&previousPort);
SetPort(GetWindowPort(window)); SetPort(GetWindowPort(window));
BeginUpdate(window); BeginUpdate(window);
EraseRect(GetWindowPortBounds(window, &tempRect)); EraseRect(GetWindowPortBounds(window, &tempRect));
DrawControls(window); DrawControls(window);
DrawGrowIcon(window); DrawGrowIcon(window);
EndUpdate(window); EndUpdate(window);
SetPort(curPort); SetPort(previousPort);
} }
void DrawAboutWindow(WindowRef window)
{
GrafPtr previousPort;
GetPort(&previousPort);
SetPort(GetWindowPort(window));
MoveTo(10,30);
DrawString("\phttp://www.videolan.org");
SetPort(previousPort);
}
#else #else
...@@ -786,3 +870,110 @@ static pascal OSStatus MyEventHandler(EventHandlerCallRef myHandler, EventRef ev ...@@ -786,3 +870,110 @@ static pascal OSStatus MyEventHandler(EventHandlerCallRef myHandler, EventRef ev
return result; return result;
} }
#endif #endif
//FIXME Adding this has introduced or surfaced a lot of bugs...
//comented out a lot of things to strip this down to make this a 'quicky'
OSErr MyOpenDocument(const FSSpecPtr defaultLocationfssPtr)
{
NavDialogOptions dialogOptions;
// AEDesc defaultLocation;
// NavEventUPP eventProc = NewNavEventProc(myEventProc);
// NavObjectFilterUPP filterProc =
// NewNavObjectFilterProc(myFilterProc);
OSErr anErr = noErr;
// Specify default options for dialog box
anErr = NavGetDefaultDialogOptions(&dialogOptions);
if (anErr == noErr)
{
// Adjust the options to fit our needs
// Set default location option
// dialogOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
// Clear preview option
dialogOptions.dialogOptionFlags ^= kNavAllowPreviews;
// make descriptor for default location
// anErr = AECreateDesc(typeFSS, defaultLocationfssPtr,
// sizeof(*defaultLocationfssPtr),
// &defaultLocation );
if (anErr == noErr)
{
// Get 'open' resource. A nil handle being returned is OK,
// this simply means no automatic file filtering.
NavTypeListHandle typeList = (NavTypeListHandle)GetResource(
'open', 128);
NavReplyRecord reply;
// Call NavGetFile() with specified options and
// declare our app-defined functions and type list
// anErr = NavGetFile (&defaultLocation, &reply, &dialogOptions,
anErr = NavGetFile (nil, &reply, &dialogOptions,
// eventProc, nil, filterProc,
nil, nil, nil,
typeList, nil);
if (anErr == noErr && reply.validRecord)
{
// Deal with multiple file selection
long count;
anErr = AECountItems(&(reply.selection), &count);
// Set up index for file list
if (anErr == noErr)
{
long index;
for (index = 1; index <= count; index++)
{
AEKeyword theKeyword;
DescType actualType;
Size actualSize;
FSSpec documentFSSpec;
// Get a pointer to selected file
anErr = AEGetNthPtr(&(reply.selection), index,
typeFSS, &theKeyword,
&actualType,&documentFSSpec,
sizeof(documentFSSpec),
&actualSize);
if (anErr == noErr)
{
// anErr = DoOpenFile(&documentFSSpec);
//HERE
FSRef newRef;
char path[MAXPATHLEN];
//make an FSRef out of an FSSpec
anErr = FSpMakeFSRef( &documentFSSpec, &newRef);
if (anErr != noErr)
{
return(anErr);
}
//make a path out of the FSRef
anErr = FSRefMakePath( &newRef, path, MAXPATHLEN);
if (anErr != noErr)
{
return(anErr);
}
//else, ok...add it to playlist!
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, path );
}
}
}
// Dispose of NavReplyRecord, resources, descriptors
anErr = NavDisposeReply(&reply);
}
if (typeList != NULL)
{
ReleaseResource( (Handle)typeList);
}
//(void) AEDisposeDesc(&defaultLocation);
}
}
// DisposeRoutineDescriptor(eventProc);
// DisposeRoutineDescriptor(filterProc);
return anErr;
}
/*****************************************************************************
* macosx.c : MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $$
*
* Authors: Colin Delacroix <colin@zoy.org>
*
* 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, USA.
*****************************************************************************/
/*****************************************************************************
* Constants & more
*****************************************************************************/
#ifndef __CARBONPREFIX__
#define __CARBONPREFIX__
// Needed for carbonization
#define TARGET_API_MAC_CARBON 1
// For the pascal to C or C to pascal string conversions in carbon
#define OLDP2C 1
#endif
#include <Carbon/Carbon.h>
#define PLAYING 0
#define PAUSED 1
#define STOPPED 2
/*****************************************************************************
* Type declarations that unfortunately need to be known to both
* ...
* Kind of a hack due to the fact that on Mac OS, there is little difference
* between the interface and the video output, and hence little separation
* between those elements.
*****************************************************************************/
/*****************************************************************************
* 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
{
Rect wrect;
WindowRef p_window;
short gwLocOffscreen;
GWorldPtr p_gw[ 2 ];
Boolean gNewNewGWorld; /* can we allocate in VRAm or AGP memory ? */
GDHandle theGDList;
Ptr theBase;
int theRow;
int theDepth;
int playback_status; // remember playback state
int vol_val; // remember the current volume
} vout_sys_t;
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* *
* Authors: * Authors: Colin Delacroix <colin@zoy.org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -38,26 +38,20 @@ ...@@ -38,26 +38,20 @@
#include "mtime.h" #include "mtime.h"
#include "tests.h" #include "tests.h"
#include "video.h"
#include "video_output.h"
#include "intf_msg.h" #include "intf_msg.h"
#include "main.h" #include "video.h"
#include "video_output.h"
#include "modules.h" #include "modules.h"
#include "main.h"
#ifndef __CARBONPREFIX__ #include "macosx_common.h"
#define __CARBONPREFIX__
// Needed for carbonization
#define TARGET_API_MAC_CARBON 1
// For the pascal to C or C to pascal string conversions in carbon /*****************************************************************************
#define OLDP2C 1 * Constants & more
#endif *****************************************************************************/
#include <Carbon/Carbon.h>
// Initial Window Constants // Initial Window Constants
enum enum
...@@ -74,32 +68,6 @@ enum ...@@ -74,32 +68,6 @@ enum
kInSystem 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 * Local prototypes
...@@ -174,8 +142,6 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -174,8 +142,6 @@ static int vout_Create( vout_thread_t *p_vout )
p_vout->p_sys->p_window = NULL; p_vout->p_sys->p_window = NULL;
p_vout->p_sys->p_gw[ 0 ] = NULL; p_vout->p_sys->p_gw[ 0 ] = NULL;
p_vout->p_sys->p_gw[ 1 ] = 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 ) ) if ( CreateDisplay( p_vout ) )
{ {
...@@ -189,22 +155,6 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -189,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_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_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->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 #endif
return( 0 ); return( 0 );
...@@ -237,9 +187,7 @@ void FindBestMemoryLocation( vout_thread_t *p_vout ) ...@@ -237,9 +187,7 @@ void FindBestMemoryLocation( vout_thread_t *p_vout )
#if 0 #if 0
p_vout->i_screen_depth = wPixDepth; p_vout->i_screen_depth = wPixDepth;
p_vout->i_bytes_per_pixel = 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->i_bytes_per_line = (**(**hgdWindow).gdPMap).rowBytes & 0x3FFF ;
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 ;
#endif #endif
if( ( noErr == NewGWorld( &pgwTest, wPixDepth, &rectTest, NULL, hgdWindow, if( ( noErr == NewGWorld( &pgwTest, wPixDepth, &rectTest, NULL, hgdWindow,
noNewDevice | useDistantHdwrMem ) ) noNewDevice | useDistantHdwrMem ) )
...@@ -322,6 +270,7 @@ static int MakeWindow( vout_thread_t *p_vout ) ...@@ -322,6 +270,7 @@ static int MakeWindow( vout_thread_t *p_vout )
int top = 0; int top = 0;
int bottom = p_vout->i_height; int bottom = p_vout->i_height;
int right = p_vout->i_width; int right = p_vout->i_width;
ProcessSerialNumber PSN;
WindowAttributes windowAttr = kWindowStandardDocumentAttributes | WindowAttributes windowAttr = kWindowStandardDocumentAttributes |
kWindowStandardHandlerAttribute | kWindowStandardHandlerAttribute |
...@@ -339,16 +288,18 @@ static int MakeWindow( vout_thread_t *p_vout ) ...@@ -339,16 +288,18 @@ static int MakeWindow( vout_thread_t *p_vout )
InstallStandardEventHandler(GetWindowEventTarget(p_vout->p_sys->p_window)); InstallStandardEventHandler(GetWindowEventTarget(p_vout->p_sys->p_window));
SetPort( GetWindowPort( p_vout->p_sys->p_window ) ); SetPort( GetWindowPort( p_vout->p_sys->p_window ) );
SetWindowTitleWithCFString( p_vout->p_sys->p_window, CFSTR("VLC") ); SetWindowTitleWithCFString( p_vout->p_sys->p_window, CFSTR("VLC") );
// ShowWindow( p_vout->p_sys->p_window ); ShowWindow( p_vout->p_sys->p_window );
TransitionWindow( p_vout->p_sys->p_window, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL); SelectWindow( p_vout->p_sys->p_window );
BringToFront( 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; short wPixDepth = (**(GetPortPixMap( GetWindowPort( p_vout->p_sys->p_window ) ))).pixelSize;
p_vout->i_screen_depth = wPixDepth; p_vout->i_screen_depth = wPixDepth;
p_vout->i_bytes_per_pixel = p_vout->i_screen_depth / 8; 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->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 = (**(**GetWindowDevice( p_vout )).gdPMap).rowBytes & 0x3FFF ; p_vout->i_bytes_per_line = (**(**GetWindowDevice( p_vout )).gdPMap).rowBytes & 0x3FFF ;
...@@ -369,6 +320,7 @@ static int MakeWindow( vout_thread_t *p_vout ) ...@@ -369,6 +320,7 @@ static int MakeWindow( vout_thread_t *p_vout )
default: default:
break; break;
} }
}
#if 0 #if 0
p_vout->i_red_lshift = 0x10; p_vout->i_red_lshift = 0x10;
...@@ -383,7 +335,6 @@ static int MakeWindow( vout_thread_t *p_vout ) ...@@ -383,7 +335,6 @@ static int MakeWindow( vout_thread_t *p_vout )
p_vout->i_gray_pixel = 0x808080; p_vout->i_gray_pixel = 0x808080;
p_vout->i_blue_pixel = 0x32; p_vout->i_blue_pixel = 0x32;
#endif #endif
}
return( 0 ); return( 0 );
} }
...@@ -459,18 +410,13 @@ static void vout_Destroy( vout_thread_t *p_vout ) ...@@ -459,18 +410,13 @@ static void vout_Destroy( vout_thread_t *p_vout )
{ {
//intf_ErrMsg( "vout_Destroy()" ); //intf_ErrMsg( "vout_Destroy()" );
//FIXME KLUDGE to lock pixels //FIXME Big Lock around Gworlds
#if 1
{
PixMapHandle hPixmap0, hPixmap1; PixMapHandle hPixmap0, hPixmap1;
hPixmap0 = GetGWorldPixMap( p_vout->p_sys->p_gw[0] ); hPixmap0 = GetGWorldPixMap( p_vout->p_sys->p_gw[0] );
hPixmap1 = GetGWorldPixMap( p_vout->p_sys->p_gw[1] ); hPixmap1 = GetGWorldPixMap( p_vout->p_sys->p_gw[1] );
UnlockPixels(hPixmap0); UnlockPixels(hPixmap0);
UnlockPixels(hPixmap1); UnlockPixels(hPixmap1);
}
#endif
#if 1
if ( p_vout->p_sys->p_gw[0] ) if ( p_vout->p_sys->p_gw[0] )
{ {
DisposeGWorld( p_vout->p_sys->p_gw[0] ); DisposeGWorld( p_vout->p_sys->p_gw[0] );
...@@ -483,8 +429,7 @@ static void vout_Destroy( vout_thread_t *p_vout ) ...@@ -483,8 +429,7 @@ static void vout_Destroy( vout_thread_t *p_vout )
{ {
DisposeWindow( p_vout->p_sys->p_window ); DisposeWindow( p_vout->p_sys->p_window );
} }
#endif
free( p_vout->p_sys->p_video );
free( p_vout->p_sys ); free( p_vout->p_sys );
} }
...@@ -510,6 +455,7 @@ static void vout_Display( vout_thread_t *p_vout ) ...@@ -510,6 +455,7 @@ static void vout_Display( vout_thread_t *p_vout )
{ {
// intf_ErrMsg( "vout_Display()" ); // intf_ErrMsg( "vout_Display()" );
if ( p_vout->p_sys->playback_status != PAUSED && p_vout->p_sys->playback_status != STOPPED )
BlitToWindow ( p_vout, p_vout->i_buffer_index ); BlitToWindow ( p_vout, p_vout->i_buffer_index );
} }
...@@ -562,9 +508,17 @@ void BlitToWindow( vout_thread_t *p_vout, short index ) ...@@ -562,9 +508,17 @@ void BlitToWindow( vout_thread_t *p_vout, short index )
//FIXME have global lock - kinda bad but oh well //FIXME have global lock - kinda bad but oh well
// if ( LockPixels( GetGWorldPixMap( p_vout->p_sys->p_gw[index] ) ) ) // 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] ), CopyBits( GetPortBitMapForCopyBits( p_vout->p_sys->p_gw[index] ),
GetPortBitMapForCopyBits( GetWindowPort( p_vout->p_sys->p_window ) ), GetPortBitMapForCopyBits( GetWindowPort( p_vout->p_sys->p_window ) ),
&rectSource, &rectDest, srcCopy, NULL); &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] ) ); // UnlockPixels( GetGWorldPixMap( p_vout->p_sys->p_gw[index] ) );
//flushQD( p_vout ); //flushQD( p_vout );
// } // }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules.c : Built-in and dynamic modules management functions * modules.c : Built-in and dynamic modules management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: modules.c,v 1.20 2001/04/06 18:18:10 massiot Exp $ * $Id: modules.c,v 1.21 2001/04/11 13:30:30 ej Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com> * Ethan C. Baldridge <BaldridgeE@cadmus.com>
...@@ -122,10 +122,8 @@ void module_InitBank( module_bank_t * p_bank ) ...@@ -122,10 +122,8 @@ void module_InitBank( module_bank_t * p_bank )
{ {
once = 1; once = 1;
strncpy( app_path, p_main->ppsz_argv[ 0 ], i_pathlen ); strncpy( app_path, p_main->ppsz_argv[ 0 ], i_pathlen );
intf_ErrMsg( "%s", p_main->ppsz_argv[ 0 ] );
strcat( app_path, "lib" ); strcat( app_path, "lib" );
path[ 3 ] = app_path ; path[ 3 ] = app_path ;
intf_ErrMsg( "%s", path[ 3 ] );
} }
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_text.c : text manipulation functions * video_text.c : text manipulation functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_text.c,v 1.21 2001/04/06 18:18:10 massiot Exp $ * $Id: video_text.c,v 1.22 2001/04/11 13:30:30 ej Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include "video_text.h" #include "video_text.h"
#ifdef SYS_DARWIN1_3 #ifdef SYS_DARWIN1_3
// #include <CFBundle.h>
#include <sys/param.h> /* for MAXPATHLEN */ #include <sys/param.h> /* for MAXPATHLEN */
#include "main.h" #include "main.h"
extern main_t *p_main; extern main_t *p_main;
...@@ -229,7 +228,6 @@ vout_font_t *vout_LoadFont( const char *psz_name ) ...@@ -229,7 +228,6 @@ vout_font_t *vout_LoadFont( const char *psz_name )
static char app_path[ MAXPATHLEN ]; static char app_path[ MAXPATHLEN ];
/* HACK TO CUT OUT trailing 'vlc' */ /* HACK TO CUT OUT trailing 'vlc' */
int i_pathlen = strlen( p_main->ppsz_argv[ 0 ] ) - 3; int i_pathlen = strlen( p_main->ppsz_argv[ 0 ] ) - 3;
// CFBundleRef mainBundle;
#endif #endif
int i_char, i_line; /* character and line indexes */ int i_char, i_line; /* character and line indexes */
int i_file = -1; /* source file */ int i_file = -1; /* source file */
...@@ -237,17 +235,12 @@ vout_font_t *vout_LoadFont( const char *psz_name ) ...@@ -237,17 +235,12 @@ vout_font_t *vout_LoadFont( const char *psz_name )
vout_font_t * p_font; /* the font itself */ vout_font_t * p_font; /* the font itself */
#ifdef SYS_DARWIN1_3 #ifdef SYS_DARWIN1_3
// Get the main bundle for the app
// mainBundle = CFBundleGetMainBundle();
if( !once ) if( !once )
{ {
once = 1; once = 1;
strncpy( app_path, p_main->ppsz_argv[ 0 ], i_pathlen ); strncpy( app_path, p_main->ppsz_argv[ 0 ], i_pathlen );
intf_ErrMsg( "%s", p_main->ppsz_argv[ 0 ] );
strcat( app_path, "share" ); strcat( app_path, "share" );
path[ 2 ] = app_path ; path[ 2 ] = app_path ;
intf_ErrMsg( "%s", path[ 2 ] );
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment