This commit is contained in:
Glenn Maynard
2005-10-24 02:41:58 +00:00
parent bcf1d288f9
commit 5507c323da
2 changed files with 34 additions and 34 deletions
@@ -37,19 +37,19 @@ void RageSound_ALSA9_Software::MixerThread()
{ {
setpriority( PRIO_PROCESS, 0, -15 ); setpriority( PRIO_PROCESS, 0, -15 );
while(!shutdown) while( !m_bShutdown )
{ {
while( !shutdown && GetData() ) while( !m_bShutdown && GetData() )
; ;
pcm->WaitUntilFramesCanBeFilled( 100 ); m_pPCM->WaitUntilFramesCanBeFilled( 100 );
} }
} }
/* Returns the number of frames processed */ /* Returns the number of frames processed */
bool RageSound_ALSA9_Software::GetData() bool RageSound_ALSA9_Software::GetData()
{ {
const int frames_to_fill = pcm->GetNumFramesToFill(); const int frames_to_fill = m_pPCM->GetNumFramesToFill();
if( frames_to_fill <= 0 ) if( frames_to_fill <= 0 )
return false; return false;
@@ -57,11 +57,11 @@ bool RageSound_ALSA9_Software::GetData()
if (!buf) if (!buf)
buf = new int16_t[max_writeahead*samples_per_frame]; buf = new int16_t[max_writeahead*samples_per_frame];
const int64_t play_pos = pcm->GetPlayPos(); const int64_t play_pos = m_pPCM->GetPlayPos();
const int64_t cur_play_pos = pcm->GetPosition(); const int64_t cur_play_pos = m_pPCM->GetPosition();
this->Mix( buf, frames_to_fill, play_pos, cur_play_pos ); this->Mix( buf, frames_to_fill, play_pos, cur_play_pos );
pcm->Write( buf, frames_to_fill ); m_pPCM->Write( buf, frames_to_fill );
return true; return true;
} }
@@ -69,7 +69,7 @@ bool RageSound_ALSA9_Software::GetData()
int64_t RageSound_ALSA9_Software::GetPosition(const RageSoundBase *snd) const int64_t RageSound_ALSA9_Software::GetPosition(const RageSoundBase *snd) const
{ {
return pcm->GetPosition(); return m_pPCM->GetPosition();
} }
void RageSound_ALSA9_Software::SetupDecodingThread() void RageSound_ALSA9_Software::SetupDecodingThread()
@@ -80,8 +80,8 @@ void RageSound_ALSA9_Software::SetupDecodingThread()
RageSound_ALSA9_Software::RageSound_ALSA9_Software() RageSound_ALSA9_Software::RageSound_ALSA9_Software()
{ {
pcm = NULL; m_pPCM = NULL;
shutdown = false; m_bShutdown = false;
} }
CString RageSound_ALSA9_Software::Init() CString RageSound_ALSA9_Software::Init()
@@ -101,39 +101,39 @@ CString RageSound_ALSA9_Software::Init()
if( PREFSMAN->m_iSoundWriteAhead ) if( PREFSMAN->m_iSoundWriteAhead )
max_writeahead = PREFSMAN->m_iSoundWriteAhead; max_writeahead = PREFSMAN->m_iSoundWriteAhead;
pcm = new Alsa9Buf(); m_pPCM = new Alsa9Buf();
sError = pcm->Init( Alsa9Buf::HW_DONT_CARE, channels ); sError = m_pPCM->Init( Alsa9Buf::HW_DONT_CARE, channels );
if( sError != "" ) if( sError != "" )
return sError; return sError;
samplerate = pcm->FindSampleRate( samplerate ); samplerate = m_pPCM->FindSampleRate( samplerate );
pcm->SetSampleRate( samplerate ); m_pPCM->SetSampleRate( samplerate );
LOG->Info( "ALSA: Software mixing at %ihz", samplerate ); LOG->Info( "ALSA: Software mixing at %ihz", samplerate );
pcm->SetWriteahead( max_writeahead ); m_pPCM->SetWriteahead( max_writeahead );
pcm->SetChunksize( max_writeahead / num_chunks ); m_pPCM->SetChunksize( max_writeahead / num_chunks );
pcm->LogParams(); m_pPCM->LogParams();
StartDecodeThread(); StartDecodeThread();
MixingThread.SetName( "RageSound_ALSA9_Software" ); m_MixingThread.SetName( "RageSound_ALSA9_Software" );
MixingThread.Create( MixerThread_start, this ); m_MixingThread.Create( MixerThread_start, this );
return ""; return "";
} }
RageSound_ALSA9_Software::~RageSound_ALSA9_Software() RageSound_ALSA9_Software::~RageSound_ALSA9_Software()
{ {
if( MixingThread.IsCreated() ) if( m_MixingThread.IsCreated() )
{ {
/* Signal the mixing thread to quit. */ /* Signal the mixing thread to quit. */
shutdown = true; m_bShutdown = true;
LOG->Trace("Shutting down mixer thread ..."); LOG->Trace("Shutting down mixer thread ...");
MixingThread.Wait(); m_MixingThread.Wait();
LOG->Trace("Mixer thread shut down."); LOG->Trace("Mixer thread shut down.");
} }
delete pcm; delete m_pPCM;
UnloadALSA(); UnloadALSA();
} }
@@ -9,17 +9,6 @@
class RageSound_ALSA9_Software: public RageSound_Generic_Software class RageSound_ALSA9_Software: public RageSound_Generic_Software
{ {
private:
bool shutdown;
Alsa9Buf *pcm;
static int MixerThread_start(void *p);
void MixerThread();
RageThread MixingThread;
bool GetData();
public: public:
/* virtuals: */ /* virtuals: */
int64_t GetPosition( const RageSoundBase *snd ) const; int64_t GetPosition( const RageSoundBase *snd ) const;
@@ -32,6 +21,17 @@ public:
RageSound_ALSA9_Software(); RageSound_ALSA9_Software();
CString Init(); CString Init();
~RageSound_ALSA9_Software(); ~RageSound_ALSA9_Software();
private:
bool shutdown;
Alsa9Buf *pcm;
static int MixerThread_start(void *p);
void MixerThread();
RageThread MixingThread;
bool GetData();
}; };
#define USE_RAGE_SOUND_ALSA9_SOFTWARE #define USE_RAGE_SOUND_ALSA9_SOFTWARE