convert line ends
[canaan.git] / prj / tech / libsrc / sndutil / roneshot.c
blob5a3fa80aa0be0ef91324750c83a670a47e0a7e4c
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // (c) 1996 Looking Glass Technologies Inc.
4 // Pat McElhatton
5 //
6 // Module name: Sound resource one-shot player
7 // File name: roneshot.c
8 //
9 // Description: Play a sound resource in one-shot mode given its rez id
11 ////////////////////////////////////////////////////////////////////////
12 #include <sndutil.h>
13 #include <oneshot.h>
14 #include <timelog.h>
15 #include <mprintf.h>
16 #include <memall.h>
19 // getRezData - function to copy resource data into one-shot buffer
21 static void
22 *getRezData( void *pCBData,
23 void *pDst,
24 uint32 nBytes )
26 sndOneShotStuff *pInfo;
28 pInfo = (sndOneShotStuff *) pCBData;
29 ResExtractPartial( (Id) pInfo->extras[0], pDst, pInfo->playOffset, nBytes );
31 return pDst;
35 ////////////////////////////////////
36 // CreateSoundRezOneShot - create a one-shot sound from a sound resource
38 // Takes:
39 // pMixer audio mixer to play sounds on
40 // rezId Id of sound resource to play
41 // endCB app callback, invoked when sound is done playing
42 // pEndCBData callback data for endCB
44 // Returns: An ISndSample * that is ready to go.
46 ISndSample *
47 CreateSoundRezOneShot( ISndMixer *pMixer,
48 Id rezId,
49 SndEndCallback endCB,
50 void *pEndCBData )
52 uint32 rezLen;
53 ISndSample *pSample;
54 sndOneShotStuff *pInfo;
56 pInfo = (sndOneShotStuff *) Malloc( sizeof( sndOneShotStuff ) );
57 pInfo->extras[0] = rezId;
58 rezLen = ResSize( rezId );
60 LOG2("CreateSoundRezOneShot %d rezId, %ld rezLen",
61 rezId, rezLen );
62 pSample = CreateSoundOneShot( pMixer, getRezData, pInfo, rezLen,
63 endCB, pEndCBData );
64 return pSample;