FS#5539 - OTTD MIDI stops Windows from playing sounds on other applications

Attached to Project: OpenTTD
Opened by Ricardo (Samu) - Wednesday, 01 May 2013, 18:11 GMT
Last edited by Remko Bijker (Rubidium) - Sunday, 09 June 2013, 11:22 GMT
Type Bug
Category Core
Status Closed
Assigned To No-one
Operating System Windows
Severity High
Priority Normal
Reported Version 1.3.0
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


I'm using Windows 7 Ultimate 64-bit and using the OpenMSX 0.3.1 music pack. Music plays fine for a few hours, but suddenly, it just stops playing any more music, and the sound effects from the game will appear delayed, or cut, or playing all at once or paused. However, the main problem is that while I still have OpenTTD or any other application running, which makes use of sound, like for example, Internet Explorer, or Windows Media Player, they will always play no sound, or come up with an error saying there's no win32 audio device available.

This sucks because sometimes it's a really bad timing to close OpenTTD, or the other applications. It looks like OpenTTD is hogging all sound resources to itself and thus prevents anything else on the system to play sounds. Sometimes not even closing OpenTTD fixs it, only restarting Windows will fix it.

The workaround I found so far is to never play any MIDI in OpenTTD, but that's to say I just want to prevent the bug to happen.

I'm using a somewhat complex/hybrid/licensed/whatever integrated audio device from my motherboard, ASUS Crosshair V Formula

It's still a Realtek High Definition Audio but with those things licensed from Creative Labs, they call it then "SupremeFX X-Fi 2 built-in 8-Channel High Definition Audio CODEC "

I have EAX, THX, ALchemy and TruStudio installed. There are a few issues with ALchemy and EAX together in some older games, but I managed to work this out and no longer have any issues, but I can't really find a way out with OpenTTD completely shutting down all sounds from the system.

The best clue I can give to you was some error from Windows when I was trying to mess with sound properties with its own tests saying that some other application is taking exclusive access to the DirectSound buffer and warned me that it could cause Windows to become unstable should I force Windows to play a testing sound.

What could that mean?
This task depends upon

Closed by  Remko Bijker (Rubidium)
Sunday, 09 June 2013, 11:22 GMT
Reason for closing:  Bug in external library
Comment by Remko Bijker (Rubidium) - Saturday, 01 June 2013, 12:08 GMT
OpenTTD's MIDI playback is nothing more than calling the appropriate Windows/DirectX APIs for MIDI playback. That code hasn't changed since 2008. Since this is the first time I see this issue, I rather suspect something external (outside of OpenTTD's control) to create this issue. It might, for example, be some software that takes over MIDI playback from the standard software MIDI device, or the sound card driver that lets the sound card play the MIDI.

If shutting down OpenTTD does not solve the issue, then (in theory) it can't be OpenTTD as any application that is closed releases by definition all its handles, including any locks on sound cards etc.
Comment by Ricardo (Samu) - Saturday, 01 June 2013, 19:16 GMT
Hello, thank you for the reply.

I discovered meanwhile that Audiodg.exe is part of the problem. Days ago I terminated this process when the sound coming from my system was behaving "delayed-or-cut-or-playing-all-at-once-or-paused" and I got sound back again, including Midi playback. Just before this happening, I was playing a Youtube vídeo which only played video and no sound, while OpenTTD was running at the same time. Everything went eery with OpenTTD sounds since the failed vídeo - I tried to start playing midi from Openttd jukebox, and no music was coming out, but I noticed that the Midi playlist was updating from time to time - somehow OpenTTD believed the midis were playing and updating track titles accordingly.

I used an utility named Process Explorer to spy inside Audiodg.exe and it appeared to be queuing many sound pieces at once, including (failed) midis, instead of playing them asap, leading to cpu usage spikes. Each spike appeared to be related to that "delayed-or-cut-or-playing-all-at-once-or-paused" playback that I was experiencing. The only application that was playing sounds at the moment was OpenTTD and it was the only one that could play sounds. Any other application that I posteriorly started running, would not play any sound. I tried Windows Media Player, Need for Speed World, even another copy of OpenTTD and no sound would come out of them at all.

However, terminating Audiodg.exe did not solve the whole problem. The only application coming with sounds, OpenTTD, did start playing sound correctly, even midi, but once I started other applications, this remaining OpenTTD instance suddenly went mute playing sounds and midi when I didn't expect it. Thanksfully, all other applications did play sound correctly with no issues, even another OpenTTD instance. I "fixed" it by exiting that first OpenTTD. Didn't have to restart system, but this really is annoying. I don't know who's to blame, but apparently it's Microsoft and how it handles Audio. Searching for Audiodg.exe on the Internet pops up many similar topics with problems similar to mine.
Comment by Ricardo (Samu) - Sunday, 16 June 2013, 19:49 GMT
Small update, quoting myself from another forum

Hi again, I have a small update regarding this topic.

I have not 'yet' resorted to install the sound drivers from ASUS website, but I've been having no issues ever since the time I first opened this topic - I've uninstalled that day Adobe Flash Player (uncertain about which version, but it was for IE10), and so far, 10 days and ongoing, I haven't had any sound issues whatsoever. Reading through Adobe website also seems to indicate there was some sort of sound problem within the same timeframe, April - June.

Unfortunately for me, that wasn't the only thing I have uninstalled that day. I've also uninstalled MSI Afterburner and HWiNFO which were both running at Windows start-up. I especially think the conflict is between the audio/video recording feature of MSI Afterburner which was always turned on for video capturing whenever I wanted, and Adobe Flash Player for whenever I wanted to watch some youtube video - something to do with microphone or audio capturing, and I know both applications (Afterburner and Flash) do resort to audio capturing devices.

Maybe I'm talking out of my ass and nobody's here to even care, but those are just my obvervations. I will be more aware next time I re-install these two programs, one at a time, then if I don't get into the same sound issues again, I will install the other one a week later.

I no longer believe it to be a driver issue anymore.