mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 23:21:19 +02:00
- moved sound system debug into a new debugSound property to lessen the impact of regular debug logging since sound processing is now threaded and therefore logging sound system items may slow down performance
- added texture caching for faction preview textures
This commit is contained in:
@@ -22,22 +22,22 @@ using namespace Util;
|
||||
|
||||
SoundSource::SoundSource()
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
alGenSources(1, &source);
|
||||
SoundPlayerOpenAL::checkAlError("Couldn't create audio source: ");
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
SoundSource::~SoundSource()
|
||||
{
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
stop();
|
||||
alDeleteSources(1, &source);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
bool SoundSource::playing()
|
||||
@@ -59,13 +59,13 @@ void SoundSource::unQueueBuffers() {
|
||||
|
||||
void SoundSource::stop()
|
||||
{
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
alSourceStop(source);
|
||||
|
||||
SoundPlayerOpenAL::checkAlError("Problem stopping audio source: ");
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
unQueueBuffers();
|
||||
|
||||
@@ -73,29 +73,36 @@ void SoundSource::stop()
|
||||
|
||||
alSourcei(source, AL_BUFFER, AL_NONE);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
SoundPlayerOpenAL::checkAlError("Problem stopping audio source: ");
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
ALenum SoundSource::getFormat(Sound* sound)
|
||||
{
|
||||
if(sound->getInfo()->getChannels() == 2) {
|
||||
if(sound->getInfo()->getBitsPerSample() == 16)
|
||||
if(sound->getInfo()->getBitsPerSample() == 16) {
|
||||
return AL_FORMAT_STEREO16;
|
||||
else if(sound->getInfo()->getBitsPerSample() == 8)
|
||||
}
|
||||
else if(sound->getInfo()->getBitsPerSample() == 8) {
|
||||
return AL_FORMAT_STEREO8;
|
||||
else
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("[1] Sample format not supported in file: " + sound->getFileName());
|
||||
} else if(sound->getInfo()->getChannels() == 1) {
|
||||
if(sound->getInfo()->getBitsPerSample() == 16)
|
||||
}
|
||||
}
|
||||
else if(sound->getInfo()->getChannels() == 1) {
|
||||
if(sound->getInfo()->getBitsPerSample() == 16) {
|
||||
return AL_FORMAT_MONO16;
|
||||
else if(sound->getInfo()->getBitsPerSample() == 8)
|
||||
}
|
||||
else if(sound->getInfo()->getBitsPerSample() == 8) {
|
||||
return AL_FORMAT_MONO8;
|
||||
else
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("[2] Sample format not supported in file: " + sound->getFileName());
|
||||
}
|
||||
}
|
||||
|
||||
throw std::runtime_error("[3] Sample format not supported in file: " + sound->getFileName());
|
||||
@@ -114,8 +121,9 @@ StaticSoundSource::~StaticSoundSource() {
|
||||
}
|
||||
}
|
||||
|
||||
void StaticSoundSource::play(StaticSound* sound)
|
||||
{
|
||||
void StaticSoundSource::play(StaticSound* sound) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(bufferAllocated) {
|
||||
stop();
|
||||
alDeleteBuffers(1, &buffer);
|
||||
@@ -125,14 +133,18 @@ void StaticSoundSource::play(StaticSound* sound)
|
||||
alGenBuffers(1, &buffer);
|
||||
SoundPlayerOpenAL::checkAlError("Couldn't create audio buffer: ");
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] filename [%s] format = %d, sound->getSamples() = %d, sound->getInfo()->getSize() = %d, sound->getInfo()->getSamplesPerSecond() = %d\n",__FILE__,__FUNCTION__,__LINE__,sound->getFileName().c_str(),format,sound->getSamples(),sound->getInfo()->getSize(),sound->getInfo()->getSamplesPerSecond());
|
||||
|
||||
bufferAllocated = true;
|
||||
alBufferData(buffer, format, sound->getSamples(),
|
||||
static_cast<ALsizei> (sound->getInfo()->getSize()),
|
||||
static_cast<ALsizei> (sound->getInfo()->getSamplesPerSecond()));
|
||||
|
||||
SoundPlayerOpenAL::checkAlError("Couldn't fill audio buffer: ");
|
||||
|
||||
alSourcei(source, AL_BUFFER, buffer);
|
||||
alSourcef(source, AL_GAIN, sound->getVolume());
|
||||
|
||||
alSourcePlay(source);
|
||||
SoundPlayerOpenAL::checkAlError("Couldn't start audio source: ");
|
||||
}
|
||||
@@ -192,14 +204,14 @@ void StreamSoundSource::play(StrSound* sound, int64 fadeon)
|
||||
|
||||
void StreamSoundSource::update()
|
||||
{
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(sound == 0) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(fadeState == NoFading){
|
||||
alSourcef(source, AL_GAIN, sound->getVolume());
|
||||
}
|
||||
@@ -217,18 +229,18 @@ void StreamSoundSource::update()
|
||||
break;
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// we might have to restart the source if we had a buffer underrun
|
||||
if(!playing()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Restarting audio source because of buffer underrun.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d] Restarting audio source because of buffer underrun.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
std::cerr << "Restarting audio source because of buffer underrun.\n";
|
||||
alSourcePlay(source);
|
||||
SoundPlayerOpenAL::checkAlError("Couldn't restart audio source: ");
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// handle fading
|
||||
switch(fadeState) {
|
||||
@@ -253,7 +265,7 @@ void StreamSoundSource::update()
|
||||
break;
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
bool StreamSoundSource::fillBufferAndQueue(ALuint buffer)
|
||||
@@ -289,21 +301,21 @@ bool StreamSoundSource::fillBufferAndQueue(ALuint buffer)
|
||||
// ================================
|
||||
|
||||
SoundPlayerOpenAL::SoundPlayerOpenAL() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
device = 0;
|
||||
initOk = false;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
SoundPlayerOpenAL::~SoundPlayerOpenAL() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
end();
|
||||
initOk = false;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void SoundPlayerOpenAL::printOpenALInfo()
|
||||
@@ -315,7 +327,7 @@ void SoundPlayerOpenAL::printOpenALInfo()
|
||||
}
|
||||
|
||||
bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
initOk = false;
|
||||
|
||||
@@ -341,11 +353,11 @@ bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) {
|
||||
checkAlError("Audio error after init: ");
|
||||
|
||||
initOk = true;
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
printOpenALInfo();
|
||||
//throw std::runtime_error(ex.what());
|
||||
}
|
||||
@@ -355,7 +367,7 @@ bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) {
|
||||
|
||||
void SoundPlayerOpenAL::end() {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
||||
for(StaticSoundSources::iterator i = staticSources.begin();
|
||||
@@ -364,7 +376,7 @@ void SoundPlayerOpenAL::end() {
|
||||
src->stop();
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
for(StreamSoundSources::iterator i = streamSources.begin();
|
||||
i != streamSources.end(); ++i) {
|
||||
@@ -372,32 +384,32 @@ void SoundPlayerOpenAL::end() {
|
||||
src->stop();
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
for(StaticSoundSources::iterator i = staticSources.begin();
|
||||
i != staticSources.end(); ++i) {
|
||||
delete *i;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
for(StreamSoundSources::iterator i = streamSources.begin();
|
||||
i != streamSources.end(); ++i) {
|
||||
delete *i;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
alcMakeContextCurrent( NULL );
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(context != 0) {
|
||||
alcDestroyContext(context);
|
||||
context = 0;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(device != 0) {
|
||||
alcCloseDevice(device);
|
||||
@@ -405,7 +417,7 @@ void SoundPlayerOpenAL::end() {
|
||||
initOk = false;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void SoundPlayerOpenAL::play(StaticSound* staticSound) {
|
||||
@@ -415,13 +427,15 @@ void SoundPlayerOpenAL::play(StaticSound* staticSound) {
|
||||
|
||||
try {
|
||||
StaticSoundSource* source = findStaticSoundSource();
|
||||
if(source == 0)
|
||||
|
||||
if(source == 0) {
|
||||
return;
|
||||
}
|
||||
source->play(staticSound);
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
std::cerr << "Couldn't play static sound: " << e.what() << "\n";
|
||||
std::cerr << "Couldn't play static sound: [" << e.what() << "]\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +495,7 @@ void SoundPlayerOpenAL::updateStreams() {
|
||||
source->update();
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
|
||||
std::cerr << "Error while updating sound stream: "<< e.what() << "\n";
|
||||
@@ -491,13 +505,13 @@ void SoundPlayerOpenAL::updateStreams() {
|
||||
checkAlcError("Error while processing audio context: ");
|
||||
}
|
||||
catch(exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
printOpenALInfo();
|
||||
throw runtime_error(ex.what());
|
||||
}
|
||||
catch(...) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
printOpenALInfo();
|
||||
throw;
|
||||
@@ -521,12 +535,12 @@ StaticSoundSource* SoundPlayerOpenAL::findStaticSoundSource() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
StaticSoundSource* source = new StaticSoundSource();
|
||||
staticSources.push_back(source);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
return source;
|
||||
}
|
||||
@@ -548,12 +562,12 @@ StreamSoundSource* SoundPlayerOpenAL::findStreamSoundSource() {
|
||||
throw std::runtime_error("Too many stream sounds played at once");
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
StreamSoundSource* source = new StreamSoundSource();
|
||||
streamSources.push_back(source);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
return source;
|
||||
}
|
||||
|
@@ -159,30 +159,24 @@ void OggSoundFileLoader::open(const string &path, SoundInfo *soundInfo){
|
||||
throw runtime_error("Can't read ogg header info for file: "+path);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] vi->version = %d, vi->channels = %d, vi->rate = %ld, vi->bitrate_upper = %ld, vi->bitrate_nominal = %ld, vi->bitrate_lower = %ld, vi->bitrate_window = %ld\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),vi->version,vi->channels,vi->rate,vi->bitrate_upper,vi->bitrate_nominal,vi->bitrate_lower,vi->bitrate_window);
|
||||
uint32 samples = static_cast<uint32>(ov_pcm_total(vf, -1));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] path = [%s] vi->version = %d, vi->channels = %d, vi->rate = %ld, vi->bitrate_upper = %ld, vi->bitrate_nominal = %ld, vi->bitrate_lower = %ld, vi->bitrate_window = %ld, samples = %lu\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),vi->version,vi->channels,vi->rate,vi->bitrate_upper,vi->bitrate_nominal,vi->bitrate_lower,vi->bitrate_window,samples);
|
||||
|
||||
soundInfo->setChannels(vi->channels);
|
||||
soundInfo->setsamplesPerSecond(vi->rate);
|
||||
soundInfo->setBitsPerSample(16);
|
||||
|
||||
uint32 samples = static_cast<uint32>(ov_pcm_total(vf, -1));
|
||||
|
||||
//if(vi->channels == 1) {
|
||||
soundInfo->setSize(samples * 2);
|
||||
//}
|
||||
//else {
|
||||
// soundInfo->setSize(samples * 4);
|
||||
//}
|
||||
soundInfo->setSize(samples * 2);
|
||||
}
|
||||
|
||||
uint32 OggSoundFileLoader::read(int8 *samples, uint32 size){
|
||||
int section;
|
||||
int totalBytesRead= 0;
|
||||
|
||||
while(size>0){
|
||||
while(size>0) {
|
||||
int bytesRead= ov_read(vf, reinterpret_cast<char*> (samples), size,
|
||||
0, 2, 1, §ion);
|
||||
if(bytesRead==0){
|
||||
if(bytesRead==0) {
|
||||
break;
|
||||
}
|
||||
size-= bytesRead;
|
||||
|
@@ -186,13 +186,14 @@ void SystemFlags::init(bool haveSpecialOutputCommandLineOption) {
|
||||
if(SystemFlags::debugLogFileList == NULL) {
|
||||
SystemFlags::debugLogFileList = new std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>();
|
||||
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugSound] = SystemFlags::SystemFlagsType(SystemFlags::debugSound);
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError);
|
||||
}
|
||||
|
||||
if(threadLogger == NULL) {
|
||||
|
Reference in New Issue
Block a user