Ejemplo n.º 1
0
// ------------
// I_ShutdownCD
// Shutdown CD Audio subsystem, release whatever was allocated
// ------------
void I_ShutdownCD (void)
{
	MCIERROR    iErr;

	if (!cdaudio_started)
		return;

	CONS_Printf("I_ShutdownCD()\n");

	I_StopCD();

	// closes MCI CD
	iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_CLOSE, 0, 0);
	if (iErr)
		MCIErrorMessageBox (iErr);
}
Ejemplo n.º 2
0
Archivo: win_cd.c Proyecto: STJr/SRB2
// pause cd music
void I_StopCD(void)
{
	MCIERROR    iErr;

	if (!cdaudio_started || !cdEnabled)
		return;

	iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_PAUSE, MCI_WAIT, 0);
	if (iErr)
		MCIErrorMessageBox (iErr);
	else
	{
		wasPlaying = cdPlaying;
		cdPlaying = FALSE;
	}
}
Ejemplo n.º 3
0
void CDAudio_Stop(void)
{
	DWORD	dwReturn;

	if (!enabled)
		return;
	
	if (!playing)
		return;

	dwReturn = mciSendCommand(wDeviceID, MCI_STOP, 0, (DWORD_PTR)NULL);
	if (dwReturn)
		Con_DPrintf("CDAudio_Stop: MCI_STOP failed (%u)", (unsigned int)dwReturn);

	wasPlaying = false;
	playing = false;
}
Ejemplo n.º 4
0
/*
	fileCloseMovie -- uses MCI_CLOSE to close the movie, and
		InvalidateRect to make the movie actually disappear from
		the screen.
*/
void fileCloseMovie(PMOVIEINFO pMovieInfo, BOOL bUpdate)
{
  MCI_GENERIC_PARMS  mciGeneric;
  
  pMovieInfo->fPlaying = FALSE; // can't be playing any longer
  pMovieInfo->fMovieOpen = FALSE;   // no more movies open
  
  mciSendCommand(pMovieInfo->wMCIDeviceID, MCI_CLOSE, MCI_WAIT, 
                 (DWORD)(LPMCI_GENERIC_PARMS)&mciGeneric);
                 
  if (bUpdate)
    {    
    /* cause a total repaint to occur */
    InvalidateRect(pMovieInfo->hwndParent, NULL, TRUE);
    UpdateWindow(pMovieInfo->hwndParent);
    }
}
Ejemplo n.º 5
0
// 음악파일의 디바이스를 연다.
DWORD CGameView::OpenSounds(CString name)
{
	// Load Part
	MCI_OPEN_PARMS mciOpen ;		// mci열기 플레이
	DWORD dv ;		// 디바이스

	mciOpen.lpstrElementName = name ;			//재생 할 파일 및경로
	mciOpen.lpstrDeviceType = L"MPEGVideo";		// 재생 할 타입

	mciSendCommand (NULL, MCI_OPEN, MCI_OPEN_ELEMENT|MCI_OPEN_TYPE,
		(DWORD)(LPVOID) &mciOpen) ;          //MCI_OPEN 명령을 준다.

	// Play Part
	dv = mciOpen.wDeviceID;        //디바이스 아이디를 받느다.
	
	return dv;
}
Ejemplo n.º 6
0
/*
	GetMovieLength -- uses MCI_STATUS to find out number of frames in
		movie.
*/
DWORD GetMovieLength(PMOVIEINFO pMovieInfo)
{
    MCI_STATUS_PARMS mciStatus;

    mciStatus.dwTrack = 1;
    mciStatus.dwCallback = NULL;
    mciStatus.dwItem = MCI_STATUS_LENGTH;

    if (0 != (mciSendCommand(pMovieInfo->wMCIDeviceID, MCI_STATUS, (DWORD)MCI_STATUS_ITEM,
            (DWORD)(LPMCI_STATUS_PARMS)&mciStatus)))
        {
        OutputDebugString("Error getting movie length");
        return 0;
        }
            
    return (mciStatus.dwReturn);
}
Ejemplo n.º 7
0
static int set_volume(audio_output_t *ao, USHORT setvolume)
{
	if(setvolume > 100) setvolume = 100;
	volume = setvolume; /* useful when device is closed and reopened */

	if(maop.usDeviceID)
	{
		memset(&msp,0,sizeof(msp));
		msp.ulAudio = MCI_SET_AUDIO_ALL;
		msp.ulLevel = setvolume;
		
		mciSendCommand(maop.usDeviceID, MCI_SET,
			MCI_WAIT | MCI_SET_AUDIO | MCI_SET_VOLUME,
			&msp, 0);
	}
	return setvolume;
}
Ejemplo n.º 8
0
int main(int argc, char *argv[])
{
	MSG msg;
	HWND hWnd;
	int deviceID, result;

   	hWnd = MCIWndCreate(NULL, NULL,
		   	WS_OVERLAPPED | WS_CAPTION | WS_BORDER | WS_SYSMENU |
		   	WS_VISIBLE | MCIWNDF_RECORD | MCIWNDF_SHOWALL, NULL);

	MCIWndNew(hWnd, "waveaudio");
	MCI_WAVE_SET_PARMS set_parms;
	set_parms.wFormatTag      = WAVE_FORMAT_PCM;
	set_parms.wBitsPerSample  = 16;
	set_parms.nChannels       = 1;
	set_parms.nBlockAlign     = (set_parms.nChannels*set_parms.wBitsPerSample)/8;
	set_parms.nSamplesPerSec  = 44100;
	set_parms.nAvgBytesPerSec = ((set_parms.wBitsPerSample) *
		   	set_parms.nChannels *
			set_parms.nSamplesPerSec) / 8;

	// now send the format changes with MCI_SET
	deviceID = MCIWndGetDeviceID(hWnd);
	result = mciSendCommand(deviceID, MCI_SET,
			MCI_WAIT
			| MCI_WAVE_SET_FORMATTAG
			| MCI_WAVE_SET_BITSPERSAMPLE
			| MCI_WAVE_SET_CHANNELS
			| MCI_WAVE_SET_SAMPLESPERSEC
			| MCI_WAVE_SET_AVGBYTESPERSEC
			| MCI_WAVE_SET_BLOCKALIGN,
			(DWORD)(LPVOID)&set_parms);
	MCIWndRecord(hWnd);  //开始录制

	while (GetMessage(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	MCIWndStop(hWnd);  //录制完毕
	MCIWndSave(hWnd, L"abc.wav");   //保存
	MCIWndClose(hWnd);
	MCIWndDestroy(hWnd);
	return 0;
}
Ejemplo n.º 9
0
int WinMMDrv_CD_IsPlaying(void)
{
    MCI_STATUS_PARMS mcistatusparms;
    DWORD rv;

    if (!cdDeviceID) {
        return 0;
    }

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

    return (mcistatusparms.dwReturn == MCI_MODE_PLAY);
}
Ejemplo n.º 10
0
void CDAudio_Pause(void)
{
	DWORD				dwReturn;
	MCI_GENERIC_PARMS	mciGenericParms;

	if (!enabled)
		return;

	if (!playing)
		return;

	mciGenericParms.dwCallback = (DWORD)cl_hwnd;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_PAUSE, 0, (DWORD)(LPVOID) &mciGenericParms))
		Com_DPrintf("MCI_PAUSE failed (%i)", dwReturn);

	wasPlaying = playing;
	playing = false;
}
Ejemplo n.º 11
0
void CWndMovie::OnDestroy()
{

	if (theApp.m_wndMain.GetProgPos () == CWndMain::movie)
		theApp.m_wndMain.SetProgPos ( CWndMain::playing );

	m_bInDestroy = TRUE;

	if (m_mciDevID != 0)
		CloseMovie ();

	if ( m_MainmciDevID != 0 )
		{
		MCI_GENERIC_PARMS mgp;
		memset (&mgp, 0, sizeof (mgp) );
		mciSendCommand (m_MainmciDevID, MCI_CLOSE, 0, (DWORD) &mgp );
		}
}
Ejemplo n.º 12
0
/* General ioctl() CD-ROM command function */
static bool 
_cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg)
{
#ifdef _XBOX
  return false;
#else
  MCIERROR mci_error;
  
  mci_error = mciSendCommand(id, msg, flags, (DWORD_PTR)arg);
  if ( mci_error ) {
    char error[256];
    
    mciGetErrorString(mci_error, error, 256);
    cdio_warn("mciSendCommand() error: %s", error);
  }
  return(mci_error == 0);
#endif
}
Ejemplo n.º 13
0
void CDAudio_Pause(void)
{
    DWORD				dwReturn;
    MCI_GENERIC_PARMS	mciGenericParms;

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

    if (!playing)
        return;

    mciGenericParms.dwCallback = (DWORD)mainwindow;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_PAUSE, 0, (DWORD)(LPVOID) &mciGenericParms))
        Con_DPrintf("MCI_PAUSE failed (%i)", dwReturn);

    wasPlaying = playing;
    playing = false;
}
Ejemplo n.º 14
0
/*
 * MusicAbort:  Turn off currently playing music
 */
void MusicAbort(void)
{
   if (!has_midi)
      return;

   if (playing_music || playing_midi)
   {
#ifdef M59_MSS
      AIL_end_sample(hseqBackground);
      AIL_end_sample(hseqImmediate);
#else
      mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, 0, 0);
#endif
   }

   playing_music = False;
   music_pos = 0;
}
Ejemplo n.º 15
0
//-----------------------------------------------------------------------------
// Purpose: Pause playback
//-----------------------------------------------------------------------------
void CCDAudio::_Pause( int, int )
{
	MCI_GENERIC_PARMS	mciGenericParms;

	if (!m_bEnabled)
		return;

	if (!m_bIsPlaying)
		return;

	mciGenericParms.dwCallback = (DWORD)game->GetMainWindow();
    mciSendCommand(m_uiDeviceID, MCI_PAUSE, 0, (DWORD)(LPVOID) &mciGenericParms);

	m_bWasPlaying = m_bIsPlaying;
	m_bIsPlaying = false;

	m_dPauseTime = Sys_FloatTime();
}
Ejemplo n.º 16
0
/* 
	initAVI -- Opens the "avivideo" device with MCI_OPEN command
 */
BOOL initAVI(void)
{
    MCI_DGV_OPEN_PARMS  mciOpen;
         
    /* set up the open parameters */
    mciOpen.dwCallback = NULL;
    mciOpen.wDeviceID = mciOpen.wReserved0 =
             mciOpen.wReserved1 = 0;
    mciOpen.lpstrDeviceType = "avivideo";
    mciOpen.lpstrElementName = NULL;
    mciOpen.lpstrAlias = NULL;
    mciOpen.dwStyle = 0;
    mciOpen.hWndParent = NULL;
         
   /* try to open the driver */
   return (mciSendCommand(0, MCI_OPEN, (DWORD)(MCI_OPEN_TYPE), 
                          (DWORD)(LPMCI_DGV_OPEN_PARMS)&mciOpen) == 0);
}
Ejemplo n.º 17
0
void WinMMDrv_CD_Stop(void)
{
    MCI_GENERIC_PARMS mcigenparms;
    DWORD rv;

    if (!cdDeviceID) {
        return;
    }

    cdPlayTrack = 0;
    cdLoop = 0;
    cdPaused = 0;

    rv = mciSendCommand(cdDeviceID, MCI_STOP, 0, (DWORD)(LPVOID) &mcigenparms);
    if (rv) {
        fprintf(stderr, "WinMM CD_Stop MCI_STOP err %d\n", (int) rv);
    }
}
Ejemplo n.º 18
0
int PlatStopCDDA(void)
{
	DWORD dwReturn;

    /* check the cdDeviceId */
    if(cdDeviceID==NO_DEVICE) 
    {
    	return SOUND_PLATFORMERROR;
	}

	/* stop the cd player */
	dwReturn = mciSendCommand((UINT)cdDeviceID,MCI_STOP,MCI_WAIT,NULL);
	if(dwReturn)
    {
    	/* error */
    	return SOUND_PLATFORMERROR;
    }
    return 0;
}
Ejemplo n.º 19
0
void MusicClose(void)
{
   if (!has_midi)
      return;

#ifdef M59_MSS
   AIL_release_sample_handle(hseqBackground);
   AIL_release_sample_handle(hseqImmediate);

   if (pMIDIImmediate)
      AIL_mem_free_lock(pMIDIImmediate);
   if (pMIDIBackground)
      AIL_mem_free_lock(pMIDIBackground);

   AIL_shutdown();
#else
   mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, 0, 0);
#endif
}
Ejemplo n.º 20
0
void CDAudio_Pause(void)
{
	DWORD				dwReturn;
	MCI_GENERIC_PARMS	mciGenericParms;

	if (!enabled)
		return;

	if (!playing)
		return;

	mciGenericParms.dwCallback = (DWORD_PTR)mainwindow;
	dwReturn = mciSendCommand(wDeviceID, MCI_PAUSE, 0, (DWORD_PTR) (LPVOID) &mciGenericParms);
	if (dwReturn)
		Con_DPrintf("CDAudio_Pause: MCI_PAUSE failed (%u)", (unsigned int)dwReturn);

	wasPlaying = playing;
	playing = false;
}
Ejemplo n.º 21
0
// continue after a pause
void I_ResumeCD (void)
{
	MCIERROR    iErr;

	if (!cdaudio_started || !cdEnabled)
		return;

	if (!cdValid)
		return;

	if (!wasPlaying)
		return;

	iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_RESUME, MCI_WAIT, 0);
	if (iErr)
		MCIErrorMessageBox (iErr);
	else
		cdPlaying = true;
}
Ejemplo n.º 22
0
			//////////////////////////////////////
			// Midi Function
			//////////////////////////////////////
DllExport LPTSTR MIDI(UINT msg, HWNDdll hwnd)
{
	mciSendCommand(MidiId, MCI_CLOSE, 0, 0);

	MCIERROR MciError;
	MCI_OPEN_PARMS Open;
	memset(&Open, 0, sizeof(MCI_OPEN_PARMS));
	Open.lpstrElementName = File;
	DWORD style = MCI_OPEN_ELEMENT;
	MciError = mciSendCommand(0, MCI_OPEN, style, DWORD(&Open));    
	MidiId = Open.wDeviceID;
	if(!MciError)
		{
			MCI_SET_PARMS InfoSet;
			memset(&InfoSet, 0, sizeof(MCI_SET_PARMS));
			InfoSet.dwTimeFormat	= MCI_FORMAT_MILLISECONDS;
			MciError = mciSendCommand(MidiId, MCI_SET, MCI_SET_TIME_FORMAT, DWORD(&InfoSet));
		}

switch(msg)
	{
	case PLAY:
		if(!MciError)
			{
				MCI_STATUS_PARMS InfoStat;
				memset(&InfoStat, 0, sizeof(MCI_STATUS_PARMS));
				InfoStat.dwCallback = 0;
				InfoStat.dwItem			= MCI_STATUS_LENGTH;
				InfoStat.dwTrack		= 0;
				MciError = mciSendCommand(MidiId, MCI_STATUS, MCI_STATUS_ITEM, DWORD(&InfoStat));

				MCI_PLAY_PARMS InfoPlay;
				memset(&InfoPlay, 0, sizeof(MCI_PLAY_PARMS));
				InfoPlay.dwCallback = (DWORD)hwnd;
				InfoPlay.dwFrom	= (DWORD)(sec * 1000);
				MciError = mciSendCommand(MidiId, MCI_PLAY, MCI_FROM | MCI_NOTIFY, DWORD(&InfoPlay));

				MTimeRate = (InfoStat.dwReturn) - (sec * 1000);
				SetTimer(hwnd, ID_MTIMER, MTimeRate, NULL);
			}
		break;
	case STOP:
		mciSendCommand(MidiId, MCI_STOP, 0, 0);
		break;
	}

	mciGetErrorString(MciError, error, sizeof(error));
	return error;
}
Ejemplo n.º 23
0
bool Win32RedBookDevice::stop()
{
   if(!mAcquired)
   {
      setLastError("Device has not been acquired");
      return(false);
   }

   MCI_GENERIC_PARMS genParms;

   U32 error = mciSendCommand(mDeviceId, MCI_STOP, 0, (DWORD_PTR)(LPMCI_GENERIC_PARMS)&genParms);
   if(error)
   {
      setLastError(error);
      return(false);
   }

   setLastError("");
   return(true);
}
Ejemplo n.º 24
0
ULONG PSMMInitMM( char *pszWavFile, USHORT *pusDevID )
{
    MCI_OPEN_PARMS  mop;
    ULONG           ulRC;

    memset( &mop, 0, sizeof( mop ) );

    if( !pszWavFile || !*pszWavFile )
        mop.pszElementName = "roadkill.wav";
    else
        mop.pszElementName = pszWavFile;

    ulRC = mciSendCommand(  0,
                            MCI_OPEN,
                            MCI_WAIT | MCI_OPEN_ELEMENT | MCI_READONLY | MCI_OPEN_SHAREABLE,
                            &mop,
                            0 );
    *pusDevID = mop.usDeviceID;
    return( ulRC );
}
Ejemplo n.º 25
0
void CWndMovie::Quit ()
{

	theApp.Log ( "Ending movie player" );
	m_bInDestroy = TRUE;

	if (m_mciDevID != 0)
		CloseMovie ();

	if ( m_MainmciDevID != 0 )
		{
		MCI_GENERIC_PARMS mgp;
		memset (&mgp, 0, sizeof (mgp) );
		mciSendCommand (m_MainmciDevID, MCI_CLOSE, 0, (DWORD) &mgp );
		}

	theApp.m_wndMain.SetProgPos ( CWndMain::playing );
	theApp.m_wndMain.ShowWindow (SW_SHOW);
	theApp.m_wndMain.InvalidateRect (NULL);

	if ( m_bStartMusic )
		{
		m_bStartMusic = FALSE;
		theMusicPlayer.OnActivate ( TRUE );
		}

	if ( m_hWnd == NULL )
		{
		ShowCursor ( TRUE );
		theApp.PostIntro ();
		}
	else
		DestroyWindow ();

#ifdef BUGBUG
	if ( ( ! m_bShowLic ) || theApp.IsShareware () )
		theApp.PostIntro ();
#endif

	theApp.Log ( "Exiting movie player" );
}
Ejemplo n.º 26
0
// Sets "pos" to point at the beginning of the specified track
void CAudioCD::setPlayPos(int track)
{
	MCI_STATUS_PARMS status; // For holding status about the device

	status.dwCallback = (ULONG)win_hwnd; // Set the window handle
	status.dwTrack = track; // Set the track number
	status.dwItem = MCI_STATUS_POSITION; // We want dwReturn to be filled with a
										// position in the track

	// All the parameters for the mciSendCommand() are "like usual" except for the 
	// dwFlags parameter.  So here's what each flag means:
	// MCI_STATUS_ITEM -- Says that "dwItem" in "status" is valid (ie is filled in)
	// MCI_TRACK -- Says the dwTrack in "status" is valid
	// So by combining these flags this will return us the starting position of the track
	// that we've specified
	mciSendCommand(device_handle, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK, (DWORD)&status);

	// Save the start position
	pos = status.dwReturn;

}
Ejemplo n.º 27
0
VOID CALLBACK
PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
    MCI_STATUS_PARMS mciStatus;
    DWORD dwPos;

    if (!bIsOpened) KillTimer(hwnd, IDT_PLAYTIMER);

    mciStatus.dwItem = MCI_STATUS_POSITION;
    mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
    dwPos = mciStatus.dwReturn;

    if((UINT)dwPos >= MaxFilePos)
    {
        StopPlayback(hwnd);
    }
    else
    {
        SendMessage(hTrackBar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) dwPos);
    }
}
Ejemplo n.º 28
0
DWORD LoadMP3(HWND hWnd, LPCTSTR lpszWave)
{
	DWORD Result;

	mciOpen.lpstrDeviceType = "MPEGVideo";
	mciOpen.lpstrElementName = lpszWave;

	Result = mciSendCommand(wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)(LPVOID)&mciOpen);

	if (Result)
		return Result;

	wDeviceID = mciOpen.wDeviceID;

	mciPlay.dwCallback = (DWORD)hWnd;

	if (Result)
		return Result;

	return 0;
}
Ejemplo n.º 29
0
bool Win32RedBookDevice::getTrackCount(U32 * numTracks)
{
   if(!mAcquired)
   {
      setLastError("Device has not been acquired");
      return(false);
   }

   MCI_STATUS_PARMS statusParms;

   statusParms.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
   U32 error = mciSendCommand(mDeviceId, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD_PTR)(LPMCI_STATUS_PARMS)&statusParms);
   if(error)
   {
      setLastError(error);
      return(false);
   }

   *numTracks = statusParms.dwReturn;
   return(true);
}
Ejemplo n.º 30
0
int MusicBox::addMusic(CString name)
{
	m_nID++;
	if(m_nID==MAX_MUSIC)
	{
		MessageBox(NULL,"音乐播放数量超过游戏引擎承载能力","提示",0);
		return -1;
	}

	mciOpen.lpstrElementName=name;
	MCIERROR mciErr;
	mciErr=mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE|MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
	if(mciErr)
	{
		char str[128];
		mciGetErrorString(mciErr,str,128);
		MessageBox(NULL,str,"提示",0);
		return -1;
	}
	m_ID[m_nID]=mciOpen.wDeviceID;
	return m_nID;
}