Increased buffer size for audio sources from 32k to 64k.
Changed song used by Tutorial1_2DSound. Added some comments. Changed cVector3 to use a custom Episilon instead of including float.h (less bloat) Added debug log entries to cAudio Allowed cOggDecoder to return error values from decoding. cAudio now handles those errors a little better.
This commit is contained in:
parent
0df02507dc
commit
cd1a2a61d9
|
@ -6,8 +6,6 @@
|
|||
//Include our version of Sleep to free CPU usage
|
||||
#include "../../include/cAudioSleep.h"
|
||||
|
||||
//#include "../../include/cAudioLog.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -42,7 +40,7 @@ int main(int argc, char* argv[])
|
|||
manager->initialize(manager->getAvailableDeviceName(deviceSelection));
|
||||
|
||||
//Create a IAudio object and load a sound from a file
|
||||
cAudio::IAudio* mysound = manager->createFromFile("bling","../../media/cAudioTheme2.ogg",true);
|
||||
cAudio::IAudio* mysound = manager->createFromFile("bling","../../media/cAudioTheme1.ogg",true);
|
||||
|
||||
if(mysound)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
|
||||
#define BUFFER_SIZE ( 1024 * 32 )
|
||||
#define BUFFER_SIZE ( 1024 * 64 )
|
||||
#include "../include/IAudio.h"
|
||||
#include "../Include/cVector3.h"
|
||||
#include "../Headers/cMutex.h"
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
#define CUTILS_H_INCLUDED
|
||||
#include <string>
|
||||
|
||||
//!Grabs the current extention of a given string.
|
||||
//! Grabs the current extention of a given string.
|
||||
static std::string getExt(const std::string& filename)
|
||||
{
|
||||
if(filename.find_last_of(".") == std::string::npos) return filename;
|
||||
return filename.substr(filename.find_last_of(".") + 1, filename.length()-filename.find_last_of(".")-1);
|
||||
}
|
||||
|
||||
//! Prevents a bug with NULL passed into std::string.
|
||||
static std::string safeCStr(const char* str)
|
||||
{
|
||||
if( str != NULL ) return std::string(str);
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace cAudio
|
|||
alDeleteBuffers(3, buffers);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Audio source released.");
|
||||
}
|
||||
|
||||
//!Plays back sound source
|
||||
|
@ -116,6 +117,7 @@ namespace cAudio
|
|||
{
|
||||
//stores the caculated data into buffer that is passed to output.
|
||||
size_t totalread = 0;
|
||||
unsigned int errorcount = 0;
|
||||
char tempbuffer[BUFFER_SIZE];
|
||||
while( totalread < BUFFER_SIZE )
|
||||
{
|
||||
|
@ -128,7 +130,10 @@ namespace cAudio
|
|||
}
|
||||
if(actualread < 0)
|
||||
{
|
||||
break;
|
||||
++errorcount;
|
||||
getLogger()->logDebug("Audio Source", "Decoder returned an error: %i (%i of 3)", actualread, errorcount);
|
||||
if(errorcount >= 3)
|
||||
break;
|
||||
}
|
||||
if(actualread == 0)
|
||||
{
|
||||
|
@ -136,6 +141,7 @@ namespace cAudio
|
|||
{
|
||||
//If we are to loop, set to the beginning and reload from the start
|
||||
Decoder->setPosition(0,false);
|
||||
getLogger()->logDebug("Audio Source", "Buffer looping.");
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
@ -147,7 +153,7 @@ namespace cAudio
|
|||
{
|
||||
return false;
|
||||
}
|
||||
//std::cout << buffer << std::endl;
|
||||
getLogger()->logDebug("Audio Source", "Buffered %i bytes of data into buffer %i at %i hz.", totalread, buffer, Decoder->getFrequency());
|
||||
alBufferData(buffer, Decoder->getFormat(), tempbuffer, totalread, Decoder->getFrequency());
|
||||
checkError();
|
||||
return true;
|
||||
|
@ -388,6 +394,7 @@ namespace cAudio
|
|||
alSourcePlay(source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Source playing.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -399,6 +406,7 @@ namespace cAudio
|
|||
alSourceStop(source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Source stopped.");
|
||||
}
|
||||
|
||||
//!Used to pause the audio source
|
||||
|
@ -409,6 +417,7 @@ namespace cAudio
|
|||
alSourcePause(source);
|
||||
checkError();
|
||||
Mutex.unlock();
|
||||
getLogger()->logDebug("Audio Source", "Source paused.");
|
||||
}
|
||||
|
||||
const ALuint& cAudio::getSource()const
|
||||
|
|
|
@ -81,7 +81,8 @@ namespace cAudio
|
|||
{
|
||||
int temp = 0;
|
||||
int result = ov_read(&oggStream,(char*)output,amount,0,2,1,&temp);
|
||||
return (result < 0) ? 0 : result;
|
||||
//return (result < 0) ? 0 : result;
|
||||
return result;
|
||||
}
|
||||
|
||||
//!Sets the postion for vorbis data reader
|
||||
|
|
|
@ -9,6 +9,9 @@ namespace cAudio
|
|||
class IAudioCapture
|
||||
{
|
||||
public:
|
||||
IAudioCapture() { }
|
||||
virtual ~IAudioCapture() { }
|
||||
|
||||
//! Initializes the capture device to the selected settings
|
||||
/** Note that calling this will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
|
||||
\param deviceName: Name of the audio device to capture audio from, pass NULL to specify the default one
|
||||
|
@ -84,9 +87,6 @@ namespace cAudio
|
|||
|
||||
//! Returns the current size of the internal audio buffer in bytes
|
||||
virtual unsigned int getCurrentCapturedAudioSize() = 0;
|
||||
|
||||
IAudioCapture() { }
|
||||
virtual ~IAudioCapture() { }
|
||||
};
|
||||
|
||||
//! Creates an interface to an Audio Capture Object
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
#ifndef CVECTOR3_H
|
||||
#define CVECTOR3_H
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
const float Epsilon = 0.000001f;
|
||||
|
||||
inline bool float_equals(const float a, const float b)
|
||||
{
|
||||
return (a + FLT_EPSILON >= b) && (a - FLT_EPSILON <= b);
|
||||
return (a + Epsilon >= b) && (a - Epsilon <= b);
|
||||
}
|
||||
|
||||
class cVector3
|
||||
|
|
Loading…
Reference in New Issue