summaryrefslogtreecommitdiffstats
path: root/src/audio/oal/stream.h
blob: 666d42e08aec6602150caad5de97b17c44cd4ed9 (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
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include "common.h"

#ifdef AUDIO_OAL
#include <AL/al.h>

#define NUM_STREAMBUFFERS 5
#define STREAMBUFFER_SIZE 0x4000

class CStream
{
	char     m_aFilename[128];
	ALuint  &m_alSource;
	ALuint (&m_alBuffers)[NUM_STREAMBUFFERS];
	
	bool     m_bIsOpened;
	bool     m_bPaused;
		
	uint32   m_nLength;
	uint32   m_nLengthMS;
	uint32   m_nBitRate;
	
	unsigned long   m_nFormat;
	unsigned long   m_nFreq;
	
	uint32   m_nBufferSize;
	void    *m_pBuffer;
	
	ALint iTotalBuffersProcessed;
	
	bool   FillBuffer(ALuint alBuffer);
	int32  FillBuffers();
public:
	static void Initialise();
	static void Terminate();
	
	CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]);
	~CStream();
	
	void   Delete();
	
	bool   IsOpened();
	bool   IsPlaying();
	void   SetPause (bool bPause);
	void   SetVolume(uint32 nVol);
	void   SetPan   (uint8 nPan);
	void   SetPos   (uint32 nPos); 

	uint32 GetPos();
	uint32 GetLength();
	
	bool Setup();
	void Start();
	void Update(void);
};

#endif