Пример #1
0
void CDAudio_Resume(void)
{
	DWORD			dwReturn;
    MCI_PLAY_PARMS	mciPlayParms;

	if (!enabled)
		return;
	
	if (!cdValid)
		return;

	if (!wasPlaying)
		return;
	
	mciPlayParms.dwFrom = MCI_MAKE_TMSF(playTrack, 0, 0, 0);
	mciPlayParms.dwTo = MCI_MAKE_TMSF(playTrack + 1, 0, 0, 0);
	mciPlayParms.dwCallback = (DWORD_PTR)mainwindow;
	dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD_PTR) (LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		Con_DPrintf("CDAudio_Resume: MCI_PLAY failed (%u)\n", (unsigned int)dwReturn);
		return;
	}
    
	wasPlaying = false;
	playing = true;
}
Пример #2
0
int WinMMDrv_CD_Play(int track, int loop)
{
    MCI_PLAY_PARMS mciplayparms;
    DWORD rv;

    if (!cdDeviceID) {
        ErrorCode = WinMMErr_Uninitialised;
        return WinMMErr_Error;
    }

    cdPlayTrack = track;
    cdLoop = loop;
    cdPaused = 0;

    mciplayparms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
    mciplayparms.dwTo   = MCI_MAKE_TMSF(track + 1, 0, 0, 0);
    mciplayparms.dwCallback = (DWORD) notifyWindow;
    rv = mciSendCommand(cdDeviceID, MCI_PLAY, MCI_FROM | MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID) &mciplayparms);
    if (rv) {
        fprintf(stderr, "WinMM CD_Play MCI_PLAY err %d\n", (int) rv);
        ErrorCode = WinMMErr_CDMCIPlay;
        return WinMMErr_Error;
    }

    return WinMMErr_Ok;
}
Пример #3
0
void CDAudio_Resume(void)
{
    DWORD			dwReturn;
    MCI_PLAY_PARMS	mciPlayParms;

    if (!cd_enabled.value || !initialized) // Manoel Kasimier - CD player in menu - edited
        return;

    if (!cdValid)
        return;

    if (!wasPlaying)
        return;

    mciPlayParms.dwFrom = MCI_MAKE_TMSF(playTrack, 0, 0, 0);
    mciPlayParms.dwTo = MCI_MAKE_TMSF(playTrack + 1, 0, 0, 0);
    mciPlayParms.dwCallback = (DWORD)mainwindow;
    dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID) &mciPlayParms);
    if (dwReturn)
    {
        Con_DPrintf("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
        return;
    }
    playing = true;
}
Пример #4
0
void CDAudio_Resume(void)
{
	DWORD			dwReturn;
    MCI_PLAY_PARMS	mciPlayParms;

	if (!enabled)
		return;
	
	if (!cdValid)
		return;

	if (!wasPlaying)
		return;
	
    mciPlayParms.dwFrom = MCI_MAKE_TMSF(playTrack, 0, 0, 0);
    mciPlayParms.dwTo = MCI_MAKE_TMSF(playTrack + 1, 0, 0, 0);
    mciPlayParms.dwCallback = (DWORD)cl_hwnd;
    dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		Com_DPrintf("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
		return;
	}
	playing = true;
}
Пример #5
0
//-----------------------------------------------------------------------------
// Purpose: Resume playing cd
//-----------------------------------------------------------------------------
void CCDAudio::_Resume( int, int )
{
	double curTime;
	DWORD			dwReturn;
    MCI_PLAY_PARMS	mciPlayParms;

	if (!m_bEnabled)
		return;
	
	if (!m_bIsValid)
		return;

	if (!m_bWasPlaying)
		return;

    mciPlayParms.dwFrom = MCI_MAKE_TMSF(m_nPlayTrack, 0, 0, 0);
    mciPlayParms.dwTo = MCI_MAKE_TMSF(m_nPlayTrack + 1, 0, 0, 0);
    mciPlayParms.dwCallback = (DWORD)game->GetMainWindow();
    dwReturn = mciSendCommand(m_uiDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		ResetCDTimes();
		return;
	}
	m_bIsPlaying = true;

	curTime = Sys_FloatTime();

	// Subtract the elapsed time from the current playback time. (i.e., add it to the start time).

	m_dStartTime += (curTime - m_dPauseTime);

	m_dPauseTime = 0.0;
}
Пример #6
0
int PlatPlayCDDA(int track)
{
	DWORD dwReturn;
    MCI_SET_PARMS mciSetParms = {0,0,0};
    MCI_PLAY_PARMS mciPlayParms = {0,0,0};
	MCI_STATUS_PARMS mciStatusParms = {0,0,0,0};

    /* check the cdDeviceId */
    if(cdDeviceID==NO_DEVICE) return SOUND_PLATFORMERROR;
    
    /* set the time format */
	mciSetParms.dwTimeFormat = MCI_FORMAT_MSF;
	dwReturn = mciSendCommand((UINT)cdDeviceID,MCI_SET,MCI_SET_TIME_FORMAT,(DWORD)(LPVOID) &mciSetParms);
	if(dwReturn)
	{
//    	NewOnScreenMessage("CD ERROR - TIME FORMAT");
    	/* error */
    	return SOUND_PLATFORMERROR;
	}  
	
	/* find the length of the track... */
	mciStatusParms.dwItem = MCI_STATUS_LENGTH;
	mciStatusParms.dwTrack = track;
    dwReturn = mciSendCommand((UINT)cdDeviceID,MCI_STATUS,MCI_STATUS_ITEM|MCI_TRACK,(DWORD)(LPVOID)&mciStatusParms);
	if(dwReturn)
	{
    	/* error */
//    	NewOnScreenMessage("CD ERROR - GET LENGTH");
    	return SOUND_PLATFORMERROR;
	}  

    /* set the time format */
	mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF;
	dwReturn = mciSendCommand((UINT)cdDeviceID,MCI_SET,MCI_SET_TIME_FORMAT,(DWORD)(LPVOID) &mciSetParms);
	if(dwReturn)
	{
    	/* error */
//    	NewOnScreenMessage("CD ERROR - TIME FORMAT");
    	return SOUND_PLATFORMERROR;
	}  

	/* play the track: set up for notification when track finishes, or an error occurs */ 
    mciPlayParms.dwFrom=MCI_MAKE_TMSF(track,0,0,0);
    mciPlayParms.dwTo=MCI_MAKE_TMSF(track,	MCI_MSF_MINUTE(mciStatusParms.dwReturn),
    										MCI_MSF_SECOND(mciStatusParms.dwReturn),
    										MCI_MSF_FRAME(mciStatusParms.dwReturn));
    mciPlayParms.dwCallback=(DWORD)hWndMain;
    dwReturn = mciSendCommand((UINT)cdDeviceID,MCI_PLAY,MCI_FROM|MCI_TO|MCI_NOTIFY,(DWORD)(LPVOID)&mciPlayParms);
	if(dwReturn)
    {
    	/* error */
//    	NewOnScreenMessage("CD ERROR - PLAY");
    	return SOUND_PLATFORMERROR;
    }
    return 0;
}
Пример #7
0
			//////////////////////////////////////
			// Wave Function
			//////////////////////////////////////
DllExport LPTSTR CDAudio(UINT msg, DWORD TrackNumber)
{
	mciSendCommand(PlayCDId, MCI_CLOSE, 0, 0);

	MCIERROR MciError;
	MCI_OPEN_PARMS Open;
	memset(&Open, 0, sizeof(MCI_OPEN_PARMS));
	Open.lpstrDeviceType = MAKEINTRESOURCE(MCI_DEVTYPE_CD_AUDIO); 
	DWORD style = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID;
	MciError = mciSendCommand(0, MCI_OPEN, style, DWORD(&Open));   
	PlayCDId = Open.wDeviceID;
//	Setting format to play Track
	if(!MciError)
			{
			MCI_SET_PARMS InfoSet;
			memset(&InfoSet, 0, sizeof(MCI_SET_PARMS));
			InfoSet.dwTimeFormat	= MCI_FORMAT_TMSF;
			MciError = mciSendCommand(PlayCDId, MCI_SET, MCI_SET_TIME_FORMAT, DWORD(&InfoSet));
			}
	switch(msg)
		{
			case PLAY:
				{
// Playing CD
				if(!MciError)
					{
						MCI_PLAY_PARMS InfoPlay;
						memset(&InfoPlay, 0, sizeof(MCI_PLAY_PARMS));
						InfoPlay.dwFrom	= MCI_MAKE_TMSF(TrackNumber,0,0,0);
						MciError = mciSendCommand(PlayCDId, MCI_PLAY, MCI_FROM | MCI_NOTIFY, DWORD(&InfoPlay));
					}
				}	break;
			case STOP:
				{
					MCI_GENERIC_PARMS GenInfo;
					memset(&GenInfo, 0, sizeof(MCI_GENERIC_PARMS));
					GenInfo.dwCallback = 0;
					mciSendCommand(PlayCDId, MCI_STOP, MCI_NOTIFY, DWORD(&GenInfo));
				}	break;
			case SEEK:
				{
					MCI_SEEK_PARMS InfoSeek;
					memset(&InfoSeek, 0, sizeof(MCI_SEEK_PARMS));
					InfoSeek.dwTo	= MCI_MAKE_TMSF(TrackNumber,0,0,0);
					MciError = mciSendCommand(PlayCDId, MCI_SEEK, MCI_TO, DWORD(&InfoSeek));
				}
			case PAUSE:
				{
					MCI_GENERIC_PARMS GenInfo;
					memset(&GenInfo, 0, sizeof(MCI_GENERIC_PARMS));
					mciSendCommand(PlayCDId, MCI_PAUSE, 0, DWORD(&GenInfo));
				}
		}
mciGetErrorString(MciError, error, sizeof(error));
return error;
}
Пример #8
0
DWORD playCDTrack(BYTE bTrack)
	{
	UINT wDeviceID;
	DWORD dwReturn;
	MCI_OPEN_PARMS mciOpenParms;
	MCI_SET_PARMS mciSetParms;
	MCI_PLAY_PARMS mciPlayParms;
	
	// Open the compact disc device by specifying the device name.
	mciOpenParms.lpstrDeviceType = "cdaudio";
	
	if ((dwReturn = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE,
			(DWORD)(LPVOID) &mciOpenParms)) != 0)
		{
		// Failed to open device; don't close it, just return error.

		return (dwReturn);
		}
		
	
	// Device opened successfully, get the device ID.
	wDeviceID = mciOpenParms.wDeviceID;
																
 	// Set the time format to track/minute/second/frame.
	mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF;
	if ((dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT,
			(DWORD)(LPVOID) &mciSetParms)) != 0)
		{
		mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
		return (dwReturn);
		}

	// Begin playback from the given track and play until the beginning of
	// the next track. The window procedure function for the parent window
	// will be notified with an MM_MCINOTIFY message when playback is
	// complete. Unless the play command fails, the window procedure closes
	// the device.

	mciPlayParms.dwFrom = MCI_MAKE_TMSF(bTrack, 0, 0, 0);
	mciPlayParms.dwTo = MCI_MAKE_TMSF(bTrack + 1, 0, 0, 0);
	mciPlayParms.dwCallback = (DWORD) MainDlgH;

	if ((dwReturn = mciSendCommand(wDeviceID, MCI_PLAY,
			MCI_FROM | MCI_TO | MCI_NOTIFY,
			(DWORD)(LPVOID) &mciPlayParms)) != 0)
		{
		mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
		return (dwReturn);
		}

	return (0);
	}
Пример #9
0
long cdrom_notification_routine ( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{

	if ( cdrom_track_repeat )
	{

		MCI_PLAY_PARMS
			play_parameters;

		MCI_STATUS_PARMS
			status_parameters;

		DWORD
			value;

		status_parameters.dwItem = MCI_STATUS_LENGTH;
		status_parameters.dwTrack = cdrom_track_playing;

		value = mciSendCommand ( cdrom_device_id, MCI_STATUS, ( MCI_TRACK | MCI_STATUS_ITEM ), ( DWORD ) ( LPVOID ) &status_parameters );

		if ( !value )
		{

			int
				minutes,
				seconds,
				frames;
	
			minutes = MCI_MSF_MINUTE ( status_parameters.dwReturn ),
			seconds = MCI_MSF_SECOND ( status_parameters.dwReturn ),
			frames = MCI_MSF_FRAME ( status_parameters.dwReturn ),
	
			play_parameters.dwFrom = 0;
			play_parameters.dwTo = 0;
			play_parameters.dwFrom = MCI_MAKE_TMSF ( cdrom_track_playing, 0, 0, 0 );
			play_parameters.dwTo = MCI_MAKE_TMSF ( cdrom_track_playing, minutes, seconds, frames );
			play_parameters.dwCallback = ( DWORD ) application_window;
	
			mciSendCommand ( cdrom_device_id, MCI_PLAY, ( MCI_FROM | MCI_TO | MCI_NOTIFY ), ( DWORD ) ( LPVOID ) &play_parameters );
		}
	}
	else
	{

		cdrom_audio_track_playing = FALSE;
	}

	return ( TRUE );
}
Пример #10
0
int CDAudio_SysResume (void)
{
	DWORD			dwReturn;
	MCI_PLAY_PARMS	mciPlayParms;

	mciPlayParms.dwFrom = MCI_MAKE_TMSF(cdPlayTrack, 0, 0, 0);
	mciPlayParms.dwTo = MCI_MAKE_TMSF(cdPlayTrack + 1, 0, 0, 0);
	mciPlayParms.dwCallback = (DWORD_PTR)mainwindow;
	dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD_PTR)(LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		Con_Printf("CDAudio_SysResume: MCI_PLAY failed (%x)\n", (unsigned)dwReturn);
		return -1;
	}
	return 0;
}
Пример #11
0
/*
============
CDAudio_ResumeDevice
============
*/
qboolean CDAudio_ResumeDevice (void)
{
	DWORD		dwReturn;
	MCI_PLAY_PARMS	mciPlayParms;
	
	mciPlayParms.dwFrom = MCI_MAKE_TMSF(playTrack, 0, 0, 0);
	mciPlayParms.dwTo = MCI_MAKE_TMSF(playTrack + 1, 0, 0, 0);
	mciPlayParms.dwCallback = (DWORD)mainwindow;
	dwReturn = mciSendCommandA (wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID)&mciPlayParms);
	if (dwReturn)
	{
		Con_DPrintf ("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
		return false;
	}
	
	return true;
}
Пример #12
0
bool NativePlayer::SeekTrack( BYTE bTrack )
{
    if ( !m_wDeviceID )
        return true;

    MCI_SEEK_PARMS mciParms;
    mciParms.dwTo = MCI_MAKE_TMSF( bTrack, 0, 0, 0 );
    return SendCommand( m_wDeviceID, MCI_SEEK, MCI_TO, (DWORD)(LPVOID)&mciParms );
}
Пример #13
0
void I_PlayCD (UINT8 nTrack, UINT8 bLooping)
{
	MCI_PLAY_PARMS  mciPlay;
	MCIERROR        iErr;

	if (!cdaudio_started || !cdEnabled)
		return;

	//faB: try again if it didn't work (just free the user of typing 'cd reset' command)
	if (!cdValid)
		cdValid = CD_ReadTrackInfo();
	if (!cdValid)
		return;

	// tracks start at 0 in the code..
	nTrack--;
	if (nTrack < 0 || nTrack >= m_nTracksCount)
		nTrack = nTrack % m_nTracksCount;

	nTrack = cdRemap[nTrack];

	if (cdPlaying)
	{
		if (cdPlayTrack == nTrack)
			return;
		I_StopCD ();
	}

	cdPlayTrack = nTrack;

	if (!m_nTracks[nTrack].IsAudio)
	{
		//CONS_Printf ("\2CD Play: not an audio track\n"); // Tails 03-25-2001
		return;
	}

	cdLooping = bLooping;

	//faB: stop MIDI music, MIDI music will restart if volume is upped later
	cv_digmusicvolume.value = 0;
	cv_midimusicvolume.value = 0;
	I_StopSong (0);

	//faB: I don't use the notify message, I'm trying to minimize the delay
	mciPlay.dwCallback = (DWORD_PTR)((size_t)hWndMain);
	mciPlay.dwFrom = MCI_MAKE_TMSF(nTrack+1, 0, 0, 0);
	iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_PLAY, MCI_FROM|MCI_NOTIFY, (DWORD_PTR)&mciPlay);
	if (iErr)
	{
		MCIErrorMessageBox (iErr);
		cdValid = false;
		cdPlaying = false;
		return;
	}

	cdPlaying = true;
}
Пример #14
0
/**************************************************************************
 * 			MCICDA_CalcTime				[internal]
 */
static DWORD MCICDA_CalcTime(WINE_MCICDAUDIO* wmcda, DWORD tf, DWORD dwFrame, LPDWORD lpRet)
{
    DWORD	dwTime = 0;
    UINT	wTrack;
    UINT	wMinutes;
    UINT	wSeconds;
    UINT	wFrames;
    CDROM_TOC   toc;
    DWORD       br;

    TRACE("(%p, %08X, %u);\n", wmcda, tf, dwFrame);

    switch (tf) {
    case MCI_FORMAT_MILLISECONDS:
	dwTime = (dwFrame * 1000) / CDFRAMES_PERSEC + 1;
	TRACE("MILLISECONDS %u\n", dwTime);
	*lpRet = 0;
	break;
    case MCI_FORMAT_MSF:
	wMinutes = dwFrame / CDFRAMES_PERMIN;
	wSeconds = (dwFrame - CDFRAMES_PERMIN * wMinutes) / CDFRAMES_PERSEC;
	wFrames = dwFrame - CDFRAMES_PERMIN * wMinutes - CDFRAMES_PERSEC * wSeconds;
	dwTime = MCI_MAKE_MSF(wMinutes, wSeconds, wFrames);
	TRACE("MSF %02u:%02u:%02u -> dwTime=%u\n",
	      wMinutes, wSeconds, wFrames, dwTime);
	*lpRet = MCI_COLONIZED3_RETURN;
	break;
    case MCI_FORMAT_TMSF:
    default:	/* unknown format ! force TMSF ! ... */
        if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                             &toc, sizeof(toc), &br, NULL))
            return 0;
	if (dwFrame < FRAME_OF_TOC(toc, toc.FirstTrack) ||
            dwFrame > FRAME_OF_TOC(toc, toc.LastTrack + 1)) {
            ERR("Out of range value %u [%u,%u]\n",
		dwFrame, FRAME_OF_TOC(toc, toc.FirstTrack),
                FRAME_OF_TOC(toc, toc.LastTrack + 1));
	    *lpRet = 0;
	    return 0;
	}
	for (wTrack = toc.FirstTrack; wTrack <= toc.LastTrack; wTrack++) {
	    if (FRAME_OF_TOC(toc, wTrack) > dwFrame)
		break;
	}
        wTrack--;
	dwFrame -= FRAME_OF_TOC(toc, wTrack);
	wMinutes = dwFrame / CDFRAMES_PERMIN;
	wSeconds = (dwFrame - CDFRAMES_PERMIN * wMinutes) / CDFRAMES_PERSEC;
	wFrames = dwFrame - CDFRAMES_PERMIN * wMinutes - CDFRAMES_PERSEC * wSeconds;
	dwTime = MCI_MAKE_TMSF(wTrack, wMinutes, wSeconds, wFrames);
	TRACE("%02u-%02u:%02u:%02u\n", wTrack, wMinutes, wSeconds, wFrames);
	*lpRet = MCI_COLONIZED4_RETURN;
	break;
    }
    return dwTime;
}
Пример #15
0
    // plays one track (blocking)
    HRESULT PlayImpl(int nTrack)
    {
        MCI_PLAY_PARMS mciPlayParms;
        mciPlayParms.dwFrom = MCI_MAKE_TMSF(nTrack, 0, 0, 0);
        mciPlayParms.dwTo = MCI_MAKE_TMSF(nTrack + 1, 0, 0, 0);
        DWORD dwError = mciSendCommand(m_idDevice, MCI_PLAY, MCI_FROM | MCI_TO, (UINT_PTR)&mciPlayParms);

        // if the track is out of range, retry without the stop point in case 
        // this is the last track on the CD.  (review: we could store it, but
        // this case handles switching the CD)
        if (dwError == MCIERR_OUTOFRANGE)
            dwError = mciSendCommand(m_idDevice, MCI_PLAY, MCI_FROM, (UINT_PTR)&mciPlayParms);

        // this is the highest track on the CD
        if (dwError)
        {
            char cbError[256];
            mciGetErrorStringA(dwError, cbError, 256);
            debugf("Play track %d failed for CD Audio device: %s\n", nTrack, cbError);
            return E_FAIL;
        }
        return S_OK;
    };
Пример #16
0
/*
============
CDAudio_PlayTrack
============
*/
qboolean CDAudio_PlayTrack (byte track, int length)
{
	DWORD				dwReturn;
	MCI_PLAY_PARMS		mciPlayParms;

	mciPlayParms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
	mciPlayParms.dwTo = (length << 8) | track;
	mciPlayParms.dwCallback = (DWORD)mainwindow;
	dwReturn = mciSendCommandA (wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD)(LPVOID)&mciPlayParms);
	if (dwReturn)
	{
		Con_DPrintf ("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
		return false;
	}

	return true;
}
Пример #17
0
void WinMMDrv_CD_Pause(int pauseon)
{
    if (!cdDeviceID) {
        return;
    }

    if (cdPaused == pauseon) {
        return;
    }

    if (pauseon) {
        MCI_STATUS_PARMS mcistatusparms;
        MCI_GENERIC_PARMS mcigenparms;
        DWORD rv;

        mcistatusparms.dwItem = MCI_STATUS_POSITION;
        rv = mciSendCommand(cdDeviceID, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, (DWORD)(LPVOID) &mcistatusparms);
        if (rv) {
            fprintf(stderr, "WinMM CD_Pause MCI_STATUS err %d\n", (int) rv);
            return;
        }

        cdPausePosition = mcistatusparms.dwReturn;

        rv = mciSendCommand(cdDeviceID, MCI_STOP, 0, (DWORD)(LPVOID) &mcigenparms);
        if (rv) {
            fprintf(stderr, "WinMM CD_Pause MCI_STOP err %d\n", (int) rv);
        }
    } else {
        MCI_PLAY_PARMS mciplayparms;
        DWORD rv;

        mciplayparms.dwFrom = cdPausePosition;
        mciplayparms.dwTo   = MCI_MAKE_TMSF(cdPlayTrack + 1, 0, 0, 0);
        mciplayparms.dwCallback = (DWORD) notifyWindow;
        rv = mciSendCommand(cdDeviceID, MCI_PLAY, MCI_FROM | MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID) &mciplayparms);
        if (rv) {
            fprintf(stderr, "WinMM CD_Pause MCI_PLAY err %d\n", (int) rv);
            return;
        }

        cdPausePosition = 0;
    }

    cdPaused = pauseon;
}
Пример #18
0
int CDAudio_SysPlay (int track)
{
	DWORD				dwReturn;
	MCI_PLAY_PARMS		mciPlayParms;
	MCI_STATUS_PARMS	mciStatusParms;

	// don't try to play a non-audio track
	mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
	mciStatusParms.dwTrack = track;
	dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms);
	if (dwReturn)
	{
		Con_Printf("CDAudio_SysPlay: MCI_STATUS failed (%x)\n", (unsigned)dwReturn);
		return -1;
	}
	if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO)
	{
		Con_Printf("CDAudio_SysPlay: track %i is not audio\n", track);
		return -1;
	}

	if (cdPlaying)
		CDAudio_Stop();

	// get the length of the track to be played
	mciStatusParms.dwItem = MCI_STATUS_LENGTH;
	mciStatusParms.dwTrack = track;
	dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms);
	if (dwReturn)
	{
		Con_Printf("CDAudio_SysPlay: MCI_STATUS failed (%x)\n", (unsigned)dwReturn);
		return -1;
	}

	mciPlayParms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
	mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | track;
	mciPlayParms.dwCallback = (DWORD_PTR)mainwindow;
	dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD_PTR)(LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		Con_Printf("CDAudio_SysPlay: MCI_PLAY failed (%x)\n", (unsigned)dwReturn);
		return -1;
	}

	return 0;
}
Пример #19
0
/**
 * Begin playback of a specifc audio track, possibly looped.
 */
int DM_CDAudio_Play(int track, int looped)
{
    int len;

    if(!cdInited)
        return false;

    // Get the length of the track.
    cdTrackLength = len = getTrackLength(track);
    if(!len)
        return false; // Hmm?!

    // Play it!
    if(!sendMCICmd(0, 0, "play " DEVICEID " from %i to %i", track,
                   MCI_MAKE_TMSF(track, 0, len, 0)))
        return false;

    // Success!
    cdLooping = (looped? true:false);
    cdStartTime = Timer_Seconds();
    return cdCurrentTrack = track;
}
Пример #20
0
// Plays a specified audio track using MCI_OPEN, MCI_PLAY. Returns as 
// soon as playback begins. The window procedure function for the 
// specified window will be notified when playback is complete. 
// Returns 0L on success; otherwise, returns an MCI error code.
bool NativePlayer::PlayTrack( BYTE bTrack )
{
    if ( !m_wDeviceID /* && !Open() */ )
        return false;

    // Begin play from the specified track and play to the beginning 
    // of the next track. The window procedure function for the parent 
    // window will be notified with an MM_MCINOTIFY message when 
    // playback is complete. Unless the play command fails, the window 
    // procedure closes the device.    
    MCI_PLAY_PARMS mciPlayParms;
    mciPlayParms.dwFrom = 0L;
    mciPlayParms.dwTo = 0L;
    mciPlayParms.dwFrom = MCI_MAKE_TMSF( bTrack, 0, 0, 0 );
    //mciPlayParms.dwTo = MCI_MAKE_TMSF(bTrack + 1, 0, 0, 0);
    mciPlayParms.dwCallback = m_callback;
    if ( !SendCommand( m_wDeviceID, MCI_PLAY, MCI_FROM | MCI_NOTIFY, (DWORD)(LPVOID)&mciPlayParms ) )
    {
        Close();
        return false;
    }
    return true;
}
Пример #21
0
//-----------------------------------------------------------------------------
// Purpose: Play cd
// Input  : track - 
//			looping - 
//-----------------------------------------------------------------------------
void CCDAudio::_Play( int track, int looping )
{
	int mins, secs;
	DWORD               dwm_flPlayTime;
	DWORD				dwReturn;
    MCI_PLAY_PARMS		mciPlayParms;
	MCI_STATUS_PARMS	mciStatusParms;

	if (!m_bEnabled)
		return;
	
	if (!m_bIsValid)
	{
		GetAudioDiskInfo();
		if (!m_bIsValid)
			return;
	}

	track = m_rgRemapCD[track];

	if (track < 1 || track > m_nMaxTrack)
	{
		return;
	}

	// don't try to play a non-audio track
	mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
	mciStatusParms.dwTrack = track;
    dwReturn = mciSendCommand(m_uiDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
	if (dwReturn)
	{
		char szErr[256];
		int nErr = 256;

		mciGetErrorString(dwReturn, szErr, nErr);
		return;
	}
	if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO)
	{
		return;
	}

	// get the length of the track to be played
	mciStatusParms.dwItem = MCI_STATUS_LENGTH;
	mciStatusParms.dwTrack = track;
    dwReturn = mciSendCommand(m_uiDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
	if (dwReturn)
	{
		return;
	}

	if (m_bIsPlaying)
	{
		if (m_nPlayTrack == track)
			return;
		_Stop( 0, 0 );
	}

	dwm_flPlayTime = mciStatusParms.dwReturn;

    mciPlayParms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
	mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | track;
    mciPlayParms.dwCallback = (DWORD)game->GetMainWindow();
    dwReturn = mciSendCommand(m_uiDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD)(LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		return;
	}

	// Clear any old data.
	ResetCDTimes();

	m_dStartTime = Sys_FloatTime();

	mins = MCI_MSF_MINUTE(dwm_flPlayTime);
	secs = MCI_MSF_SECOND(dwm_flPlayTime);

	m_flPlayTime = (float)(60.0f * mins + (float) secs );

	m_bIsLooping = looping ? true : false;
	m_nPlayTrack = track;
	m_bIsPlaying = true;

	if (m_flVolume == 0.0)
		_Pause ( 0, 0 );
}
Пример #22
0
void CDAudio_Play2(int track, qboolean looping)
{
	DWORD				dwReturn;
    MCI_PLAY_PARMS		mciPlayParms;
	MCI_STATUS_PARMS	mciStatusParms;

	if (!enabled)
		return;
	
	if (!cdValid)
	{
		CDAudio_GetAudioDiskInfo();
		if (!cdValid)
			return;
	}

	track = remap[track];

	if (track < 1 || track > maxTrack)
	{
		CDAudio_Stop();
		return;
	}

	// don't try to play a non-audio track
	mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
	mciStatusParms.dwTrack = track;
    dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
	if (dwReturn)
	{
		Com_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
		return;
	}
	if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO)
	{
		Com_Printf("CDAudio: track %i is not audio\n", track);
		return;
	}

	// get the length of the track to be played
	mciStatusParms.dwItem = MCI_STATUS_LENGTH;
	mciStatusParms.dwTrack = track;
    dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
	if (dwReturn)
	{
		Com_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
		return;
	}

	if (playing)
	{
		if (playTrack == track)
			return;
		CDAudio_Stop();
	}

    mciPlayParms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
	mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | track;
    mciPlayParms.dwCallback = (DWORD)cl_hwnd;
    dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD)(LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		Com_DPrintf("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
		return;
	}

	playLooping = looping;
	playTrack = track;
	playing = true;

	if ( Cvar_VariableValue( "cd_nocd" ) )
		CDAudio_Pause ();
}
Пример #23
0
int internal_play_cd_audio_track ( void *data )
{

	int
		track;

	track = *( ( int * ) data );

	if ( cdrom_device_captured )
	{

		MCI_PLAY_PARMS
			play_parameters;

		MCI_STATUS_PARMS
			status_parameters;

		DWORD
			value;

		status_parameters.dwItem = MCI_STATUS_LENGTH;
		status_parameters.dwTrack = track;

		value = mciSendCommand ( cdrom_device_id, MCI_STATUS, ( MCI_TRACK | MCI_STATUS_ITEM ), ( DWORD ) ( LPVOID ) &status_parameters );

		if ( value )
		{

			debug_log ( "Unable to get track length" );
		}
		else
		{

			int
				minutes,
				seconds,
				frames;
	
			minutes = MCI_MSF_MINUTE ( status_parameters.dwReturn ),
			seconds = MCI_MSF_SECOND ( status_parameters.dwReturn ),
			frames = MCI_MSF_FRAME ( status_parameters.dwReturn ),
	
			play_parameters.dwFrom = 0;
			play_parameters.dwTo = 0;
			play_parameters.dwFrom = MCI_MAKE_TMSF ( track, 0, 0, 0 );
			play_parameters.dwTo = MCI_MAKE_TMSF ( track, minutes, seconds, frames );
			play_parameters.dwCallback = ( DWORD ) application_window;
	
			value = mciSendCommand ( cdrom_device_id, MCI_PLAY, ( MCI_FROM | MCI_TO | MCI_NOTIFY ), ( DWORD ) ( LPVOID ) &play_parameters );
	
			if ( value )
			{
	
				//
				// Ditch the cd player!
				//
	
				debug_log ( "Unable to play cd" );
	
				release_cd_audio_device ();
			}
			else
			{
	
				cdrom_audio_track_playing = TRUE;
			}
		}
	}

	return ( TRUE );
}
Пример #24
0
void CDAudio_Play(byte track, qboolean looping)
{
	DWORD				dwReturn;
    MCI_PLAY_PARMS		mciPlayParms;
	MCI_STATUS_PARMS	mciStatusParms;

	if (!enabled)
		return;
	
	if (!cdValid)
	{
		CDAudio_GetAudioDiskInfo();
		if (!cdValid)
			return;
	}

	track = remap[track];

	if (track < 1 || track > maxTrack)
	{
		Con_DPrintf("CDAudio_Play: Bad track number %u.\n", track);
		return;
	}

	// don't try to play a non-audio track
	mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
	mciStatusParms.dwTrack = track;
	dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms);
	if (dwReturn)
	{
		Con_DPrintf("CDAudio_Play: MCI_STATUS failed (%u)\n", (unsigned int)dwReturn);
		return;
	}
	if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO)
	{
		Con_DPrintf("CDAudio_Play: track %i is not audio\n", track);
		return;
	}

	// get the length of the track to be played
	mciStatusParms.dwItem = MCI_STATUS_LENGTH;
	mciStatusParms.dwTrack = track;
	dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms);
	if (dwReturn)
	{
		Con_DPrintf("CDAudio_Play: MCI_STATUS failed (%u)\n", (unsigned int)dwReturn);
		return;
	}

	if (playing)
	{
		if (playTrack == track)
			return;
		CDAudio_Stop();
	}

	mciPlayParms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
	mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | track;
	mciPlayParms.dwCallback = (DWORD_PTR)mainwindow;
	dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD_PTR) (LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		Con_DPrintf("CDAudio_Play: MCI_PLAY failed (%u)\n", (unsigned int)dwReturn);
		return;
	}

	playLooping = looping;
	playTrack = track;
	playing = true;

	if (bgmvolume.value == 0.0)
		CDAudio_Pause ();
}
Пример #25
0
// W.P. van Paassen
void CDAudio_RandomPlay(void)
{
	int track, i = 0, free_tracks = 0, remap_track;
	float f;
	byte* track_bools;
	DWORD				dwReturn;
	MCI_PLAY_PARMS		mciPlayParms;
	MCI_STATUS_PARMS	mciStatusParms;

	if (!enabled)
		return;

	//create array of available audio tracknumbers

	track_bools = (byte*)malloc(maxTrack * sizeof(byte));

	if (track_bools == 0)
		return;

	for (; i < maxTrack; i++)
	{
		// don't try to play a non-audio track
		mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
		mciStatusParms.dwTrack = remap[i];
		dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
		if (dwReturn)
		{
			track_bools[i] = 0;
		}
		else
			track_bools[i] = (mciStatusParms.dwReturn == MCI_CDA_TRACK_AUDIO);

		free_tracks += track_bools[i];
	}

	if (!free_tracks)
	{
		Com_DPrintf("CDAudio_RandomPlay: Unable to find and play a random audio track, insert an audio cd please");
		goto free_end;
	}

	//choose random audio track
	do
	{
		do
		{
			f = ((float)rand()) / ((float)RAND_MAX + 1.0);
			track = (int)(maxTrack  * f);
		}
		while(!track_bools[track]);

		remap_track = remap[track];

		// get the length of the track to be played
		mciStatusParms.dwItem = MCI_STATUS_LENGTH;
		mciStatusParms.dwTrack = remap_track;
		dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
		if (dwReturn)
		{
			Com_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
			goto free_end;
		}

		if (playing)
		{
			if (playTrack == remap_track)
			{
				goto free_end;
			}
			CDAudio_Stop();
		}

		mciPlayParms.dwFrom = MCI_MAKE_TMSF(remap_track, 0, 0, 0);
		mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | remap_track;
		mciPlayParms.dwCallback = (DWORD)cl_hwnd;
		dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD)(LPVOID) &mciPlayParms);
		if (dwReturn)
		{
			track_bools[track] = 0;
			free_tracks--;
		}
		else
		{
			playLooping = 1;
			playTrack = remap_track;
			playing = 1;
			break;
		}
	}
	while (free_tracks > 0);

free_end:
	free((void*)track_bools);
}