コード例 #1
0
ファイル: WaveIn.cpp プロジェクト: shuangye/FrequencyAnalyzer
void InDevice::Open (Win::Event & event)
{
    _status = ::waveInOpen (
                  &_handle,
                  _devId,
                  &_format,
                  reinterpret_cast<DWORD> (event.Get ()),
                  0, // callback instance data
                  CALLBACK_EVENT);
    switch (_status)
    {
    case MMSYSERR_NOERROR:
        return;
    case MMSYSERR_ALLOCATED:
        throw Win::Exception("Cannot open input device: Specified resource is already allocated.");
    case MMSYSERR_BADDEVICEID:
        throw Win::Exception("Cannot open input device: Specified device identifier is out of range.");
    case MMSYSERR_NODRIVER:
        throw Win::Exception("Cannot open input device: No device driver is present.");
    case MMSYSERR_NOMEM:
        throw Win::Exception("Cannot open input device: Unable to allocate or lock memory.");
    case WAVERR_BADFORMAT:
        throw Win::Exception("Cannot open input device: Attempted to open with an unsupported waveform-audio format.");
    case WAVERR_SYNC:
        throw Win::Exception("Cannot open input device: The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag.");
    default:
        throw Win::Exception ("Cannot open input device: Unknown error");
    }
    if (!Ok ())
        throw Win::Exception ("Opening the input device failed.");
}
コード例 #2
0
void OutDevice::Open (Win::Event & event)
{
	_status = ::waveOutOpen (
		&_handle, 
		_devId, 
		&_format, 
		reinterpret_cast<DWORD> (event.Get ()),
		0, // callback instance data
		CALLBACK_EVENT);
	if (!Ok ())
		throw Win::Exception ("Cannot open device");
}