Git Product home page Git Product logo

Comments (18)

flibitijibibo avatar flibitijibibo commented on July 19, 2024

Does the XNA4 spec even allow for this? I thought you had to stop media
playback before exiting, since a separate process handles that content.
On Jun 6, 2013 9:16 AM, "Jordan S" [email protected] wrote:

When closing my game I receive:

A callback was made on a garbage collected delegate of type
'SDL2#!SDL2.SDL_mixer+MusicFinishedDelegate::Invoke'. This may cause
application crashes, corruption and data loss. When passing delegates to
unmanaged code, they must be kept alive by the managed application until it
is guaranteed that they will never be called.


Reply to this email directly or view it on GitHubhttps://github.com//issues/90
.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

Actually, this might be a good opportunity to get this out of someone if they don't want to poke around SDL2_mixer too much.

I'd like to port that Song implementation to libvorbisfile/OpenAL, but I failed my attempt and just left SDL2_mixer there:

https://github.com/flibitijibibo/VorbisFile-CS/issues/1

I think VorbisFile# might just be crap, which would be a shame since it seems to be the only library that uses native libvorbisfile. The code I link to in that issue should work if VorbisFile# gets it together.

from fna-mghistory.

xanather avatar xanather commented on July 19, 2024

I'm not sure if XNA recommends disposing Songs, but it sure shouldn't cause the program to crash. Shamelessly, I'm not that good of a low level programmer and have never worked with native Interops etc... Ill try to get the word around where I can though.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

It probably won't crash on XNA4, but my guess is WMP can keep going and cause various other problems if you don't stop your media player properly. Crash, unending leak, pick your poison I suppose.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

Actually, question: Does adding 'Media.Mediaplayer.Stop()' just before 'SDL_mixer.Mix_CloseAudio()' in SDL2_GamePlatform.Exit() resolve this? Wondering if we should just force stop the MediaPlayer when we call Game.Exit().

from fna-mghistory.

xanather avatar xanather commented on July 19, 2024

Sadly, no it does not look like it

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

Well, there's always the cop-out of making Song.OnFinishedPlaying() static... there's nothing really in there that warrants it being an instance method, so why not? 🤷

from fna-mghistory.

xanather avatar xanather commented on July 19, 2024

I am receiving a InvalidOperationException was unhandled
Collection was modified; enumeration operation may not execute. Ill try and get track trace if you want.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

Yeah, that'd be good. I'm assuming there'd be a bit more to it than adding the 'static' keyword, but not that much...

from fna-mghistory.

xanather avatar xanather commented on July 19, 2024

My Exit method just looks like this now

    public override void Exit()
    {
        // End the network subsystem
        Net.NetworkSession.Exit();

        // Destroy our window
        INTERNAL_window.INTERNAL_Destroy();

        // Stop the audio
        Media.MediaPlayer.Stop();

        // Close SDL2_mixer
        SDL_mixer.Mix_CloseAudio();
    }

Stack Trace:
System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Collection was modified; enumeration operation may not execute.
Source=mscorlib
StackTrace:
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at Microsoft.Xna.Framework.Media.MediaPlayer.Stop() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Media\MediaPlayer.cs:line 486
at Microsoft.Xna.Framework.SDL2_GamePlatform.Exit() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\SDL2\SDL2_GamePlatform.cs:line 156
at Microsoft.Xna.Framework.Game.Exit() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Game.cs:line 376
at removed.Interface.Menu.MenuWindow.Update() in c:\Users\Xanather\Documents\Programming\Main\removed\removed\Interface\Menu\MenuWindow.cs:line 40
at removed.Interface.UIManager.Update() in c:\Users\Xanather\Documents\Programming\Main\removed\removed\Interface\UIManager.cs:line 83
at removed.Menu.Update() in c:\Users\Xanather\Documents\Programming\Main\removed\removed\Menu.cs:line 68
at removed.Engine.Update(GameTime gameTime) in c:\Users\Xanather\Documents\Programming\Main\removed\removed\Engine.cs:line 125
at Microsoft.Xna.Framework.Game.DoUpdate(GameTime gameTime) in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Game.cs:line 697
at Microsoft.Xna.Framework.Game.Tick() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Game.cs:line 505
at Microsoft.Xna.Framework.SDL2_GameWindow.INTERNAL_RunLoop() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\SDL2\SDL2_GameWindow.cs:line 409
at Microsoft.Xna.Framework.SDL2_GamePlatform.RunLoop() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\SDL2\SDL2_GamePlatform.cs:line 139
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Game.cs:line 437
at Microsoft.Xna.Framework.Game.Run() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Game.cs:line 415
at removed.Program.Main() in c:\Users\Xanather\Documents\Programming\Main\removed\removed\Program.cs:line 16
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

from fna-mghistory.

xanather avatar xanather commented on July 19, 2024

Okay, so just closing (edit: calling .Stop() ) the MediaPlayer anytime results in this exception (so its not related to the crashing issue).

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

Does this game even work with upstream MonoGame? Almost all of the problems I'm seeing have nothing to do with MG-SDL2 specifically, and the Song itself is only different in that it uses SDL2_mixer, rather than SDL_mixer.

In fact, does WindowsGL even have a Song player? I thought only Linux had it...

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

There's some cleanup I need to do with Song, going to burn through that now. Will post again when it's committed, might fix the issue.

from fna-mghistory.

xanather avatar xanather commented on July 19, 2024

I couldnt even play/load songs correctly on WindowsDX with Windows 7. MonoGame#1766. I think I had problems with WindowsGL aswell, but I cant remember what.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

a20e4f8

The deconstructor might help now.

EDIT: Added it to Stop() as well.

from fna-mghistory.

xanather avatar xanather commented on July 19, 2024

Okay, thanks, testing it now.

from fna-mghistory.

xanather avatar xanather commented on July 19, 2024

It worked, now it looks like Texture.cs has a disposing issue. (the closing issue that I originally created #86 which I thought was my cause). I'm going to create another issue page.

from fna-mghistory.

flibitijibibo avatar flibitijibibo commented on July 19, 2024

Neat, and this works for my games still. Song looks a lot better now too... might be easier to navigate around if someone makes a libvorbisfile/OpenAL port.

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.