From: Larry on 26 Dec 2009 14:52 "Larry" <dontmewithme(a)got.it> ha scritto nel messaggio news:4b366783$0$1101$4fafbaef(a)reader4.news.tin.it... > I'm sorry that's because I was writing fast to the group! One more thing...I don't seem to be getting the WHDR_DONE...ever! instead the first time I get 18 then only 3...what's the matter? thanks (window vista)
From: ScottMcP [MVP] on 26 Dec 2009 16:47 On Dec 26, 2:52 pm, "Larry" <dontmewit...(a)got.it> wrote: > "Larry" <dontmewit...(a)got.it> ha scritto nel messaggionews:4b366783$0$1101$4fafbaef(a)reader4.news.tin.it... > One more thing...I don't seem to be getting the WHDR_DONE...ever! instead > the first time I get 18 then only 3...what's the matter? > > thanks (window vista) You are getting WHDR_DONE but you're not testing for it correctly. WHDR_DONE is the 0x01 bit, which is part of 0x03. if (buff->dwFlags & WHDR_DONE) { ...header is done }
From: Larry on 26 Dec 2009 17:53 "ScottMcP [MVP]" <scottmcp(a)mvps.org> ha scritto nel messaggio news:94552def-7e53-4df9-a247-e5029c6b5696(a)e20g2000vbb.googlegroups.com... > You are getting WHDR_DONE but you're not testing for it correctly. > WHDR_DONE is the 0x01 bit, which is part of 0x03. > if (buff->dwFlags & WHDR_DONE) > { ...header is done > } Perfect! anyway, I wonder what's the use of WHDR_DONE now that thru the CALLBACK_EVENT I get the signal when the buffer is filled by the sistem! Just for the record now this is the code: { .... while(1) { WaitForSingleObject(hevent, INFINITE); if(buff->dwFlags & WHDR_DONE) { save_buffer(buff); waveInAddBuffer(hwi, buff, sizeof(WAVEHDR)); } if(stop_thread_flag) break; } waveInUnprepareHeader(hwi, buff, sizeof(WAVEHDR)); waveInClose(hwi); return 0; }; thenks
From: Larry on 28 Dec 2009 18:14 "ScottMcP [MVP]" <scottmcp(a)mvps.org> ha scritto nel messaggio news:4c1e1254-2c4f-4fd5-88cd-5a66d5e32d98(a)n13g2000vbe.googlegroups.com... > You allocated all the WAVEINHDR structs and the lpData. Don't lose > track of them. After all, you're supposed to delete them later, when > you're finished. > The dwUser field in WAVEINHDR can be used by you. For example, put a > 0 in there for buffer 0, a 1 in there for buffer 1, etc. > When WaitForSingleObject returns you are going to have to assume which > buffer finished. Of course, if you have a nextbuffernumber counter > that starts at zero you can use that. Make it an index into wherever > your array of WAVEINHDR is. Do you think I could check out every buffer right after the WaitForSingleObject? something like the following: // Loop... while(1) { WaitForSingleObject(hevent, INFINITE); for (int k = 0; k<num_buffers; k++) { if(buff[k].dwFlags & WHDR_DONE) { save_buffer(&buff[k]); waveInAddBuffer(hwi, &buff[k], sizeof(WAVEHDR)); } } if(stop_thread_flag) break; } for (int u = 0; u<num_buffers; u++) { waveInUnprepareHeader(hwi, &buff[u], sizeof(WAVEHDR)); } waveInClose(hwi); return 0; Do you think this is the right approach? I tested the code and it seems to be working great though. thanks
From: ScottMcP [MVP] on 28 Dec 2009 20:14 On Dec 28, 6:14 pm, "Larry" <dontmewit...(a)got.it> wrote: > "ScottMcP [MVP]" <scott...(a)mvps.org> ha scritto nel messaggionews:4c1e1254-2c4f-4fd5-88cd-5a66d5e32d98(a)n13g2000vbe.googlegroups.com... > > > You allocated all the WAVEINHDR structs and the lpData. Don't lose > > track of them. After all, you're supposed to delete them later, when > > you're finished. > > The dwUser field in WAVEINHDR can be used by you. For example, put a > > 0 in there for buffer 0, a 1 in there for buffer 1, etc. > > When WaitForSingleObject returns you are going to have to assume which > > buffer finished. Of course, if you have a nextbuffernumber counter > > that starts at zero you can use that. Make it an index into wherever > > your array of WAVEINHDR is. > > Do you think I could check out every buffer right after the > WaitForSingleObject? something like the following: > > // Loop... > while(1) > { > WaitForSingleObject(hevent, INFINITE); > for (int k = 0; k<num_buffers; k++) > { > if(buff[k].dwFlags & WHDR_DONE) > { > save_buffer(&buff[k]); > waveInAddBuffer(hwi, &buff[k], sizeof(WAVEHDR)); > } > } > > if(stop_thread_flag) > break; > } > for (int u = 0; u<num_buffers; u++) > { > waveInUnprepareHeader(hwi, &buff[u], sizeof(WAVEHDR)); > } > waveInClose(hwi); > return 0; > > Do you think this is the right approach? I tested the code and it seems to > be working great though. > > thanks It seems fine to do it that way. I think you could get by just fine without the checks though, because the buffers will be filled in the same order you output them. So a counter variable would be needed, like save_buffer(&buff[k]); waveInAddBuffer(hwi, &buff[k], sizeof(WAVEHDR)); k++;
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: using variables in RegCreateKeyEx raise type casts Next: create a wave file (riff) |