2004-07-21 04:04:20 +02:00
|
|
|
#ifndef CMUSICPLAYER_H
|
|
|
|
#define CMUSICPLAYER_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <al.h>
|
|
|
|
#include <alut.h>
|
|
|
|
#include <ogg/ogg.h>
|
|
|
|
#include <vorbis/codec.h>
|
|
|
|
#include <vorbis/vorbisfile.h>
|
|
|
|
|
2004-07-22 15:24:03 +02:00
|
|
|
#define AUDIO_BUFFER_SIZE (64*1024)
|
2004-07-21 04:04:20 +02:00
|
|
|
|
|
|
|
struct SOggFile
|
|
|
|
{
|
|
|
|
char *dataPtr;
|
|
|
|
int dataSize;
|
|
|
|
int dataRead;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CMusicPlayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CMusicPlayer(void);
|
|
|
|
~CMusicPlayer(void);
|
|
|
|
void open(char *filename);
|
|
|
|
void release();
|
|
|
|
bool play();
|
|
|
|
bool isPlaying();
|
|
|
|
bool update();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool stream(ALuint buffer);
|
|
|
|
void check();
|
|
|
|
void empty();
|
|
|
|
std::string errorString(int errorcode);
|
|
|
|
|
|
|
|
private:
|
|
|
|
SOggFile memFile;
|
|
|
|
ov_callbacks vorbisCallbacks;
|
|
|
|
OggVorbis_File oggStream;
|
|
|
|
vorbis_info *info;
|
|
|
|
ALuint buffers[2]; //the 2 buffers, one will be filled whilst the other is being played
|
|
|
|
ALuint source;
|
|
|
|
ALenum format;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|