This bug report was migrated from our old Bugzilla tracker.
Reported in version: don't know Reported for operating system, platform: Windows (All), x86
Comments on the original bug report:
On 2006-01-24 00:20:44 +0000, Sam Lantinga wrote:
Date: Thu, 13 Mar 2003 11:56:55 -0500
From: Mark Aikens marka@desert.cx
Subject: [SDL] Sound under Windows
Hello.
A couple friends and I wrote a game using pygame (which uses SDL) and it
runs great under Linux. However, when running it under Windows, the
music breaks up. Increasing the sound buffer size makes it better but
then the latency of sound effects is terrible.
I traced the problem to the SDL directsound audio driver and modified it
slightly to fix it on my machine. The patch also fixed the breakups on
one of my friend's Windows machine. My other friend reports that the
sound quality got worse with the patch though.
I'm not a DirectSound or Windows expert so maybe someone can explain
what is going on. I've included the patch in this message.
Thanks.
-Mark
P.S. I'm not on the list so please CC me any replies.
Patch Description:
According to DirectX documentation, you're not supposed to write
between the play cursor and the write cursor, only after the write
cursor. Also enabled position notifications by default. Notifications
and polling were both tested and improved sound quality on my machine.
/* Define this if you want to use DirectX 6 DirectSoundNotify interface */
-//#define USE_POSITION_NOTIFY
+#define USE_POSITION_NOTIFY
/* DirectX function pointers for audio */
HRESULT (WINAPI *DSoundCreate)(LPGUID, LPDIRECTSOUND , LPUNKNOWN);
@@ -261,7 +261,7 @@
/ Semi-busy wait, since we have no way of getting play notification
on a primary mixing buffer located in hardware (DirectX 5.0)
*/
result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &cursor, &junk);
result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &junk, &cursor);
if ( result != DS_OK ) {
if ( result == DSERR_BUFFERLOST ) {
IDirectSoundBuffer_Restore(mixbuf);
@@ -271,9 +271,8 @@
#endif
return;
}
cursor /= mixlen;
while ( cursor == playing ) {
while((cursor/mixlen) == playing) {
/* FIXME: find out how much time is left and sleep that long */
SDL_Delay(10);
@@ -299,12 +298,11 @@
/* Find out where we are playing */
result = IDirectSoundBuffer_GetCurrentPosition(mixbuf,
&cursor, &junk);
&junk, &cursor);
if ( result != DS_OK ) {
SetDSerror("DirectSound GetCurrentPosition", result);
return;
}
cursor /= mixlen;
}
}
@@ -353,7 +351,7 @@
/* Figure out which blocks to fill next */
locked_buf = NULL;
result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &cursor, &junk);
result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &junk, &cursor);
if ( result == DSERR_BUFFERLOST ) {
IDirectSoundBuffer_Restore(mixbuf);
result = IDirectSoundBuffer_GetCurrentPosition(mixbuf,
This bug report was migrated from our old Bugzilla tracker.
Reported in version: don't know
Reported for operating system, platform: Windows (All), x86
Comments on the original bug report:
On 2006-01-24 00:20:44 +0000, Sam Lantinga wrote:
On 2006-01-27 11:23:21 +0000, Ryan C. Gordon wrote:
On 2006-06-23 05:05:57 +0000, Sam Lantinga wrote:
The text was updated successfully, but these errors were encountered: