Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Detect Audio Device ?

Author
Message
Ortu
DBPro Master
10
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 14th Dec 2017 06:42 Edited at: 14th Dec 2017 06:48
Came across an error today which only seems to affect Windows 10 Home:

When attempting to load and play music (specifically with the enhanced audio plugin, have not tested native commands), if I do not have any speakers or headphones plugged in, I get an error about having no audio device, then another 4 or 5 errors about the music failing due to the lack of audio device. Program continues running as normal after clearing the error message pop ups.

No errors are given on windows 7 Pro, 8.1 Pro, or 10 Pro in this situation.

Then I thought, well surely there is something like 'perform checklist for audio devices' so that I can skip sound and music if no audio is available but I haven't been able to find anything. I've also checked through enhanced audio, d3d, and matrix1, none of which seem to have any ability to detect if an audio device is available.

So, anyone have a good way to detect if there is audio available?


(interestingly, iTunes also complains about the 'audio configuration' and refuses to load if no speaker/headphone is present on this machine)
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Green Gandalf
13
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 14th Dec 2017 12:04 Edited at: 14th Dec 2017 12:24
Yes, I have the same problem - and, annoyingly, Dark Shader needs audio to be active too. I get those sort of errors even when I'm not trying to load sound, etc, so it seems DBPro tries to load sound DLLs by default. Is it possible to exclude those DLLs at the compile stage if you know you won't need them?

I've had other sound issues, unrelated to DBPro, which have been solved by simply including an old DirectSound dll in the game folder (or something like that ). It's something to do with a recent update to W10 I believe. I'll try to dig out a link in case it's relevant to your issue. I think it was something to do with a reduction in the number of sound channels that are available.

Edit: Here's a link to the relevant advice (it concerned the game Civilization 3 on Steam):

https://pcgamingwiki.com/wiki/Civilization_III#No_music_or_sound_effects_during_diplomacy

The relevant bit of that page is the reference to IndirectSound. All I needed was the dsound.dll but you might need to tinker with settings in the ini file as well.

No idea whether this is relevant to your issue (seems a bit unlikely to me but it's worth a shot).
ReversalGames
2
Years of Service
User Offline
Joined: 24th Mar 2016
Location:
Posted: 16th Dec 2017 14:10
Just a suggestion ...
I think it would be great if we could have a command like "GetSoundDeviceStatus"
It could return the information like
- Sound Device present or not
- Speaker/Headphone connected or not
- Mic connected or not
Rudolpho
12
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 17th Dec 2017 22:24
This happens to me all the time on Windows 10; youtube videos freeze, games crash and so on when an audio device suddenly becomes unresponsive. Usually this happens because I have an external soundcard that seems to have a ~30% chance of not being recognized when coming out of sleep mode without un- and replugging it, but there can be other causes as well - for example my screen, which has a pair of speakers and as such qualifies as a separate audio device, will sometimes be considered to have been dis- and reconnected from static electricity discharges (I really should look into getting better cables for it I guess...). When this happens I sometimes get zombie devices where the old one still exists and can be active / activated if disconnecting another one, but won't work.
For the record this is using Windows 10 Pro; curiously I haven't had it happen on the Windows 10 Home computer I use at work (yes I know ), but that is probably because I don't really use anything but headphones or no audio device at all there.

As for the thread title I agree, but I'm not sure if it is possible to manually use any other audio device than the one currently set as the main one on newer versions of Windows. Many games will however keep using the old device when switched, while other software can detect the device change and then swap to the new device instead, so it might be possible.

Also here is a function to set the current main audio device; it works on Windows 7 and 10. Probably 8 and Vista as well:

Got to love how Microsoft likes to hide functionality under very unobvious function calls like that...

Login to post a reply

Server time is: 2018-08-18 21:40:38
Your offset time is: 2018-08-18 21:40:38