Esempio n. 1
0
    HRESULT Init(const ZString& strDevice)
    {
        DWORD dwError; 

        // try to open the device
        MCI_OPEN_PARMSA mciOpenParms;
        DWORD dwFlags;

        mciOpenParms.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
        dwFlags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID;

        // translate the device name into an element name, if appropriate
        if (!strDevice.IsEmpty())
        {
            m_strElementName = TranslateElementName(strDevice);
            mciOpenParms.lpstrElementName = m_strElementName;
            dwFlags |= MCI_OPEN_ELEMENT;
        }

        // try opening it to make sure it exists
        dwError = mciSendCommand(NULL, MCI_OPEN, dwFlags, (UINT_PTR)&mciOpenParms);  //Fix memory leak -Imago 8/2/09
        if (dwError)
        {
            char cbError[256];
            mciGetErrorStringA(dwError, cbError, 256);
            debugf("Open failed for CD Audio device '%c': %s\n", (const char*)strDevice, cbError);
            return E_FAIL;
        }
        mciSendCommand(mciOpenParms.wDeviceID, MCI_CLOSE, 0, NULL);

        // start the background (io) thread
        StartThread(THREAD_PRIORITY_NORMAL, 200);

        return S_OK;
    }
void Win32RedBookDevice::setLastError(U32 errorId)
{
   char buffer[256];
   if(!mciGetErrorStringA(errorId, buffer, sizeof(buffer) - 1))
      setLastError("Failed to get MCI error string!");
   else
      setLastError(buffer);
}
Esempio n. 3
0
// -------------------
// MCIErrorMessageBox
// Retrieve error message corresponding to return value from
//  mciSendCommand() or mciSenString()
// -------------------
static VOID MCIErrorMessageBox (MCIERROR iErrorCode)
{
	char szErrorText[128];
	if (!mciGetErrorStringA (iErrorCode, szErrorText, sizeof (szErrorText)))
		wsprintfA(szErrorText,"MCI CD Audio Unknow Error #%d\n", iErrorCode);
	CONS_Printf (szErrorText);
	/*MessageBox (GetActiveWindow(), szTemp+1, "LEGACY",
				MB_OK | MB_ICONSTOP);*/
}
Esempio n. 4
0
 // stops the CD player (blocking)
 HRESULT StopImpl()
 {
     DWORD dwError = mciSendCommand(m_idDevice, MCI_STOP, 0, NULL);
     if (dwError)
     {
         char cbError[256];
         mciGetErrorStringA(dwError, cbError, 256);
         debugf("Stop failed for CD Audio device: %s\n", cbError);
         return E_FAIL;
     }
     return S_OK;
 };
Esempio n. 5
0
    void ThreadInit()
    {
        DWORD dwError; 

        // try to open the device
        MCI_OPEN_PARMSA mciOpenParms;
        DWORD dwFlags;
        ZString strElementName;

        mciOpenParms.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
        dwFlags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID;

        if (!m_strElementName.IsEmpty())
        {
            mciOpenParms.lpstrElementName = m_strElementName;
            dwFlags |= MCI_OPEN_ELEMENT;
        }

        dwError = mciSendCommand(NULL, MCI_OPEN, dwFlags, (UINT_PTR)&mciOpenParms);
        if (dwError)
        {
            char cbError[256];
            mciGetErrorStringA(dwError, cbError, 256);
            debugf("Open failed for CD Audio device '%': %s\n", (const char*)m_strElementName, cbError);
        }
        m_idDevice = mciOpenParms.wDeviceID;


        // Set the time format to track/minute/second/frame (TMSF).
        MCI_SET_PARMS mciSetParms;
        mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF;

        dwError = mciSendCommand(m_idDevice, MCI_SET, MCI_SET_TIME_FORMAT, (UINT_PTR)&mciSetParms);
        if (dwError)
        {
            char cbError[256];
            mciGetErrorStringA(dwError, cbError, 256);
            debugf("Set format failed for CD Audio device: %s\n", cbError);
        } 
    }
Esempio n. 6
0
    // returns S_OK if the CD player is playing, S_FALSE otherwise (blocking)
    HRESULT IsPlayingImpl()
    {
        MCI_STATUS_PARMS mciStatusParams;
        mciStatusParams.dwItem = MCI_STATUS_MODE;

        DWORD dwError = mciSendCommandA(m_idDevice, MCI_STATUS, MCI_STATUS_ITEM, (UINT_PTR)&mciStatusParams);
        if (dwError)
        {
            char cbError[256];
            mciGetErrorStringA(dwError, cbError, 256);
            debugf("Status:Mode failed for CD Audio device: %s\n", cbError);
            return E_FAIL;
        }
        return (mciStatusParams.dwReturn == MCI_MODE_PLAY) ? S_OK : S_FALSE;
    };
Esempio n. 7
0
    // returns the current track of the CD player (blocking)
    HRESULT GetCurrentTrackImpl(int& nTrack)
    {
        MCI_STATUS_PARMS mciStatusParams;
        mciStatusParams.dwItem = MCI_STATUS_CURRENT_TRACK;

        DWORD dwError = mciSendCommand(m_idDevice, MCI_STATUS, MCI_STATUS_ITEM, (UINT_PTR)&mciStatusParams);
        if (dwError)
        {
            char cbError[256];
            mciGetErrorStringA(dwError, cbError, 256);
            debugf("Status:Track failed for CD Audio device: %s\n", cbError);
            return E_FAIL;
        }
        nTrack = mciStatusParams.dwReturn;
        return S_OK;
    };
Esempio n. 8
0
/**
 * Execute an MCI command string.
 *
 * @return              @c true, if successful.
 */
static int sendMCICmd(char* returnInfo, int returnLength,
                      const char *format, ...)
{
    char                buf[300];
    va_list             args;
    MCIERROR            error;

    va_start(args, format);
    dd_vsnprintf(buf, sizeof(buf), format, args);
    va_end(args);

    if((error = mciSendStringA(buf, returnInfo, returnLength, NULL)))
    {
        mciGetErrorStringA(error, buf, 300);
        Con_Message("DM_WinCD: %s", buf);

        return false;
    }

    return true;
}
Esempio n. 9
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;
    };
Esempio n. 10
0
/**************************************************************************
 * 				mciGetErrorString		[MMSYSTEM.706]
 */
BOOL16 WINAPI mciGetErrorString16(DWORD wError, LPSTR lpstrBuffer, UINT16 uLength)
{
    return mciGetErrorStringA(wError, lpstrBuffer, uLength);
}