I ask for help on this since i cant implement good directsound playing
I use a directsound buffer to store data and is played with DSBPLAY_LOOPING.
I use a custom write cursor that starts at play cursor position (0 for it first time) when the dsound buffer is first played. When an emulator frame has passed i call a Cawrite() function that tell me how many buffer bytes free there are. Basically it returns play_cursor - custom_write; if the play cursor has wrapped it does buffer_size - customwrite + play_cursor.
Suppouse i need 1300 bytes free in the buffer for this frame. Naturally i should wait for CanWrite() to return that value. But the thing is that it there is no way to get exactly 1300 bytes free.
I don't want to use any pre-made lib that communicates with dsound.
So, how do you i implement dicctsound sound in your emus? or maybe a more general question how do you implement sound in your emus?
p.s:
I know that there is not low level support in Windows Vista for DirectSound, but i choose it for backwards compatibility.
I use a directsound buffer to store data and is played with DSBPLAY_LOOPING.
I use a custom write cursor that starts at play cursor position (0 for it first time) when the dsound buffer is first played. When an emulator frame has passed i call a Cawrite() function that tell me how many buffer bytes free there are. Basically it returns play_cursor - custom_write; if the play cursor has wrapped it does buffer_size - customwrite + play_cursor.
Suppouse i need 1300 bytes free in the buffer for this frame. Naturally i should wait for CanWrite() to return that value. But the thing is that it there is no way to get exactly 1300 bytes free.
I don't want to use any pre-made lib that communicates with dsound.
So, how do you i implement dicctsound sound in your emus? or maybe a more general question how do you implement sound in your emus?
p.s:
I know that there is not low level support in Windows Vista for DirectSound, but i choose it for backwards compatibility.