1'st
Init() { ... output[i].event_handle = CreateEvent(0, FALSE /* manual reset */, FALSE /* initial state */, 0); ----->the event object initial state is FALSE,--nonsignaled. .. } 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;
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) { ... } case WOM_OPEN: case WOM_CLOSE: -----> nothing to do in this. break; }
------------------------------
Message: 2 Date: Fri, 19 Aug 2005 11:39:24 -0700 From: Rob Leslie rob@mars.org Subject: Re: [mad-dev] [madplay]:audio_win32.c::struct buffer.event_handle: Can not find the time that sets the event object to the signaled state To: mad-dev@lists.mars.org Message-ID: DE968453-D275-4D13-9D99-F285590788C2@mars.org Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
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.
-------->yes, This callback routine will to be called after each data block sent via
[waveOutWrite()] has finished playing. but after waveOutOpen(),the callback do nothing.the event object is nonsignaled also.
On Aug 19, 2005, at 6:04 PM, cnmmd wrote:
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.
-------->yes, This callback routine will to be called after each data block sent via [waveOutWrite()] has finished playing. but after waveOutOpen(),the callback do nothing.the event object is nonsignaled also.
I don't understand what your question is. The event object is initially nonsignaled. It becomes signaled after waveOutWrite() finishes playing the data block associated with it. The main thread waits for the event object to become signaled before reusing the data block.
Are you puzzled because the event object is nonsignaled before waveOutWrite() is first called? The event object is not checked unless the data block is currently being used for playback (buffer-
playing).