convert line ends
[canaan.git] / prj / tech / libsrc / sndsrc / fileseg.cpp
blobfad9a890459862da0b1c3e68e18f1585d2fd37e1
1 ////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/sndsrc/RCS/fileseg.cpp $
3 // $Author: PATMAC $
4 // $Date: 1997/06/24 16:36:48 $
5 // $Revision: 1.2 $
6 //
7 // (c) 1997 Looking Glass Technologies Inc.
8 // Pat McElhatton
9 //
10 // Module name: file sound segment reader
11 // File name: fileseg.cpp
13 // Description: low-level fetch of sound data from a .WAV file
15 ////////////////////////////////////////////////////////////////////////
17 #include <sndsegi.h>
18 #include <mprintf.h>
20 cFileSegment::cFileSegment()
22 mpInFile = NULL;
25 cFileSegment::~cFileSegment()
27 if ( mpInFile != NULL ) {
28 fclose( mpInFile );
32 void
33 cFileSegment::Init( char *pName,
34 uint32 offset,
35 sSndAttribs *pAttribs,
36 BOOL doDouble )
38 mpInFile = fopen( pName, "rb" );
39 assert( mpInFile != NULL );
41 InitBase( offset, pAttribs, doDouble );
44 void *
45 cFileSegment::GetRawData( void *pDst,
46 uint32 nBytes )
48 int nRead;
49 if ( mNeedsSeek ) {
50 fseek( mpInFile, mSrcOffset, SEEK_SET );
52 //mprintf("fileseg %x %d bytes @ %d seek: %d\n", this, nBytes, mSrcOffset, mNeedsSeek);
53 nRead = fread( pDst, 1, nBytes, mpInFile );
54 assert( nRead == nBytes );
56 return pDst;