Click here to Skip to main content
15,894,180 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Using handle between two process Pin
Nishad S10-Jan-08 1:43
Nishad S10-Jan-08 1:43 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 2:16
mveCPallini10-Jan-08 2:16 
GeneralRe: Using handle between two process Pin
David Crow10-Jan-08 2:19
David Crow10-Jan-08 2:19 
GeneralRe: Using handle between two process Pin
ashtwin10-Jan-08 18:32
ashtwin10-Jan-08 18:32 
GeneralRe: Using handle between two process Pin
David Crow11-Jan-08 2:29
David Crow11-Jan-08 2:29 
GeneralAbout wavein API Pin
minihotto9-Jan-08 23:26
minihotto9-Jan-08 23:26 
QuestionRe: About wavein API Pin
Mark Salsbery10-Jan-08 7:38
Mark Salsbery10-Jan-08 7:38 
GeneralRe: About wavein API [modified] Pin
minihotto10-Jan-08 17:49
minihotto10-Jan-08 17:49 
Thx for ur reply.
I have a button that would let user click to stop recording.
That would make isclose = 1;

Originally, I use waveInStop but I waveInStop only stop recording.
waveInReset would stop recording and set the position to 0.
I see some information in the Internet that says use waveInUnPrepareHeader before using waveInReset.

Originally, I don't use Sleep() function,but it has same problem.

I write it in a new small program as follow.
It halts at waveInReset.
If I delete waveInReset, waveInUnPrepareHeader and waveInClose falses and returns 33.


#include "stdafx.h"<br />
#include <winsock2.h><br />
#include <windows.h><br />
#include <iostream><br />
#include <mmsystem.h><br />
#pragma comment(lib, "ws2_32.lib")<br />
#pragma comment(lib, "Winmm.lib")<br />
using namespace System;<br />
using namespace std;<br />
static void CALLBACK WaveInProc(HWAVEIN, UINT,  DWORD , DWORD , DWORD );<br />
<br />
static const int SNDNBUF = 2;<br />
static const int SNDSIZEBUF = 320;<br />
HWAVEOUT hWavout;<br />
MMRESULT mmrr;<br />
WAVEHDR headersend[SNDNBUF];<br />
char hdrDatasend[SNDSIZEBUF*SNDNBUF];<br />
HWAVEIN hWavin;<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
			WAVEFORMATEX wfx; <br />
			 wfx.nSamplesPerSec = 8000;<br />
			 wfx.nChannels = 1;<br />
			 wfx.wFormatTag = WAVE_FORMAT_PCM;<br />
			 wfx.wBitsPerSample = 16;<br />
			 wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample / 8);<br />
			 wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;<br />
<br />
	memset(headersend, 0,sizeof(WAVEHDR)*SNDNBUF);<br />
			 for(int i=0;i<sndnbuf;i++){<br />
				 headersend[i].lpData = hdrDatasend + i*SNDSIZEBUF;<br />
 				 headersend[i].dwBufferLength =  SNDSIZEBUF;}<br />
<br />
			  memset(hdrDatasend,0,SNDSIZEBUF*SNDNBUF);<br />
			<br />
			if(waveInOpen(&hWavin,WAVE_MAPPER, &wfx,(DWORD_PTR)WaveInProc ,0,  CALLBACK_FUNCTION) == MMSYSERR_NOERROR){<br />
 				for(int i=0;i<sndnbuf;i++)>{  <br />
				   mmrr = waveInPrepareHeader(hWavin, headersend + i, sizeof(WAVEHDR));<br />
				   mmrr = waveInAddBuffer(hWavin, headersend + i, sizeof(WAVEHDR));}<br />
				mmrr = waveInStart(hWavin);	}<br />
			int i;<br />
			cin >> i;<br />
			mmrr=waveInStop(hWavin);<br />
			mmrr=waveInReset(hWavin);<br />
			Sleep(500);<br />
			for(int i=0;i<sndnbuf;i++){<br />
				if ((headersend+i)->dwFlags & WHDR_PREPARED){<br />
			mmrr=waveInUnprepareHeader(hWavin,headersend+i, sizeof(WAVEHDR));}<br />
			Sleep(500);<br />
mmrr=waveInClose(hWavin);<br />
				cin >> i;<br />
	return 0;<br />
}<br />
<br />
static void CALLBACK WaveInProc(HWAVEIN hw, UINT uMsg,DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD dwParam2)<br />
{<br />
		 WAVEHDR* curhdrin = (WAVEHDR*)dwParam1;<br />
		if(uMsg != WIM_DATA)return;<br />
		waveInAddBuffer(hw, curhdrin, sizeof(WAVEHDR));<br />
		return;<br />
}</sndnbuf;i++)></mmsystem.h></iostream></windows.h></winsock2.h>

Jane

modified on Friday, January 11, 2008 4:23:59 AM

GeneralRe: About wavein API Pin
Mark Salsbery11-Jan-08 6:51
Mark Salsbery11-Jan-08 6:51 
GeneralRead a file which is located in another machine Pin
CodingLover9-Jan-08 23:13
CodingLover9-Jan-08 23:13 
GeneralRe: Read a file which is located in another machine Pin
toxcct9-Jan-08 23:19
toxcct9-Jan-08 23:19 
GeneralRe: Read a file which is located in another machine Pin
CodingLover9-Jan-08 23:35
CodingLover9-Jan-08 23:35 
GeneralRe: Read a file which is located in another machine Pin
Maxwell Chen9-Jan-08 23:26
Maxwell Chen9-Jan-08 23:26 
GeneralRe: Read a file which is located in another machine Pin
CodingLover9-Jan-08 23:54
CodingLover9-Jan-08 23:54 
GeneralRe: Read a file which is located in another machine Pin
David Crow10-Jan-08 2:26
David Crow10-Jan-08 2:26 
GeneralRe: Read a file which is located in another machine Pin
toxcct10-Jan-08 5:14
toxcct10-Jan-08 5:14 
GeneralRe: Read a file which is located in another machine Pin
David Crow10-Jan-08 5:30
David Crow10-Jan-08 5:30 
GeneralRe: Read a file which is located in another machine Pin
toxcct10-Jan-08 5:38
toxcct10-Jan-08 5:38 
GeneralRe: Read a file which is located in another machine Pin
CodingLover10-Jan-08 16:09
CodingLover10-Jan-08 16:09 
GeneralRe: Read a file which is located in another machine Pin
CodingLover10-Jan-08 15:57
CodingLover10-Jan-08 15:57 
Generalreg. editbox Pin
mail2h.jain9-Jan-08 23:10
mail2h.jain9-Jan-08 23:10 
GeneralRe: reg. editbox Pin
Maxwell Chen9-Jan-08 23:12
Maxwell Chen9-Jan-08 23:12 
GeneralRe: reg. editbox Pin
Hamid_RT9-Jan-08 23:25
Hamid_RT9-Jan-08 23:25 
GeneralRe: reg. editbox Pin
Maxwell Chen9-Jan-08 23:29
Maxwell Chen9-Jan-08 23:29 
GeneralRe: reg. editbox Pin
Hamid_RT9-Jan-08 23:42
Hamid_RT9-Jan-08 23:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.