Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Media";
Текущий архив: 2006.01.01;
Скачать: [xml.tar.bz2];

Вниз

Событие буфера DirectSound?   Найти похожие ветки 

 
Wm.DIGGER ©   (2005-07-28 09:28) [0]

Объясните, как вызывать собитие (а конкретно, событие это должна быть моя функция ...) при достижении определённой позиции в звуковом буфере DirectSound?

HRESULT SetStopNotification(HANDLE hMyEvent,
       LPDIRECTSOUNDBUFFER8 lpDsbSecondary)
{
 LPDIRECTSOUNDNOTIFY8 lpDsNotify;
 DSBPOSITIONNOTIFY PositionNotify;
 HRESULT hr;

 if (SUCCEEDED(
     hr = lpDsbSecondary->QueryInterface(IID_IDirectSoundNotify8,
            (LPVOID*)&lpDsNotify)))
 {
   PositionNotify.dwOffset = DSBPN_OFFSETSTOP;
   PositionNotify.hEventNotify = hMyEvent;
   hr = lpDsNotify->SetNotificationPositions(1, &PositionNotify);
   lpDsNotify->Release();
 }
 return hr;
}


 
Wm.DIGGER ©   (2005-07-28 09:31) [1]

Имеется ввиду, что такое HANDLE hMyEvent и чего с ним делать?

Описание из SDK:
Play Buffer Notification
DirectSound can notify your application when the play cursor reaches certain points in a buffer, or when the buffer stops. This can be useful in two common situations:

The application must take some action, such as playing another buffer, when a sound has finished playing.
The application is streaming data to the buffer, and needs to know when the play cursor reaches predefined points so that data that has been played can be replaced by new data.
Note   If you are taking advantage of voice management, it"s possible that a buffer could be terminated before a notification position is reached. See the Remarks for DSBPOSITIONNOTIFY.

Using the IDirectSoundNotify8::SetNotificationPositions method, 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 obtain a pointer to the IDirectSoundNotify8 interface. You can do this by using the buffer object"s QueryInterface method. A separate interface must be obtained from each buffer on which you want to set notifications.

For each notification position, create an event object with the Win32 CreateEvent function. Put the handle to this event in the hEventNotify member of a DSBPOSITIONNOTIFY structure. In the dwOffset member of that structure, specify the offset within the buffer where you want the event to be signaled. Then pass the address of the structure—or of an array of structures, if you want to set more than one notification position—to SetNotificationPositions.

The following example function sets a single notification position. The event will be signaled when playback stops, either because the end of a nonlooping buffer has been reached, or because the application called the IDirectSoundBuffer8::Stop method. Assume that hMyEvent is a handle returned by CreateEvent and that lpDsbSecondary is a secondary buffer created with the DSBCAPS_CTRLPOSITIONNOTIFY flag.


 
Wm.DIGGER ©   (2005-07-28 11:51) [2]

проблема решена ... :)



Страницы: 1 вся ветка

Форум: "Media";
Текущий архив: 2006.01.01;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.136 c
4-1130688697
TStas
2005-10-30 19:11
2006.01.01
Как получить серийный номер диска?


2-1134689494
Змей
2005-12-16 02:31
2006.01.01
не активная кнопка "Свернуть"


8-1122797191
cava
2005-07-31 12:06
2006.01.01
mediaplayer


2-1134557559
pussycat
2005-12-14 13:52
2006.01.01
Создать папку


2-1134764701
RX
2005-12-16 23:25
2006.01.01
Дебагинг





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский