[Mplayer-cvslog] CVS: main/Gui Makefile,NONE,1.1 app.c,NONE,1.1 app.h,NONE,1.1 config.c,NONE,1.1 config.h,NONE,1.1 error.c,NONE,1.1 error.h,NONE,1.1 events.c,NONE,1.1 events.h,NONE,1.1 gui.mak,NONE,1.1 language.c,NONE,1.1 language.h,NONE,1.1 shmem.c,NONE,1.1 shmem.h,NONE,1.1 timer.c,NONE,1.1 timer.h,NONE,1.1
Arpi of Ize
arpi at mplayer.dev.hu
Sat Aug 25 23:04:29 CEST 2001
Update of /cvsroot/mplayer/main/Gui
In directory mplayer:/var/tmp.root/cvs-serv13203
Added Files:
Makefile app.c app.h config.c config.h error.c error.h
events.c events.h gui.mak language.c language.h shmem.c
shmem.h timer.c timer.h
Log Message:
GUI version n-1
--- NEW FILE ---
LIB = libgui.a
include ../config.mak
include config.mak
include bitmap/bitmap.mak
MPLAYERDIR = mplayer/
include gui.mak
INCDIR = -I. -I./event -I./wm -I./skin $(GTKINC)
OPTIMIZE = $(OPTFLAGS) -fomit-frame-pointer \
-fexpensive-optimizations -malign-double -fschedule-insns2 -mwide-multiply -Wall
CFLAGS = $(OPTIMIZE) $(INCDIR) $(DEBUG)
.SUFFIXES: .c .o
.c.o:
$(CC) -c $(CFLAGS) -o $@ $<
### TARGETS ###
$(LIB): .depend $(OBJS)
$(MAKE) -C mplayer
rm -f $(LIB)
ar rc $(LIB) $(OBJS) $(MPLAYEROBJS)
all: $(LIB)
clean:
$(MAKE) -C mplayer clean
rm -rf $(OBJS) *.o *~ *.bak main $(PRG) $(LIB) .depend
#dep: depend
#
#depend:
# makedepend -- $(CFLAGS) -- $(SRCS) &>/dev/null
#
distclean: clean
dep: depend
depend: .depend
.depend: Makefile config.mak config.h gui.mak bitmap/bitmap.mak
$(MAKE) -C mplayer depend
$(CC) -MM $(CFLAGS) $(SRCS) 1>.depend
#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif
--- NEW FILE ---
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "app.h"
#include "../config.h"
#include "config.h"
#include "error.h"
#include "wm/wskeys.h"
#include "skin/skin.h"
#include "mplayer/mplayer.h"
listItems appMPlayer;
listItems appTV;
listItems appRadio;
char * appMPlayerDirInHome=NULL;
char * appMPlayerDir=NULL;
char * skinDirInHome=NULL;
char * skinMPlayerDir=NULL;
void appClearItem( wItem * item )
{
item->type=0;
// ---
item->x=0; item->y=0; item->width=0; item->height=0;
// ---
item->px=0; item->py=0; item->psx=0; item->psy=0;
// ---
item->msg=0; item->msg2=0;
item->pressed=0;
item->tmp=0;
item->key=0; item->key2=0;
item->Bitmap.Width=0; item->Bitmap.Height=0; item->Bitmap.BPP=0; item->Bitmap.ImageSize=0;
if ( item->Bitmap.Image )
{ free( item->Bitmap.Image ); item->Bitmap.Image=NULL; }
// ---
item->fontid=0;
if ( item->label ) free( item->label ); item->label=NULL;
item->event=0;
}
void appCopy( listItems * dest,listItems * source )
{
dest->NumberOfItems=source->NumberOfItems;
memcpy( &dest->Items,&source->Items,128 * sizeof( wItem ) );
dest->NumberOfMenuItems=source->NumberOfMenuItems;
memcpy( &dest->MenuItems,&source->MenuItems,32 * sizeof( wItem ) );
memcpy( &dest->main,&source->main,sizeof( wItem ) );
memcpy( &dest->sub,&source->sub,sizeof( wItem ) );
memcpy( &dest->eq,&source->eq,sizeof( wItem ) );
memcpy( &dest->menuBase,&source->menuBase,sizeof( wItem ) );
memcpy( &dest->menuSelected,&source->menuSelected,sizeof( wItem ) );
}
void appInitStruct( listItems * item )
{
int i;
for ( i=0;i<item->NumberOfItems;i++ )
appClearItem( &item->Items[i] );
for ( i=0;i<item->NumberOfMenuItems;i++ )
appClearItem( &item->MenuItems[i] );
item->NumberOfItems=-1;
memset( item->Items,0,128 * sizeof( wItem ) );
item->NumberOfMenuItems=-1;
memset( item->MenuItems,0,32 * sizeof( wItem ) );
appClearItem( &item->main );
appClearItem( &item->sub );
item->sub.Bitmap.Width=256; item->sub.Bitmap.Height=256;
item->sub.width=256; item->sub.height=256;
appClearItem( &item->menuBase );
appClearItem( &item->menuSelected );
item->subR=0;
item->subG=0;
item->subB=0;
}
int appFindKey( unsigned char * name )
{
int i;
for ( i=0;i<wsKeyNumber;i++ )
if ( !strcmp( wsKeyNames[i].name,name ) ) return wsKeyNames[i].code;
return -1;
}
int appFindMessage( unsigned char * str )
{
int i;
for ( i=0;i<evBoxs;i++ )
if ( !strcmp( evNames[i].name,str ) ) return evNames[i].msg;
return -1;
}
void appInit( int argc,char* argv[], char *envp[] )
{
if ( ( appMPlayerDirInHome=(char *)calloc( 1,strlen( getenv( "HOME" ) ) + 9 ) ) != NULL )
{ strcpy( appMPlayerDirInHome,getenv( "HOME" ) ); strcat( appMPlayerDirInHome,"/.mplayer" ); }
if ( ( skinDirInHome=(char *)calloc( 1,strlen( appMPlayerDirInHome ) + 5 ) ) != NULL )
{ strcpy( skinDirInHome,appMPlayerDirInHome ); strcat( skinDirInHome,"/Skin" ); }
if ( ( appMPlayerDir=(char *)calloc( 1,strlen( PREFIX ) + 14 ) ) != NULL )
{ strcpy( appMPlayerDir,PREFIX ); strcat( appMPlayerDir,"/share/mplayer" ); }
if ( ( skinMPlayerDir=(char *)calloc( 1,strlen( appMPlayerDir ) + 5 ) ) != NULL )
{ strcpy( skinMPlayerDir,appMPlayerDir ); strcat( skinMPlayerDir,"/Skin" ); }
initDebug();
cfgDefaults();
cfgRead();
if ( !strcmp( cfgAppName,"movieplayer" ) )
{
appMPlayer.sub.x=-1; appMPlayer.sub.y=-1; appMPlayer.sub.width=512; appMPlayer.sub.height=256;
switch ( skinRead( cfgSkin ) )
{
case -1: dbprintf( 0,"[app] skin configfile not found.\n" ); exit( 0 );
case -2: dbprintf( 0,"[app] skin configfile read error.\n" ); exit( 0 );
}
mplInit( argc,argv,envp );
}
}
--- NEW FILE ---
#ifndef __MY_APPS
#define __MY_APPS
#include "bitmap/bitmap.h"
#include "wm/ws.h"
#include "wm/wskeys.h"
#include "events.h"
#define itNULL 0
#define itButton 101 // button
#define itHPotmeter 102 // horizontal potmeter
#define itVPotmeter 103 // vertical potmeter
#define itSLabel 104 // static label
#define itDLabel 105 // dynamic label
#define itBase 106
#define itPotmeter 107
#define itFont 108
// ---
#define btnPressed 0
#define btnReleased 1
#define btnDisabled 2
// ---
typedef struct
{
int type;
// ---
int x,y;
int width,height;
// ---
int px,py,psx,psy;
// ---
int msg,msg2;
int pressed,disabled,tmp;
int key,key2;
int phases;
float value;
txSample Bitmap;
txSample Mask;
// ---
int fontid;
int align;
char * label;
// ---
int event;
} wItem;
typedef struct
{
wItem main;
wsTWindow mainWindow;
wItem sub;
wsTWindow subWindow;
int subR,subG,subB;
int subPixel;
wItem eq;
wsTWindow eqWindow;
wItem menuBase;
wItem menuSelected;
wsTWindow menuWindow;
// ---
int NumberOfItems;
wItem Items[256];
// ---
int NumberOfMenuItems;
wItem MenuItems[32];
} listItems;
extern listItems appMPlayer;
extern listItems appTV;
extern listItems appRadio;
extern char * appMPlayerDirInHome;
extern char * appMPlayerDir;
extern char * skinDirInHome;
extern char * skinMPlayerDir;
extern void appInit( int argc,char* argv[], char *envp[] );
extern void appInitStruct( listItems * item );
extern void appClearItem( wItem * item );
extern void appCopy( listItems * item1,listItems * item2 );
extern int appFindMessage( unsigned char * str );
extern int appFindKey( unsigned char * name );
#endif
--- NEW FILE ---
#include <stdlib.h>
#include <stdio.h>
unsigned char * cfgAppName = "movieplayer";
unsigned char * cfgSkin = NULL;
void cfgDefaults( void )
{
if ( ( cfgSkin=(char *)calloc( 1,256 ) ) == NULL )
{
fprintf( stderr,"[config] Not enough memory.\n" );
exit( 1 );
}
strcpy( cfgSkin,"default" );
// strcpy( cfgSkin,"blueHeart" );
}
int cfgRead( void )
{
return 0;
}
--- NEW FILE ---
#ifndef __MYCONFIG
#define __MYCONFIG
extern unsigned char * cfgAppName;
extern unsigned char * cfgSkin;
extern int cfgRead( void );
extern void cfgDefaults( void );
#endif
--- NEW FILE ---
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "error.h"
int debug_level = 6;
FILE * debug_file;
int debug_stderr = 0;
void defaultErrorHandler( int critical,const char * format, ... )
{
char * p;
va_list ap;
if ( (p=(char *)malloc( 512 ) ) == NULL ) return;
va_start( ap,format );
vsnprintf( p,512,format,ap );
va_end( ap );
fprintf( stderr,"%s",p );
free( p );
if ( critical ) exit( 1 );
}
void defaultDebugHandler( int critical,const char * format, ... )
{
char * p;
va_list ap;
if ( critical >= debug_level ) return;
if ( (p=(char *)malloc( 512 ) ) == NULL ) return;
va_start( ap,format );
vsnprintf( p,512,format,ap );
va_end( ap );
fprintf( debug_file,"%s",p );
free( p );
}
errorTHandler message = defaultErrorHandler;
errorTHandler dbprintf = defaultDebugHandler;
void initDebug( char * name )
{
if ( name )
{
if ( ( debug_file=fopen( name,"wt+" ) ) != NULL )
{
debug_stderr=0;
return;
}
}
debug_file=stderr;
debug_stderr=1;
}
void doneDebug( void )
{
if ( !debug_stderr ) fclose( debug_file );
debug_file=stderr;
debug_stderr=1;
}
--- NEW FILE ---
#ifndef _MPLAYER_ERROR_HANDLER
#define _MPLAYER_ERROR_HANDLER
#define True 1
#define False 0
// 0 - standard message
// 1 - detto
// 2 - events
// 3 - skin reader messages
// 4 - bitmap reader messages
// 5 - signal handling messages
// 6 - gtk messages
typedef void (*errorTHandler)( int critical,const char * format, ... );
extern errorTHandler message;
extern errorTHandler dbprintf;
#endif
--- NEW FILE ---
#include "events.h"
evName evNames[] =
{
{ evNone, "evNone" }, // 1
{ evPlay, "evPlay" }, // 2
{ evStop, "evStop" }, // 3
{ evPause, "evPause" }, // 4
{ evPrev, "evPrev" }, // 7
{ evNext, "evNext" }, // 8
{ evLoad, "evLoad" }, // 9
{ evEqualeaser, "evEqualeaser" }, // 10
{ evPlayList, "evPlaylist" }, // 11
{ evExit, "evExit" }, // 12
{ evPlusVideo, "evPlusVideo" }, // 13
{ evMinusVideo, "evMinusVideo" }, // 14
{ evIconify, "evIconify" }, // 15
{ evPlusBalance, "evPlusBalance" }, // 16
{ evMinusBalance, "evMinusBalance" }, // 17
{ evFullScreen, "evFullScreen" }, // 18
{ evFName, "evFName" }, // 19
{ evMovieTime, "evMovieTime" }, // 20
{ evAbout, "evAbout" }, // 22
{ evLoadPlay, "evLoadPlay" }, // 23
{ evPreferences, "evPreferences" }, // 24
{ evSkinBrowser, "evSkinBrowser" }, // 25
{ evBackward10sec, "evBackward10sec" }, // 26
{ evForward10sec, "evForward10sec" }, // 27
{ evBackward1min, "evBackward1min" }, // 28
{ evForward1min, "evForward1min" }, // 29
{ evIncVolume, "evIncVolume" }, // 30
{ evDecVolume, "evDecVolume" }, // 31
{ evMute, "evMute" }, // 32
{ evIncAudioBufDelay, "evIncAudioBufDelay" }, // 33
{ evDecAudioBufDelay, "evDecAudioBufDelay" }, // 34
{ evPlaySwitchToPause, "evPlaySwitchToPause" }, // 35
{ evPauseSwitchToPlay, "evPauseSwitchToPlay" }, // 36
{ evNormalSize, "evNormalSize" }, // 37
{ evDoubleSize, "evDoubleSize" }, // 38
{ evSetMoviePosition, "evSetMoviePosition" }, // 39
{ evSetVolume, "evSetVolume" }, // 40
{ evSetBalance, "evSetBalance" } // 41
};
const int evBoxs = sizeof( evNames ) / sizeof( evName );
--- NEW FILE ---
#ifndef _MYEVENTHANDLER
#define _MYEVENTHANDLER
// --- User events ------
#define evNone 0
#define evPlay 1
#define evStop 2
#define evPause 3
#define evPrev 6
#define evNext 7
#define evLoad 8
#define evEqualeaser 9
#define evPlayList 10
#define evPlusVideo 11
#define evMinusVideo 12
#define evIconify 13
#define evPlusBalance 14
#define evMinusBalance 15
#define evFullScreen 16
#define evAbout 18
#define evLoadPlay 19
#define evPreferences 20
#define evSkinBrowser 21
#define evBackward10sec 22
#define evForward10sec 23
#define evBackward1min 24
#define evForward1min 25
#define evIncVolume 26
#define evDecVolume 27
#define evMute 28
#define evIncAudioBufDelay 29
#define evDecAudioBufDelay 30
#define evPlaySwitchToPause 31
#define evPauseSwitchToPlay 32
#define evNormalSize 33
#define evDoubleSize 34
#define evSetMoviePosition 35
#define evSetVolume 36
#define evSetBalance 37
#define evExit 1000
// --- General events ---
#define evFileLoaded 5000
#define evHideMouseCursor 5001
#define evMessageBox 5002
#define evGeneralTimer 5003
#define evGtkIsOk 5004
#define evFName 7000
#define evMovieTime 7001
#define evRedraw 7002
#define evHideWindow 7003
#define evShowWindow 7004
// ----------------------
typedef struct
{
int msg;
char * name;
} evName;
extern int evBoxs;
extern evName evNames[];
#endif
--- NEW FILE ---
SKINSRC = skin/skin.c skin/font.c skin/cut.c
SKINOBJ = skin/skin.o skin/font.o skin/cut.o
MPLAYERSRCS = $(MPLAYERDIR)mplayer.c $(MPLAYERDIR)widgets.c $(MPLAYERDIR)play.c \
$(MPLAYERDIR)psignal.c $(MPLAYERDIR)mixer.c
MPLAYEROBJS = $(MPLAYERSRCS:.c=.o)
SRCS = $(SKINSRC) $(BITMAPSRCS) wm/ws.c wm/wsconv.c app.c config.c events.c timer.c language.c error.c shmem.c
OBJS = $(SRCS:.c=.o)
--- NEW FILE ---
// --- labels ---
char * langAbout = "About";
char * langFileSelect = "Select file ...";
char * langMessageBox = "MessageBox";
char * langPlayList = "PlayList";
char * langSkinBrowser = "Skin Browser";
// --- buttons ---
char * langOk = "Ok";
char * langCancel = "Cancel";
char * langAdd = "Add";
char * langRemove = "Remove";
// --- error messages ---
char * langNEMDB = "Sorry, not enough memory for draw buffer.";
char * langNEMFMR = "Sorry, not enough memory for menu rendering.";
char * langNEMFMM = "Sorry, not enough memory for main window shape mask.";
char * langLIRCSNW = "LIRC support not working. Disabled.";
char * langAudioDriverSelectNotSupported = "Your audio driver DOES NOT support select(). Recompile mplayer with #undef HAVE_AUDIO_SELECT in config.h !";
char * langNotSupportedFileFormat = "Sorry, this file format not recognized/supported. If this file is an AVI, ASF or MPEG stream, please contact the author!";
char * langCodecConfNotFound = "The codecs.conf config file not found. Please copy/link DOCS/codecs.conf to ~/.mplayer/codecs.conf.";
char * langErrorProcessingDVDKey = "Error processing DVD KEY.";
char * langErrorInDVDAuth = "Error in DVD authentication.";
char * langAVIMissing = "AVI_NI: missing video stream!? contact the author, it may be a bug. :(";
char * langAVIMissingVideoStream = "AVI: missing video stream!? contact the author, it may be a bug. :(";
char * langASFMissingVideoStream = "ASF: missing video stream!? contact the author, it may be a bug. :(";
char * langMPEGEOFNotFound = "MPEG: FATAL: EOF while searching for sequence header.";
char * langCannotAllocateSharedMem = "Cannot allocate shared memory. ( Not enough memory ? )";
char * langMPEGCannotReadSeqHeader = "MPEG: FATAL: Cannot read sequence header!";
char * langMPEGBadSeqHeader = "MPEG: Bad sequence header!";
char * langMPEGCannotReadSeqHeaderExt = "MPEG: FATAL: Cannot read sequence header extension!";
char * langMPEGBadSeqHeaderExt = "MPEG: Bad sequence header extension!";
char * langCantFindCodec = "Can't find codec for video format";
char * langSelectedVideoOutIncompTheCodec = "Sorry, selected video_out device is incompatible with this codec.";
char * langMPCompWithoutDSSupport = "MPlayer was compiled WITHOUT directshow support!";
char * langDSCodecNotFound = "ERROR: Couldn't open required DirectShow codec: %s. " \
"Maybe you forget to upgrade your win32 codecs?? It's time to download the new " \
"package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip! " \
"Or you should disable DShow support.";
char * langCantInitVideoDriver = "FATAL: Cannot initialize video driver!";
char * langUnknowError = "Unknow error. Please contact the developer team.";
--- NEW FILE ---
#ifndef __MPLAYER_LANG
#define __MPLAYER_LANG
// --- labels ---
extern char * langAbout;
extern char * langFileSelect;
extern char * langMessageBox;
extern char * langPlayList;
extern char * langSkinBrowser;
// --- buttons ---
extern char * langOk;
extern char * langCancel;
extern char * langAdd;
extern char * langRemove;
// --- error messages ---
extern char * langNEMDB;
extern char * langNEMFMR;
extern char * langNEMFMM;
extern char * langLIRCSNW;
extern char * langAudioDriverSelectNotSupported;
extern char * langNotSupportedFileFormat;
extern char * langCodecConfNotFound;
extern char * langErrorProcessingDVDKey;
extern char * langErrorInDVDAuth;
extern char * langAVIMissing;
extern char * langAVIMissingVideoStream;
extern char * langASFMissingVideoStream;
extern char * langMPEGEOFNotFound;
extern char * langCannotAllocateSharedMem;
extern char * langMPEGCannotReadSeqHeader;
extern char * langMPEGBadSeqHeader;
extern char * langMPEGCannotReadSeqHeaderExt;
extern char * langMPEGBadSeqHeaderExt;
extern char * langCantFindCodec;
extern char * langSelectedVideoOutIncompTheCodec;
extern char * langMPCompWithoutDSSupport;
extern char * langDSCodecNotFound;
extern char * langCantInitVideoDriver;
extern char * langUnknowError;
#endif
--- NEW FILE ---
/*
* shmem.c - Shared memory allocation
*
* based on mpg123's xfermem.c by
* Oliver Fromme <oliver.fromme at heim3.tu-clausthal.de>
* Sun Apr 6 02:26:26 MET DST 1997
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <fcntl.h>
#ifdef AIX
#include <sys/select.h>
#endif
#include <sys/ipc.h>
#include <sys/shm.h>
extern int errno;
#if defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
#define MAP_ANON MAP_ANONYMOUS
#endif
static int shmem_type=0;
void* shmem_alloc(int size){
void* p;
static int devzero = -1;
while(1){
switch(shmem_type){
case 0: // ========= MAP_ANON|MAP_SHARED ==========
#ifdef MAP_ANON
p=mmap(0,size,PROT_READ|PROT_WRITE,MAP_ANON|MAP_SHARED,-1,0);
if(p==MAP_FAILED) break; // failed
// printf("shmem: %d bytes allocated using mmap anon (%X)\n",size,p);
return p;
#else
// system does not support MAP_ANON at all (e.g. solaris 2.5.1/2.6), just fail
break;
#endif
case 1: // ========= MAP_SHARED + /dev/zero ==========
if (devzero == -1 && (devzero = open("/dev/zero", O_RDWR, 0)) == -1) break;
p=mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,devzero,0);
if(p==MAP_FAILED) break; // failed
// printf("shmem: %d bytes allocated using mmap /dev/zero (%X)\n",size,p);
return p;
case 2: { // ========= shmget() ==========
struct shmid_ds shmemds;
int shmemid;
if ((shmemid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0600)) == -1) break;
if ((int)(p = shmat(shmemid, 0, 0)) == -1){
perror ("shmat()");
shmctl (shmemid, IPC_RMID, &shmemds);
break;
}
if (shmctl(shmemid, IPC_RMID, &shmemds) == -1) {
perror ("shmctl()");
if (shmdt(p) == -1) perror ("shmdt()");
break;
}
// printf("shmem: %d bytes allocated using shmget() & shmat() (%X)\n",size,p);
return p;
}
default:
printf("FATAL: Cannot alloate %d bytes shared memory :(\n",size);
return NULL;
}
++shmem_type;
}
}
void shmem_free(void* p){
switch(shmem_type){
case 2:
if (shmdt(p) == -1) perror ("shmdt()");
break;
}
}
--- NEW FILE ---
void* shmem_alloc(int size);
void shmem_free(void* p);
--- NEW FILE ---
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include "timer.h"
static struct itimerval it;
static struct sigaction sa;
timerTSigHandler timerSigHandler;
void timerSetHandler( timerTSigHandler handler )
{ timerSigHandler=handler; }
void timerInit( void )
{
sa.sa_handler=timerSigHandler;
sa.sa_flags=SA_RESTART;
sigemptyset( &sa.sa_mask );
sigaction( SIGALRM,&sa,NULL );
it.it_interval.tv_sec=0;
it.it_interval.tv_usec=20000;
it.it_value.tv_sec=0;
it.it_value.tv_usec=50000;
setitimer( ITIMER_REAL,&it,NULL );
}
void timerDone( void )
{
it.it_interval.tv_sec=0;
it.it_interval.tv_usec=0;
it.it_value.tv_sec=0;
it.it_value.tv_usec=0;
setitimer( ITIMER_REAL,&it,NULL );
}
--- NEW FILE ---
#ifndef __MYTIMER
#define __MYTIMER
typedef void (* timerTSigHandler)( int signum );
extern timerTSigHandler timerSigHandler;
extern void timerSetHandler( timerTSigHandler handler );
extern void timerInit( void );
extern void timerDone( void );
#endif;
More information about the MPlayer-cvslog
mailing list