Permalink
Browse files

pull in changes from HPL2 engine.

- new features are enumeration of devices
- also StreamBufferSize is now in bytes instead of # of 4K chunks
  • Loading branch information...
1 parent 2bc2064 commit b504f6b8d7dad47af12d80470875b02bc549126d @urkle urkle committed Nov 28, 2011
@@ -56,6 +56,7 @@ class cOAL_Device : public iOAL_LoggerObject
inline bool IsEFXActive () { return (mbEFXActive && (mpEFXManager!=NULL)); }
inline int GetEFXSends() { return mlEFXSends; }
static string& GetExtensionName(int alWhich);
+ static string GetDefaultDeviceName();
static vector<string>GetOutputDevices();
@@ -8,9 +8,9 @@
#ifndef _OAL_EFXMANAGER_H
#define _OAL_EFXMANAGER_H
-#include "OALWrapper/OAL_Types.h"
-#include "OALWrapper/OAL_Helper.h"
-#include "OALWrapper/OAL_LoggerObject.h"
+#include "OAL_Types.h"
+#include "OAL_Helper.h"
+#include "OAL_LoggerObject.h"
#include <SDL/SDL.h>
@@ -8,7 +8,7 @@
#ifndef _OAL_EFFECT_H
#define _OAL_EFFECT_H
-#include "OALWrapper/OAL_LowLevelObject.h"
+#include "OAL_LowLevelObject.h"
#include <SDL/SDL.h>
@@ -8,8 +8,8 @@
#ifndef _OAL_EFFECTSLOT_H
#define _OAL_EFFECTSLOT_H
-#include "OALWrapper/OAL_Types.h"
-#include "OALWrapper/OAL_LowLevelObject.h"
+#include "OAL_Types.h"
+#include "OAL_LowLevelObject.h"
#include <SDL/SDL.h>
@@ -8,9 +8,9 @@
#ifndef _OAL_EFFECT_REVERB_H
#define _OAL_EFFECT_REVERB_H
-#include "OALWrapper/OAL_Effect.h"
-#include "OALWrapper/OAL_Types.h"
-#include "OALWrapper/OAL_Helper.h"
+#include "OAL_Effect.h"
+#include "OAL_Types.h"
+#include "OAL_Helper.h"
class cOAL_Effect_Reverb : public cOAL_Effect
{
@@ -8,7 +8,7 @@
#ifndef _OAL_FILTER_H
#define _OAL_FILTER_H
-#include "OALWrapper/OAL_Types.h"
+#include "OAL_Types.h"
#include "OAL_LowLevelObject.h"
@@ -77,6 +77,9 @@ const int OAL_Info_GetMajorVersion();
const int OAL_Info_GetMinorVersion();
const int OAL_Info_GetNumSources();
const bool OAL_Info_IsEFXActive();
+int OAL_Info_GetStreamBufferCount();
+int OAL_Info_GetStreamBufferSize();
+string OAL_Info_GetDefaultOutputDevice();
vector<string> OAL_Info_GetOutputDevices();
void OAL_LogSourcePoolStatus();
@@ -26,7 +26,7 @@ class cOAL_Sample : public iOAL_AudioData
public:
cOAL_Sample();
- ~cOAL_Sample();
+ virtual ~cOAL_Sample();
void Destroy(){}
@@ -145,6 +145,8 @@ class cOAL_Source : public iOAL_LowLevelObject
// Misc methods
void Update();
+ // Special
+ void IncRefCount();
// Logging
//void LogMsg("",eOAL_LogVerbose aeVerboseLevelReq, eOAL_LogMsg aeMessageType, const char* asMessage, ...);
@@ -187,7 +189,6 @@ class cOAL_Source : public iOAL_LowLevelObject
bool LowLevelSet(eOAL_SourceParam aeParam);
void LowLevelSetMuted( bool abX );
- inline void IncRefCount();
int GetPackedHandle(int alRef, int alId);
};
#endif
@@ -21,7 +21,7 @@ class cOAL_SourceManager : public iOAL_LoggerObject
cOAL_SourceManager();
~cOAL_SourceManager();
- cOAL_Source* GetSource ( int alSourceHandle, bool abUsingAbsoluteIndex = false );
+ cOAL_Source* GetSource ( int alSourceHandle, bool abSkipRefCountCheck = false );
cOAL_Source* GetAvailableSource ( unsigned int alPriority, int alNumOfVoices );
bool Initialize( bool abManageVoices, int alNumSourcesHint, bool abUseThreading, int alUpdateFreq, int alEFXSends = 0 );
@@ -17,7 +17,7 @@ class cOAL_Stream : public iOAL_AudioData
public:
cOAL_Stream();
- ~cOAL_Stream();
+ virtual ~cOAL_Stream();
/////////////////////////////////////
@@ -35,7 +35,7 @@ class cOAL_Stream : public iOAL_AudioData
// Streaming Config stuff
static inline void SetBufferCount(unsigned int alBufferCount) { if(alBufferCount >= 1) mlBufferCount = alBufferCount; }
- static inline void SetBufferSize(unsigned int alBufferSize) { if(alBufferSize >= 1) mlBufferSize = alBufferSize * STREAMING_BLOCK_SIZE; }
+ static inline void SetBufferSize(unsigned int alBufferSize) { if(alBufferSize >= 1) mlBufferSize = alBufferSize; }
static inline unsigned int GetBufferSize() { return mlBufferSize; }
static inline unsigned int GetBufferCount() { return mlBufferCount; }
@@ -16,8 +16,8 @@
#ifndef _OAL_WAVSAMPLE_H
#define _OAL_WAVSAMPLE_H
-#include "OALWrapper/OAL_Sample.h"
-#include "OALWrapper/OAL_Helper.h"
+#include "OAL_Sample.h"
+#include "OAL_Helper.h"
//-----------------------------------------------------------
View
@@ -88,7 +88,7 @@ bool cOAL_Device::Init( cOAL_Init_Params& acParams )
LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Attempting to open device...\n" );
// Open the device, if fails return false
- if (strcmp( acParams.msDeviceName.c_str(), "NULL" ) == 0)
+ if(acParams.msDeviceName.empty())
mpDevice = alcOpenDevice(NULL);
else
mpDevice = alcOpenDevice( acParams.msDeviceName.c_str() );
@@ -115,7 +115,8 @@ bool cOAL_Device::Init( cOAL_Init_Params& acParams )
ALCint lAttrList[] =
{
ALC_FREQUENCY, acParams.mlOutputFreq,
-#ifndef __APPLE__
+#ifdef __APPLE__
+#else
ALC_MONO_SOURCES, acParams.mbVoiceManagement ? 256 : acParams.mlMinMonoSourcesHint,
ALC_STEREO_SOURCES, acParams.mbVoiceManagement ? 0 : acParams.mlMinStereoSourcesHint,
#endif
@@ -339,9 +340,17 @@ cOAL_Stream* cOAL_Device::LoadStream(const wstring &asFilename)
wstring strExt = GetExtensionW(asFilename);
if(strExt.compare(L"ogg")==0)
+ {
pStream = new cOAL_OggStream;
-
- if(pStream && pStream->CreateFromFile(asFilename))
+ }
+ else
+ {
+ return NULL;
+ }
+
+ /////////////////////////////////
+ //Create from file
+ if(pStream->CreateFromFile(asFilename))
{
mlstStreams.push_back(pStream);
//hpl::Log("Loaded stream %s\n", pStream->msName.c_str());
@@ -526,6 +535,17 @@ string& cOAL_Device::GetExtensionName(int alWhich)
//-------------------------------------------------------------------------
+string cOAL_Device::GetDefaultDeviceName()
+{
+ DEF_FUNC_NAME(cOAL_Device::GetDefaultDeviceName);
+ FUNC_USES_ALC;
+
+ string sDev = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
+
+ return sDev;
+}
+
+//-------------------------------------------------------------------------
vector<string> cOAL_Device::GetOutputDevices()
{
DEF_FUNC_NAME(cOAL_Device::GetOutputDevices);
View
@@ -17,6 +17,7 @@
#include "OALWrapper/OAL_Types.h"
#include "OALWrapper/OAL_Device.h"
#include "OALWrapper/OAL_SourceManager.h"
+#include "OALWrapper/OAL_Stream.h"
cOAL_Device* gpDevice = NULL;
@@ -28,27 +29,12 @@ cOAL_Device* gpDevice = NULL;
// bool abUseThread, int alUpdateFreq,
// int alReqMajorVersion, int alReqMinorVersion)
///////////////////////////////////////////////////////////
-/*
-bool OAL_Init ( const char* asDeviceName, int alOutputFreq,
- bool abUseThread, int alUpdateFreq,
- int alReqMajorVersion, int alReqMinorVersion,
- int alNumSourcesHint, bool abVoiceManagement,
- int alMinMonoSourceHint, int alMinStereoSourceHint,
- int alStreamingBufferSize, int alStreamingBufferCount)
-*/
bool OAL_Init ( cOAL_Init_Params &acParams )
{
OAL_Log(eOAL_LogVerbose_None, eOAL_LogMsg_Text,"-------------------------------------\n----- OpenAL Wrapper Log opened -----\n-------------------------------------\n");
gpDevice = new cOAL_Device;
bool bSuccess = gpDevice->Init( acParams );
- /*asDeviceName , alOutputFreq,
- abUseThread, alUpdateFreq,
- true, 4, 4,
- alReqMajorVersion, alReqMinorVersion,
- alNumSourcesHint, abVoiceManagement,
- alMinMonoSourceHint, alMinStereoSourceHint,
- alStreamingBufferSize, alStreamingBufferCount);*/
if ( bSuccess )
{
atexit(OAL_Close);
@@ -207,11 +193,11 @@ void OAL_SetupLogging ( bool abLogSounds, eOAL_LogOutput aeOutput, eOAL_LogVerbo
if (pTempFile)
{
fclose(pTempFile);
- #ifdef WIN32
+#ifdef WIN32
_wremove (iOAL_LoggerObject::GetLogFilename().c_str());
- #else
+#else
remove (WString2String(iOAL_LoggerObject::GetLogFilename()).c_str());
- #endif
+#endif
}
pTempFile = NULL;
@@ -322,6 +308,21 @@ const bool OAL_Info_IsEFXActive()
return gpDevice->IsEFXActive();
else
return false;
+}
+
+int OAL_Info_GetStreamBufferCount()
+{
+ return cOAL_Stream::GetBufferCount();
+}
+
+int OAL_Info_GetStreamBufferSize()
+{
+ return cOAL_Stream::GetBufferSize();
+}
+
+string OAL_Info_GetDefaultOutputDevice()
+{
+ return cOAL_Device::GetDefaultDeviceName();
}
vector<string> OAL_Info_GetOutputDevices()
View
@@ -25,7 +25,7 @@ extern ov_callbacks gCallbacks;
//---------------------------------------------------------------------
-cOAL_OggStream::cOAL_OggStream()
+cOAL_OggStream::cOAL_OggStream(): mbIsValidHandle(false)
{
}
@@ -72,11 +72,9 @@ bool cOAL_OggStream::Stream(cOAL_Buffer* apDestBuffer)
// If we get a negative value, then something went wrong. Clean up and set error status.
else if(lChunkSize == OV_HOLE)
;
- else if(lChunkSize == OV_EINVAL)
- mbStatus = false;
- else if(lChunkSize == OV_EBADLINK)
- mbStatus = false;
- else if(lChunkSize<0)
+ else if(lChunkSize==OV_EINVAL ||
+ lChunkSize==OV_EBADLINK ||
+ lChunkSize<0)
mbStatus = false;
else
lDataSize += lChunkSize;
View
@@ -43,7 +43,10 @@ cOAL_Sample::~cOAL_Sample()
{
tSourceListIt it;
for(it=mlstBoundSources.begin(); it!=mlstBoundSources.end(); ++it)
- (*it)->Stop(false);
+ {
+ cOAL_Source* pSource = *it;
+ pSource->Stop(false);
+ }
mlstBoundSources.clear();
}
}
View
@@ -209,19 +209,14 @@ eOAL_SourceStatus cOAL_Source::GetSourceStatus ()
{
if(mpAudioData->HasBufferUnderrun())
return eOAL_SourceStatus_Busy_BufferUnderrun;
-
- /*if(mSourceType==eOAL_SourceType_Stream)
- {
- if ( !mpAudioData->IsEOF() ||
- (mpAudioData->IsEOF() && (GetQueuedBuffers() > 0 ))) //!= GetProcessedBuffers())) )
- return eOAL_SourceStatus_Busy_BufferUnderrun;
- }*/
}
return eOAL_SourceStatus_Free;
}
return eOAL_SourceStatus_Busy;
}
+//--------------------------------------------------------------------------------
+
eOAL_AudioDataType cOAL_Source::GetSourceType()
{
if(mpAudioData)
@@ -372,6 +367,8 @@ void cOAL_Source::IncRefCount()
mlRefCount = 0;
}
+//--------------------------------------------------------------------------------
+
int cOAL_Source::GetPackedHandle(int alRef, int alId)
{
return (alRef<<12) | alId;
@@ -541,12 +538,13 @@ void cOAL_Source::Update()
return;
// Check if the sound data is still healthy
- if(mpAudioData->GetStatus()==false) {
+ if(mpAudioData==NULL ||
+ mpAudioData->GetStatus()==false) {
Stop();
return;
}
- //hpl::Log("Updating source - mbPlaying %d status %d elapsed %f\n", mbPlaying, sourceStatus, GetElapsedTime());
+ //hpl::Log(" OAL: Updating source %p audiodata: %p - mbPlaying %d status %d elapsed %f/%f\n",this,mpAudioData, mbPlaying, sourceStatus, GetElapsedTime(),GetTotalTime());
mpAudioData->Update();
// If the source had a buffer underrun (this means it ran out of data and stopped), tell it to continue playing
Oops, something went wrong.

0 comments on commit b504f6b

Please sign in to comment.