realbasic-games
[Top] [All Lists]

Re: Debug App quits without giving a reason.

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Debug App quits without giving a reason.
From: Asher Dunn <asher at fireyesoftware dot com>
Date: Mon, 23 May 2005 19:48:37 -0400
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <BEB76469 dot 4AEE%ForeverTangent at yahoo dot com>

On May 23, 2005, at 10:43 AM, Stan Rosenbaum wrote:


    Hey Asher,

Your probably right about the string... Here is what I am trying to
do.


This is the Declare I have made:

====

FMODEX.FMOD_System_CreateSound:
Protected Function FMOD_System_CreateSound(ByVal SystemFMOD As Integer,
ByVal name_or_data As String, ByVal mode As Integer, exinfo As integer,
ByRef Sound As Integer) As Integer

ByVal is not needed. If you do not specify ByRef, parameters are passed byval by default.

  #if targetWin32
  #elseif targetLinux
  #elseif targetMachO

    Dim result as Integer
    Dim stringPtr as MemoryBlock

    stringPtr = FMODEX.stringToMemoryBlock(name_or_data)

Declare Function FMOD_System_CreateSound Lib FMODdylibLocation (ByVal System As Integer, name_or_data As Ptr, ByVal mode As Integer, ByRef exinfo As Integer, ByRef Sound As Integer) As Integer result = FMOD_System_CreateSound( SystemFMOD, stringPtr.CString(0), mode, exinfo, Sound )

    return result

  #endif
End Function

Again, you don't need ByVal. Also, to pass a CString, you can declare the parameter as a CString (declare sub foo lib "bar" (data as cstring)), and then just pass a string. You don't need to convert it to a memoryBlock manually. There is another problem here though -- you are passing a CString where it expects a pointer. This can cause all sorts of lovely memory corruption problems (hence the crash), because the first four bytes of the string are being interpreted as a pointer, and the rest of it is being discarded. Declare the parameter in the declare statement as "name_or_data as cstring", and then pass a regular RB string.

And this is the "FMODEX.stringToMemoryBlock" helper function,

====

FMODEX.stringToMemoryBlock:
Protected Function stringToMemoryBlock(stringToConvert as String) As
MemoryBlock

  Dim memBlock as MemoryBlock
  memBlock = NewMemoryBlock( len(stringToConvert) + 1 )

  memBlock.CString(0) = stringToConvert

  return memBlock

End Function


This function is unnecessary. Just declare the parameter to the declare as a CString and pass an RB string.

I am totally, clueless at this point. [I am blaming it on my evil cats].

Oh c'mon, cats are cool :-)

FMOD_RESULT System::createSound( char * name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO * exinfo, FMOD::Sound ** sound );

"FOMD::Sound** sound" is a pointer to a pointer to an FMOD::Sound. I can't remember how to accommodate this in RB, but it needs special consideration.
Any declare masters hanging around to remember how to do this?

HTH!

Asher Dunn
--------------------------------------------------------
President and Head Developer of Fireye Software <http://www.fireyesoftware.com/>
AIM and Yahoo: fireye7517

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>