Move OpenAL_SoundStream function definitions out of the class

This commit is contained in:
Chris Robinson 2012-03-17 03:15:07 -07:00
parent 2f6b73d461
commit 1b41987e18

View File

@ -63,8 +63,17 @@ class OpenAL_SoundStream : public Sound
std::auto_ptr<Sound_Decoder> Decoder; std::auto_ptr<Sound_Decoder> Decoder;
public: public:
OpenAL_SoundStream(std::auto_ptr<Sound_Decoder> decoder) : Decoder(decoder) OpenAL_SoundStream(std::auto_ptr<Sound_Decoder> decoder);
{ virtual ~OpenAL_SoundStream();
virtual bool Play();
virtual void Stop();
virtual bool isPlaying();
};
OpenAL_SoundStream::OpenAL_SoundStream(std::auto_ptr<Sound_Decoder> decoder)
: Decoder(decoder)
{
throwALerror(); throwALerror();
alGenSources(1, &Source); alGenSources(1, &Source);
@ -84,8 +93,8 @@ public:
try try
{ {
int srate; int srate;
enum Sound_Decoder::ChannelConfig chans; Sound_Decoder::ChannelConfig chans;
enum Sound_Decoder::SampleType type; Sound_Decoder::SampleType type;
Decoder->GetInfo(&srate, &chans, &type); Decoder->GetInfo(&srate, &chans, &type);
Format = getALFormat(chans, type); Format = getALFormat(chans, type);
@ -98,17 +107,17 @@ public:
alGetError(); alGetError();
throw; throw;
} }
} }
virtual ~OpenAL_SoundStream() OpenAL_SoundStream::~OpenAL_SoundStream()
{ {
alDeleteSources(1, &Source); alDeleteSources(1, &Source);
alDeleteBuffers(NumBuffers, Buffers); alDeleteBuffers(NumBuffers, Buffers);
alGetError(); alGetError();
Decoder->Close(); Decoder->Close();
} }
virtual bool Play() bool OpenAL_SoundStream::Play()
{ {
std::vector<char> data(BufferSize); std::vector<char> data(BufferSize);
alSourceStop(Source); alSourceStop(Source);
@ -128,18 +137,18 @@ public:
throwALerror(); throwALerror();
return true; return true;
} }
virtual void Stop() void OpenAL_SoundStream::Stop()
{ {
alSourceStop(Source); alSourceStop(Source);
alSourcei(Source, AL_BUFFER, 0); alSourcei(Source, AL_BUFFER, 0);
throwALerror(); throwALerror();
// FIXME: Rewind decoder // FIXME: Rewind decoder
} }
virtual bool isPlaying() bool OpenAL_SoundStream::isPlaying()
{ {
ALint processed, state; ALint processed, state;
alGetSourcei(Source, AL_SOURCE_STATE, &state); alGetSourcei(Source, AL_SOURCE_STATE, &state);
@ -180,8 +189,7 @@ public:
} }
return true; return true;
} }
};
bool OpenAL_Output::Initialize(const std::string &devname) bool OpenAL_Output::Initialize(const std::string &devname)