static BOOL Dart_Init(void) { MCI_AMP_OPEN_PARMS AmpOpenParms; MCI_GENERIC_PARMS GenericParms; MixBuffers[0].pBuffer = NULL; /* marker */ DeviceID = 0; memset(&GenericParms, 0, sizeof(MCI_GENERIC_PARMS)); /* open AMP device */ memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS)); AmpOpenParms.usDeviceID = 0; AmpOpenParms.pszDeviceType = (PSZ) MAKEULONG(MCI_DEVTYPE_AUDIO_AMPMIX, (USHORT) DeviceIndex); if (mciSendCommand(0, MCI_OPEN, MCI_WAIT | MCI_OPEN_SHAREABLE | MCI_OPEN_TYPE_ID, (PVOID) & AmpOpenParms, 0) != MCIERR_SUCCESS) { _mm_errno = MMERR_OPENING_AUDIO; return 1; } DeviceID = AmpOpenParms.usDeviceID; /* setup playback parameters */ memset(&MixSetupParms, 0, sizeof(MCI_MIXSETUP_PARMS)); MixSetupParms.ulBitsPerSample = (md_mode & DMODE_16BITS) ? 16 : 8; MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM; MixSetupParms.ulSamplesPerSec = md_mixfreq; MixSetupParms.ulChannels = (md_mode & DMODE_STEREO) ? 2 : 1; MixSetupParms.ulFormatMode = MCI_PLAY; MixSetupParms.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; MixSetupParms.pmixEvent = Dart_UpdateBuffers; if (mciSendCommand(DeviceID, MCI_MIXSETUP, MCI_WAIT | MCI_MIXSETUP_INIT, (PVOID) & MixSetupParms, 0) != MCIERR_SUCCESS) { _mm_errno = MMERR_OS2_MIXSETUP; return 1; } /* Compute audio buffer size now if necessary */ if (BufferSize == (ULONG)-1) { /* DART suggested buffer size is somewhat too big. We compute a size for circa 1/4" of playback. */ int bit; BufferSize = md_mixfreq >> 2; if (md_mode & DMODE_STEREO) BufferSize <<= 1; if (md_mode & DMODE_16BITS) BufferSize <<= 1; for (bit = 15; bit >= 12; bit--) if (BufferSize & (1 << bit)) break; BufferSize = (1 << bit); }
void OpenAudioDevice(HWND hwnd) { MCI_OPEN_PARMS lpWaveOpen; /* Used for MCI_OPEN messages */ ULONG ulReturn; /* Used for ret code for API */ /* * Initialize the MCI_OPEN_PARMS data structure with hwndMainDialogBox * as callback handle for MM_MCIPASSDEVICE, then issue the MCI_OPEN * command with the mciSendCommand function. No alias is used. */ lpWaveOpen.hwndCallback = hwnd; lpWaveOpen.pszAlias = (PSZ) NULL; /* * Open the correct waveform device with the MCI_OPEN message to MCI. * Use 0 instead of 1 because this will then use the default audio device. */ lpWaveOpen.pszDeviceType = (PSZ) (MAKEULONG(MCI_DEVTYPE_WAVEFORM_AUDIO,0)); /* * The address of the buffer which will record and play the wave. */ lpWaveOpen.pszElementName = (PSZ) &aplayList[0]; /* * Open the waveform file in the playlist mode. */ ulReturn = mciSendCommand(0, MCI_OPEN, MCI_WAIT | MCI_OPEN_PLAYLIST | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE, (PVOID) &lpWaveOpen, (USHORT) NULL); if (ulReturn != 0) { /* MCI Open was not successfull so show a message by passing a TRUE */ ShowAMessage( IDS_ERROR_TITLE, ulReturn, MB_OK | MB_INFORMATION | MB_MOVEABLE | MB_HELP | MB_APPLMODAL, TRUE); } /* Save the Device Id in the global variable to be used later */ usWaveDeviceId = lpWaveOpen.usDeviceID; }
static BOOL Dart_IsPresent(void) { MCI_AMP_OPEN_PARMS AmpOpenParms; MCI_GENERIC_PARMS GenericParms; memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS)); AmpOpenParms.pszDeviceType = (PSZ) MAKEULONG(MCI_DEVTYPE_AUDIO_AMPMIX, (USHORT) DeviceIndex); if (mciSendCommand(0, MCI_OPEN, MCI_WAIT | MCI_OPEN_SHAREABLE | MCI_OPEN_TYPE_ID, (PVOID) &AmpOpenParms, 0) != MCIERR_SUCCESS) return 0; mciSendCommand(AmpOpenParms.usDeviceID, MCI_CLOSE, MCI_WAIT, (PVOID) &GenericParms, 0); return 1; }
/*--------------------------------------------------------------------------------------*\ * Procedure to initialize HELP. * * Req: * * hab ........... Anchor block handle * * pHelpFile ..... A pointer to helppanel filename in SD/2 directory * * pHwndHelp .... A pointer to a HWND structure * * Returns: * * pHwndHelp ..... If called sucessfully/unsucessfully hwnd/NULL * \*--------------------------------------------------------------------------------------*/ BOOL WinStartHelp(HAB hab, UCHAR *pHelpFile, HWND *pHwndHelp) { HELPINIT HelpInit; HelpInit.cb=sizeof(HELPINIT); /* Size of HELPINIT structure */ HelpInit.ulReturnCode=0; /* Returnvalue from HelpManager */ HelpInit.pszTutorialName=NULL; /* No tutorial */ /* Ressource of Helptable */ HelpInit.phtHelpTable=(PHELPTABLE)MAKEULONG(MAIN_HELP_TABLE, 0xffff); /* Ressource in .EXE */ HelpInit.hmodHelpTableModule=NULLHANDLE; /* No handle */ HelpInit.hmodAccelActionBarModule=NULLHANDLE; HelpInit.idAccelTable=0; /* None */ HelpInit.idActionBar=0; /* None */ /* Window title of help window */ HelpInit.pszHelpWindowTitle="SD/2 - ShutDown/2 Help"; HelpInit.pszHelpLibraryName=pHelpFile; /* Library name of help panel via SD/2 directory */ HelpInit.fShowPanelId=0; /* Panel ID not displayed */ /* *\ * First assume ShutDown.HLP in HELP path and try to create it from there. * \* */ *pHwndHelp=WinCreateHelpInstance( /* Create help */ hab, /* Anchor block */ &HelpInit); /* Test for successful help creation */ if((*pHwndHelp) && (!HelpInit.ulReturnCode)) /* Associate HELP with frame window */ if(WinAssociateHelpInstance(*pHwndHelp, hwndFrame)!=FALSE) return(TRUE); /* *\ * Second assume ShutDown.HLP in SD/2's directory and try to create it from there. * \* */ HelpInit.ulReturnCode=0; /* Returnvalue from HelpManager */ /* Library name of help panel via HELP path */ HelpInit.pszHelpLibraryName="ShutDown.hlp"; *pHwndHelp=WinCreateHelpInstance(hab, &HelpInit); if((*pHwndHelp) && (!HelpInit.ulReturnCode)) if(WinAssociateHelpInstance(*pHwndHelp, hwndFrame)!=FALSE) return(TRUE); *pHwndHelp=NULLHANDLE; return(FALSE); }
/* checks for availability of an OS/2 MCI-WAVEAUDIO-device */ static BOOL OS2_IsPresent(void) { MCI_OPEN_PARMS mciOpenParms; MCI_GENERIC_PARMS mciGenericParms; memset(&mciOpenParms, 0, sizeof(mciOpenParms)); mciOpenParms.pszDeviceType = (PSZ) MAKEULONG(MCI_DEVTYPE_WAVEFORM_AUDIO, (USHORT) DeviceIndex); /* try to open WAVEAUDIO-device */ if (mciSendCommand(0, MCI_OPEN, MCI_WAIT | MCI_OPEN_SHAREABLE | MCI_OPEN_TYPE_ID, (PVOID) & mciOpenParms, 0) != MCIERR_SUCCESS) return 0; mciSendCommand(mciOpenParms.usDeviceID, MCI_CLOSE, MCI_WAIT, (PVOID) & mciGenericParms, 0); return 1; }
//************************************************************************************************ // The allmighty StartupThread //************************************************************************************************ void _Optlink StartupThread(void *pArg) { AnchorBlock ab; MessageQueue mq(ab); PINITDATA pinit = (PINITDATA)pArg; int i; USHORT usDeviceIndex = 0; // default use default deviceindex USHORT usVolume = 75; // default 75% volume ULONG ulError = 0; // mci error MCI_OPEN_PARMS mciOpenParms; BOOL fDeviceOpen = FALSE; //********************************************************************************************* // Set the lowest posible priority to make us systemfriendly //********************************************************************************************* DosSetPriority(PRTYS_THREAD, PRTYC_IDLETIME, PRTYD_MINIMUM, 0); //********************************************************************************************* // Clear some evetual garbage, just in case.... //********************************************************************************************* WinSetWindowPtr(pinit->hWnd, QWP_PLAYLIST, NULL); WinSetWindowPtr(pinit->hWnd, QWP_CURRENTENTRY, NULL); WinSetWindowULong(pinit->hWnd, QWL_PLAYLISTENTRIES, 0); WinSetWindowUShort(pinit->hWnd, QWS_DEVICEID, 0); WinSetWindowULong(pinit->hWnd, QWL_LOOP, 0); // do not loop by default //********************************************************************************************* // Parse the commandline //********************************************************************************************* for(i = 1; i < pinit->argc; i++) { switch(pinit->argv[i][0]) { case '/': case '-': switch(pinit->argv[i][1]) { case 'i': case 'I': usDeviceIndex = (USHORT)atoi(&pinit->argv[i][2]); break; case 'l': case 'L': WinSetWindowULong(pinit->hWnd, QWL_LOOP, 1); break; case 'v': case 'V': usVolume = (USHORT)atoi(&pinit->argv[i][2]); break; } break; default: AddToPlaylist(pinit->hWnd, pinit->argv[i]); break; } } // make sure we're at the first entry of the playlist WinSetWindowPtr(pinit->hWnd, QWP_CURRENTENTRY, WinQueryWindowPtr(pinit->hWnd, QWP_PLAYLIST)); //********************************************************************************************* // open the waveaudio device //********************************************************************************************* memset((void*)&mciOpenParms, 0, sizeof(mciOpenParms)); mciOpenParms.pszDeviceType = (PSZ)MAKEULONG(MCI_DEVTYPE_WAVEFORM_AUDIO, usDeviceIndex); ulError = mciSendCommand((USHORT)0, MCI_OPEN, MCI_WAIT | MCI_OPEN_TYPE_ID, (PVOID)&mciOpenParms, 0); if(LOUSHORT(ulError) == MCIERR_SUCCESS) { fDeviceOpen = TRUE; WinSetWindowUShort(pinit->hWnd, QWS_DEVICEID, mciOpenParms.usDeviceID); } if((fDeviceOpen == TRUE) && (WinQueryWindowULong(pinit->hWnd, QWL_PLAYLISTENTRIES) != 0)) { MCI_SET_PARMS msp; msp.ulLevel = usVolume; msp.ulAudio = MCI_SET_AUDIO_ALL; ulError = mciSendCommand(mciOpenParms.usDeviceID, MCI_SET, MCI_WAIT | MCI_SET_AUDIO | MCI_SET_VOLUME, (PVOID)&msp, 0); if(LOUSHORT(ulError) == MCIERR_SUCCESS) { WinSendMsg(WinWindowFromID(pinit->hWnd, SLRD_VOLUME), SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPFROMSHORT(usVolume)); WinEnableWindow(WinWindowFromID(pinit->hWnd, SLRD_VOLUME), TRUE); } if((BOOL)WinSendMsg(pinit->hWnd, WMU_LOAD, NULL, NULL)) { WinSendMsg(pinit->hWnd, WMU_PLAY, NULL, NULL); } } //********************************************************************************************* // free the initdata buffer //********************************************************************************************* delete pinit; // show the window SWP swp; ULONG pulBufferMax = sizeof(swp); if(PrfQueryProfileData(HINI_USERPROFILE, "WavePlayer", "WindowPosition", (PVOID)&swp, &pulBufferMax)) WinSetWindowPos(WinQueryWindow(pinit->hWnd, QW_PARENT), HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_SHOW | SWP_MOVE | SWP_SIZE); else WinShowWindow(WinQueryWindow(pinit->hWnd, QW_PARENT), TRUE); // bye, bye! _endthread(); }
int open_os2(audio_output_t *ao) { ULONG rc,i; char *temp; ULONG openflags; PPIB ppib; USHORT bits; if(maop.usDeviceID) return (maop.usDeviceID); if(!ai) return -1; if(!ao->device) ao->device = "0"; if(ao->rate < 0) ao->rate = 44100; if(ao->channels < 0) ao->channels = 2; if(ao->format < 0) ao->format = MPG123_ENC_SIGNED_16; if(ao->format == MPG123_ENC_SIGNED_16) bits = 16; else if(ao->format == MPG123_ENC_UNSIGNED_8) bits = 8; else return -1; /* open the mixer device */ memset (&maop, 0, sizeof(maop)); maop.usDeviceID = 0; maop.pszDeviceType = (PSZ) MAKEULONG(MCI_DEVTYPE_AUDIO_AMPMIX, atoi(ao->device)); openflags = MCI_WAIT | MCI_OPEN_TYPE_ID; if(!lockdevice) openflags |= MCI_OPEN_SHAREABLE; rc = mciSendCommand(0, MCI_OPEN, openflags, &maop, 0); if (ULONG_LOWD(rc) != MCIERR_SUCCESS) { MciError(rc); maop.usDeviceID = 0; return(-1); } /* volume in ao->gain ?? */ /* Set the MCI_MIXSETUP_PARMS data structure to match the audio stream. */ memset(&mmp, 0, sizeof(mmp)); mmp.ulBitsPerSample = bits; mmp.ulFormatTag = MCI_WAVE_FORMAT_PCM; mmp.ulSamplesPerSec = ao->rate; mmp.ulChannels = ao->channels; /* Setup the mixer for playback of wave data */ mmp.ulFormatMode = MCI_PLAY; mmp.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; mmp.pmixEvent = DARTEvent; rc = mciSendCommand( maop.usDeviceID, MCI_MIXSETUP, MCI_WAIT | MCI_MIXSETUP_INIT, &mmp, 0 ); if ( ULONG_LOWD(rc) != MCIERR_SUCCESS ) { MciError(rc); maop.usDeviceID = 0; return(-1); } volume = audio_set_volume(ai,volume); /* Set up the BufferParms data structure and allocate * device buffers from the Amp-Mixer */ memset(&mbp, 0, sizeof(mbp)); free(MixBuffers); free(bufferinfo); if(numbuffers < 5) numbuffers = 5; if(numbuffers > 200) numbuffers = 200; MixBuffers = calloc(numbuffers, sizeof(*MixBuffers)); bufferinfo = calloc(numbuffers, sizeof(*bufferinfo)); ulMCIBuffers = numbuffers; mbp.ulNumBuffers = ulMCIBuffers; /* mbp.ulBufferSize = mmp.ulBufferSize; */ /* I don't like this... they must be smaller than 64KB or else the engine needs major rewrite */ mbp.ulBufferSize = audiobufsize; mbp.pBufList = MixBuffers; rc = mciSendCommand( maop.usDeviceID, MCI_BUFFER, MCI_WAIT | MCI_ALLOCATE_MEMORY, (PVOID) &mbp, 0 ); if ( ULONG_LOWD(rc) != MCIERR_SUCCESS ) { MciError(rc); maop.usDeviceID = 0; return(-1); } pBufferplayed = playedbuffer.pBuffer = calloc(1,audiobufsize); ulMCIBuffers = mbp.ulNumBuffers; /* never know! */ /* Fill all device buffers with zeros and set linked list */ for(i = 0; i < ulMCIBuffers; i++) { MixBuffers[i].ulFlags = 0; MixBuffers[i].ulBufferLength = mbp.ulBufferSize; memset(MixBuffers[i].pBuffer, 0, MixBuffers[i].ulBufferLength); MixBuffers[i].ulUserParm = (ULONG) &bufferinfo[i]; bufferinfo[i].NextBuffer = &MixBuffers[i+1]; } bufferinfo[i-1].NextBuffer = &MixBuffers[0]; /* Create a semaphore to know when data has been played by the DART thread */ DosCreateEventSem(NULL,&dataplayed,0,FALSE); playingbuffer = &MixBuffers[0]; tobefilled = &MixBuffers[1]; playingframe = 0; nomoredata = TRUE; nobuffermode = FALSE; justflushed = FALSE; if(boostprio) { temp = alloca(strlen(boostprio)+1); strcpy(temp,boostprio); boostdelta = atoi(temp+1); *(temp+1) = 0; boostclass = atoi(temp); } if(boostclass > 4) boostdelta = 3; if(boostdelta > 31) boostdelta = 31; if(boostdelta < -31) boostdelta = -31; if(normalprio) { temp = alloca(strlen(normalprio)+1); strcpy(temp,normalprio); normaldelta = atoi(temp+1); *(temp+1) = 0; normalclass = atoi(temp); } if(normalclass > 4) normaldelta = 3; if(normaldelta > 31) normaldelta = 31; if(normaldelta < -31) normaldelta = -31; DosGetInfoBlocks(&mainthread,&ppib); /* ppib not needed, but makes some DOSCALLS.DLL crash */ DosSetPriority(PRTYS_THREAD,boostclass,boostdelta,mainthread->tib_ptib2->tib2_ultid); /* Write buffers to kick off the amp mixer. see DARTEvent() */ rc = mmp.pmixWrite( mmp.ulMixHandle, MixBuffers, ulMCIBuffers ); return maop.usDeviceID; }
int OpenDevice() { CHAR achBuffer[CCHMAXPATH] = ""; APIRET rc; MCI_AMP_OPEN_PARMS AmpOpenParms; MCI_CONNECTOR_PARMS ConnectorParms; MCI_AMP_SET_PARMS AmpSetParms ; MCI_GENERIC_PARMS GenericParms; int i; ULONG Action; ULONG Wrote; // Setup the open structure, pass the playlist and tell MCI_OPEN to use it memset(&AmpOpenParms,0,sizeof(AmpOpenParms)); AmpOpenParms.usDeviceID = ( USHORT ) 0; // AmpOpenParms.pszDeviceType = ( PSZ ) MCI_DEVTYPE_AUDIO_AMPMIX; AmpOpenParms.pszDeviceType = (PSZ) MAKEULONG(MCI_DEVTYPE_AUDIO_AMPMIX, device); rc = mciSendCommand(0, MCI_OPEN, MCI_WAIT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE, ( PVOID ) &AmpOpenParms, 0 ); if (ULONG_LOWD(rc) != MCIERR_SUCCESS) { mciGetErrorString( rc, (PSZ)achBuffer, sizeof( achBuffer)); cout << "Error #" << ULONG_LOWD(rc) << ": " << achBuffer << endl; goto Init_Err; } DeviceId = AmpOpenParms.usDeviceID; //Grab exclusive rights to device instance (NOT entire device) GenericParms.hwndCallback = 0; //Not needed, so set to 0 rc = mciSendCommand(DeviceId, MCI_ACQUIREDEVICE, MCI_EXCLUSIVE_INSTANCE, (PVOID)&GenericParms, 0); if (ULONG_LOWD(rc) != MCIERR_SUCCESS) { mciGetErrorString( rc, (PSZ)achBuffer, sizeof( achBuffer)); cout << "Error #" << ULONG_LOWD(rc) << ": " << achBuffer << endl; goto Init_Err; } /* Set the MixSetupParms data structure to match the loaded file. * This is a global that is used to setup the mixer. */ memset( &MixSetupParms, 0, sizeof( MCI_MIXSETUP_PARMS ) ); MixSetupParms.ulBitsPerSample = RecSettings.bits; MixSetupParms.ulSamplesPerSec = RecSettings.rate; MixSetupParms.ulFormatTag = RecSettings.format; MixSetupParms.ulChannels = RecSettings.numchan; /* Setup the mixer for playback of wave data */ MixSetupParms.ulFormatMode = MCI_RECORD; MixSetupParms.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; MixSetupParms.pmixEvent = MixHandler; rc = mciSendCommand( DeviceId, MCI_MIXSETUP, MCI_WAIT | MCI_MIXSETUP_INIT, ( PVOID ) &MixSetupParms, 0 ); if ( rc != MCIERR_SUCCESS ) { mciGetErrorString( rc, (PSZ)achBuffer, sizeof( achBuffer)); cout << "Error #" << hex << rc << ": " << achBuffer << endl; goto Init_Err; } /* Use the suggested buffer size provide by the mixer device * and the size of the audio file to calculate the required * number of Amp-Mixer buffers. */ ulNumBuffers = NUM_BUFFERS; /* * Set up the BufferParms data structure and allocate * device buffers from the Amp-Mixer */ MixSetupParms.ulBufferSize = ulBuffersize; BufferParms.ulNumBuffers = ulNumBuffers; BufferParms.ulBufferSize = MixSetupParms.ulBufferSize; BufferParms.pBufList = MixBuffers; for(i=0;i<NUM_BUFFERS;i++) { MixBuffers[i].ulUserParm = i; //nr of buffer (used in mixer.c) } rc = mciSendCommand( DeviceId, MCI_BUFFER, MCI_WAIT | MCI_ALLOCATE_MEMORY, ( PVOID ) &BufferParms, 0 ); if ( ULONG_LOWD( rc) != MCIERR_SUCCESS ) { goto Init_Err; } rc = wavfile.openWAV(filename, CREATE, RecSettings.rate, RecSettings.numchan, RecSettings.bits, RecSettings.format); if(rc) goto Init_Err; #if 0 rc = DosOpen(filename, /* file name from Open dialog */ &modin, /* file handle returned */ &Action, 0L, FILE_NORMAL, OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYWRITE, (PEAOP2)NULL); if(rc) goto Init_Err; //save settings to file DosWrite(modin, (char *)&RecSettings, sizeof(RecSettings), &Wrote); #endif /* Set the connector to 'line in' */ memset( &ConnectorParms, '\0', sizeof( MCI_CONNECTOR_PARMS ) ); ConnectorParms.ulConnectorType = MCI_LINE_IN_CONNECTOR; rc = mciSendCommand( DeviceId, MCI_CONNECTOR, MCI_WAIT | MCI_ENABLE_CONNECTOR | MCI_CONNECTOR_TYPE, ( PVOID ) &ConnectorParms, 0 ); /* Allow the user to hear what is being recorded * by turning the monitor on */ memset( &AmpSetParms, '\0', sizeof( MCI_AMP_SET_PARMS ) ); AmpSetParms.ulItem = MCI_AMP_SET_MONITOR; rc = mciSendCommand( DeviceId, MCI_SET, MCI_WAIT | MCI_SET_ON | MCI_SET_ITEM, ( PVOID ) &AmpSetParms, 0 ); return(TRUE); Init_Err: return(FALSE); }
RC MCIInfo (FUNCTION_PARM_BLOCK *pFuncBlock) { ULONG ulrc = MCIERR_SUCCESS; // Propogated Error Code ULONG ulParam1; // Message flags PMCI_INFO_PARMS pInfoParms; // Pointer to info structure PINSTANCE pInstance; // Pointer to instance /*****************************************************/ /* dereference the values from pFuncBlock */ /*****************************************************/ ulParam1 = pFuncBlock->ulParam1; pInstance = pFuncBlock->pInstance; pInfoParms = (PMCI_INFO_PARMS)pFuncBlock->pParam2; /**********************************************************/ /* Lock access to this instance until this command is done*/ /**********************************************************/ DosRequestMutexSem (pInstance->hmtxAccessSem, -2); // wait for semaphore switch (ulParam1 & MCD_INFO_FLAGS) { /**********************************************************/ /* Return a description of the hardware this device */ /* represents */ /**********************************************************/ case MCI_INFO_PRODUCT: if (pInfoParms->ulRetSize < MAX_PRODINFO) strncpy(pInfoParms->pszReturn, pInstance->szProductInfo, pInfoParms->ulRetSize); else strncpy(pInfoParms->pszReturn, pInstance->szProductInfo, MAX_PRODINFO); break; /**********************************************************/ /* Return the file name associated with this device */ /* instance */ /**********************************************************/ case MCI_INFO_FILE: if (pInfoParms->ulRetSize < MAX_FILE_NAME) strncpy(pInfoParms->pszReturn, pInstance->szFileName, pInfoParms->ulRetSize); else strncpy(pInfoParms->pszReturn, pInstance->szFileName, MAX_FILE_NAME); break; default: ulrc = MCIERR_UNSUPPORTED_FLAG; break; } /* Switch */ DosReleaseMutexSem (pInstance->hmtxAccessSem); // release semaphore /***************************************************************/ /* Send back a notification if the notify flag was on */ /* and no error */ /***************************************************************/ if ((ulParam1 & MCI_NOTIFY) & (!ulrc)) mdmDriverNotify (pInstance->usDeviceID, pInfoParms->hwndCallback, MM_MCINOTIFY, pFuncBlock->usUserParm, MAKEULONG (MCI_INFO, MCI_NOTIFY_SUCCESSFUL)); return (ulrc); } /* end of MCIInfo */
{"RWSP_MPFN", RWSP_MPFN, XDS_HEX}, {"RWSP_KPFN", RWSP_KPFN, XDS_HEX}, {"RWSP_MNAMI", RWSP_MNAMI, XDS_STR}, {"RWSP_MPFNI", RWSP_MPFNI, XDS_HEX}, {"RWSP_KORDI", RWSP_KORDI, XDS_DEC}, {"RWSP_KPFNI", RWSP_KPFNI, XDS_HEX}, {"RWSP_MNAMZ", RWSP_MNAMZ, XDS_STR}, {"RWSP_MPFNZ", RWSP_MPFNZ, XDS_HEX}, {"RWSP_KORDZ", RWSP_KORDZ, XDS_DEC}, {"RWSP_KPFNZ", RWSP_KPFNZ, XDS_HEX}, {0, 0, 0} }; PSZULNDX ArgList[] = { {"(none)", 0xffffffff, MAKEULONG(LIT_NONE, 0)}, {"RWSI_ASIS", RWSI_ASIS, XDS_HEX}, {"RWSI_PSTR", RWSI_PSTR, XDS_STR}, {"RWSI_PBUF", RWSI_PBUF, XDS_HEX}, {"RWSI_PPVOID", RWSI_PPVOID, XDS_HEX}, {"RWSI_OPATH", RWSI_OPATH, XDS_STR}, {"RWSI_OFTITLE", RWSI_OFTITLE, XDS_STR}, {"RWSI_OHNDL", RWSI_OHNDL, XDS_HEX}, {"RWSI_OHWND", RWSI_OHWND, XDS_HEX}, {"RWSI_OPREC", RWSI_OPREC, XDS_HEX}, {"RWSI_SFTITLE", RWSI_SFTITLE, XDS_STR}, {"RWSI_SHNDL", RWSI_SHNDL, XDS_HEX}, {"RWSI_SPREC", RWSI_SPREC, XDS_HEX}, {"RWSI_CNAME", RWSI_CNAME, XDS_STR}, {"RWSI_COBJ", RWSI_COBJ, XDS_HEX}, {"RWSI_COPATH", RWSI_COPATH, XDS_STR},
static int dart_init_sound (SINT16 *buffer) { int i, flags, device = 0; MCI_AMP_OPEN_PARMS AmpOpenParms; if ((bsize < BUF_MIN || bsize > BUF_MAX) && bsize != 0) { bsize = 16 * 1024; } else { bsize *= 1024; } MixBuffers[0].pBuffer = NULL; /* marker */ memset (&GenericParms,0,sizeof (MCI_GENERIC_PARMS)); /* open AMP device */ memset(&AmpOpenParms,0,sizeof(MCI_AMP_OPEN_PARMS)); AmpOpenParms.usDeviceID=0; AmpOpenParms.pszDeviceType = (PSZ) MAKEULONG (MCI_DEVTYPE_AUDIO_AMPMIX, (USHORT)device); flags = MCI_WAIT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE; if (mciSendCommand (0,MCI_OPEN, flags, (PVOID)&AmpOpenParms,0) != MCIERR_SUCCESS) { return -1; } DeviceID=AmpOpenParms.usDeviceID; /* setup playback parameters */ memset(&MixSetupParms,0,sizeof(MCI_MIXSETUP_PARMS)); MixSetupParms.ulBitsPerSample = 16; MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM; MixSetupParms.ulSamplesPerSec = 22050; MixSetupParms.ulChannels = 1; MixSetupParms.ulFormatMode = MCI_PLAY; MixSetupParms.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; MixSetupParms.pmixEvent = OS2_Dart_UpdateBuffers; if (mciSendCommand(DeviceID,MCI_MIXSETUP, MCI_WAIT | MCI_MIXSETUP_INIT, (PVOID)&MixSetupParms,0)!=MCIERR_SUCCESS) { mciSendCommand (DeviceID, MCI_CLOSE, MCI_WAIT, (PVOID)&GenericParms,0); return -1; } /* take in account the DART suggested buffer size... */ if( bsize == 0 ) { bsize=MixSetupParms.ulBufferSize; } BufferParms.ulNumBuffers = BUFFERCOUNT; BufferParms.ulBufferSize = bsize; BufferParms.pBufList = MixBuffers; if (mciSendCommand (DeviceID, MCI_BUFFER, MCI_WAIT | MCI_ALLOCATE_MEMORY, (PVOID)&BufferParms,0) != MCIERR_SUCCESS) { mciSendCommand (DeviceID, MCI_CLOSE, MCI_WAIT, (PVOID)&GenericParms,0); return -1; } for (i = 0 ; i < BUFFERCOUNT ; i++ ) { MixBuffers[i].ulBufferLength = bsize; } /* Start Playback */ memset (MixBuffers[0].pBuffer, /*32767*/0, bsize); memset (MixBuffers[1].pBuffer, /*32767*/0, bsize); MixSetupParms.pmixWrite (MixSetupParms.ulMixHandle,MixBuffers,2); return 0; }
ULONG ConnectToAmp( INSTANCE *ulpInstance, MMDRV_OPEN_PARMS *pDrvOpenParams, ULONG ulOpenFlags ) { ULONG ulDeviceTypeID; // device id of connected device ULONG ulrc; // return code variable // ULONG ulHoldError; USHORT usConnLength; // length of conn struct MCI_AMP_OPEN_PARMS MCIAmpOpenParms; // MCI AmpMixer Open Parameters DEFAULTCONNECTIONS2 DefCon; // MCI Connections Block // SPCB tempspcb; MMAUDIOHEADER mmaudioheader; VSD_AUDIOOPEN_PARMS vsdOpen; CONCB concb; /* Inform the amp how we wish to initialize the device */ memmove( &mmaudioheader, &ulpInstance->mmAudioHeader, sizeof( MMAUDIOHEADER )); vsdOpen.pHeader = ( PVOID) &mmaudioheader; vsdOpen.ulFlags = VSD_AUDIO_OPEN; vsdOpen.ulReserved2 = (ULONG) &concb; /***************************** * Obtain WaveAudio Device ID *****************************/ ulpInstance->usWaveDeviceID = pDrvOpenParams->usDeviceID; ulDeviceTypeID = MAKEULONG ( MCI_DEVTYPE_WAVEFORM_AUDIO, pDrvOpenParams->usDeviceOrd); /****************************************************** * Ensure that the INI file contains the right device id ******************************************************/ if ( pDrvOpenParams->usDeviceType != MCI_DEVTYPE_WAVEFORM_AUDIO ) { return ( MCIERR_INI_FILE ); } usConnLength = sizeof(DEFAULTCONNECTIONS2); ulrc = mciQueryDefaultConnections ( ulDeviceTypeID, &DefCon, &usConnLength); /****************************************************** * Ensure that the INI file says that we are connected * to an amp mixer. If it says that we are connected * to ourselves, return an error. ******************************************************/ if ( ULONG_LOWD( DefCon.dwDeviceTypeID2 ) == MCI_DEVTYPE_WAVEFORM_AUDIO ) { return ( MCIERR_INI_FILE ); } /****************************** * Open an AMP/MIXER Instance ******************************/ MCIAmpOpenParms.pszDeviceType = (PSZ) DefCon.dwDeviceTypeID2; MCIAmpOpenParms.hwndCallback = (ULONG) NULL; // 6421 --no need to retrive this information any more // we are truly device independent // GetPDDName (DefCon.dwDeviceTypeID2, szPDDName); // strcpy ( ulpInstance->szAudioDevName, szPDDName); /* Copy the name of the pdd + vsd dll to amp structure */ // strcpy ((PSZ) AMPMIX.szDeviceName, // ulpInstance->szAudioDevName); // strcpy ((PSZ) ulpInstance->StreamInfo.AudioDCB.szDevName, // ulpInstance->szAudioDevName); /******************************************* * The current amp/mixer uses an undocumented * structure. Pass this structure in on the * open also. ********************************************/ MCIAmpOpenParms.pDevDataPtr = (PVOID) &vsdOpen; /* Open what we are connected to--usually the amp */ ulrc = mciSendCommand (0, MCI_OPEN, MCI_OPEN_TYPE_ID| MCI_WAIT| ulOpenFlags, (PVOID) &MCIAmpOpenParms, 0); // CODEC change /*-------------------------------------------- * It is possible that the VSD may require a * best fit. Try with the best fit parameters. *-------------------------------------------*/ if (ulrc) { #ifndef CONNECTION if ( ulrc == MCIERR_UNSUPP_FORMAT_TAG ) { /* Open what we are connected to--usually the amp */ ulrc = mciSendCommand (0, MCI_OPEN, MCI_OPEN_TYPE_ID| MCI_WAIT| ulOpenFlags, (PVOID) &MCIAmpOpenParms, 0); } if ( ulrc ) #endif { return ( ulrc ); } ulpInstance->ulRealTimeTranslation = MMIO_REALTIME; memmove( &ulpInstance->mmAudioHeader, &mmaudioheader, sizeof( MMAUDIOHEADER ) ); } /* If the amp-mixer could not deal with the data type */ else { ulpInstance->ulRealTimeTranslation = MMIO_NONREALTIME; } // CODEC feature--removed functionality /* Remember the amp device id so that we can close it */ ulpInstance->usAmpDeviceID = MCIAmpOpenParms.usDeviceID; #ifndef CONNECTION ulrc = GetMixerInfo( ulpInstance, &concb ); if ( ulrc ) { /*----------------------------------------- * Ensure that the amp-mixer is CLOSED!!!!!! * Else an error will lock the device. *------------------------------------------*/ mciSendCommand ((WORD)ulpInstance->usAmpDeviceID, MCI_CLOSE, MCI_WAIT, 0, 0); } #endif return ( ulrc ); } /* ConnectToAmp */