| Summary: | Remove unnecessary audio delay | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Thomas Klausner <tk> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | Keywords: | target-2.0.10 |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | NetBSD | ||
| See Also: | https://bugzilla.libsdl.org/show_bug.cgi?id=4642 | ||
| Attachments: | Patch removing the delay. | ||
(In reply to Thomas Klausner from comment #0) > The BSD audio backend has an SDL_Delay inside, which is unnecessary, since > writing audio is automatically slowing it down (there is a limited buffer > size). Remove it. (patch in pkgsrc for ages, no user complaints) Well, this might be necessary on BSD systems other than NetBSD...at a minimum, it looks like it's meant to work around driver quirks. Maybe we can wrap this in an #ifndef __NetBSD__ with a comment that this condition isn't necessary on that platform, instead? --ryan. The comment at the top of the file says that this file is the audio backend for OpenBSD and NetBSD. I've checked OpenBSD ports and found that they use the OpenBSD-specific sndio backend instead. I've also checked FreeBSD ports, and they use the esd backend. That said, I have no problem with a '#ifndef __NetBSD__' around the code instead, but I think it's not really necessary. Looking more closely still: In configure, src/audio/bsd is _only_ used on NetBSD. (In reply to Thomas Klausner from comment #2) > I've also checked FreeBSD ports, and they use the esd backend. Oh my god, can that actually be true? That has to be a mistake. Let's leave this as-is (and this bug open) until 2.0.4 is finished, and then I'll figure out what happened with that. If this really has turned into a NetBSD-only audio target, let's rename it to "netbsd" and remove that delay code. --ryan. Just a ping since not only 2.0.4, but also 2.0.5 has been out in the meantime. (In reply to Thomas Klausner from comment #5) > Just a ping since not only 2.0.4, but also 2.0.5 has been out in the > meantime. This has been renamed from "bsd" to "netbsd" in https://hg.libsdl.org/SDL/rev/25cd7fe50180 ...we can resolve the SDL_Delay thing now. However, as it stands right now, it looks like this code is opening the device with O_NONBLOCK. A lifetime ago, we needed to open() audio devices on Linux as O_NONBLOCK because Open Sound System might hang indefinitely otherwise--during the open() call! It's 100% possible this is not a problem NetBSD has or ever had. If so, I'd like to make sure the device on NetBSD is not opened as O_NONBLOCK and delete all the #ifndef USE_BLOCKING_WRITES code in src/audio/netbsd. (One of the primary reasons Open Sound System would block indefinitely is if something else had the device open...so an MP3 player in the background, or Esound daemon or whatever, would cause games to hang on startup. I just need some assurance that NetBSD won't have that problem. --ryan.
(To be clear: there are several SDL_Delay calls, not just the one in Attachment #2299 [details], and I'd like to remove them all if possible.)
--ryan.
Starting from the upcoming NetBSD 8.0 release, NetBSD comes with an in-kernel audio mixer, so there are no limits on parallel opened audio devices (see https://blog.netbsd.org/tnf/entry/netbsd_8_0_release_process). Does that answer your question? We applied the patch from NetBSD's package system, which removes the SDL_Delay() and fixes a bunch of other stuff too. That patch is here: https://hg.libsdl.org/SDL/rev/f26b341b14b4 In theory, this should resolve all the problems, but please reopen this bug if there an issue. (THANK YOU for being so patient with this bug that was opened so long ago!) --ryan. |
Created attachment 2299 [details] Patch removing the delay. The BSD audio backend has an SDL_Delay inside, which is unnecessary, since writing audio is automatically slowing it down (there is a limited buffer size). Remove it. (patch in pkgsrc for ages, no user complaints)