summaryrefslogtreecommitdiff
path: root/engine/audio/private/snd_wave_data.h
blob: 54a8285f1607ecbf0e5aeca6b2bf79ec601d3354 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef SND_WAVE_DATA_H
#define SND_WAVE_DATA_H
#ifdef _WIN32
#pragma once
#endif

#include "snd_audio_source.h"

//-----------------------------------------------------------------------------
// Purpose: Linear iterator over source data.
//			Keeps track of position in source, and maintains necessary buffers
//-----------------------------------------------------------------------------
abstract_class IWaveData
{
public:
	virtual						~IWaveData( void ) {}
	virtual CAudioSource		&Source( void ) = 0;
	virtual int					ReadSourceData( void **pData, int sampleIndex, int sampleCount, char copyBuf[AUDIOSOURCE_COPYBUF_SIZE] ) = 0;
	virtual bool				IsReadyToMix() = 0;
};

abstract_class IWaveStreamSource
{
public:
	virtual int		UpdateLoopingSamplePosition( int samplePosition ) = 0;
	virtual void	UpdateSamples( char *pData, int sampleCount ) = 0;
	virtual int		GetLoopingInfo( int *pLoopBlock, int *pNumLeadingSamples, int *pNumTrailingSamples ) = 0;
};

class IFileReadBinary;
class CSfxTable;

extern IWaveData *CreateWaveDataStream( CAudioSource &source, IWaveStreamSource *pStreamSource, const char *pFileName, int dataStart, int dataSize, CSfxTable *pSfx, int startOffset );
extern IWaveData *CreateWaveDataMemory( CAudioSource &source );

void PrefetchDataStream( const char *pFileName, int dataOffset, int dataSize );

#endif // SND_WAVE_DATA_H