RageSound_ -> RageSoundDriver_

This commit is contained in:
Glenn Maynard
2006-12-07 02:16:51 +00:00
parent 0e8b6ed2e8
commit f4c7193c70
21 changed files with 152 additions and 152 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ struct RegisterSoundDriver
};
// Can't use Create##name because many of these have -sw suffixes.
#define REGISTER_SOUND_DRIVER_CLASS2( name, x ) \
static RageSoundDriver *Create##x() { return new RageSound_##x; } \
static RageSoundDriver *Create##x() { return new RageSoundDriver_##x; } \
static RegisterSoundDriver register_##x( #name, Create##x )
#define REGISTER_SOUND_DRIVER_CLASS( name ) REGISTER_SOUND_DRIVER_CLASS2( name, name )
@@ -20,13 +20,13 @@ const unsigned max_writeahead = 1024*8;
const int num_chunks = 8;
const int chunksize = max_writeahead / num_chunks;
int RageSound_ALSA9::MixerThread_start(void *p)
int RageSoundDriver_ALSA9::MixerThread_start(void *p)
{
((RageSound_ALSA9 *) p)->MixerThread();
((RageSoundDriver_ALSA9 *) p)->MixerThread();
return 0;
}
void RageSound_ALSA9::MixerThread()
void RageSoundDriver_ALSA9::MixerThread()
{
while(!shutdown)
{
@@ -81,13 +81,13 @@ void RageSound_ALSA9::MixerThread()
}
}
RageSound_ALSA9::stream::~stream()
RageSoundDriver_ALSA9::stream::~stream()
{
delete pcm;
}
/* Returns the number of frames processed */
bool RageSound_ALSA9::stream::GetData( bool &bEOF )
bool RageSoundDriver_ALSA9::stream::GetData( bool &bEOF )
{
bEOF = false;
@@ -154,7 +154,7 @@ bool RageSound_ALSA9::stream::GetData( bool &bEOF )
}
void RageSound_ALSA9::StartMixing(RageSoundBase *snd)
void RageSoundDriver_ALSA9::StartMixing(RageSoundBase *snd)
{
/* Lock INACTIVE sounds[], and reserve a slot. */
m_InactiveSoundMutex.Lock();
@@ -205,7 +205,7 @@ void RageSound_ALSA9::StartMixing(RageSoundBase *snd)
stream_pool[i]->state = stream_pool[i]->PLAYING;
}
void RageSound_ALSA9::Update()
void RageSoundDriver_ALSA9::Update()
{
for(unsigned i = 0; i < stream_pool.size(); ++i)
{
@@ -223,7 +223,7 @@ void RageSound_ALSA9::Update()
}
}
void RageSound_ALSA9::StopMixing(RageSoundBase *snd)
void RageSoundDriver_ALSA9::StopMixing(RageSoundBase *snd)
{
/* Lock, to make sure the decoder thread isn't running on this sound while we do this. */
LockMut( m_Mutex );
@@ -254,7 +254,7 @@ void RageSound_ALSA9::StopMixing(RageSoundBase *snd)
stream_pool[i]->snd = NULL;
}
bool RageSound_ALSA9::PauseMixing( RageSoundBase *snd, bool bStop )
bool RageSoundDriver_ALSA9::PauseMixing( RageSoundBase *snd, bool bStop )
{
unsigned i;
for( i = 0; i < stream_pool.size(); ++i )
@@ -276,7 +276,7 @@ bool RageSound_ALSA9::PauseMixing( RageSoundBase *snd, bool bStop )
return true;
}
int64_t RageSound_ALSA9::GetPosition(const RageSoundBase *snd) const
int64_t RageSoundDriver_ALSA9::GetPosition(const RageSoundBase *snd) const
{
unsigned i;
for( i = 0; i < stream_pool.size(); ++i )
@@ -290,7 +290,7 @@ int64_t RageSound_ALSA9::GetPosition(const RageSoundBase *snd) const
return stream_pool[i]->pcm->GetPosition();
}
int RageSound_ALSA9::GetSampleRate( int rate ) const
int RageSoundDriver_ALSA9::GetSampleRate( int rate ) const
{
stream *str = stream_pool[0];
return str->pcm->FindSampleRate( rate );
@@ -310,14 +310,14 @@ static RString CheckMixingBlacklist()
return "";
}
RageSound_ALSA9::RageSound_ALSA9():
RageSoundDriver_ALSA9::RageSoundDriver_ALSA9():
m_Mutex("ALSAMutex"),
m_InactiveSoundMutex("InactiveSoundMutex")
{
shutdown = false;
}
RString RageSound_ALSA9::Init()
RString RageSoundDriver_ALSA9::Init()
{
RString sError = LoadALSA();
if( sError != "" )
@@ -355,13 +355,13 @@ RString RageSound_ALSA9::Init()
LOG->Info( "ALSA: Got %i hardware buffers", stream_pool.size() );
MixingThread.SetName( "RageSound_ALSA9" );
MixingThread.SetName( "RageSoundDriver_ALSA9" );
MixingThread.Create( MixerThread_start, this );
return "";
}
RageSound_ALSA9::~RageSound_ALSA9()
RageSoundDriver_ALSA9::~RageSoundDriver_ALSA9()
{
if( MixingThread.IsCreated() )
{
@@ -7,7 +7,7 @@
#include "ALSA9Helpers.h"
class RageSound_ALSA9: public RageSoundDriver
class RageSoundDriver_ALSA9: public RageSoundDriver
{
public:
/* virtuals: */
@@ -19,9 +19,9 @@ public:
void Update();
RageSound_ALSA9();
RageSoundDriver_ALSA9();
RString Init();
~RageSound_ALSA9();
~RageSoundDriver_ALSA9();
private:
/* This mutex serializes the decode thread and StopMixing. */
@@ -27,13 +27,13 @@ static const unsigned safe_writeahead = 1024*4;
static unsigned g_iMaxWriteahead;
const int num_chunks = 8;
int RageSound_ALSA9_Software::MixerThread_start( void *p )
int RageSoundDriver_ALSA9_Software::MixerThread_start( void *p )
{
((RageSound_ALSA9_Software *) p)->MixerThread();
((RageSoundDriver_ALSA9_Software *) p)->MixerThread();
return 0;
}
void RageSound_ALSA9_Software::MixerThread()
void RageSoundDriver_ALSA9_Software::MixerThread()
{
setpriority( PRIO_PROCESS, 0, -15 );
@@ -47,7 +47,7 @@ void RageSound_ALSA9_Software::MixerThread()
}
/* Returns the number of frames processed */
bool RageSound_ALSA9_Software::GetData()
bool RageSoundDriver_ALSA9_Software::GetData()
{
const int frames_to_fill = m_pPCM->GetNumFramesToFill();
if( frames_to_fill <= 0 )
@@ -67,24 +67,24 @@ bool RageSound_ALSA9_Software::GetData()
}
int64_t RageSound_ALSA9_Software::GetPosition( const RageSoundBase *pSound ) const
int64_t RageSoundDriver_ALSA9_Software::GetPosition( const RageSoundBase *pSound ) const
{
return m_pPCM->GetPosition();
}
void RageSound_ALSA9_Software::SetupDecodingThread()
void RageSoundDriver_ALSA9_Software::SetupDecodingThread()
{
setpriority( PRIO_PROCESS, 0, -5 );
}
RageSound_ALSA9_Software::RageSound_ALSA9_Software()
RageSoundDriver_ALSA9_Software::RageSoundDriver_ALSA9_Software()
{
m_pPCM = NULL;
m_bShutdown = false;
}
RString RageSound_ALSA9_Software::Init()
RString RageSoundDriver_ALSA9_Software::Init()
{
RString sError = LoadALSA();
if( sError != "" )
@@ -116,13 +116,13 @@ RString RageSound_ALSA9_Software::Init()
StartDecodeThread();
m_MixingThread.SetName( "RageSound_ALSA9_Software" );
m_MixingThread.SetName( "RageSoundDriver_ALSA9_Software" );
m_MixingThread.Create( MixerThread_start, this );
return "";
}
RageSound_ALSA9_Software::~RageSound_ALSA9_Software()
RageSoundDriver_ALSA9_Software::~RageSoundDriver_ALSA9_Software()
{
if( m_MixingThread.IsCreated() )
{
@@ -138,7 +138,7 @@ RageSound_ALSA9_Software::~RageSound_ALSA9_Software()
UnloadALSA();
}
float RageSound_ALSA9_Software::GetPlayLatency() const
float RageSoundDriver_ALSA9_Software::GetPlayLatency() const
{
return float(g_iMaxWriteahead) / m_iSampleRate;
}
@@ -7,11 +7,11 @@
#include "ALSA9Helpers.h"
class RageSound_ALSA9_Software: public RageSound_Generic_Software
class RageSoundDriver_ALSA9_Software: public RageSound_Generic_Software
{
public:
RageSound_ALSA9_Software();
~RageSound_ALSA9_Software();
RageSoundDriver_ALSA9_Software();
~RageSoundDriver_ALSA9_Software();
RString Init();
/* virtuals: */
+10 -10
View File
@@ -37,21 +37,21 @@ static inline RString FourCCToString( uint32_t num )
return s;
}
RageSound_AU::RageSound_AU() : m_OutputUnit(NULL), m_iSampleRate(0), m_bDone(false), m_bStarted(false),
RageSoundDriver_AU::RageSoundDriver_AU() : m_OutputUnit(NULL), m_iSampleRate(0), m_bDone(false), m_bStarted(false),
m_pIOThread(NULL), m_pNotificationThread(NULL), m_Semaphore("Sound")
{
}
void RageSound_AU::NameHALThread( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *inRefCon )
void RageSoundDriver_AU::NameHALThread( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *inRefCon )
{
RageSound_AU *This = (RageSound_AU *)inRefCon;
RageSoundDriver_AU *This = (RageSoundDriver_AU *)inRefCon;
This->m_pNotificationThread = new RageThreadRegister( "HAL notification thread" );
This->m_Semaphore.Post();
}
RString RageSound_AU::Init()
RString RageSoundDriver_AU::Init()
{
ComponentDescription desc;
@@ -169,7 +169,7 @@ RString RageSound_AU::Init()
return RString();
}
RageSound_AU::~RageSound_AU()
RageSoundDriver_AU::~RageSoundDriver_AU()
{
if( !m_OutputUnit )
return;
@@ -184,20 +184,20 @@ RageSound_AU::~RageSound_AU()
delete m_pNotificationThread;
}
int64_t RageSound_AU::GetPosition( const RageSoundBase *sound ) const
int64_t RageSoundDriver_AU::GetPosition( const RageSoundBase *sound ) const
{
double scale = m_iSampleRate / AudioGetHostClockFrequency();
return int64_t( scale * AudioGetCurrentHostTime() );
}
void RageSound_AU::SetupDecodingThread()
void RageSoundDriver_AU::SetupDecodingThread()
{
/* Increase the scheduling precedence of the decoder thread. */
SetThreadPrecedence( 0.75f );
}
float RageSound_AU::GetPlayLatency() const
float RageSoundDriver_AU::GetPlayLatency() const
{
OSStatus error;
UInt32 bufferSize;
@@ -278,14 +278,14 @@ float RageSound_AU::GetPlayLatency() const
}
OSStatus RageSound_AU::Render( void *inRefCon,
OSStatus RageSoundDriver_AU::Render( void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData )
{
RageSound_AU *This = (RageSound_AU *)inRefCon;
RageSoundDriver_AU *This = (RageSoundDriver_AU *)inRefCon;
if( unlikely(This->m_pIOThread == NULL) )
This->m_pIOThread = new RageThreadRegister( "HAL I/O thread" );
@@ -5,12 +5,12 @@
#include "RageThreads.h"
#include <AudioUnit/AudioUnit.h>
class RageSound_AU : public RageSound_Generic_Software
class RageSoundDriver_AU: public RageSound_Generic_Software
{
public:
RageSound_AU();
RageSoundDriver_AU();
RString Init();
~RageSound_AU();
~RageSoundDriver_AU();
float GetPlayLatency() const;
int GetSampleRate( int rate ) const { return m_iSampleRate; }
int64_t GetPosition( const RageSoundBase *sound ) const;
+15 -15
View File
@@ -47,7 +47,7 @@ static float g_fLastMixTimes[NUM_MIX_TIMES];
static int g_iLastMixTimePos = 0;
static int g_iNumIOProcCalls = 0;
RageSound_CA::RageSound_CA() : m_fLatency(0.0f), m_Converter(NULL), m_bStarted(false), m_iSampleRate(0),
RageSoundDriver_CA::RageSoundDriver_CA() : m_fLatency(0.0f), m_Converter(NULL), m_bStarted(false), m_iSampleRate(0),
m_iLastSampleTime(0), m_iOffset(0), m_pIOThread(NULL), m_pNotificationThread(NULL)
{
}
@@ -75,7 +75,7 @@ static inline RString FourCCToString( uint32_t num )
#define WERROR(str, num, extra...) str ": '%s' (%lu).", ## extra, FourCCToString(num).c_str(), (num)
#define ERROR(str, num, extra...) (ssprintf(WERROR(str, (num), ## extra)))
RString RageSound_CA::Init()
RString RageSoundDriver_CA::Init()
{
OSStatus error;
UInt32 size = sizeof(m_OutputDevice);
@@ -327,7 +327,7 @@ RString RageSound_CA::Init()
return RString();
}
RageSound_CA::~RageSound_CA()
RageSoundDriver_CA::~RageSoundDriver_CA()
{
if( m_bStarted )
{
@@ -343,7 +343,7 @@ RageSound_CA::~RageSound_CA()
AudioHardwareUnload();
}
void RageSound_CA::AddListener( AudioDevicePropertyID propertyID, AudioDevicePropertyListenerProc handler,
void RageSoundDriver_CA::AddListener( AudioDevicePropertyID propertyID, AudioDevicePropertyListenerProc handler,
const char *name )
{
OSStatus error;
@@ -360,7 +360,7 @@ void RageSound_CA::AddListener( AudioDevicePropertyID propertyID, AudioDevicePro
}
}
void RageSound_CA::RemoveListeners()
void RageSoundDriver_CA::RemoveListeners()
{
while( m_vPropertyListeners.size() )
{
@@ -373,7 +373,7 @@ void RageSound_CA::RemoveListeners()
}
}
int64_t RageSound_CA::GetPosition( const RageSoundBase *sound ) const
int64_t RageSoundDriver_CA::GetPosition( const RageSoundBase *sound ) const
{
AudioTimeStamp time;
OSStatus error;
@@ -388,9 +388,9 @@ int64_t RageSound_CA::GetPosition( const RageSoundBase *sound ) const
return m_iLastSampleTime;
}
void RageSound_CA::NameHALThread( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info )
void RageSoundDriver_CA::NameHALThread( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info )
{
RageSound_CA *This = (RageSound_CA *)info;
RageSoundDriver_CA *This = (RageSoundDriver_CA *)info;
This->m_pNotificationThread = new RageThreadRegister( "HAL notification thread" );
@@ -399,7 +399,7 @@ void RageSound_CA::NameHALThread( CFRunLoopObserverRef observer, CFRunLoopActivi
CFRelease( observer );
}
OSStatus RageSound_CA::GetData( AudioDeviceID inDevice,
OSStatus RageSoundDriver_CA::GetData( AudioDeviceID inDevice,
const AudioTimeStamp *inNow,
const AudioBufferList *inInputData,
const AudioTimeStamp *inInputTime,
@@ -408,7 +408,7 @@ OSStatus RageSound_CA::GetData( AudioDeviceID inDevice,
void *inClientData )
{
RageTimer tm;
RageSound_CA *This = (RageSound_CA *)inClientData;
RageSoundDriver_CA *This = (RageSoundDriver_CA *)inClientData;
if( unlikely(This->m_pIOThread == NULL) )
This->m_pIOThread = new RageThreadRegister( "HAL I/O thread" );
@@ -444,7 +444,7 @@ OSStatus RageSound_CA::GetData( AudioDeviceID inDevice,
}
OSStatus RageSound_CA::OverloadListener( AudioDeviceID inDevice,
OSStatus RageSoundDriver_CA::OverloadListener( AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
@@ -465,7 +465,7 @@ OSStatus RageSound_CA::OverloadListener( AudioDeviceID inDevice,
return noErr;
}
OSStatus RageSound_CA::DeviceChanged( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput,
OSStatus RageSoundDriver_CA::DeviceChanged( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput,
AudioDevicePropertyID inPropertyID, void *inData )
{
if( isInput )
@@ -474,12 +474,12 @@ OSStatus RageSound_CA::DeviceChanged( AudioDeviceID inDevice, UInt32 inChannel,
return noErr;
}
OSStatus RageSound_CA::JackChanged( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput,
OSStatus RageSoundDriver_CA::JackChanged( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput,
AudioDevicePropertyID inPropertyID, void *inData )
{
if( isInput )
return noErr;
RageSound_CA *This = (RageSound_CA *)inData;
RageSoundDriver_CA *This = (RageSoundDriver_CA *)inData;
UInt32 result;
UInt32 size = sizeof( result );
AudioTimeStamp time;
@@ -503,7 +503,7 @@ OSStatus RageSound_CA::JackChanged( AudioDeviceID inDevice, UInt32 inChannel, Bo
}
void RageSound_CA::SetupDecodingThread()
void RageSoundDriver_CA::SetupDecodingThread()
{
/* Increase the scheduling precedence of the decoder thread. */
SetThreadPrecedence( 0.75f );
@@ -9,12 +9,12 @@
class RageSoundBase;
class RageThreadRegister;
class RageSound_CA : public RageSound_Generic_Software
class RageSoundDriver_CA : public RageSound_Generic_Software
{
public:
RageSound_CA();
RageSoundDriver_CA();
RString Init();
~RageSound_CA();
~RageSoundDriver_CA();
float GetPlayLatency() const { return m_fLatency; }
int GetSampleRate( int rate ) const { return m_iSampleRate; }
int64_t GetPosition( const RageSoundBase *sound ) const;
@@ -28,13 +28,13 @@ const int buffersize = 1024*8; /* in frames */
const int num_chunks = 8;
const int chunksize = buffersize / num_chunks;
int RageSound_DSound::MixerThread_start(void *p)
int RageSoundDriver_DSound::MixerThread_start(void *p)
{
((RageSound_DSound *) p)->MixerThread();
((RageSoundDriver_DSound *) p)->MixerThread();
return 0;
}
void RageSound_DSound::MixerThread()
void RageSoundDriver_DSound::MixerThread()
{
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL) )
LOG->Warn(werr_ssprintf(GetLastError(), "Failed to set sound thread priority"));
@@ -103,7 +103,7 @@ void RageSound_DSound::MixerThread()
stream_pool[i]->pcm->Stop();
}
void RageSound_DSound::Update()
void RageSoundDriver_DSound::Update()
{
/* SoundStopped might erase sounds out from under us, so make a copy
* of the sound list. */
@@ -126,7 +126,7 @@ void RageSound_DSound::Update()
/* If init is true, we're filling the buffer while it's stopped, so fill the
* entire buffer. If false, fill only one chunk. If EOF is reached, set bEOF. */
bool RageSound_DSound::stream::GetData( bool init, bool &bEOF )
bool RageSoundDriver_DSound::stream::GetData( bool init, bool &bEOF )
{
CHECKPOINT;
@@ -196,19 +196,19 @@ bool RageSound_DSound::stream::GetData( bool init, bool &bEOF )
return true;
}
RageSound_DSound::stream::~stream()
RageSoundDriver_DSound::stream::~stream()
{
delete pcm;
}
RageSound_DSound::RageSound_DSound():
RageSoundDriver_DSound::RageSoundDriver_DSound():
m_Mutex("DSoundMutex"),
m_InactiveSoundMutex("InactiveSoundMutex")
{
shutdown = false;
}
RString RageSound_DSound::Init()
RString RageSoundDriver_DSound::Init()
{
RString sError = ds.Init();
if( sError != "" )
@@ -257,7 +257,7 @@ RString RageSound_DSound::Init()
return RString();
}
RageSound_DSound::~RageSound_DSound()
RageSoundDriver_DSound::~RageSoundDriver_DSound()
{
/* Signal the mixing thread to quit. */
if( MixingThread.IsCreated() )
@@ -274,7 +274,7 @@ RageSound_DSound::~RageSound_DSound()
delete stream_pool[i];
}
void RageSound_DSound::StartMixing( RageSoundBase *snd )
void RageSoundDriver_DSound::StartMixing( RageSoundBase *snd )
{
/* Lock INACTIVE sounds[], and reserve a slot. */
m_InactiveSoundMutex.Lock();
@@ -325,7 +325,7 @@ void RageSound_DSound::StartMixing( RageSoundBase *snd )
* call completes, snd->GetPCM (which runs in a separate thread) will
* not be running and will not be called unless StartMixing is called
* again. */
void RageSound_DSound::StopMixing( RageSoundBase *snd )
void RageSoundDriver_DSound::StopMixing( RageSoundBase *snd )
{
/* Lock, to make sure the decoder thread isn't running on this sound while we do this. */
LockMut( m_Mutex );
@@ -349,7 +349,7 @@ void RageSound_DSound::StopMixing( RageSoundBase *snd )
stream_pool[i]->state = stream_pool[i]->INACTIVE;
}
bool RageSound_DSound::PauseMixing( RageSoundBase *snd, bool bStop )
bool RageSoundDriver_DSound::PauseMixing( RageSoundBase *snd, bool bStop )
{
unsigned i;
for( i = 0; i < stream_pool.size(); ++i )
@@ -371,7 +371,7 @@ bool RageSound_DSound::PauseMixing( RageSoundBase *snd, bool bStop )
return true;
}
int64_t RageSound_DSound::GetPosition( const RageSoundBase *snd ) const
int64_t RageSoundDriver_DSound::GetPosition( const RageSoundBase *snd ) const
{
unsigned i;
for(i = 0; i < stream_pool.size(); ++i)
@@ -9,11 +9,11 @@
struct IDirectSound;
struct IDirectSoundBuffer;
class RageSound_DSound: public RageSoundDriver
class RageSoundDriver_DSound: public RageSoundDriver
{
public:
RageSound_DSound();
~RageSound_DSound();
RageSoundDriver_DSound();
~RageSoundDriver_DSound();
RString Init();
private:
@@ -19,7 +19,7 @@ static int g_iMaxWriteahead;
static const int num_chunks = 8;
static int chunksize() { return g_iMaxWriteahead / num_chunks; }
void RageSound_DSound_Software::MixerThread()
void RageSoundDriver_DSound_Software::MixerThread()
{
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL) )
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL) )
@@ -60,24 +60,24 @@ void RageSound_DSound_Software::MixerThread()
m_pPCM->Stop();
}
int64_t RageSound_DSound_Software::GetPosition( const RageSoundBase *pSound ) const
int64_t RageSoundDriver_DSound_Software::GetPosition( const RageSoundBase *pSound ) const
{
return m_pPCM->GetPosition();
}
int RageSound_DSound_Software::MixerThread_start(void *p)
int RageSoundDriver_DSound_Software::MixerThread_start(void *p)
{
((RageSound_DSound_Software *) p)->MixerThread();
((RageSoundDriver_DSound_Software *) p)->MixerThread();
return 0;
}
RageSound_DSound_Software::RageSound_DSound_Software()
RageSoundDriver_DSound_Software::RageSoundDriver_DSound_Software()
{
m_bShutdownMixerThread = false;
m_pPCM = NULL;
}
RString RageSound_DSound_Software::Init()
RString RageSoundDriver_DSound_Software::Init()
{
RString sError = ds.Init();
if( sError != "" )
@@ -111,7 +111,7 @@ RString RageSound_DSound_Software::Init()
return RString();
}
RageSound_DSound_Software::~RageSound_DSound_Software()
RageSoundDriver_DSound_Software::~RageSoundDriver_DSound_Software()
{
/* Signal the mixing thread to quit. */
if( m_MixingThread.IsCreated() )
@@ -127,18 +127,18 @@ RageSound_DSound_Software::~RageSound_DSound_Software()
delete m_pPCM;
}
void RageSound_DSound_Software::SetupDecodingThread()
void RageSoundDriver_DSound_Software::SetupDecodingThread()
{
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL) )
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set decoding thread priority") );
}
float RageSound_DSound_Software::GetPlayLatency() const
float RageSoundDriver_DSound_Software::GetPlayLatency() const
{
return (1.0f / m_iSampleRate) * g_iMaxWriteahead;
}
int RageSound_DSound_Software::GetSampleRate( int rate ) const
int RageSoundDriver_DSound_Software::GetSampleRate( int rate ) const
{
return m_iSampleRate;
}
@@ -5,11 +5,11 @@
#include "RageThreads.h"
#include "RageSoundDriver_Generic_Software.h"
class RageSound_DSound_Software: public RageSound_Generic_Software
class RageSoundDriver_DSound_Software: public RageSound_Generic_Software
{
public:
RageSound_DSound_Software();
virtual ~RageSound_DSound_Software();
RageSoundDriver_DSound_Software();
virtual ~RageSoundDriver_DSound_Software();
RString Init();
int64_t GetPosition( const RageSoundBase *pSound ) const;
@@ -8,7 +8,7 @@ REGISTER_SOUND_DRIVER_CLASS( Null );
const int channels = 2;
void RageSound_Null::Update()
void RageSoundDriver_Null::Update()
{
/* "Play" frames. */
while( m_iLastCursorPos < GetPosition(NULL)+1024*4 )
@@ -21,12 +21,12 @@ void RageSound_Null::Update()
RageSound_Generic_Software::Update();
}
int64_t RageSound_Null::GetPosition( const RageSoundBase *snd ) const
int64_t RageSoundDriver_Null::GetPosition( const RageSoundBase *snd ) const
{
return int64_t( RageTimer::GetTimeSinceStart() * m_iSampleRate );
}
RageSound_Null::RageSound_Null()
RageSoundDriver_Null::RageSoundDriver_Null()
{
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 )
@@ -35,7 +35,7 @@ RageSound_Null::RageSound_Null()
StartDecodeThread();
}
int RageSound_Null::GetSampleRate( int iRate ) const
int RageSoundDriver_Null::GetSampleRate( int iRate ) const
{
return m_iSampleRate;
}
@@ -3,10 +3,10 @@
#include "RageSoundDriver_Generic_Software.h"
class RageSound_Null: public RageSound_Generic_Software
class RageSoundDriver_Null: public RageSound_Generic_Software
{
public:
RageSound_Null();
RageSoundDriver_Null();
int64_t GetPosition( const RageSoundBase *snd ) const;
int GetSampleRate( int iRate ) const;
void Update();
@@ -24,13 +24,13 @@ const int num_chunks = 4;
const int buffersize = num_chunks * (1 << (chunk_order-1)); /* in bytes */
const int buffersize_frames = buffersize/bytes_per_frame; /* in frames */
int RageSound_OSS::MixerThread_start(void *p)
int RageSoundDriver_OSS::MixerThread_start(void *p)
{
((RageSound_OSS *) p)->MixerThread();
((RageSoundDriver_OSS *) p)->MixerThread();
return 0;
}
void RageSound_OSS::MixerThread()
void RageSoundDriver_OSS::MixerThread()
{
/* We want to set a higher priority, but Unix only lets root renice
* < 0, which is silly. Give it a try, anyway. */
@@ -52,12 +52,12 @@ void RageSound_OSS::MixerThread()
}
}
void RageSound_OSS::SetupDecodingThread()
void RageSoundDriver_OSS::SetupDecodingThread()
{
nice( -5 );
}
bool RageSound_OSS::GetData()
bool RageSoundDriver_OSS::GetData()
{
/* Look for a free buffer. */
audio_buf_info ab;
@@ -87,18 +87,18 @@ bool RageSound_OSS::GetData()
/* XXX: There's a race on last_cursor_pos here: new data might be written after the
* ioctl returns, incrementing last_cursor_pos. */
int64_t RageSound_OSS::GetPosition(const RageSoundBase *snd) const
int64_t RageSoundDriver_OSS::GetPosition(const RageSoundBase *snd) const
{
ASSERT( fd != -1 );
int delay;
if(ioctl(fd, SNDCTL_DSP_GETODELAY, &delay) == -1)
RageException::Throw("RageSound_OSS: ioctl(SNDCTL_DSP_GETODELAY): %s", strerror(errno));
RageException::Throw("RageSoundDriver_OSS: ioctl(SNDCTL_DSP_GETODELAY): %s", strerror(errno));
return last_cursor_pos - (delay / bytes_per_frame);
}
RString RageSound_OSS::CheckOSSVersion( int fd )
RString RageSoundDriver_OSS::CheckOSSVersion( int fd )
{
int version = 0;
@@ -127,7 +127,7 @@ RString RageSound_OSS::CheckOSSVersion( int fd )
#ifndef FORCE_OSS
#define ALSA_SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0))
if( version == ALSA_SNDRV_OSS_VERSION && IsADirectory("/rootfs/proc/asound") )
return "RageSound_OSS: ALSA detected. ALSA OSS emulation is buggy; use ALSA natively.";
return "RageSoundDriver_OSS: ALSA detected. ALSA OSS emulation is buggy; use ALSA natively.";
#endif
if( version )
{
@@ -149,18 +149,18 @@ RString RageSound_OSS::CheckOSSVersion( int fd )
return "";
}
RageSound_OSS::RageSound_OSS()
RageSoundDriver_OSS::RageSoundDriver_OSS()
{
fd = -1;
shutdown = false;
last_cursor_pos = 0;
}
RString RageSound_OSS::Init()
RString RageSoundDriver_OSS::Init()
{
fd = open("/dev/dsp", O_WRONLY|O_NONBLOCK);
if( fd == -1 )
return ssprintf( "RageSound_OSS: Couldn't open /dev/dsp: %s", strerror(errno) );
return ssprintf( "RageSoundDriver_OSS: Couldn't open /dev/dsp: %s", strerror(errno) );
RString sError = CheckOSSVersion( fd );
if( sError != "" )
@@ -168,33 +168,33 @@ RString RageSound_OSS::Init()
int i = AFMT_S16_LE;
if(ioctl(fd, SNDCTL_DSP_SETFMT, &i) == -1)
return ssprintf( "RageSound_OSS: ioctl(SNDCTL_DSP_SETFMT, %i): %s", i, strerror(errno) );
return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_SETFMT, %i): %s", i, strerror(errno) );
if(i != AFMT_S16_LE)
return ssprintf( "RageSound_OSS: Wanted format %i, got %i instead", AFMT_S16_LE, i );
return ssprintf( "RageSoundDriver_OSS: Wanted format %i, got %i instead", AFMT_S16_LE, i );
i = channels;
if(ioctl(fd, SNDCTL_DSP_CHANNELS, &i) == -1)
return ssprintf( "RageSound_OSS: ioctl(SNDCTL_DSP_CHANNELS, %i): %s", i, strerror(errno) );
return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_CHANNELS, %i): %s", i, strerror(errno) );
if(i != channels)
return ssprintf( "RageSound_OSS: Wanted %i channels, got %i instead", channels, i );
return ssprintf( "RageSoundDriver_OSS: Wanted %i channels, got %i instead", channels, i );
i = 44100;
if(ioctl(fd, SOUND_PCM_WRITE_RATE, &i) == -1 )
return ssprintf( "RageSound_OSS: ioctl(SOUND_PCM_WRITE_RATE, %i): %s", i, strerror(errno) );
return ssprintf( "RageSoundDriver_OSS: ioctl(SOUND_PCM_WRITE_RATE, %i): %s", i, strerror(errno) );
samplerate = i;
LOG->Trace("RageSound_OSS: sample rate %i", samplerate);
LOG->Trace("RageSoundDriver_OSS: sample rate %i", samplerate);
i = (num_chunks << 16) + chunk_order;
if(ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &i) == -1)
return ssprintf( "RageSound_OSS: ioctl(SNDCTL_DSP_SETFRAGMENT, %i): %s", i, strerror(errno) );
return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_SETFRAGMENT, %i): %s", i, strerror(errno) );
StartDecodeThread();
MixingThread.SetName( "RageSound_OSS" );
MixingThread.SetName( "RageSoundDriver_OSS" );
MixingThread.Create( MixerThread_start, this );
return "";
}
RageSound_OSS::~RageSound_OSS()
RageSoundDriver_OSS::~RageSoundDriver_OSS()
{
if( MixingThread.IsCreated() )
{
@@ -209,7 +209,7 @@ RageSound_OSS::~RageSound_OSS()
close( fd );
}
float RageSound_OSS::GetPlayLatency() const
float RageSoundDriver_OSS::GetPlayLatency() const
{
return 0; // (1.0f / samplerate) * (buffersize_frames - chunksize_frames);
}
@@ -5,7 +5,7 @@
#include "RageThreads.h"
#include "RageTimer.h"
class RageSound_OSS: public RageSound_Generic_Software
class RageSoundDriver_OSS: public RageSound_Generic_Software
{
int fd;
@@ -28,9 +28,9 @@ public:
float GetPlayLatency() const;
void SetupDecodingThread();
RageSound_OSS();
RageSoundDriver_OSS();
RString Init();
~RageSound_OSS();
~RageSoundDriver_OSS();
};
#endif
@@ -1103,7 +1103,7 @@ namespace
}
}
void RageSound_WDMKS::Read( void *pData, int iFrames, int iLastCursorPos, int iCurrentFrame )
void RageSoundDriver_WDMKS::Read( void *pData, int iFrames, int iLastCursorPos, int iCurrentFrame )
{
/* If we need conversion, read into a temporary buffer. Otherwise, read directly
* into the target buffer. */
@@ -1139,7 +1139,7 @@ void RageSound_WDMKS::Read( void *pData, int iFrames, int iLastCursorPos, int iC
memcpy( pData, pBuf, iFrames * m_pStream->m_iDeviceOutputChannels * m_pStream->m_iBytesPerOutputSample );
}
bool RageSound_WDMKS::Fill( int iPacket, RString &sError )
bool RageSoundDriver_WDMKS::Fill( int iPacket, RString &sError )
{
uint64_t iCurrentFrame = GetPosition( NULL );
// if( iCurrentFrame == m_iLastCursorPos )
@@ -1154,7 +1154,7 @@ bool RageSound_WDMKS::Fill( int iPacket, RString &sError )
return m_pStream->SubmitPacket( iPacket, sError );
}
void RageSound_WDMKS::MixerThread()
void RageSoundDriver_WDMKS::MixerThread()
{
/* I don't trust this driver with THREAD_PRIORITY_TIME_CRITICAL just yet. */
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) )
@@ -1223,19 +1223,19 @@ void RageSound_WDMKS::MixerThread()
REGISTER_SOUND_DRIVER_CLASS( WDMKS );
int RageSound_WDMKS::MixerThread_start( void *p )
int RageSoundDriver_WDMKS::MixerThread_start( void *p )
{
((RageSound_WDMKS *) p)->MixerThread();
((RageSoundDriver_WDMKS *) p)->MixerThread();
return 0;
}
void RageSound_WDMKS::SetupDecodingThread()
void RageSoundDriver_WDMKS::SetupDecodingThread()
{
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL) )
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") );
}
int64_t RageSound_WDMKS::GetPosition( const RageSoundBase *pSound ) const
int64_t RageSoundDriver_WDMKS::GetPosition( const RageSoundBase *pSound ) const
{
KSAUDIO_POSITION pos;
@@ -1248,7 +1248,7 @@ int64_t RageSound_WDMKS::GetPosition( const RageSoundBase *pSound ) const
return pos.PlayOffset;
}
RageSound_WDMKS::RageSound_WDMKS()
RageSoundDriver_WDMKS::RageSoundDriver_WDMKS()
{
m_pStream = NULL;
m_pFilter = NULL;
@@ -1257,7 +1257,7 @@ RageSound_WDMKS::RageSound_WDMKS()
m_hSignal = CreateEvent( NULL, FALSE, FALSE, NULL ); /* abort event */
}
RString RageSound_WDMKS::Init()
RString RageSoundDriver_WDMKS::Init()
{
RString sError;
if( !PaWinWdm_Initialize(sError) )
@@ -1327,7 +1327,7 @@ RString RageSound_WDMKS::Init()
return RString();
}
RageSound_WDMKS::~RageSound_WDMKS()
RageSoundDriver_WDMKS::~RageSoundDriver_WDMKS()
{
/* Signal the mixing thread to quit. */
if( MixingThread.IsCreated() )
@@ -1345,12 +1345,12 @@ RageSound_WDMKS::~RageSound_WDMKS()
CloseHandle( m_hSignal );
}
int RageSound_WDMKS::GetSampleRate( int iRate ) const
int RageSoundDriver_WDMKS::GetSampleRate( int iRate ) const
{
return m_pStream->m_iSampleRate;
}
float RageSound_WDMKS::GetPlayLatency() const
float RageSoundDriver_WDMKS::GetPlayLatency() const
{
/* If we have a 1000-byte buffer, and we fill 500 bytes at a time, we
* almost always have between 500 and 1000 bytes filled; on average, 750. */
@@ -8,11 +8,11 @@
struct WinWdmStream;
struct WinWdmFilter;
class RageSound_WDMKS: public RageSound_Generic_Software
class RageSoundDriver_WDMKS: public RageSound_Generic_Software
{
public:
RageSound_WDMKS();
~RageSound_WDMKS();
RageSoundDriver_WDMKS();
~RageSoundDriver_WDMKS();
RString Init();
int64_t GetPosition( const RageSoundBase *pSound ) const;
@@ -37,13 +37,13 @@ static RString wo_ssprintf( MMRESULT err, const char *szFmt, ...)
return s += ssprintf( "(%s)", szBuf );
}
int RageSound_WaveOut::MixerThread_start( void *p )
int RageSoundDriver_WaveOut::MixerThread_start( void *p )
{
((RageSound_WaveOut *) p)->MixerThread();
((RageSoundDriver_WaveOut *) p)->MixerThread();
return 0;
}
void RageSound_WaveOut::MixerThread()
void RageSoundDriver_WaveOut::MixerThread()
{
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL) )
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") );
@@ -59,7 +59,7 @@ void RageSound_WaveOut::MixerThread()
waveOutReset( m_hWaveOut );
}
bool RageSound_WaveOut::GetData()
bool RageSoundDriver_WaveOut::GetData()
{
/* Look for a free buffer. */
int b;
@@ -82,13 +82,13 @@ bool RageSound_WaveOut::GetData()
return true;
}
void RageSound_WaveOut::SetupDecodingThread()
void RageSoundDriver_WaveOut::SetupDecodingThread()
{
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL) )
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") );
}
int64_t RageSound_WaveOut::GetPosition( const RageSoundBase *pSound ) const
int64_t RageSoundDriver_WaveOut::GetPosition( const RageSoundBase *pSound ) const
{
MMTIME tm;
tm.wType = TIME_SAMPLES;
@@ -99,7 +99,7 @@ int64_t RageSound_WaveOut::GetPosition( const RageSoundBase *pSound ) const
return tm.u.sample;
}
RageSound_WaveOut::RageSound_WaveOut()
RageSoundDriver_WaveOut::RageSoundDriver_WaveOut()
{
m_bShutdown = false;
m_iLastCursorPos = 0;
@@ -109,7 +109,7 @@ RageSound_WaveOut::RageSound_WaveOut()
m_hWaveOut = NULL;
}
RString RageSound_WaveOut::Init()
RString RageSoundDriver_WaveOut::Init()
{
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 )
@@ -152,7 +152,7 @@ RString RageSound_WaveOut::Init()
return RString();
}
RageSound_WaveOut::~RageSound_WaveOut()
RageSoundDriver_WaveOut::~RageSoundDriver_WaveOut()
{
/* Signal the mixing thread to quit. */
if( MixingThread.IsCreated() )
@@ -178,7 +178,7 @@ RageSound_WaveOut::~RageSound_WaveOut()
CloseHandle( m_hSoundEvent );
}
float RageSound_WaveOut::GetPlayLatency() const
float RageSoundDriver_WaveOut::GetPlayLatency() const
{
/* If we have a 1000-byte buffer, and we fill 100 bytes at a time, we
* almost always have between 900 and 1000 bytes filled; on average, 950. */
@@ -6,11 +6,11 @@
#include <windows.h>
#include <mmsystem.h>
class RageSound_WaveOut: public RageSound_Generic_Software
class RageSoundDriver_WaveOut: public RageSound_Generic_Software
{
public:
RageSound_WaveOut();
~RageSound_WaveOut();
RageSoundDriver_WaveOut();
~RageSoundDriver_WaveOut();
RString Init();
int64_t GetPosition( const RageSoundBase *pSound ) const;