Microsoft Windows CE 3.0  

Play Buffer Notification

This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

When streaming audio, you may want your application to be notified when the current play position reaches a certain point in the buffer, or when playback is stopped. With the IDirectSoundNotify::SetNotificationPositionsmethod you can set any number of points within the buffer where events are to be signaled. You cannot do this while the buffer is playing.

First you have to obtain a pointer to the IDirectSoundNotifyinterface. You can do this by using the buffer object's QueryInterfacemethod, as in the following C++ example:

// LPDIRECTSOUNDBUFFER lpDsbSecondary; // The
buffer has been initialized already. LPDIRECTSOUNDNOTIFY
lpDsNotify; // pointer to the interface HRESULT hr =
lpDsbSecondary->QueryInterface(IID_IDirectSoundNotify, (LPVOID
*)&lpDsNotify); if SUCCEEDED(hr) { // Go ahead and use
lpDsNotify->SetNotificationPositions. }
Note   The IDirectSoundNotifyinterface is associated with the object that obtained the pointer, in this case the secondary buffer. The methods of the new interface will automatically apply to that buffer.

Now create an event object with the Win32 CreateEventfunction. You put the handle to this event in the hEventNotifymember of a DSBPOSITIONNOTIFYstructure, and in the dwOffsetmember of that structure you specify the offset within the buffer where you want the event to be signaled. Then you pass the address of the structureor of an array of structures, if you want to set more than one notification positionto the IDirectSoundNotify::SetNotificationPositionsmethod.

The following example sets a single notification position. The event will be signaled when playback stops, either because it was not looping and the end of the buffer has been reached, or because the application called the IDirectSoundBuffer::Stopmethod.

PositionNotify.Offset = DSBPN_OFFSETSTOP;
PositionNotify.hEventNotify = hMyEvent; // hMyEvent is the handle
returned by CreateEvent()

 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.