wine/multimedia/mcianim.c
Alexandre Julliard bd34d4ff41 Release 950620
Mon Jun 19 20:29:50 1995  Alexandre Julliard  (julliard@sunsite.unc.edu)

	* [debugger/*.c]
	Modified debugger to use segmented pointers everywhere.

	* [if1632/shell.spec] [if1632/sound.spec] [if1632/user.spec]
	Declared all functions that return only 16-bit as 'pascal16'.

	* [include/ldt.h] [memory/ldt.c]
	Export LDT_EntryToBytes (new) and LDT_BytesToEntry for DPMI.
	Maintain a copy of the selector flags, removing the need to make a
	system call to retrieve an LDT entry.

	* [loader/module.c]
	Fixed bug with module file handle cache.

	* [loader/ne_resource.c]
	Fixed file name bug in NE_AccessResource().

	* [loader/resource.c]
	Fixed bug in LoadIcon() that caused wrong colors to be used for
	the icon mask.

	* [loader/signal.c]
	Moved instruction emulation to miscemu/instr.c.

	* [misc/dos_fs.c] [miscemu/int21.c]
	Lots of small fixes, thanks to Morten Welinder.

	* [miscemu/dpmi.c]
	More complete DPMI emulation.

	* [miscemu/instr.c]
	Added support for prefixes in instructions to emulate.

	* [miscemu/int2f.c]
	Use register macros instead of destroying the high part of 32-bit
	registers.

	* [objects/dc.c]
	Fixed bug in GetDCState() that failed to clear the new DC.

	* [rc/sysres.rc]
	Removed dialogs 11 and 12 that were never used.

	* [tools/build.c]
	'pascal16' generated functions did not save %dx.
	Removed use of %fs to access the stack.
	%ds is no longer initialized before calling a 16-bit routine.

	* [windows/defwnd.c]
	Accept a NULL pointer as window title.

	* [windows/mdi.c]
	MDICascade: skip iconic windows.
	Implemented CalcChildScroll().
	
	* [windows/utility.c]
	Fixed MulDiv() for illegal values.

	* [windows/win.c]
	Fixed X error in CreateWindowEx() when WM_NCCALCSIZE returned
	a zero width or height.

Sun Jun 18 22:22:30 MET DST 1995  Fons Botman  (botman@inter.nl.net)

	* [controls/edit.c]
	Fixed "uninitalized" message which -Wall couldnt see to be ok
	in EDIT_WriteText.

	* [include/debug.h]
	Added define for extra checks in API definitions during debugging.

	* [loader/ne_image.c]
	Added newline in NE_FixupPrologs to avoid long lines.

	* [misc/dos_fs.c]
	Added extra safety check in DOS_ValidDrive.

	* [misc/exec.c]
	Fixed definition of ExitWindows.
	
Sun Jun 18 21:16:08 1995   Bernd Schmidt <crux@pool.informatik.rwth-aachen.de>

	* [controls/edit.c]
	Some fixes, mostly for memory management, but also for text selection
	and tab postitions. General cleanup. Notepad.exe now works.

	* [controls/combo.c]
	Fix: the hwnd field of the DRAWITEMSTRUCT should always be that of
	the combo box, not the ComboLBox that belongs to it.

	* [controls/listbox.c]
	Handle itemID field correctly throughout.

	* [memory/local.c]
	Implemented flag LMEM_ZEROINIT.
	LocalReAlloc() could trash the heap. Fixed.

	* [objects/font.c]
	FONT_MatchFont(): don't get confused by negative widths.
	Fixed a segfault in EnumFonts().

	* [objects/text.c]
	DrawText(): DT_CALCRECT implies DT_NOCLIP.

	* [objects/dcvalues.c]
	MAKELONG was used with bad parameters in DC_GET_X_Y.

	* [windows/dialog.c]
	Don't show the dialog if WS_VISIBLE isn't set in the template.

	* [windows/utility.c]
	UTILITY_convertArgs(): Never pass an expression containing ++ into a
	macro...

	* [windows/win.c]
	SetParent() should unlink the window before changing the parent.

	* [windows/message.c]
	Don't call timer functions via CallWindowProc(), since it checks
	whether hwnd==0 and does not call the function in that case.

	* [miscemu/instr.c]
	Ignore interrupt 0x3D, for VBRUN300.DLL.

	* [misc/commdlg.c]
	Don't rely on the itemData field of the DRAWITEMSTRUCT to contain a
	pointer to the item text.

	* [if1632/relay.c]
	Disable OLE and DDEML DLLs by default, since they contain nothing but
	stubs anyway. SHELL, COMMDLG and WIN87EM are left enabled, although
	some programs may work better without them.
	
	* [multimedia/*.c] [include/multimedia.h] [include/driver.h]
	Begun cleaning things up a little. Replaced printfs with dprintf_
	macros, made functions static where possible, and some other minor
	changes.

Sun Jun 11 23:19:10 1995  Martin von Loewis  <martin@informatik.hu-berlin.de>

	* [debugger/dbg.y][debugger/dbg.l]
	Removed special handling for FILE_IDENTIFER, because it caused
	problems with x/<format> statements.

	* [debugger/info.c]
	Use SC_ESP instead of SC_EIP for stack dump.

	* [misc/compobj.c][if1632/compobj.spec]
	CoBuildVersion, CoInitialize, CoUninitialize: new functions

	* [misc/ole2.c][if1632/ole2.spec][misc/Imakefile][include/ole2.h]
	New files ole2.c, ole2.h
	OleBuildVersion, OleInitialize, OleUninitialize: new functions

	* [if1632/ole2disp.spec]
	Added missing ordinals above 109

	* [misc/ole2nls.c][if1632/ole2nls.spec][include/winnls.h]
	New file winnls.h
	GetLocaleInfoA: new function

	* [if1632/shell.spec]
	Added FindEnvironmentString as stub

	* [misc/olecli.c][if1632/olecli.spec]
	OleIsDcMeta: New function

	* [objects/font][misc/gdi.spec]
	GetKerningPairs: new function

	* [misc/shell.c]
	ShellExecute: Implemented support for starting programs

	* [if1632/user.spec]
	Inserted missing relay to GetClipCursor

Sun Jun 11 20:34:47 1995   Bernd Schmidt <crux@pool.informatik.rwth-aachen.de>
        
	* [controls/edit.c]
	Fix a problem with the local heap.

	* [include/wintypes.h]
	Fixed wrong declarations of CATCHBUF and LPCATCHBUF.
	
	* [include/mdi.h] [windows/mdi.c]
	This code still assumed segmented address==linear address. Fixed.

	* [include/msdos.h] [misc/dos_fs.c]
	The filemask field of the dosdirent structure could be overrun. Fixed.
	If you had a file called foobar and a file called foo, trying to 
	FindFile(foo) could accidentally find file foobar instead. Fixed.
	
	* [misc/file.c]
	OpenFile(): Always return the full pathname in ofs->szPathName. This 
	also fixes GetModuleFilename().
	Prevent _lclose() from closing stderr or stdout.

	* [misc/profile.c]
	Search for .ini files in the path of the current module as well.
	(Needed by Lotus Organizer.)

	* [loader/task.c] [loader/ne_image.c] [loader/module.c]
	[memory/local.c]
	Local heaps are now initialized by InitTask() for executables. DLLs
	have to call LocalInit() themselves, LocalInit() has to put the
	heap at the end of the segment when called with start==0. We no longer
	allocate the DGROUP with 64k on startup, but grow the local heap
	in LOCAL_GetBlock() when necessary.

        * [loader/module.c]
	LoadLibrary() should call LoadModule() in all cases, even if the
	DLL is already loaded, to ensure that the reference count is correct.

	* [loader/ne_image.c]
	Some changes to function prolog fixup. Does anyone know exactly how
	this is supposed to work? I am only guessing here.
	In NE_InitializeDLLs(), initialize the DLLs a module refers to before
	the module itself.
	
        * [loader/task.c]
	Initialize instance data at the beginning of the DGROUP in InitTask().

	* [memory/local.c]
	Some fixes for moveable blocks.

	* [memory/selector.c]
	All the IsBad*Pointer() functions returned exactly the wrong boolean
	value in all cases!
	
	* [objects/bitblt.c]
	Fixed another null pointer dereference in debugging output.
	
	* [objects/font.c]
	Some more recovery possibilities for FONT_MatchFont() if a specified
	font does not exist.
	
	* [windows/win.c]
	The dialog code may call CreateWindowEx with an integer in windowName.
	This happens for static icon controls that expect a resource ID as
	the window name. CreateWindowEx() used to crash. Fixed.
	
	* [windows/class.c] [windows/win.c]
	Window classes are owned by modules, not instances. Changed
	RegisterClass(), UnregisterClass(), GetClassInfo() and CreateWindowEx()
	accordingly.

Sat Jun 10 16:10:53 1995  Olaf Flebbe <o.flebbe@science-computing.uni-tuebingen.de>

	* [miscemu/int21.c]
	  clock.exe was displaying incorrect year.

Fri Jun 9 20:36:56 1995  Victor Schneider <tailor@crl.com>

	* [include/cursor.h] [windows/cursor.c]
	Implemented CreateCursorIconIndirect().
1995-06-20 19:08:12 +00:00

680 lines
21 KiB
C

/*
* Sample MCI ANIMATION Wine Driver for Linux
*
* Copyright 1994 Martin Ayotte
*/
#ifndef WINELIB
#define BUILTIN_MMSYSTEM
#endif
#ifdef BUILTIN_MMSYSTEM
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "windows.h"
#include "user.h"
#include "driver.h"
#include "mmsystem.h"
#include "stddebug.h"
#include "debug.h"
#define MAX_ANIMDRV 2
#define ANIMFRAMES_PERSEC 30
#define ANIMFRAMES_PERMIN 1800
#define SECONDS_PERMIN 60
#ifdef linux
typedef struct {
int nUseCount; /* Incremented for each shared open */
BOOL fShareable; /* TRUE if first open was shareable */
WORD wNotifyDeviceID; /* MCI device ID with a pending notification */
HANDLE hCallback; /* Callback handle for pending notification */
MCI_OPEN_PARMS openParms;
DWORD dwTimeFormat;
int mode;
UINT nCurTrack;
DWORD dwCurFrame;
UINT nTracks;
DWORD dwTotalLen;
LPDWORD lpdwTrackLen;
LPDWORD lpdwTrackPos;
} LINUX_ANIM;
static LINUX_ANIM AnimDev[MAX_ANIMDRV];
#endif
/*-----------------------------------------------------------------------*/
/**************************************************************************
* ANIM_mciOpen [internal]
*/
static DWORD ANIM_mciOpen(UINT wDevID, DWORD dwFlags, LPMCI_OPEN_PARMS lpParms)
{
#ifdef linux
LPSTR lpstrElementName;
char str[128];
dprintf_mcianim(stddeb,"ANIM_mciOpen(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (AnimDev[wDevID].nUseCount > 0) {
/* The driver already open on this channel */
/* If the driver was opened shareable before and this open specifies */
/* shareable then increment the use count */
if (AnimDev[wDevID].fShareable && (dwFlags & MCI_OPEN_SHAREABLE))
++AnimDev[wDevID].nUseCount;
else
return MCIERR_MUST_USE_SHAREABLE;
}
else {
AnimDev[wDevID].nUseCount = 1;
AnimDev[wDevID].fShareable = dwFlags & MCI_OPEN_SHAREABLE;
}
dprintf_mcianim(stddeb,"ANIM_mciOpen // wDevID=%04X\n", wDevID);
lpParms->wDeviceID = wDevID;
dprintf_mcianim(stddeb,"ANIM_mciOpen // lpParms->wDevID=%04X\n", lpParms->wDeviceID);
if (dwFlags & MCI_OPEN_ELEMENT) {
lpstrElementName = (LPSTR)PTR_SEG_TO_LIN(lpParms->lpstrElementName);
dprintf_mcianim(stddeb,"ANIM_mciOpen // MCI_OPEN_ELEMENT '%s' !\n",
lpstrElementName);
if (strlen(lpstrElementName) > 0) {
strcpy(str, lpstrElementName);
AnsiUpper(str);
}
}
memcpy(&AnimDev[wDevID].openParms, lpParms, sizeof(MCI_OPEN_PARMS));
AnimDev[wDevID].wNotifyDeviceID = lpParms->wDeviceID;
AnimDev[wDevID].mode = 0;
AnimDev[wDevID].dwTimeFormat = MCI_FORMAT_TMSF;
AnimDev[wDevID].nCurTrack = 0;
AnimDev[wDevID].nTracks = 0;
AnimDev[wDevID].dwTotalLen = 0;
AnimDev[wDevID].lpdwTrackLen = NULL;
AnimDev[wDevID].lpdwTrackPos = NULL;
if (dwFlags & MCI_NOTIFY) {
dprintf_mcianim(stddeb,
"ANIM_mciOpen // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* ANIM_mciClose [internal]
*/
static DWORD ANIM_mciClose(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
{
#ifdef linux
dprintf_mcianim(stddeb,"ANIM_mciClose(%u, %08lX, %p);\n",
wDevID, dwParam, lpParms);
if (AnimDev[wDevID].lpdwTrackLen != NULL) free(AnimDev[wDevID].lpdwTrackLen);
if (AnimDev[wDevID].lpdwTrackPos != NULL) free(AnimDev[wDevID].lpdwTrackPos);
#endif
return 0;
}
/**************************************************************************
* ANIM_mciGetDevCaps [internal]
*/
static DWORD ANIM_mciGetDevCaps(UINT wDevID, DWORD dwFlags,
LPMCI_GETDEVCAPS_PARMS lpParms)
{
#ifdef linux
dprintf_mcianim(stddeb,"ANIM_mciGetDevCaps(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (dwFlags & MCI_GETDEVCAPS_ITEM) {
dprintf_mcianim(stddeb,
"ANIM_mciGetDevCaps // MCI_GETDEVCAPS_ITEM dwItem=%08lX;\n",
lpParms->dwItem);
switch(lpParms->dwItem) {
case MCI_GETDEVCAPS_CAN_RECORD:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_HAS_AUDIO:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_HAS_VIDEO:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_DEVICE_TYPE:
lpParms->dwReturn = MCI_DEVTYPE_ANIMATION;
break;
case MCI_GETDEVCAPS_USES_FILES:
lpParms->dwReturn = TRUE;
break;
case MCI_GETDEVCAPS_COMPOUND_DEVICE:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_CAN_EJECT:
lpParms->dwReturn = TRUE;
break;
case MCI_GETDEVCAPS_CAN_PLAY:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_CAN_SAVE:
lpParms->dwReturn = FALSE;
break;
default:
return MCIERR_UNRECOGNIZED_COMMAND;
}
}
dprintf_mcianim(stddeb,
"ANIM_mciGetDevCaps // lpParms->dwReturn=%08lX;\n",
lpParms->dwReturn);
return 0;
#else
return MCIERR_INTERNAL;
#endif
}
/**************************************************************************
* ANIM_CalcTime [internal]
*/
static DWORD ANIM_CalcTime(UINT wDevID, DWORD dwFormatType, DWORD dwFrame)
{
DWORD dwTime = 0;
#ifdef linux
UINT wTrack;
UINT wMinutes;
UINT wSeconds;
UINT wFrames;
dprintf_mcianim(stddeb,"ANIM_CalcTime(%u, %08lX, %lu);\n",
wDevID, dwFormatType, dwFrame);
switch (dwFormatType) {
case MCI_FORMAT_MILLISECONDS:
dwTime = dwFrame / ANIMFRAMES_PERSEC * 1000;
dprintf_mcianim(stddeb,
"ANIM_CalcTime // MILLISECONDS %lu\n", dwTime);
break;
case MCI_FORMAT_MSF:
wMinutes = dwFrame / ANIMFRAMES_PERMIN;
wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC;
wFrames = dwFrame - ANIMFRAMES_PERMIN * wMinutes -
ANIMFRAMES_PERSEC * wSeconds;
dwTime = MCI_MAKE_MSF(wMinutes, wSeconds, wFrames);
dprintf_mcianim(stddeb,"ANIM_CalcTime // MSF %02u:%02u:%02u -> dwTime=%lu\n",
wMinutes, wSeconds, wFrames, dwTime);
break;
default:
/* unknown format ! force TMSF ! ... */
dwFormatType = MCI_FORMAT_TMSF;
case MCI_FORMAT_TMSF:
for (wTrack = 0; wTrack < AnimDev[wDevID].nTracks; wTrack++) {
/* dwTime += AnimDev[wDevID].lpdwTrackLen[wTrack - 1];
printf("Adding trk#%u curpos=%u \n", dwTime);
if (dwTime >= dwFrame) break; */
if (AnimDev[wDevID].lpdwTrackPos[wTrack - 1] >= dwFrame) break;
}
wMinutes = dwFrame / ANIMFRAMES_PERMIN;
wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC;
wFrames = dwFrame - ANIMFRAMES_PERMIN * wMinutes -
ANIMFRAMES_PERSEC * wSeconds;
dwTime = MCI_MAKE_TMSF(wTrack, wMinutes, wSeconds, wFrames);
dprintf_mcianim(stddeb,
"ANIM_CalcTime // %02u-%02u:%02u:%02u\n",
wTrack, wMinutes, wSeconds, wFrames);
break;
}
#endif
return dwTime;
}
/**************************************************************************
* ANIM_CalcFrame [internal]
*/
static DWORD ANIM_CalcFrame(UINT wDevID, DWORD dwFormatType, DWORD dwTime)
{
DWORD dwFrame = 0;
#ifdef linux
UINT wTrack;
dprintf_mcianim(stddeb,"ANIM_CalcFrame(%u, %08lX, %lu);\n",
wDevID, dwFormatType, dwTime);
switch (dwFormatType) {
case MCI_FORMAT_MILLISECONDS:
dwFrame = dwTime * ANIMFRAMES_PERSEC / 1000;
dprintf_mcianim(stddeb,
"ANIM_CalcFrame // MILLISECONDS %lu\n", dwFrame);
break;
case MCI_FORMAT_MSF:
dprintf_mcianim(stddeb,
"ANIM_CalcFrame // MSF %02u:%02u:%02u\n",
MCI_MSF_MINUTE(dwTime), MCI_MSF_SECOND(dwTime),
MCI_MSF_FRAME(dwTime));
dwFrame += ANIMFRAMES_PERMIN * MCI_MSF_MINUTE(dwTime);
dwFrame += ANIMFRAMES_PERSEC * MCI_MSF_SECOND(dwTime);
dwFrame += MCI_MSF_FRAME(dwTime);
break;
default:
/* unknown format ! force TMSF ! ... */
dwFormatType = MCI_FORMAT_TMSF;
case MCI_FORMAT_TMSF:
wTrack = MCI_TMSF_TRACK(dwTime);
dprintf_mcianim(stddeb,
"ANIM_CalcFrame // TMSF %02u-%02u:%02u:%02u\n",
MCI_TMSF_TRACK(dwTime), MCI_TMSF_MINUTE(dwTime),
MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime));
dprintf_mcianim(stddeb,
"ANIM_CalcFrame // TMSF trackpos[%u]=%lu\n",
wTrack, AnimDev[wDevID].lpdwTrackPos[wTrack - 1]);
dwFrame = AnimDev[wDevID].lpdwTrackPos[wTrack - 1];
dwFrame += ANIMFRAMES_PERMIN * MCI_TMSF_MINUTE(dwTime);
dwFrame += ANIMFRAMES_PERSEC * MCI_TMSF_SECOND(dwTime);
dwFrame += MCI_TMSF_FRAME(dwTime);
break;
}
#endif
return dwFrame;
}
/**************************************************************************
* ANIM_mciInfo [internal]
*/
static DWORD ANIM_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMS lpParms)
{
#ifdef linux
dprintf_mcianim(stddeb,"ANIM_mciInfo(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
lpParms->lpstrReturn = NULL;
switch(dwFlags) {
case MCI_INFO_PRODUCT:
lpParms->lpstrReturn = "Linux ANIMATION 0.5";
break;
case MCI_INFO_FILE:
lpParms->lpstrReturn =
(LPSTR)AnimDev[wDevID].openParms.lpstrElementName;
break;
case MCI_ANIM_INFO_TEXT:
lpParms->lpstrReturn = "Animation Window";
break;
default:
return MCIERR_UNRECOGNIZED_COMMAND;
}
if (lpParms->lpstrReturn != NULL)
lpParms->dwRetSize = strlen(lpParms->lpstrReturn);
else
lpParms->dwRetSize = 0;
return 0;
#else
return MCIERR_INTERNAL;
#endif
}
/**************************************************************************
* ANIM_mciStatus [internal]
*/
static DWORD ANIM_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
{
#ifdef linux
dprintf_mcianim(stddeb,"ANIM_mciStatus(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (dwFlags & MCI_NOTIFY) {
dprintf_mcianim(stddeb,
"ANIM_mciStatus // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
if (dwFlags & MCI_STATUS_ITEM) {
switch(lpParms->dwItem) {
case MCI_STATUS_CURRENT_TRACK:
lpParms->dwReturn = AnimDev[wDevID].nCurTrack;
dprintf_mcianim(stddeb,"ANIM_mciStatus // CURRENT_TRACK=%lu!\n", lpParms->dwReturn);
return 0;
case MCI_STATUS_LENGTH:
if (dwFlags & MCI_TRACK) {
dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_TRACK #%lu LENGTH=??? !\n",
lpParms->dwTrack);
if (lpParms->dwTrack > AnimDev[wDevID].nTracks)
return MCIERR_OUTOFRANGE;
lpParms->dwReturn = AnimDev[wDevID].lpdwTrackLen[lpParms->dwTrack];
}
else
lpParms->dwReturn = AnimDev[wDevID].dwTotalLen;
lpParms->dwReturn = ANIM_CalcTime(wDevID,
AnimDev[wDevID].dwTimeFormat, lpParms->dwReturn);
dprintf_mcianim(stddeb,"ANIM_mciStatus // LENGTH=%lu !\n", lpParms->dwReturn);
return 0;
case MCI_STATUS_MODE:
lpParms->dwReturn = AnimDev[wDevID].mode;
dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_MODE=%08lX !\n",
lpParms->dwReturn);
return 0;
case MCI_STATUS_MEDIA_PRESENT:
lpParms->dwReturn = TRUE;
dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_MEDIA_PRESENT !\n");
return 0;
case MCI_STATUS_NUMBER_OF_TRACKS:
lpParms->dwReturn = 1;
dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_NUMBER_OF_TRACKS = %lu !\n",
lpParms->dwReturn);
if (lpParms->dwReturn == (WORD)-1) return MCIERR_INTERNAL;
return 0;
case MCI_STATUS_POSITION:
lpParms->dwReturn = AnimDev[wDevID].dwCurFrame;
if (dwFlags & MCI_STATUS_START) {
lpParms->dwReturn = 0;
dprintf_mcianim(stddeb,"CDAUDIO_mciStatus // get MCI_STATUS_START !\n");
}
if (dwFlags & MCI_TRACK) {
if (lpParms->dwTrack > AnimDev[wDevID].nTracks)
return MCIERR_OUTOFRANGE;
lpParms->dwReturn = AnimDev[wDevID].lpdwTrackPos[lpParms->dwTrack - 1];
dprintf_mcianim(stddeb,"ANIM_mciStatus // get MCI_TRACK #%lu !\n", lpParms->dwTrack);
}
lpParms->dwReturn = ANIM_CalcTime(wDevID,
AnimDev[wDevID].dwTimeFormat, lpParms->dwReturn);
dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_POSITION=%08lX !\n",
lpParms->dwReturn);
return 0;
case MCI_STATUS_READY:
dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_READY !\n");
lpParms->dwReturn = TRUE;
return 0;
case MCI_STATUS_TIME_FORMAT:
dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_TIME_FORMAT !\n");
lpParms->dwReturn = MCI_FORMAT_MILLISECONDS;
return 0;
default:
fprintf(stderr,"ANIM_mciStatus // unknown command %08lX !\n", lpParms->dwItem);
return MCIERR_UNRECOGNIZED_COMMAND;
}
}
fprintf(stderr,"ANIM_mciStatus // not MCI_STATUS_ITEM !\n");
return 0;
#else
return MMSYSERR_NOTENABLED;
#endif
}
/**************************************************************************
* ANIM_mciPlay [internal]
*/
static DWORD ANIM_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
{
#ifdef linux
int start, end;
dprintf_mcianim(stddeb,"ANIM_mciPlay(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
start = 0; end = AnimDev[wDevID].dwTotalLen;
AnimDev[wDevID].nCurTrack = 1;
if (dwFlags & MCI_FROM) {
start = ANIM_CalcFrame(wDevID,
AnimDev[wDevID].dwTimeFormat, lpParms->dwFrom);
dprintf_mcianim(stddeb,"ANIM_mciPlay // MCI_FROM=%08lX -> %u \n",
lpParms->dwFrom, start);
}
if (dwFlags & MCI_TO) {
end = ANIM_CalcFrame(wDevID,
AnimDev[wDevID].dwTimeFormat, lpParms->dwTo);
dprintf_mcianim(stddeb,
"ANIM_mciPlay // MCI_TO=%08lX -> %u \n",
lpParms->dwTo, end);
}
AnimDev[wDevID].mode = MCI_MODE_PLAY;
if (dwFlags & MCI_NOTIFY) {
dprintf_mcianim(stddeb,
"ANIM_mciPlay // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* ANIM_mciStop [internal]
*/
static DWORD ANIM_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#ifdef linux
dprintf_mcianim(stddeb,"ANIM_mciStop(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
AnimDev[wDevID].mode = MCI_MODE_STOP;
if (dwFlags & MCI_NOTIFY) {
dprintf_mcianim(stddeb,
"ANIM_mciStop // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* ANIM_mciPause [internal]
*/
static DWORD ANIM_mciPause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#ifdef linux
dprintf_mcianim(stddeb,"ANIM_mciPause(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
AnimDev[wDevID].mode = MCI_MODE_PAUSE;
if (dwFlags & MCI_NOTIFY) {
dprintf_mcianim(stddeb,
"ANIM_mciPause // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* ANIM_mciResume [internal]
*/
static DWORD ANIM_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#ifdef linux
dprintf_mcianim(stddeb,"ANIM_mciResume(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
AnimDev[wDevID].mode = MCI_MODE_STOP;
if (dwFlags & MCI_NOTIFY) {
dprintf_mcianim(stddeb,
"ANIM_mciResume // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* ANIM_mciSeek [internal]
*/
static DWORD ANIM_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
{
#ifdef linux
DWORD dwRet;
MCI_PLAY_PARMS PlayParms;
dprintf_mcianim(stddeb,"ANIM_mciSeek(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
AnimDev[wDevID].mode = MCI_MODE_SEEK;
switch(dwFlags) {
case MCI_SEEK_TO_START:
PlayParms.dwFrom = 0;
break;
case MCI_SEEK_TO_END:
PlayParms.dwFrom = AnimDev[wDevID].dwTotalLen;
break;
case MCI_TO:
PlayParms.dwFrom = lpParms->dwTo;
break;
}
dwRet = ANIM_mciPlay(wDevID, MCI_WAIT | MCI_FROM, &PlayParms);
if (dwRet != 0) return dwRet;
dwRet = ANIM_mciStop(wDevID, MCI_WAIT, (LPMCI_GENERIC_PARMS)&PlayParms);
if (dwFlags & MCI_NOTIFY) {
dprintf_mcianim(stddeb,
"ANIM_mciSeek // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return dwRet;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* ANIM_mciSet [internal]
*/
static DWORD ANIM_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
{
#ifdef linux
dprintf_mcianim(stddeb,"ANIM_mciSet(%u, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
/*
printf("ANIM_mciSet // dwTimeFormat=%08lX\n", lpParms->dwTimeFormat);
printf("ANIM_mciSet // dwAudio=%08lX\n", lpParms->dwAudio);
*/
if (dwFlags & MCI_SET_TIME_FORMAT) {
switch (lpParms->dwTimeFormat) {
case MCI_FORMAT_MILLISECONDS:
dprintf_mcianim(stddeb,
"ANIM_mciSet // MCI_FORMAT_MILLISECONDS !\n");
break;
case MCI_FORMAT_MSF:
dprintf_mcianim(stddeb,"ANIM_mciSet // MCI_FORMAT_MSF !\n");
break;
case MCI_FORMAT_TMSF:
dprintf_mcianim(stddeb,"ANIM_mciSet // MCI_FORMAT_TMSF !\n");
break;
default:
fprintf(stderr,"ANIM_mciSet // bad time format !\n");
return MCIERR_BAD_TIME_FORMAT;
}
AnimDev[wDevID].dwTimeFormat = lpParms->dwTimeFormat;
}
if (dwFlags & MCI_SET_VIDEO) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_SET_ON) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_SET_OFF) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_NOTIFY) {
dprintf_mcianim(stddeb,
"ANIM_mciSet // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* ANIM_DriverProc [sample driver]
*/
LONG ANIM_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg,
DWORD dwParam1, DWORD dwParam2)
{
#ifdef linux
switch(wMsg) {
case DRV_LOAD:
return 1;
case DRV_FREE:
return 1;
case DRV_OPEN:
case MCI_OPEN_DRIVER:
case MCI_OPEN:
return ANIM_mciOpen(dwDevID, dwParam1,
(LPMCI_OPEN_PARMS)PTR_SEG_TO_LIN(dwParam2));
case DRV_CLOSE:
case MCI_CLOSE_DRIVER:
case MCI_CLOSE:
return ANIM_mciClose(dwDevID, dwParam1,
(LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case DRV_ENABLE:
return 1;
case DRV_DISABLE:
return 1;
case DRV_QUERYCONFIGURE:
return 1;
case DRV_CONFIGURE:
MessageBox((HWND)NULL, "Sample MultiMedia Linux Driver !",
"MMLinux Driver", MB_OK);
return 1;
case DRV_INSTALL:
return DRVCNF_RESTART;
case DRV_REMOVE:
return DRVCNF_RESTART;
case MCI_GETDEVCAPS:
return ANIM_mciGetDevCaps(dwDevID, dwParam1,
(LPMCI_GETDEVCAPS_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_INFO:
return ANIM_mciInfo(dwDevID, dwParam1,
(LPMCI_INFO_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_STATUS:
return ANIM_mciStatus(dwDevID, dwParam1,
(LPMCI_STATUS_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_SET:
return ANIM_mciSet(dwDevID, dwParam1,
(LPMCI_SET_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_PLAY:
return ANIM_mciPlay(dwDevID, dwParam1,
(LPMCI_PLAY_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_STOP:
return ANIM_mciStop(dwDevID, dwParam1,
(LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_PAUSE:
return ANIM_mciPause(dwDevID, dwParam1,
(LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_RESUME:
return ANIM_mciResume(dwDevID, dwParam1,
(LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_SEEK:
return ANIM_mciSeek(dwDevID, dwParam1,
(LPMCI_SEEK_PARMS)PTR_SEG_TO_LIN(dwParam2));
default:
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
}
#else
return MCIERR_HARDWARE;
#endif
}
/*-----------------------------------------------------------------------*/
#endif /* #ifdef BUILTIN_MMSYSTEM */