AGS Support > Advanced Technical Forum

workaround for the "no digital sound" crash

(1/3) > >>

StillInThe90s:
Without starting another discussion about what AGS should and should not do, I'm trying to find a workaround for the sound issue discussed in this thread. I.e. if "no digital sound" option is chosen in the setup, the code below will make your game crash.

--- Code: Adventure Game Studio ---AudioChannel *audio = aMusic.Play();audio.Volume = 70;...unless you wrap everything in a "if(audio){}" which is too much work for me at this point.

I suppose there is no way of checking if this option is chosen, from within an ags-application? Could I do this by raw reading acetup.cfg? (been unsuccessful so far) Changing the name of audio.vox with a custom setup could do the trick, since ags can check for files. Any obvious dangers there? (such as windows security)

Thanks.

Wyz:
Without making any changes to the engine the best I can come up with is a wrapper object. This is structure that you assign an AudioChannel object and implements all functionality that AudioChannel objects already have but with the added null check.

For this example it would contain the following:

--- Code: Adventure Game Studio ---struct SafeAudioChannel{  AudioChannel *audio;   void SetVolume(int volume)  {    if (audio)      audio.Volume = volume;  }   int GetVolume(int volume)  {    if (audio)      return audio.Volume;    return -1;  }    // ... many more potentially}; 
Which you can use like this:

--- Code: Adventure Game Studio ---SafeAudioChannel channel;channel.audio = aMusic.Play();channel.SetVolume(70); 
Would be nice to have this as a module I guess. :)

Snarky:
Should be AudioChannel* audio; – but yeah.

StillInThe90s:
Interesting.
Could this be done with already defined global AudioChannels as well?

Wyz:
I believe so yes. It would need the usual im/exporting and setting up like other global variables but I can't think of a reason why not.

Navigation

[0] Message Index

[#] Next page

Go to full version