Exemple #1
0
CString CWaveIn::GetLastErrorString()
{
    TCHAR buffer[256];
    memset(buffer,0,sizeof(buffer));
    waveInGetErrorText(m_mmr,buffer,256);
    return CString(buffer);
}
Exemple #2
0
static void wavein_error (char *src, int32 ret)
{
    char errbuf[1024];
    
    waveInGetErrorText(ret, errbuf, sizeof(errbuf));
    fprintf(stderr, "%s error %d: %s\n", src, ret, errbuf);
}
Exemple #3
0
// マルチメディア関数のエラー表示
void mmerr(int mr)
{
	char err_str[256];

	waveInGetErrorText(mr, err_str,sizeof(err_str));
	fprintf(stderr,err_str);
}
Exemple #4
0
static void
wavein_error(char *src, int32 ret)
{
    TCHAR errbuf[512];

    waveInGetErrorText(ret, errbuf, sizeof(errbuf));
	OutputDebugString(errbuf);
}
Exemple #5
0
void RecordSound::displayError(int mmReturn,char errmsg[])
{
char errorbuffer[MAX_PATH];
char errorbuffer1[MAX_PATH];

	waveInGetErrorText( mmReturn,errorbuffer,MAX_PATH);
	sprintf(errorbuffer1,"RECORD: %s : %x : %s",errmsg,mmReturn,errorbuffer);
	AfxMessageBox(errorbuffer1);  
}
Exemple #6
0
void waveOutErrorMsg(MMRESULT mmr, char* szTitle)
{
	WCHAR wszClassName[256];
	memset(wszClassName, 0, sizeof(wszClassName));
	MultiByteToWideChar(CP_ACP, 0, szTitle, strlen(szTitle) + 1, wszClassName,
		sizeof(wszClassName) / sizeof(wszClassName[0]));
	WCHAR txt[MAXERRORLENGTH];
	waveInGetErrorText(mmr, txt, MAXERRORLENGTH);
	MessageBox(0, txt, wszClassName, MB_OK | MB_ICONWARNING);
}
Exemple #7
0
static const char * wave_in_error(MMRESULT error)
{
    static char msg[1024];
    static char long_msg[1100];
    MMRESULT rc;

    rc = waveInGetErrorText(error, msg, sizeof(msg));
    if (rc != MMSYSERR_NOERROR)
        sprintf(long_msg, "waveInGetErrorText(%x) failed with error %x", error, rc);
    else
        sprintf(long_msg, "%s(%s)", mmsys_error(error), msg);
    return long_msg;
}
Exemple #8
0
static int checkWaveInResult(HANDLE h, MMRESULT res, char *msg)
{
	char buf[80];

	if (h == NULL) {
		fprintf(stderr, "%s: Handle is NULL\n");
		return -1;
	}
	if (res != MMSYSERR_NOERROR) {
		if (waveInGetErrorText(res, buf, sizeof buf))
			fprintf(stderr, "%s: Unknown WaveIn error\n", msg);
		else
			fprintf(stderr, "%s: %s\n", msg, buf);
		return -1;
	}
	return 0;
}
Exemple #9
0
void mm_error_handler(snd_type snd, MMRESULT mmerror, void (*fp)())
{
    char err[MAXERRORLENGTH];
    MMRESULT errnum;
    if (snd->write_flag == SND_READ) {
        errnum = waveInGetErrorText(mmerror, err, MAXERRORLENGTH);
    } else {
        errnum = waveOutGetErrorText(mmerror, err, MAXERRORLENGTH);
    }
    if (MMSYSERR_NOERROR != errnum) {
        switch (errnum) {
        case MMSYSERR_BADERRNUM:
            (*fp)("Specified error number is out of range.");
        case MMSYSERR_NODRIVER:
            (*fp)("No device driver is present.");
        case MMSYSERR_NOMEM:
            (*fp)("Unable to allocate or lock memory.");
        }
    }
    else
        (*fp)(err);
}
Exemple #10
0
/*
* Error routines
*/
static int
audioerror(unsigned int code, int in_out, char *msg)
{
    char errorText[MAXERRORLENGTH];

    if (code != MMSYSERR_NOERROR) {
        switch(in_out) {
        case AUDIOIN:
            waveInGetErrorText(code, errorText, sizeof(errorText));
            //print("ERROR -- %s: %s\n", msg, errorText);
            return(-1);
        case AUDIOOUT:
            waveOutGetErrorText(code, errorText, sizeof(errorText));
            //print("ERROR -- %s: %s\n", msg, errorText);
            return(-1);
        default:
            print("%s: Unknown device\n", msg);
        }
    }
    //print("TRACE %s\n", msg);
    return 0;
}
CString CSoundRecDlg::StoreError(MMRESULT mRes,BOOL bDisplay,LPCTSTR lpszFormat, ...)
{
	MMRESULT mRes1=0;
	char szErrorText[1024]={0};
	char szT1[2*MAX_PATH]={0};
	
	va_list args;
	va_start(args, lpszFormat);
	_vsntprintf(szT1, MAX_PATH, lpszFormat, args);
	va_end(args);

	m_csErrorText.Empty();
	if(m_bRun)
	{
		mRes1=waveInGetErrorText(mRes,szErrorText,1024);
		if(mRes1!=0)
			wsprintf(szErrorText,"Error %d in querying the error string for error code %d",mRes1,mRes);
		m_csErrorText.Format("%s: %s",szT1,szErrorText);
		if(bDisplay)
			AfxMessageBox(m_csErrorText);
	}
	return m_csErrorText;
}
static void nt_waveinerror(char *s, int err)
{
    char t[256];
    waveInGetErrorText(err, t, 256);
    fprintf(stderr, s, t);
}
Exemple #13
0
DWORD WINAPI AudioThread(LPVOID lpParameter)
{
    // Create wave format structure

    static WAVEFORMATEX wf =
	{WAVE_FORMAT_PCM, CHANNELS,
	 SAMPLE_RATE, SAMPLE_RATE * BLOCK_ALIGN,
	 BLOCK_ALIGN, BITS_PER_SAMPLE, 0};

    MMRESULT mmr;

    // Open a waveform audio input device

    mmr = waveInOpen(&audio.hwi, WAVE_MAPPER | WAVE_FORMAT_DIRECT, &wf,
		     (DWORD_PTR)audio.id,  (DWORD_PTR)NULL, CALLBACK_THREAD);

    if (mmr != MMSYSERR_NOERROR)
    {
	static char s[64];

	waveInGetErrorText(mmr, s, sizeof(s));
	MessageBox(window.hwnd, s, "WaveInOpen", MB_OK | MB_ICONERROR);
	return mmr;
    }

    // Create the waveform audio input buffers and structures

    static short data[4][STEP];
    static WAVEHDR hdrs[4] =
	{{(LPSTR)data[0], sizeof(data[0]), 0, 0, 0, 0},
	 {(LPSTR)data[1], sizeof(data[1]), 0, 0, 0, 0},
	 {(LPSTR)data[2], sizeof(data[2]), 0, 0, 0, 0},
	 {(LPSTR)data[3], sizeof(data[3]), 0, 0, 0, 0}};

    for (int i = 0; i < LENGTH(hdrs); i++)
    {
	// Prepare a waveform audio input header

	mmr = waveInPrepareHeader(audio.hwi, &hdrs[i], sizeof(WAVEHDR));
	if (mmr != MMSYSERR_NOERROR)
	{
	    static char s[64];

	    waveInGetErrorText(mmr, s, sizeof(s));
	    MessageBox(window.hwnd, s, "WaveInPrepareHeader",
		       MB_OK | MB_ICONERROR);
	    return mmr;
	}

	// Add a waveform audio input buffer

	mmr = waveInAddBuffer(audio.hwi, &hdrs[i], sizeof(WAVEHDR));
	if (mmr != MMSYSERR_NOERROR)
	{
	    static char s[64];

	    waveInGetErrorText(mmr, s, sizeof(s));
	    MessageBox(window.hwnd, s, "WaveInAddBuffer",
		       MB_OK | MB_ICONERROR);
	    return mmr;
	}
    }

    // Start the waveform audio input

    mmr = waveInStart(audio.hwi);
    if (mmr != MMSYSERR_NOERROR)
    {
	static char s[64];

	waveInGetErrorText(mmr, s, sizeof(s));
	MessageBox(window.hwnd, s, "WaveInStart", MB_OK | MB_ICONERROR);
	return mmr;
    }

    // Create a message loop for processing thread messages

    MSG msg;
    BOOL flag;

    while ((flag = GetMessage(&msg, (HWND)-1, 0, 0)) != 0)
    {
	if (flag == -1)
	    break;

	// Process messages

	switch (msg.message)
	{
	    // Audio input opened

	case MM_WIM_OPEN:
	    // Not used
	    break;

	    // Audio input data

	case MM_WIM_DATA:
	    WaveInData(msg.wParam, msg.lParam);
	    break;

	    // Audio input closed

	case MM_WIM_CLOSE:
	    // Not used
	    break;
	}
    }

    return msg.wParam;
}
Exemple #14
0
DWORD WINAPI AudioThread(LPVOID lpParameter)
{
    // Set up timebase

    scope.scale = timebase.values[timebase.index];
    xscale.scale = scope.scale;
    xscale.step = 500 * xscale.scale;

    // Update display

    InvalidateRgn(xscale.hwnd, NULL, TRUE);

    UpdateStatus();

    // Create wave format structure

    static WAVEFORMATEX wf =
	{WAVE_FORMAT_PCM, CHANNELS,
	 SAMPLE_RATE, SAMPLE_RATE * BLOCK_ALIGN,
	 BLOCK_ALIGN, BITS_PER_SAMPLE, 0};

    MMRESULT mmr;

    // Open a waveform audio input device

    mmr = waveInOpen(&audio.hwi, WAVE_MAPPER | WAVE_FORMAT_DIRECT, &wf,
		     (DWORD_PTR)audio.id,  (DWORD_PTR)NULL, CALLBACK_THREAD);

    if (mmr != MMSYSERR_NOERROR)
    {
	static char s[64];

	waveInGetErrorText(mmr, s, sizeof(s));
	MessageBox(window.hwnd, s, "WaveInOpen", MB_OK | MB_ICONERROR);
	return mmr;
    }

    do
    {
	// Mixer structures

	static MIXERLINE mxl =
	    {sizeof(MIXERLINE)};

	static MIXERCONTROL mxc =
	    {sizeof(MIXERCONTROL)};

	static MIXERLINECONTROLS mxlc =
	    {sizeof(MIXERLINECONTROLS)};

	static MIXERCONTROLDETAILS mxcd =
	    {sizeof(MIXERCONTROLDETAILS)};

	static MIXERCONTROLDETAILS_UNSIGNED mxcdu;

	// Open a mixer device

	mmr = mixerOpen(&mixer.hmx, (UINT)audio.hwi, (DWORD_PTR)window.hwnd, 0,
			CALLBACK_WINDOW | MIXER_OBJECTF_HWAVEIN);

	if (mmr != MMSYSERR_NOERROR)
	    break;

	// Mixer line types

	DWORD types[] =
	    {MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE,
	     MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY,
	     MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER,
	     MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE,
	     MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER,
	     MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC,
	     MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED,
	     MIXERLINE_COMPONENTTYPE_SRC_DIGITAL,
	     MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT,
	     MIXERLINE_COMPONENTTYPE_SRC_ANALOG,
	     MIXERLINE_COMPONENTTYPE_SRC_LINE};

	// Get mixer line info

	for (int i = 0; i < Length(types); i++)
	{
	    // Try a component type

	    mxl.dwComponentType = types[i];

	    // Get the info

	    mmr = mixerGetLineInfo((HMIXEROBJ)mixer.hmx, &mxl,
				   MIXER_GETLINEINFOF_COMPONENTTYPE);

	    // Try again if error

	    if (mmr != MMSYSERR_NOERROR)
		continue;


	    // Check if line is active

	    if (mxl.fdwLine & MIXERLINE_LINEF_ACTIVE)
	    {
		mixer.pmxl = &mxl;
		break;
	    }
	}

	// No mixer line

	if (mixer.pmxl == NULL)
	    break;

	// Get a volume control

	mxlc.dwLineID = mxl.dwLineID;
	mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
	mxlc.cControls = 1;
	mxlc.cbmxctrl = sizeof(mxc);
	mxlc.pamxctrl = &mxc;

	mmr = mixerGetLineControls((HMIXEROBJ)mixer.hmx, &mxlc,
				   MIXER_GETLINECONTROLSF_ONEBYTYPE);

	if (mmr != MMSYSERR_NOERROR)
	    break;

	// Got a volume control

	mixer.pmxc = &mxc;

	// Get the control details

	mxcd.dwControlID = mxc.dwControlID;
	mxcd.cChannels = MIXERCONTROL_CONTROLF_UNIFORM;
	mxcd.cbDetails = sizeof(mxcdu);
	mxcd.paDetails = &mxcdu;

	mmr = mixerGetControlDetails((HMIXEROBJ)mixer.hmx, &mxcd,
				     MIXER_GETCONTROLDETAILSF_VALUE);

	if (mmr != MMSYSERR_NOERROR)
	    break;

	mixer.pmxcd = &mxcd;
	mixer.pmxcdu = &mxcdu;

    } while (FALSE);

    // Create the waveform audio input buffers and structures

    static short data[4][STEP];
    static WAVEHDR hdrs[4] =
	{{(LPSTR)data[0], sizeof(data[0]), 0, 0, 0, 0},
	 {(LPSTR)data[1], sizeof(data[1]), 0, 0, 0, 0},
	 {(LPSTR)data[2], sizeof(data[2]), 0, 0, 0, 0},
	 {(LPSTR)data[3], sizeof(data[3]), 0, 0, 0, 0}};

    for (int i = 0; i < Length(hdrs); i++)
    {
	// Prepare a waveform audio input header

	mmr = waveInPrepareHeader(audio.hwi, &hdrs[i], sizeof(WAVEHDR));
	if (mmr != MMSYSERR_NOERROR)
	{
	    static char s[64];

	    waveInGetErrorText(mmr, s, sizeof(s));
	    MessageBox(window.hwnd, s, "WaveInPrepareHeader",
		       MB_OK | MB_ICONERROR);
	    return mmr;
	}

	// Add a waveform audio input buffer

	mmr = waveInAddBuffer(audio.hwi, &hdrs[i], sizeof(WAVEHDR));
	if (mmr != MMSYSERR_NOERROR)
	{
	    static char s[64];

	    waveInGetErrorText(mmr, s, sizeof(s));
	    MessageBox(window.hwnd, s, "WaveInAddBuffer",
		       MB_OK | MB_ICONERROR);
	    return mmr;
	}
    }

    // Start the waveform audio input

    mmr = waveInStart(audio.hwi);
    if (mmr != MMSYSERR_NOERROR)
    {
	static char s[64];

	waveInGetErrorText(mmr, s, sizeof(s));
	MessageBox(window.hwnd, s, "WaveInStart", MB_OK | MB_ICONERROR);
	return mmr;
    }

    // Create a message loop for processing thread messages

    MSG msg;
    BOOL flag;

    while ((flag = GetMessage(&msg, (HWND)-1, 0, 0)) != 0)
    {
	if (flag == -1)
	    break;

	// Process messages

	switch (msg.message)
	{
	    // Audio input opened

	case MM_WIM_OPEN:
	    // Not used
	    break;

	    // Audio input data

	case MM_WIM_DATA:
	    WaveInData(msg.wParam, msg.lParam);
	    break;

	    // Audio input closed

	case MM_WIM_CLOSE:
	    // Not used
	    break;
	}
    }

    return msg.wParam;
}
Exemple #15
0
LRESULT CRecordSound::OnStartRecording(WPARAM wParam, LPARAM lParam)
{
	DWORD mmReturn = 0;

	if(m_bRecording)
		return FALSE;

	if(!m_bRecording)
	{
		// open wavein device
		MMRESULT mmReturn = ::waveInOpen( &m_hRecord, WAVE_MAPPER,
			&m_WaveFormatEx, ::GetCurrentThreadId(), 0, CALLBACK_THREAD);
		if(mmReturn)
		{
			char errorbuffer[MAX_PATH];
			char errorbuffer1[MAX_PATH];
			waveInGetErrorText( mmReturn, 
								errorbuffer,
								MAX_PATH);
			sprintf(errorbuffer1,"WAVEIN:%x:%s",mmReturn,errorbuffer);

			AfxMessageBox(errorbuffer1);  

		}
	
			
		if(!mmReturn)
		{
			for(int i=0; i < m_nMaxInputBuffers; i++)
			{
				LPWAVEHDR lpHdr = CreateWaveHeader();
				mmReturn = ::waveInPrepareHeader(m_hRecord,lpHdr, sizeof(WAVEHDR));
				mmReturn = ::waveInAddBuffer(m_hRecord, lpHdr, sizeof(WAVEHDR));
				m_nInputBuffers++;
			}
			mmReturn = ::waveInStart(m_hRecord);
			if(mmReturn )
		{
			char errorbuffer[MAX_PATH];
			char errorbuffer1[MAX_PATH];
			waveInGetErrorText( mmReturn, 
								errorbuffer,
								MAX_PATH);
			sprintf(errorbuffer1,"WAVEIN:%x:%s",mmReturn,errorbuffer);

			AfxMessageBox(errorbuffer1);  

		}
	
			if(!mmReturn)
			{
				m_bRecording = TRUE;
				if(m_Player)
					m_Player->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING, 0, 0);				
					if(m_Writer)
					{
						char SendFileName[MAX_PATH];
						memset(SendFileName,0,MAX_PATH*sizeof(char));
						pwsf= (PWRITESOUNDFILE) new WRITESOUNDFILE;
						ZeroMemory(pwsf,sizeof(WRITESOUNDFILE));
						char *p = pwsf->lpszFileName;
						CString strdir,fullname;
						strdir.Format("%sXMTvoice",XMTVoiceFile.m_Path);
						CreateFileName(strdir.GetBuffer(0),".wav",SendFileName);
						strcpy(p,SendFileName);
						memcpy(&pwsf->waveFormatEx,&m_WaveFormatEx,sizeof(m_WaveFormatEx));
						m_Writer->PostThreadMessage(WM_WRITESOUNDFILE_FILENAME,0,(LPARAM)pwsf);
					}
		
				return ERROR_SUCCESS;
			}
		}
	

	}
	return TRUE;
}