0
0

I created a program that starts up playing a .ogg file (music). It works fine, but when I close the program, I get two errors:
1:
<process has already exited> has generated errors and will be closed by Windows. You will need to restart your program. An error log is being created.

2:
Dr. Watson was unable to attach to the process. It is possible that process exited before Dr. Watson could attach to it. Windows 2000 returned an error code = 87. The parameter is incorrect.

This doesn’t happen if I never call my sub to start the music. If I do, when the program closes, I get these two error messages. If I am running the program though the VB program, it closes VB as well.

Anyone know what I am doing wrong?

Here is my code that starts the music:

Public Sub PlayMusic(song As String)

    Dim sMusicPath As String
    Dim lModulePtr As Long
    Dim bLoopit As Boolean
    Dim bVolume As Long

    bVolume = 255


'''''''''''This is the first thing you have to do before you can start working with fmod
    Dim result As Boolean
    result = FSOUND_Init(44100, 32, 0)
    If result Then
        'Successfully initialized
    Else
        'An error occured
        MsgBox "An error occured initializing fmod!" &amp; vbCrLf &amp; _
            FSOUND_GetErrorString(FSOUND_GetError), vbOKOnly
    End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    If song = "demo" Then
        sMusicPath = App.Path &amp; "\Data\Music\sokoban_demo.ogg"
    Else
        'Different song playing
    End If

    sampleHandle = FSOUND_Sample_Load(FSOUND_FREE, sMusicPath, FSOUND_NORMAL, 0, 0)

    If sampleHandle &lt;&gt; 0 Then
        'Loading was successful
    Else
        'Something went wrong
        MsgBox "An error occured opening the sample!" &amp; vbCrLf &amp; _
            FSOUND_GetErrorString(FSOUND_GetError), vbOKOnly
    End If

''''''''''''''

'You should always use FSOUND_FREE as the first paramter
'This lets fmod choose a free channel and play the sample in it
'Each sample can be played more than once if necessary
'If you need to keep track of each sample that is playing,
'You will need as much variables as times you want to play the sample
'to store the sample channels in
sampleChannel = FSOUND_PlaySound(FSOUND_FREE, sampleHandle)

If sampleChannel &lt;&gt; 0 Then
'    'Playing
Else
    'Something went wrong
    MsgBox "An error occured playing the sample!" &amp; vbCrLf &amp; _
        FSOUND_GetErrorString(FSOUND_GetError), vbOKOnly
End If
''''''''''''''

End Sub

  • You must to post comments
0
0

you should stop the sample when you exit the progra (if it is still playing)

  • You must to post comments
0
0

The music is very short… if I let it run till it is over, it still does it. I tried creating a stop sound sub, but it doesn’t seem to stop anything.
It looks like this:

Public Sub StopMusic()
FSOUND_StopSound (FSOUND_ALL)
End Sub

Maybe I just don’t know how to stop it correctly.

  • You must to post comments
0
0

Um, where is your call to FSOUND_Close() ?
That is required when closing you app. Always use it.
That will cause a crash if you don’t :)

  • You must to post comments
0
0

Duh… thanks, that was it. I don’t know what I was thinking. Thanks a lot for the help.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.