1'st Init() { ... output[i].event_handle = CreateEvent(0, FALSE /* manual reset */, FALSE /* initial state */, 0); .. } After this ,the event_handle is nonsignaled state.
but in function:
int wait(struct buffer *buffer) { MMRESULT error; DWORD tick;
if (!buffer->playing) return 0;
tick = GetTickCount(); switch (WaitForSingleObject(buffer->event_handle, INFINITE)) { .. }
why the event_handle is signaled state?
I only find this time to setevent: void CALLBACK callback(HWAVEOUT handle, UINT message, DWORD data, DWORD param1, DWORD param2) { WAVEHDR *header; struct buffer *buffer;
switch (message) { case WOM_DONE: header = (WAVEHDR *) param1; buffer = (struct buffer *) header->dwUser; if (SetEvent(buffer->event_handle) == 0) {
... }
On Aug 18, 2005, at 10:26 PM, cnmmd wrote:
why the event_handle is signaled state?
I only find this time to setevent: void CALLBACK callback(HWAVEOUT handle, UINT message, DWORD data, DWORD param1, DWORD param2) { WAVEHDR *header; struct buffer *buffer;
switch (message) { case WOM_DONE: header = (WAVEHDR *) param1; buffer = (struct buffer *) header->dwUser; if (SetEvent(buffer->event_handle) == 0) {
... }
That's it. This callback routine is passed to waveOutOpen(), which allows it to be called asynchronously after each data block sent via waveOutWrite() has finished playing.