这篇教程C++ CreateEvent函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CreateEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateEvent函数的具体用法?C++ CreateEvent怎么用?C++ CreateEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CreateEvent函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mkEventHANDLEmkEvent(){ return CreateEvent(NULL, FALSE, FALSE, NULL);}
开发者ID:melted,项目名称:hdirect,代码行数:5,
示例2: PlatformParker PlatformParker () { _ParkEvent = CreateEvent (NULL, true, false, NULL) ; guarantee (_ParkEvent != NULL, "invariant") ; }
开发者ID:AK47POMA,项目名称:openjdk-icedtea7,代码行数:4,
示例3: handle//==============================================================================WaitableEvent::WaitableEvent (const bool manualReset) noexcept : handle (CreateEvent (0, manualReset ? TRUE : FALSE, FALSE, 0)) {}
开发者ID:Ixox,项目名称:preenfm2Controller,代码行数:3,
示例4: CreateEventclNamedPipe *clNamedPipeConnectionsServer::waitForNewConnection( int timeout ){ PIPE_HANDLE hConn = this->initNewInstance();#ifdef __WXMSW__ OVERLAPPED ov = {0}; HANDLE ev = CreateEvent(NULL, TRUE, TRUE, NULL); ov.hEvent = ev; HandleLockerServer locker(ov.hEvent); bool fConnected = ConnectNamedPipe(hConn, &ov); if (fConnected != 0) { if(hConn != INVALID_PIPE_HANDLE) { CloseHandle(hConn); } this->setLastError(NP_SERVER_UNKNOWN_ERROR); return NULL; } switch (GetLastError()) { // The overlapped connection in progress. case ERROR_IO_PENDING: { DWORD res = WaitForSingleObject(ov.hEvent, timeout) ; switch (res) { case WAIT_OBJECT_0 : { clNamedPipeServer *conn = new clNamedPipeServer(_pipePath); conn->setHandle(hConn); return conn; } case WAIT_TIMEOUT : { if ( hConn != INVALID_PIPE_HANDLE ) { CloseHandle( hConn ); } this->setLastError(NP_SERVER_TIMEOUT); return NULL; } default: { if ( hConn != INVALID_PIPE_HANDLE ) { CloseHandle( hConn ); } this->setLastError(NP_SERVER_UNKNOWN_ERROR); return NULL; } } } case ERROR_PIPE_CONNECTED: { clNamedPipeServer *conn = new clNamedPipeServer(_pipePath); conn->setHandle(hConn); return conn; } // If an error occurs during the connect operation... default: { if(hConn != INVALID_PIPE_HANDLE) { CloseHandle(hConn); } this->setLastError(NP_SERVER_UNKNOWN_ERROR); return NULL; } }#else // accept new connection if (hConn != INVALID_PIPE_HANDLE) { if ( timeout > 0 ) { fd_set fds; struct timeval tv; memset( (void*)&fds, 0, sizeof( fds ) ); FD_SET( hConn, &fds ); tv.tv_sec = 0; tv.tv_usec = timeout * 1000; // convert mili to micro int rc = select(hConn + 1, &fds, 0, 0, &tv); if ( rc == 0 || rc < 0 ) { // timeout or error setLastError(NP_SERVER_TIMEOUT); return NULL; } } PIPE_HANDLE fd = ::accept(hConn, 0, 0); if (fd > 0) { clNamedPipeServer *conn = new clNamedPipeServer(_pipePath); conn->setHandle(fd); return conn; } else { perror("ERROR: accept"); return NULL; } } return NULL;#endif}
开发者ID:05storm26,项目名称:codelite,代码行数:99,
示例5: DispatchChild// The server and client have to rely on// certain interprocess communication schemes// to exchange the WSAPROTOCOL_INFO needed for// duplicating the socket. In this sample,// we use momory mapped files.BOOL DispatchChild(SOCKET ClientSock, char *pszChildProcName){ char szChildComandLineBuf[MAX_PATH]; char szFileMappingObj[MAX_PATH]; BOOL bResult = TRUE; STARTUPINFO siParent; PROCESS_INFORMATION piChild; char szParentEventName[MAX_PATH]; char szChildEventName[MAX_PATH]; ZeroMemory(&siParent, sizeof(siParent)); siParent.cb = sizeof(siParent); siParent.dwFlags = STARTF_USECOUNTCHARS; siParent.dwXCountChars = 10 * MAX_PATH; siParent.dwYCountChars = MAX_PATH; // Compose a name for the memory mappled file. sprintf_s(szFileMappingObj, MAX_PATH, "%s%i", FILE_MAPPING_BASE_NAME, nChildProcCount++); sprintf_s(szParentEventName, MAX_PATH,"%s%s", szFileMappingObj, PARENT); sprintf_s(szChildEventName, MAX_PATH,"%s%s", szFileMappingObj, CHILD); // Create an event to signal the child // that the protocol info is set if ((ghParentFileMappingEvent = CreateEvent(NULL, TRUE, FALSE, szParentEventName)) == NULL) { fprintf(stderr, "/nCreateEvent() failed: %d/n", GetLastError()); return FALSE; } // Create an event to for the child to signal the // parent that the protocol info can be released if ((ghChildFileMappingEvent = CreateEvent(NULL, TRUE, FALSE, szChildEventName)) == NULL) { fprintf(stderr, "/nCreateEvent() failed: %d/n", GetLastError()); CloseHandle(ghParentFileMappingEvent); ghParentFileMappingEvent = NULL; return FALSE; } // Set up the child process command line options. // The memory mapped file name is passed in as // one of the options. sprintf_s(szChildComandLineBuf, MAX_PATH, "%s /c %s", pszChildProcName, szFileMappingObj); if (CreateProcess(NULL, szChildComandLineBuf, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &siParent, &piChild)) { WSAPROTOCOL_INFO ProtocolInfo; int nError; LPVOID lpView; int nStructLen = sizeof(WSAPROTOCOL_INFO); // Get the protocol information // to be used to duplicate the socket if (WSADuplicateSocket(ClientSock, piChild.dwProcessId, &ProtocolInfo) == SOCKET_ERROR) { fprintf(stderr, "WSADuplicateSocket(): failed. Error = %d/n", WSAGetLastError()); DoCleanup(); exit(1); } // Set the protocol information in a // memory mapped file for the child to use ghMMFileMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, nStructLen, szFileMappingObj); if (ghMMFileMap != NULL) { if ((nError = GetLastError()) == ERROR_ALREADY_EXISTS) fprintf(stderr, "CreateFileMapping(): mappping file already exists/n"); else {//.........这里部分代码省略.........
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,
示例6: WndProcLRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam){ int nItemCount; int nSelected; int *nIndexes; BOOL bFlag; WCHAR *pszFile; WCHAR *handle; WCHAR *token; Image *imgCurrent; Image out; switch (iMessage) { case WM_CREATE: HANDLE hToken; viewer.changeCaption(L"Preview"); //Create Controls hListLayer = CreateWindow(L"ListBox", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_EXTENDEDSEL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT, 0, 80, 240, 420, hWnd, (HMENU)ID_LAYER_LIST, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonStart = CreateWindow(L"Button", L"Start", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 80, 40, hWnd, (HMENU)ID_START_BUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonSave = CreateWindow(L"Button", L"Save Selected in merged file", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 80, 0, 80, 40, hWnd, (HMENU)ID_SAVE_BUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonSaveAll = CreateWindow(L"Button", L"Save All in individual file", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 160, 0, 80, 40, hWnd, (HMENU)ID_SAVE_ALL, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonResetAll = CreateWindow(L"Button", L"Erase All", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 0, 40, 80, 40, hWnd, (HMENU)ID_RESET_ALL, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonResetSelected = CreateWindow(L"Button", L"Erase Selected", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 80, 40, 80, 40, hWnd, (HMENU)ID_RESET_SEL, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButtonResetUnselected = CreateWindow(L"Button", L"Erase Unelected", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, 160, 40, 80, 40, hWnd, (HMENU)ID_RESET_UNSEL, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hFont = CreateFont(16, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 3, 2, 1, FF_ROMAN, L"Segoe UI"); SendMessage(hListLayer, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonStart, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonSave, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonSaveAll, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonResetAll, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonResetSelected, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hButtonResetUnselected, WM_SETFONT, (WPARAM)hFont, TRUE); //Create Events hAttachSucceeded = CreateEvent(NULL, TRUE, FALSE, NULL); hDebugEnd = CreateEvent(NULL, TRUE, FALSE, NULL); hDebugInit = CreateEvent(NULL, TRUE, FALSE, NULL); //Adjust Privileges if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { if (SetPrivilege(hToken, SE_DEBUG_NAME, TRUE)) return 0; else MessageBox(hWnd, L"Fail to get debug privilege!!", L"Error", MB_OK | MB_ICONERROR); } else MessageBox(hWnd, L"Fail to get process token!!", L"Error", MB_OK | MB_ICONERROR); SendMessage(hWnd, WM_DESTROY, 0, 0); return 0; case WM_ACTIVATE: if (wParam == WA_CLICKACTIVE) { viewer.foreground(); SetForegroundWindow(hWnd); SetFocus(hListLayer); } return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_START_BUTTON: if (!bStarted) { hAokanaWnd = FindAokana(&dwThreadID, &dwProcessID); if (dwThreadID != 0) { hDebugThread = CreateThread(NULL, 0, DebugThread, NULL, 0, NULL); WaitForSingleObject(hDebugInit, INFINITE); if (WaitForSingleObject(hAttachSucceeded, 0) != WAIT_OBJECT_0) { SetEvent(hDebugEnd); MessageBox(hWnd, L"Fail to attach process!!", L"Error", MB_OK | MB_ICONERROR); break; } SendMessage(hButtonStart, WM_SETTEXT, 0, (LPARAM)L"Stop"); bStarted = TRUE; } } else { SetEvent(hDebugEnd); WaitForSingleObject(hDebugThread, INFINITE); ResetEvent(hDebugEnd); ResetEvent(hDebugInit); ResetEvent(hAttachSucceeded); CloseHandle(hDebugThread);//.........这里部分代码省略.........
开发者ID:weimingtom,项目名称:AokanaCGExtractor,代码行数:101,
示例7: _tWinMainint APIENTRY _tWinMain(HINSTANCE hinst, HINSTANCE foo1, LPTSTR foo2, int foo3) { MSG msg; WNDCLASSEX wcex = {sizeof(wcex)}; HANDLE htray; HMENU hmenu; MENUITEMINFO mi = {sizeof(mi)}; INITCOMMONCONTROLSEX icex; RECT rect; int style; HWND hwnd; wcex.lpfnWndProc = WndProc; wcex.lpszClassName = WINDOW_CLASS; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); RegisterClassEx(&wcex); icex.dwSize = sizeof(icex); icex.dwICC = ICC_DATE_CLASSES; InitCommonControlsEx(&icex); hwnd = CreateWindowEx(WS_EX_NOACTIVATE | WS_EX_TOPMOST, WINDOW_CLASS, WINDOW_TITLE, 0, 0, 0, 0, 0, NULL, NULL, hinst, NULL); if (!hwnd) return 1; style = GetWindowLong(hwnd, GWL_STYLE); if (style & WS_CAPTION) { style ^= WS_CAPTION; SetWindowLong(hwnd, GWL_STYLE, style); SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); } hcal = CreateWindowEx(0, MONTHCAL_CLASS, _T(""), WS_CHILD | WS_VISIBLE | MCS_NOTODAY | MCS_NOTRAILINGDATES | MCS_SHORTDAYSOFWEEK | MCS_NOSELCHANGEONNAV, 0, 0, 0, 0, hwnd, NULL, hinst, NULL); MonthCal_GetMinReqRect(hcal, &rect); SetWindowPos(hcal, NULL, 0, 0, rect.right, rect.bottom, SWP_NOZORDER | SWP_NOMOVE); SetWindowPos(hwnd, NULL, 0, 0, rect.right, rect.bottom, SWP_NOZORDER | SWP_NOMOVE); tti.hwnd = hwnd; tti.hcal = hcal; tti.hnotify = CreateEvent(NULL, TRUE, FALSE, NULL); tti.exit = FALSE; htray = CreateThread(NULL, 0, &TrayThreadProc, &tti, 0, NULL); if (!htray) return 1; hsubmenu = CreateMenu(); mi.fMask = MIIM_STRING | MIIM_ID; mi.wID = 1; mi.dwTypeData = EXIT_STRING; InsertMenuItem(hsubmenu, 0, TRUE, &mi); hmenu = CreateMenu(); mi.fMask = MIIM_SUBMENU; mi.hSubMenu = hsubmenu; InsertMenuItem(hmenu, 0, TRUE, &mi); WM_TASKBARCREATED = RegisterWindowMessageA(_T("TaskbarCreated")); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } DestroyMenu(hmenu); DestroyMenu(hsubmenu); WaitForSingleObject(htray, 1000); CloseHandle(htray); return (int)msg.wParam;}
开发者ID:alexmarsev,项目名称:traybin,代码行数:69,
示例8: EIO_WatchPortvoid EIO_WatchPort(uv_work_t* req) { WatchPortBaton* data = static_cast<WatchPortBaton*>(req->data); data->bytesRead = 0; data->disconnected = false; // Event used by GetOverlappedResult(..., TRUE) to wait for incoming data or timeout // Event MUST be used if program has several simultaneous asynchronous operations // on the same handle (i.e. ReadFile and WriteFile) HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); while(true) { OVERLAPPED ov = {0}; ov.hEvent = hEvent; // Start read operation - synchrounous or asynchronous DWORD bytesReadSync = 0; if(!ReadFile((HANDLE)data->fd, data->buffer, bufferSize, &bytesReadSync, &ov)) { data->errorCode = GetLastError(); if(data->errorCode != ERROR_IO_PENDING) { // Read operation error if(data->errorCode == ERROR_OPERATION_ABORTED) { data->disconnected = true; } else { ErrorCodeToString("Reading from COM port (ReadFile)", data->errorCode, data->errorString); } break; } // Read operation is asynchronous and is pending // We MUST wait for operation completion before deallocation of OVERLAPPED struct // or read data buffer // Wait for async read operation completion or timeout DWORD bytesReadAsync = 0; if(!GetOverlappedResult((HANDLE)data->fd, &ov, &bytesReadAsync, TRUE)) { // Read operation error data->errorCode = GetLastError(); if(data->errorCode == ERROR_OPERATION_ABORTED) { data->disconnected = true; } else { ErrorCodeToString("Reading from COM port (GetOverlappedResult)", data->errorCode, data->errorString); } break; } else { // Read operation completed asynchronously data->bytesRead = bytesReadAsync; } } else { // Read operation completed synchronously data->bytesRead = bytesReadSync; } // Return data received if any if(data->bytesRead > 0) { break; } } CloseHandle(hEvent);}
开发者ID:BrianAdams,项目名称:node-serialport,代码行数:64,
示例9: winmm_stream_init//.........这里部分代码省略......... switch (output_stream_params->format) { case CUBEB_SAMPLE_S16LE: wfx.Format.wBitsPerSample = 16; wfx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; break; case CUBEB_SAMPLE_FLOAT32LE: wfx.Format.wBitsPerSample = 32; wfx.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; break; default: return CUBEB_ERROR_INVALID_FORMAT; } wfx.Format.nBlockAlign = (wfx.Format.wBitsPerSample * wfx.Format.nChannels) / 8; wfx.Format.nAvgBytesPerSec = wfx.Format.nSamplesPerSec * wfx.Format.nBlockAlign; wfx.Samples.wValidBitsPerSample = wfx.Format.wBitsPerSample; EnterCriticalSection(&context->lock); /* CUBEB_STREAM_MAX is a horrible hack to avoid a situation where, when many streams are active at once, a subset of them will not consume (via playback) or release (via waveOutReset) their buffers. */ if (context->active_streams >= CUBEB_STREAM_MAX) { LeaveCriticalSection(&context->lock); return CUBEB_ERROR; } context->active_streams += 1; LeaveCriticalSection(&context->lock); stm = calloc(1, sizeof(*stm)); XASSERT(stm); stm->context = context; stm->params = *output_stream_params; stm->data_callback = data_callback; stm->state_callback = state_callback; stm->user_ptr = user_ptr; stm->written = 0; if (latency < context->minimum_latency) { latency = context->minimum_latency; } bufsz = (size_t) (stm->params.rate / 1000.0 * latency * bytes_per_frame(stm->params) / NBUFS); if (bufsz % bytes_per_frame(stm->params) != 0) { bufsz += bytes_per_frame(stm->params) - (bufsz % bytes_per_frame(stm->params)); } XASSERT(bufsz % bytes_per_frame(stm->params) == 0); stm->buffer_size = bufsz; InitializeCriticalSection(&stm->lock); stm->event = CreateEvent(NULL, FALSE, FALSE, NULL); if (!stm->event) { winmm_stream_destroy(stm); return CUBEB_ERROR; } stm->soft_volume = -1.0; /* winmm_buffer_callback will be called during waveOutOpen, so all other initialization must be complete before calling it. */ r = waveOutOpen(&stm->waveout, WAVE_MAPPER, &wfx.Format, (DWORD_PTR) winmm_buffer_callback, (DWORD_PTR) stm, CALLBACK_FUNCTION); if (r != MMSYSERR_NOERROR) { winmm_stream_destroy(stm); return CUBEB_ERROR; } r = waveOutPause(stm->waveout); if (r != MMSYSERR_NOERROR) { winmm_stream_destroy(stm); return CUBEB_ERROR; } for (i = 0; i < NBUFS; ++i) { WAVEHDR * hdr = &stm->buffers[i]; hdr->lpData = calloc(1, bufsz); XASSERT(hdr->lpData); hdr->dwBufferLength = bufsz; hdr->dwFlags = 0; r = waveOutPrepareHeader(stm->waveout, hdr, sizeof(*hdr)); if (r != MMSYSERR_NOERROR) { winmm_stream_destroy(stm); return CUBEB_ERROR; } winmm_refill_stream(stm); } *stream = stm; return CUBEB_OK;}
开发者ID:cclauss,项目名称:gecko-dev,代码行数:101,
示例10: test_capture_bufferstatic void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, LPDIRECTSOUNDCAPTUREBUFFER dscbo, int record){ HRESULT rc; DSCBCAPS dscbcaps; WAVEFORMATEX wfx; DWORD size,status; capture_state_t state; int i, ref; /* Private dsound.dll: Error: Invalid caps pointer */ rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,0); ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should " "have returned DSERR_INVALIDPARAM, returned: %s/n", DXGetErrorString8(rc)); /* Private dsound.dll: Error: Invalid caps pointer */ dscbcaps.dwSize=0; rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps); ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should " "have returned DSERR_INVALIDPARAM, returned: %s/n", DXGetErrorString8(rc)); dscbcaps.dwSize=sizeof(dscbcaps); rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps); ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCaps() failed: %s/n", DXGetErrorString8(rc)); if (rc==DS_OK && winetest_debug > 1) { trace(" Caps: size = %d flags=0x%08x buffer size=%d/n", dscbcaps.dwSize,dscbcaps.dwFlags,dscbcaps.dwBufferBytes); } /* Query the format size. Note that it may not match sizeof(wfx) */ /* Private dsound.dll: Error: Either pwfxFormat or pdwSizeWritten must * be non-NULL */ rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,NULL); ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetFormat() should " "have returned DSERR_INVALIDPARAM, returned: %s/n", DXGetErrorString8(rc)); size=0; rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,&size); ok(rc==DS_OK && size!=0,"IDirectSoundCaptureBuffer_GetFormat() should " "have returned the needed size: rc=%s, size=%d/n", DXGetErrorString8(rc),size); rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,&wfx,sizeof(wfx),NULL); ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetFormat() failed: %s/n", DXGetErrorString8(rc)); if (rc==DS_OK && winetest_debug > 1) { trace(" Format: tag=0x%04x %dx%dx%d avg.B/s=%d align=%d/n", wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample, wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign); } /* Private dsound.dll: Error: Invalid status pointer */ rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,0); ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetStatus() should " "have returned DSERR_INVALIDPARAM, returned: %s/n", DXGetErrorString8(rc)); rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status); ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %s/n", DXGetErrorString8(rc)); if (rc==DS_OK && winetest_debug > 1) { trace(" Status=0x%04x/n",status); } ZeroMemory(&state, sizeof(state)); state.dscbo=dscbo; state.wfx=&wfx; state.buffer_size = dscbcaps.dwBufferBytes; for (i = 0; i < NOTIFICATIONS; i++) state.event[i] = CreateEvent( NULL, FALSE, FALSE, NULL ); state.size = dscbcaps.dwBufferBytes / NOTIFICATIONS; rc=IDirectSoundCaptureBuffer_QueryInterface(dscbo,&IID_IDirectSoundNotify, (void **)&(state.notify)); ok((rc==DS_OK)&&(state.notify!=NULL), "IDirectSoundCaptureBuffer_QueryInterface() failed: %s/n", DXGetErrorString8(rc)); if (rc!=DS_OK) return; for (i = 0; i < NOTIFICATIONS; i++) { state.posnotify[i].dwOffset = (i * state.size) + state.size - 1; state.posnotify[i].hEventNotify = state.event[i]; } rc=IDirectSoundNotify_SetNotificationPositions(state.notify,NOTIFICATIONS, state.posnotify); ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions() failed: %s/n", DXGetErrorString8(rc)); if (rc!=DS_OK) return; ref=IDirectSoundNotify_Release(state.notify); ok(ref==0,"IDirectSoundNotify_Release(): has %d references, should have " "0/n",ref); if (ref!=0)//.........这里部分代码省略.........
开发者ID:WASSUM,项目名称:longene_travel,代码行数:101,
示例11: mmp_threadDWORD mmp_thread( DWORD dw ) { // open device int i; int nextbuf; short* sampledata; WAVEFORMATEX waveformat; WAVEHDR waveheader[NUMBUFS]; if (UseDevice==(unsigned int)-1) return 0; SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_HIGHEST); weHaveTerminated=0; waveformat.wFormatTag=WAVE_FORMAT_PCM; waveformat.nChannels=2; waveformat.wBitsPerSample=16; waveformat.nSamplesPerSec=44100; waveformat.nBlockAlign=(waveformat.nChannels*waveformat.wBitsPerSample)/8; waveformat.nAvgBytesPerSec=waveformat.nSamplesPerSec*waveformat.nBlockAlign; waveformat.cbSize=0; waveOutOpen(&audiodev,UseDevice,&waveformat,(unsigned int)bufferdone,0,CALLBACK_FUNCTION);#ifdef MMPDEBUG printf("audiodev: %X/n",audiodev);#endif musicevent=CreateEvent(NULL,FALSE,FALSE,"WinUsmPlayer"); sampledata=(short*)GlobalAlloc(MEM_COMMIT,BUFLENGTH*NUMBUFS);#ifdef MMPDEBUG printf("%X, %X/n",sampledata,sampledata+BUFLENGTH*NUMBUFS);#endif for (i=0;i<NUMBUFS;i++) { //printf("preparing %ld bytes at %X/n", BUFLENGTH, sampledata+BUFLENGTH*i); waveheader[i].lpData=(char*)sampledata+i*BUFLENGTH; waveheader[i].dwFlags=0; waveheader[i].dwBufferLength = BUFLENGTH; waveOutPrepareHeader(audiodev,&waveheader[i],sizeof(WAVEHDR)); mmp_generate( sampledata+(i*BUFLENGTH/2), BUFLENGTH>>1 ); waveOutWrite(audiodev,&waveheader[i],sizeof(WAVEHDR)); } nextbuf=0; while(playing) { IXA_PlayerActive=0; if (WaitForSingleObject(musicevent,1000)==WAIT_TIMEOUT) {// WinUsmPlayPause();// WinUsmPlayRestart(); } IXA_PlayerActive=1; for (i=0;i<NUMBUFS;i++) { if ((waveheader[i].dwFlags & WHDR_DONE) && nextbuf==i) { waveOutUnprepareHeader(audiodev,&waveheader[i],sizeof(WAVEHDR)); mmp_generate( sampledata+(i*BUFLENGTH/2), BUFLENGTH>>1 ); waveOutPrepareHeader(audiodev,&waveheader[i],sizeof(WAVEHDR)); waveOutWrite(audiodev,&waveheader[i],sizeof(WAVEHDR)); nextbuf++; if (nextbuf==NUMBUFS) nextbuf=0; } } }
开发者ID:brownman,项目名称:randomjunk,代码行数:69,
|