[futurebasic] Callback routines

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 1999 : Group Archive : Group : All Groups

From: Robert Price <support@...>
Date: Thu, 15 Jul 1999 09:10:44 -0500
FB list people

  I'm trying to do a routine where a QT midi snippet loops continuously
and when it gets to the end/beginning I want to sync up with it.

From what I've read at apple's site I need to do three things to accomplish this feat.
1. I call NewTimeBase to get a TimeBase
2. which I then pass to "NewCallBack(timebase&,cbType%)" to get a reference to a new callback event
3. which I then pass to "CallMeWhen(cbEvt&,callBackProc&,refCon&,param1&,param2&,param3&)"
   in order to actually schedule the event. (although with CallMeWhen rem'd out it still seems to occur)

The next to last parameter in the TuneQueue function (callBackProc&) takes an argument
of type TuneCallBackUPP which is (TuneCallBackUPP = UniversalProcPtr; = ...etc),
from what I can trace down to, a pointer to a function.

LOCAL MODE
LOCAL FN TuneQueue(tp&,tune&,tuneRate&,tuneStartPosition&,tuneStopPosition&,queueFlags&,callBackProc&,refCon&)
  '---------------------------------------
  `     CLR.L     -(SP)
  `     MOVE.L    ^tp&,-(SP)                      ;TunePlayer
  `     MOVE.L    ^tune&,-(SP)                    ;Var: UInt32
  `     MOVE.L    ^tuneRate&,-(SP)                ;Fixed
  `     MOVE.L    ^tuneStartPosition&,-(SP)       ;UInt32
  `     MOVE.L    ^tuneStopPosition&,-(SP)        ;UInt32
  `     MOVE.L    ^queueFlags&,-(SP)              ;UInt32
  `     MOVE.L    ^callBackProc&,-(SP)            ;TuneCallBackUPP
  `     MOVE.L    ^refCon&,-(SP)                  ;LONGINT
  `     DC.W      $2F3C,$001C,$000A,$7000,$A82A
  `     MOVE.L    (SP)+,D0
END FN = REGISTER(D0)                             'ComponentResult

My callback scheduling above does indeed seem to work, because at the end of the midi snip,
it's crash city. I have defined my callback function as "Def FN gMyCallBack USING gMyCallBack&"
and initialized it with "gMyCallBack& = @FN MyCallBack"  I have then tried passing it in the
following ways (0's are for illustration only, I have the function working with no callback"

x& = TuneQueue(0,0,0,0,00,gMyCallBack&,0)
x& = TuneQueue(0,0,0,0,00,@gMyCallBack&,0)
x& = TuneQueue(0,0,0,0,00,[gMyCallBack&],0)

Does anyone have any idea how to go about this the right way? obviously _I'm_ way off base...
or is there another way I can accomplish the same results?


Cheers,
Robert Price
Programmer/Technical Support
support@...