This commit is contained in:
Glenn Maynard
2005-10-24 02:42:56 +00:00
parent 5507c323da
commit 4bd59b5a7b
2 changed files with 20 additions and 23 deletions
@@ -22,9 +22,9 @@ static const int bytes_per_frame = sizeof(int16_t) * samples_per_frame;
/* Linux 2.6 has a fine-grained scheduler. We can almost always use a smaller buffer /* Linux 2.6 has a fine-grained scheduler. We can almost always use a smaller buffer
* size than in 2.4. XXX: Some cards can handle smaller buffer sizes than others. */ * size than in 2.4. XXX: Some cards can handle smaller buffer sizes than others. */
static const unsigned max_writeahead_linux_26 = 512; static const unsigned g_iMaxWriteahead_linux_26 = 512;
static const unsigned safe_writeahead = 1024*4; static const unsigned safe_writeahead = 1024*4;
static unsigned max_writeahead; static unsigned g_iMaxWriteahead;
const int num_chunks = 8; const int num_chunks = 8;
int RageSound_ALSA9_Software::MixerThread_start( void *p ) int RageSound_ALSA9_Software::MixerThread_start( void *p )
@@ -55,7 +55,7 @@ bool RageSound_ALSA9_Software::GetData()
static int16_t *buf = NULL; static int16_t *buf = NULL;
if (!buf) if (!buf)
buf = new int16_t[max_writeahead*samples_per_frame]; buf = new int16_t[g_iMaxWriteahead*samples_per_frame];
const int64_t play_pos = m_pPCM->GetPlayPos(); const int64_t play_pos = m_pPCM->GetPlayPos();
const int64_t cur_play_pos = m_pPCM->GetPosition(); const int64_t cur_play_pos = m_pPCM->GetPosition();
@@ -67,7 +67,7 @@ bool RageSound_ALSA9_Software::GetData()
} }
int64_t RageSound_ALSA9_Software::GetPosition(const RageSoundBase *snd) const int64_t RageSound_ALSA9_Software::GetPosition( const RageSoundBase *pSound ) const
{ {
return m_pPCM->GetPosition(); return m_pPCM->GetPosition();
} }
@@ -90,16 +90,16 @@ CString RageSound_ALSA9_Software::Init()
if( sError != "" ) if( sError != "" )
return ssprintf( "Driver unusable: %s", sError.c_str() ); return ssprintf( "Driver unusable: %s", sError.c_str() );
max_writeahead = safe_writeahead; g_iMaxWriteahead = safe_writeahead;
CString sys; CString sys;
int vers; int vers;
GetKernel( sys, vers ); GetKernel( sys, vers );
LOG->Trace( "OS: %s ver %06i", sys.c_str(), vers ); LOG->Trace( "OS: %s ver %06i", sys.c_str(), vers );
if( sys == "Linux" && vers >= 20600 ) if( sys == "Linux" && vers >= 20600 )
max_writeahead = max_writeahead_linux_26; g_iMaxWriteahead = g_iMaxWriteahead_linux_26;
if( PREFSMAN->m_iSoundWriteAhead ) if( PREFSMAN->m_iSoundWriteAhead )
max_writeahead = PREFSMAN->m_iSoundWriteAhead; g_iMaxWriteahead = PREFSMAN->m_iSoundWriteAhead;
m_pPCM = new Alsa9Buf(); m_pPCM = new Alsa9Buf();
sError = m_pPCM->Init( Alsa9Buf::HW_DONT_CARE, channels ); sError = m_pPCM->Init( Alsa9Buf::HW_DONT_CARE, channels );
@@ -110,8 +110,8 @@ CString RageSound_ALSA9_Software::Init()
m_pPCM->SetSampleRate( samplerate ); m_pPCM->SetSampleRate( samplerate );
LOG->Info( "ALSA: Software mixing at %ihz", samplerate ); LOG->Info( "ALSA: Software mixing at %ihz", samplerate );
m_pPCM->SetWriteahead( max_writeahead ); m_pPCM->SetWriteahead( g_iMaxWriteahead );
m_pPCM->SetChunksize( max_writeahead / num_chunks ); m_pPCM->SetChunksize( g_iMaxWriteahead / num_chunks );
m_pPCM->LogParams(); m_pPCM->LogParams();
StartDecodeThread(); StartDecodeThread();
@@ -140,10 +140,10 @@ RageSound_ALSA9_Software::~RageSound_ALSA9_Software()
float RageSound_ALSA9_Software::GetPlayLatency() const float RageSound_ALSA9_Software::GetPlayLatency() const
{ {
return float(max_writeahead)/samplerate; return float(g_iMaxWriteahead)/samplerate;
} }
int RageSound_ALSA9_Software::GetSampleRate( int rate ) const int RageSound_ALSA9_Software::GetSampleRate( int iRate ) const
{ {
return samplerate; return samplerate;
} }
@@ -11,27 +11,24 @@ class RageSound_ALSA9_Software: public RageSound_Generic_Software
{ {
public: public:
/* virtuals: */ /* virtuals: */
int64_t GetPosition( const RageSoundBase *snd ) const; int64_t GetPosition( const RageSoundBase *pSound ) const;
float GetPlayLatency() const; float GetPlayLatency() const;
int GetSampleRate( int rate ) const; int GetSampleRate( int iRate ) const;
void SetupDecodingThread(); void SetupDecodingThread();
RageSound_ALSA9_Software(); RageSound_ALSA9_Software();
CString Init();
~RageSound_ALSA9_Software(); ~RageSound_ALSA9_Software();
CString Init();
private: private:
bool shutdown;
Alsa9Buf *pcm;
static int MixerThread_start( void *p ); static int MixerThread_start( void *p );
void MixerThread(); void MixerThread();
RageThread MixingThread;
bool GetData(); bool GetData();
bool m_bShutdown;
Alsa9Buf *m_pPCM;
RageThread m_MixingThread;
}; };
#define USE_RAGE_SOUND_ALSA9_SOFTWARE #define USE_RAGE_SOUND_ALSA9_SOFTWARE