Bink SDK 1.5v

# BinkWait

The function BinkWait tells you when to move to the next Bink frame (based on the frame rate of the file).

    S32 BinkWait(
      HBINK bink
    );

#### In Parameters

bink
  Specifies the Bink handle.

#### Discussion

This function tells you whether it's time to move onto the next frame. It will return a 1 if you should keep waiting, and a 0 if you should move onto the next frame. Basically, the core Bink playback loop is:
1) display a frame,
2) wait until BinkWait returns a zero,
3) loop back to step 1.
Note that there is a lot of logic hidden behind this tiny interface: sound-synchronization, preloading upcoming data, sound servicing, etc. Because all this timing sensitive work is being done in this one little function, you need to call it frequently - several times the frame rate frequency at least. Under Windows and MacOS, you need to yield and process messages while you're waiting on BinkWait. The best way to handle this is to place the call to BinkWait inside your message handling loop. For example, you could do something like this on Win32:

`

    if ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ){  if ( msg.message == WM_QUIT )    break;
      TranslateMessage( &msg );  DispatchMessage( &msg );}else{  if ( !BinkWait( bink ) )  {    // do the BinkDoFrame, BinkCopyToBuffer, BinkNextFrame, blitting, etc in this function    Show_next_frame( bink, bink_buf );  }}

`

Message handling code like this allows Bink to continue to run while other processes still receive their messages. However, sometimes logic like this is difficult to implement (as in MFC or OWL applications). In these cases, it is still best to try to implement message handling like the example above. This can be accomplished by overloading the appropriate message dispatching function (contact RAD Game Tools for more details on this type of code). Another playback alternative is to use a timer callback and check the BinkWait status there. Note that although this technique can work, Bink really needs BinkWait to be called much more frequently than a timer can usually provide. However, if you create a timer callback that operates at 4 or 5 times the frame rate (so, with a 15 fps Bink file, check BinkWait 75 times a second), then this method may be easier to integrate. If neither a message loop nor a timer call back will work for you, contact RAD Game Tools for other more-complicated alternatives.

Group: Bink API
Related Sections: Bink Video Playback, NTSC and PAL on the Nintendo GameCube, NTSC and PAL on the Xbox, Sharing the CPU on the Nintendo GameCube, Sharing the CPU on the Xbox, Sharing the CPU under MacOS, Sharing the CPU under Win32
Related Functions: BinkDoFrame, BinkNextFrame, BinkPause
Related Basic Types: HBINK, S32

For technical support, e-mail Bink1@radgametools.com
© Copyright 1994-2003 RAD Game Tools, Inc. All Rights Reserved.