Git Product home page Git Product logo

Comments (9)

flibitijibibo avatar flibitijibibo commented on July 3, 2024

Technically this is half-accurate; when there's no audio device XNA should be throwing NoAudioHardwareException, but I think there should be a messagebox that tells you this. @SeanColombo or @darthdurden may be able to explain this in a bit more detail.

For now I'm going to shift some things around to try and at least get the messagebox. I might be able to get you an AudioReferenceDevice too, so you can run without worrying about runtime errors there.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 3, 2024

f7348ff

This commit should now ensure that the messagebox shows up, which should be more accurate (or at least more informative). I'll throw together a NullDevice now; shouldn't take more than a few minutes.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 3, 2024

Bam:

1d91392

Set environment variable FNA_AUDIO_DISABLE_SOUND to "1" and it should use the NullDevice. This behavior is completely undefined, but at least it should give you the opportunity to just skip sound. Hopefully this has no effect on performance, but I only tested functionality and not perf... we'll see.

EDIT: This is now documented on the FNA wiki:

https://github.com/flibitijibibo/FNA/wiki/7:-FNA-Environment-Variables#fna_audio_disable_sound

from fna-mghistory.

AxiomVerge avatar AxiomVerge commented on July 3, 2024

Ok, I get the message box now, but seem not to be catching the exception correctly (or else I am just not understanding how to use). Here is what I did:

            THGame game = null;
            try
            {
                game = new THGame();
            }
            catch(Microsoft.Xna.Framework.Audio.NoAudioHardwareException e)
            {
                System.Console.WriteLine("No hardware.  Trying to use null device.");
                System.Environment.SetEnvironmentVariable("FNA_AUDIO_DISABLE_SOUND", "1");
                game = new THGame();
            }

            if (game != null)
            {
                try
                {
                    game.Run();
                }
                finally
                {
                    game.Dispose();
                }
            }

I also tried a plain ole'

            catch(Exception e)

-but nothing happened.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 3, 2024

If you happen to have a debugger handy, make sure it's actually creating a NullDevice (or worst case, throw a printf in that block). The first NoAudioHardwareException still makes sense, but the second crash does not...

Sent from my iPhone

On Apr 25, 2015, at 17:53, Tom Happ [email protected] wrote:

Ok, I get the message box now, but seem not to be catching the exception correctly (or else I am just not understanding how to use). Here is what I did:

        THGame game = null;
        try
        {
            game = new THGame();
        }
        catch(Microsoft.Xna.Framework.Audio.NoAudioHardwareException e)
        {
            System.Console.WriteLine("No hardware.  Trying to use null device.");
            System.Environment.SetEnvironmentVariable("FNA_AUDIO_DISABLE_SOUND", "1");
            game = new THGame();
        }

        if (game != null)
        {
            try
            {
                game.Run();
            }
            finally
            {
                game.Dispose();
            }
        }

I also tried a plain ole'

        catch(Exception e)

-but nothing happened.


Reply to this email directly or view it on GitHub.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 3, 2024

FWIW, I'm now officially out of town but if you want to send me test cases I can still debug on my end as well. Doesn't have to be Linux/Mac, I can debug Windows assemblies without any fuss.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 3, 2024

I sat down with XNA4 and looked into this. It turns out XNA actually has an unhandled Exception handler internally, which calls ShowMissingRequirementMessage. So, the messagebox only shows up when you don't catch the Exception:

2d7d608

If you catch this properly the messagebox will not show up, and if not, you should expect the application to crash in these scenarios (though at least a messagebox will show up, right?).

This should now behave accurately, though it should probably be tested locally.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 3, 2024

Closing due to old age, but as far as I can tell this should now be accurate. If an AV customer happens to try playing with no sound card we might find out for sure... >_>

from fna-mghistory.

AxiomVerge avatar AxiomVerge commented on July 3, 2024

I'm sorry, I should have mentioned - I did test it, and it works. Thank you!

from fna-mghistory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.