Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
HRESULT SetCaptureNotifications(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB) { #define cEvents 3 LPDIRECTSOUNDNOTIFY8 pDSNotify; WAVEFORMATEX wfx; HANDLE rghEvent[cEvents] = {0}; DSBPOSITIONNOTIFY rgdsbpn[cEvents]; HRESULT hr; if (NULL == pDSCB) return E_INVALIDARG; if (FAILED(hr = pDSCB->QueryInterface(IID_IDirectSoundNotify, (LPVOID*)&pDSNotify))) { return hr; } if (FAILED(hr = pDSCB->GetFormat(&wfx, sizeof(WAVEFORMATEX), NULL))) { return hr; } // Create events. for (int i = 0; i < cEvents; ++i) { rghEvent[i] = CreateEvent(NULL, TRUE, FALSE, NULL); if (NULL == rghEvent[i]) { hr = GetLastError(); return hr; } } // Describe notifications. rgdsbpn[0].dwOffset = (wfx.nAvgBytesPerSec/2) -1; rgdsbpn[0].hEventNotify = rghEvent[0]; rgdsbpn[1].dwOffset = wfx.nAvgBytesPerSec - 1; rgdsbpn[1].hEventNotify = rghEvent[1]; rgdsbpn[2].dwOffset = DSBPN_OFFSETSTOP; rgdsbpn[2].hEventNotify = rghEvent[2]; // Create notifications. hr = pDSNotify->SetNotificationPositions(cEvents, rgdsbpn); pDSNotify->Release(); return hr; } |
Zitat
A thread uses the CreateEvent function to create an event object. The creating thread specifies the initial state of the object and whether it is a manual-reset or auto-reset event object. The creating thread can also specify a name for the event object. Threads in other processes can open a handle to an existing event object by specifying its name in a call to the OpenEvent function. For additional information about names for mutex, event, semaphore, and timer objects, see Interprocess Synchronization.
Werbeanzeige