mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Moved cSoundFileDefault and cSoundFileOgg to src ( this classes aren't public ).
Moved Sound States inside cSound.
This commit is contained in:
@@ -148,18 +148,18 @@ eeFloat cSound::Attenuation() const {
|
||||
return Attenuation;
|
||||
}
|
||||
|
||||
EE_SOUND_STATE cSound::GetState() const {
|
||||
cSound::Status cSound::GetState() const {
|
||||
ALint State;
|
||||
ALCheck( alGetSourcei( mSource, AL_SOURCE_STATE, &State ) );
|
||||
|
||||
switch (State) {
|
||||
case AL_INITIAL :
|
||||
case AL_STOPPED : return SOUND_STOPPED;
|
||||
case AL_PAUSED : return SOUND_PAUSED;
|
||||
case AL_PLAYING : return SOUND_PLAYING;
|
||||
case AL_STOPPED : return cSound::Stopped;
|
||||
case AL_PAUSED : return cSound::Paused;
|
||||
case AL_PLAYING : return cSound::Playing;
|
||||
}
|
||||
|
||||
return SOUND_STOPPED;
|
||||
return cSound::Stopped;
|
||||
}
|
||||
|
||||
Uint32 cSound::PlayingOffset() const {
|
||||
@@ -216,7 +216,7 @@ void cSound::ResetBuffer() {
|
||||
mBuffer = NULL;
|
||||
}
|
||||
|
||||
EE_SOUND_STATE cSound::State() const {
|
||||
cSound::Status cSound::State() const {
|
||||
return GetState();
|
||||
}
|
||||
|
||||
|
||||
62
src/eepp/audio/csoundfiledefault.hpp
Executable file
62
src/eepp/audio/csoundfiledefault.hpp
Executable file
@@ -0,0 +1,62 @@
|
||||
#ifndef EE_AUDIOCSOUNDFILEDEFAULT_H
|
||||
#define EE_AUDIOCSOUNDFILEDEFAULT_H
|
||||
|
||||
#include <eepp/audio/base.hpp>
|
||||
|
||||
#ifdef EE_LIBSNDFILE_ENABLED
|
||||
|
||||
#include <sndfile.h>
|
||||
#include <eepp/audio/csoundfile.hpp>
|
||||
|
||||
namespace EE { namespace Audio {
|
||||
|
||||
class EE_API cSoundFileDefault : public cSoundFile {
|
||||
public :
|
||||
cSoundFileDefault();
|
||||
|
||||
~cSoundFileDefault();
|
||||
|
||||
/** Check if a given file is supported by this loader. */
|
||||
static bool IsFileSupported(const std::string& Filename, bool Read);
|
||||
|
||||
/** Check if a given file in memory is supported by this loader. */
|
||||
static bool IsFileSupported(const char* Data, std::size_t SizeInBytes);
|
||||
|
||||
virtual std::size_t Read(Int16* Data, std::size_t NbSamples);
|
||||
|
||||
virtual void Write(const Int16* Data, std::size_t NbSamples);
|
||||
|
||||
virtual void Seek( Uint32 timeOffset );
|
||||
private :
|
||||
virtual bool OpenRead( const std::string& Filename, std::size_t& NbSamples, unsigned int& ChannelsCount, unsigned int& SampleRate );
|
||||
|
||||
virtual bool OpenRead( const char* Data, std::size_t SizeInBytes, std::size_t& NbSamples, unsigned int& ChannelsCount, unsigned int& SampleRate );
|
||||
|
||||
virtual bool OpenWrite( const std::string& Filename, unsigned int ChannelsCount, unsigned int SampleRate );
|
||||
|
||||
static int GetFormatFromFilename(const std::string& Filename);
|
||||
|
||||
class MemoryIO {
|
||||
public:
|
||||
SF_VIRTUAL_IO Prepare(const void* data, std::size_t sizeInBytes);
|
||||
private:
|
||||
static sf_count_t GetLength(void* UserData);
|
||||
static sf_count_t Read(void* Ptr, sf_count_t Count, void* UserData);
|
||||
static sf_count_t Seek(sf_count_t Offset, int Whence, void* UserData);
|
||||
static sf_count_t Tell(void* UserData);
|
||||
static sf_count_t Write(const void* Ptr, sf_count_t Count, void* UserData);
|
||||
|
||||
const char * mDataStart; ///< Pointer to the begining of the data
|
||||
const char * mDataPtr; ///< Pointer to the current read / write position
|
||||
sf_count_t mTotalSize; ///< Total size of the data, in bytes
|
||||
};
|
||||
|
||||
SNDFILE * mFile; ///< File descriptor
|
||||
MemoryIO mMemoryIO; ///< Memory read / write data
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
36
src/eepp/audio/csoundfileogg.hpp
Executable file
36
src/eepp/audio/csoundfileogg.hpp
Executable file
@@ -0,0 +1,36 @@
|
||||
#ifndef EE_AUDIOCSOUNDFILEOGG_H
|
||||
#define EE_AUDIOCSOUNDFILEOGG_H
|
||||
|
||||
#include <eepp/audio/base.hpp>
|
||||
#include <eepp/audio/csoundfile.hpp>
|
||||
|
||||
struct stb_vorbis;
|
||||
|
||||
namespace EE { namespace Audio {
|
||||
|
||||
class EE_API cSoundFileOgg : public cSoundFile {
|
||||
public:
|
||||
cSoundFileOgg();
|
||||
~cSoundFileOgg();
|
||||
|
||||
/** Check if a given file is supported by this loader. */
|
||||
static bool IsFileSupported(const std::string& Filename, bool Read);
|
||||
|
||||
/** Check if a given file in memory is supported by this loader. */
|
||||
static bool IsFileSupported(const char* Data, std::size_t SizeInBytes);
|
||||
|
||||
virtual std::size_t Read(Int16* Data, std::size_t NbSamples);
|
||||
|
||||
virtual void Seek( Uint32 timeOffset );
|
||||
private :
|
||||
virtual bool OpenRead(const std::string& Filename, std::size_t& NbSamples, unsigned int& ChannelsCount, unsigned int& SampleRate);
|
||||
|
||||
virtual bool OpenRead(const char* Data, std::size_t SizeInBytes, std::size_t& NbSamples, unsigned int& ChannelsCount, unsigned int& SampleRate);
|
||||
|
||||
stb_vorbis * mStream; ///< Vorbis stream
|
||||
unsigned int mChannelsCount; ///< Number of channels (1 = mono, 2 = stereo)
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -68,13 +68,13 @@ unsigned int cSoundStream::GetSampleRate() const {
|
||||
return mSampleRate;
|
||||
}
|
||||
|
||||
EE_SOUND_STATE cSoundStream::GetState() const {
|
||||
EE_SOUND_STATE Status = cSound::GetState();
|
||||
cSound::Status cSoundStream::GetState() const {
|
||||
Status status = cSound::GetState();
|
||||
|
||||
if ( ( Status == SOUND_STOPPED ) && mIsStreaming ) // To compensate for the lag between Play() and alSourcePlay()
|
||||
Status = SOUND_PLAYING;
|
||||
if ( ( status == cSound::Stopped ) && mIsStreaming ) // To compensate for the lag between Play() and alSourcePlay()
|
||||
status = cSound::Playing;
|
||||
|
||||
return Status;
|
||||
return status;
|
||||
}
|
||||
|
||||
Uint32 cSoundStream::PlayingOffset() const {
|
||||
@@ -117,7 +117,7 @@ void cSoundStream::Run() {
|
||||
|
||||
while ( mIsStreaming ) {
|
||||
// The stream has been interrupted !
|
||||
if ( cSound::GetState() == SOUND_STOPPED ) {
|
||||
if ( cSound::GetState() == cSound::Stopped ) {
|
||||
// User requested to stop : finish the streaming loop
|
||||
if ( !RequestStop ) {
|
||||
cSound::Play();
|
||||
@@ -165,7 +165,7 @@ void cSoundStream::Run() {
|
||||
}
|
||||
|
||||
// Leave some time for the other threads if the stream is still playing
|
||||
if ( cSound::GetState() != SOUND_STOPPED )
|
||||
if ( cSound::GetState() != cSound::Stopped )
|
||||
Sys::Sleep(10);
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ void cSoundStream::ClearQueue() {
|
||||
ALCheck( alSourceUnqueueBuffers( cSound::mSource, 1, &Buffer ) );
|
||||
}
|
||||
|
||||
EE_SOUND_STATE cSoundStream::State() const {
|
||||
cSound::Status cSoundStream::State() const {
|
||||
return GetState();
|
||||
}
|
||||
|
||||
|
||||
@@ -1321,7 +1321,7 @@ void cEETest::Input() {
|
||||
|
||||
mWindow->FrameRateLimit( 10 );
|
||||
|
||||
if ( mMusEnabled && Mus->State() == SOUND_PLAYING )
|
||||
if ( mMusEnabled && Mus->State() == cSound::Playing )
|
||||
Mus->Pause();
|
||||
|
||||
} else {
|
||||
@@ -1337,7 +1337,7 @@ void cEETest::Input() {
|
||||
|
||||
mWindow->FrameRateLimit( mLastFPSLimit );
|
||||
|
||||
if ( mMusEnabled && Mus->State() == SOUND_PAUSED )
|
||||
if ( mMusEnabled && Mus->State() == cSound::Paused )
|
||||
Mus->Play();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user