|
Post by larrybtoys on Jul 26, 2024 2:18:12 GMT 1
Is there a way in GB32 to see if there is an audio device attached to the PC. I had a situation where someone was playing one of my games on a PC with no audio device attached and the program crashed. When running the program again and turning off sounds in the game it ran fine. TIA
|
|
|
Post by Xavier on Jul 26, 2024 4:23:12 GMT 1
This returns a listing of devices using: Winmm.dll
Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Integer Declare Function waveOutGetDevCaps Lib "winmm.dll" Alias "waveOutGetDevCapsA" ( _ ByVal uDeviceID As Integer, lpCaps As WAVEOUTCAPS, ByVal uSize As Integer) As Integer
Const MAXPNAMELEN = 32 Type WAVEOUTCAPS wMid As Int16 wPid As Int16 vDriverVersion As Long szPname As String * MAXPNAMELEN dwFormats As Long wChannels As Int16 wReserved1 As Int16 dwSupport As Long EndType Dim numDevices As Long Dim caps As WAVEOUTCAPS Dim i As Long
' Get the number of devices numDevices = waveOutGetNumDevs()
' Iterate over each device Dim i% For i = 0 To numDevices - 1 ' Get the capabilities of the device waveOutGetDevCaps(i, caps, Len(caps)) ' Print the name of the device Debug.Print (caps.szPname) Next i
Debug output:
|
|
|
Post by dragonjim on Jul 26, 2024 8:47:48 GMT 1
If that doesn't help - although I don't see why it shouldn't - you could insert test code in a Try/Catch structure at the start of the code which tries to play audio and catches an error if any occurs.
|
|
|
Post by Xavier on Jul 26, 2024 16:37:46 GMT 1
Here is a walk-thru video that I cranked out ... Let me know if this type of video is useful to you.
|
|
|
Post by Xavier on Jul 30, 2024 12:14:39 GMT 1
Were you able to use this info?
|
|
|
Post by larrybtoys on Jul 30, 2024 21:15:06 GMT 1
Not yet. I need some time to dig into the code as the only thing I need is a 1 or 0 as to whether or not there are any audio devices present. I don't want a list of them. I have been busy getting the game jam game finished and submitted to the contest plus working on 2 other games and imaging 12 desktops and 1 laptop for installation...
|
|
|
Post by larrybtoys on Jul 30, 2024 23:16:10 GMT 1
It appears that all I need to do it insert the following code in my program:
Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Integer Declare Function waveOutGetDevCaps Lib "winmm.dll" Alias "waveOutGetDevCapsA" ( _ ByVal uDeviceID As Integer, lpCaps As WAVEOUTCAPS, ByVal uSize As Integer) As Integer
Const MAXPNAMELEN = 32 Type WAVEOUTCAPS wMid As Int16 wPid As Int16 vDriverVersion As Long szPname As String * MAXPNAMELEN dwFormats As Long wChannels As Int16 wReserved1 As Int16 dwSupport As Long EndType Dim numDevices As Long Dim caps As WAVEOUTCAPS Dim i As Long
When I need to find out if there is an audio device resent I simply put this line of code in: numDevices = waveOutGetNumDevs()
And then: If numDevices > 0 'OK to activate sounds Else 'Not OK to activate sounds Endif
|
|
|
Post by Xavier on Jul 31, 2024 1:23:12 GMT 1
You should be able to get away with: Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Integer // If the returned value of waveOutGetNumDevs is not 0 then AudioOutExists? should be True
Dim AudioOutExists? = CBool(waveOutGetNumDevs)
|
|