Audio: Update default sample rate to 48kHz to mitigate sync issues

This commit is contained in:
Patrik Nilsson
2025-06-01 08:37:19 -07:00
committed by teejusb
parent 2517959050
commit af127ca23b
12 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -147,7 +147,7 @@ public:
int SetPosition( int iFrame ) { return 1; } int SetPosition( int iFrame ) { return 1; }
int Read( float *pBuf, int iFrames ) { return RageSoundReader::END_OF_FILE; } int Read( float *pBuf, int iFrames ) { return RageSoundReader::END_OF_FILE; }
RageSoundReader *Copy() const { return new RageSoundReader_Silence; } RageSoundReader *Copy() const { return new RageSoundReader_Silence; }
int GetSampleRate() const { return 44100; } int GetSampleRate() const { return 48000; }
unsigned GetNumChannels() const { return 1; } unsigned GetNumChannels() const { return 1; }
int GetNextSourceFrame() const { return 0; } int GetNextSourceFrame() const { return 0; }
float GetStreamToSourceRatio() const { return 1.0f; } float GetStreamToSourceRatio() const { return 1.0f; }
+1 -1
View File
@@ -133,7 +133,7 @@ float RageSoundManager::GetPlayLatency() const
int RageSoundManager::GetDriverSampleRate() const int RageSoundManager::GetDriverSampleRate() const
{ {
if( m_pDriver == nullptr ) if( m_pDriver == nullptr )
return 44100; return 48000;
return m_pDriver->GetSampleRate(); return m_pDriver->GetSampleRate();
} }
+1 -1
View File
@@ -23,7 +23,7 @@
*/ */
RageSoundReader_Chain::RageSoundReader_Chain() RageSoundReader_Chain::RageSoundReader_Chain()
{ {
m_iPreferredSampleRate = 44100; m_iPreferredSampleRate = 48000;
m_iActualSampleRate = -1; m_iActualSampleRate = -1;
m_iChannels = 0; m_iChannels = 0;
m_iCurrentFrame = 0; m_iCurrentFrame = 0;
+2 -2
View File
@@ -212,7 +212,7 @@ void Alsa9Buf::GetSoundCardDebugInfo()
Alsa9Buf::Alsa9Buf() Alsa9Buf::Alsa9Buf()
{ {
samplerate = 44100; samplerate = 48000;
samplebits = 16; samplebits = 16;
last_cursor_pos = 0; last_cursor_pos = 0;
preferred_writeahead = 8192; preferred_writeahead = 8192;
@@ -229,7 +229,7 @@ RString Alsa9Buf::Init( int channels_,
preferred_writeahead = iWriteahead; preferred_writeahead = iWriteahead;
preferred_chunksize = iChunkSize; preferred_chunksize = iChunkSize;
if( iSampleRate == 0 ) if( iSampleRate == 0 )
samplerate = 44100; samplerate = 48000;
else else
samplerate = iSampleRate; samplerate = iSampleRate;
+4 -4
View File
@@ -62,7 +62,7 @@ void DSound::SetPrimaryBufferMode()
waveformat.wFormatTag = WAVE_FORMAT_PCM; waveformat.wFormatTag = WAVE_FORMAT_PCM;
waveformat.wBitsPerSample = 16; waveformat.wBitsPerSample = 16;
waveformat.nChannels = 2; waveformat.nChannels = 2;
waveformat.nSamplesPerSec = 44100; waveformat.nSamplesPerSec = 48000;
waveformat.nBlockAlign = 4; waveformat.nBlockAlign = 4;
waveformat.nAvgBytesPerSec = waveformat.nSamplesPerSec * waveformat.nBlockAlign; waveformat.nAvgBytesPerSec = waveformat.nSamplesPerSec * waveformat.nBlockAlign;
@@ -75,8 +75,8 @@ void DSound::SetPrimaryBufferMode()
hr = pBuffer->GetFormat( &waveformat, sizeof(waveformat), &got ); hr = pBuffer->GetFormat( &waveformat, sizeof(waveformat), &got );
if( FAILED(hr) ) if( FAILED(hr) )
LOG->Warn( hr_ssprintf(hr, "GetFormat on primary buffer") ); LOG->Warn( hr_ssprintf(hr, "GetFormat on primary buffer") );
else if( waveformat.nSamplesPerSec != 44100 ) else if( waveformat.nSamplesPerSec != 48000 )
LOG->Warn( "Primary buffer set to %i instead of 44100", waveformat.nSamplesPerSec ); LOG->Warn( "Primary buffer set to %i instead of 48000", waveformat.nSamplesPerSec );
/* /*
* MS docs: * MS docs:
@@ -197,7 +197,7 @@ RString DSoundBuf::Init( DSound &ds, DSoundBuf::hw hardware,
bool bNeedCtrlFrequency = false; bool bNeedCtrlFrequency = false;
if( m_iSampleRate == DYNAMIC_SAMPLERATE ) if( m_iSampleRate == DYNAMIC_SAMPLERATE )
{ {
m_iSampleRate = 44100; m_iSampleRate = 48000;
bNeedCtrlFrequency = true; bNeedCtrlFrequency = true;
} }
+1 -1
View File
@@ -66,7 +66,7 @@ public:
* hearing it. (This isn't necessarily the same as the buffer latency.) */ * hearing it. (This isn't necessarily the same as the buffer latency.) */
virtual float GetPlayLatency() const { return 0.0f; } virtual float GetPlayLatency() const { return 0.0f; }
virtual int GetSampleRate() const { return 44100; } virtual int GetSampleRate() const { return 48000; }
protected: protected:
/* Start the decoding. This should be called once the hardware is set up and /* Start the decoding. This should be called once the hardware is set up and
+1 -1
View File
@@ -151,7 +151,7 @@ RString RageSoundDriver_AU::Init()
streamFormat.mBitsPerChannel = kBitsPerChannel; streamFormat.mBitsPerChannel = kBitsPerChannel;
if( streamFormat.mSampleRate <= 0.0 ) if( streamFormat.mSampleRate <= 0.0 )
streamFormat.mSampleRate = 44100.0; streamFormat.mSampleRate = 48000.0;
m_iSampleRate = int( streamFormat.mSampleRate ); m_iSampleRate = int( streamFormat.mSampleRate );
m_TimeScale = streamFormat.mSampleRate / AudioGetHostClockFrequency(); m_TimeScale = streamFormat.mSampleRate / AudioGetHostClockFrequency();
@@ -97,7 +97,7 @@ RString RageSoundDriver_DSound_Software::Init()
m_pPCM = new DSoundBuf; m_pPCM = new DSoundBuf;
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate; m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 ) if( m_iSampleRate == 0 )
m_iSampleRate = 44100; m_iSampleRate = 48000;
sError = m_pPCM->Init( ds, DSoundBuf::HW_DONT_CARE, channels, m_iSampleRate, 16, g_iMaxWriteahead ); sError = m_pPCM->Init( ds, DSoundBuf::HW_DONT_CARE, channels, m_iSampleRate, 16, g_iMaxWriteahead );
if( sError != "" ) if( sError != "" )
return sError; return sError;
+1 -1
View File
@@ -32,7 +32,7 @@ RageSoundDriver_Null::RageSoundDriver_Null()
{ {
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate; m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 ) if( m_iSampleRate == 0 )
m_iSampleRate = 44100; m_iSampleRate = 48000;
m_iLastCursorPos = GetPosition(); m_iLastCursorPos = GetPosition();
StartDecodeThread(); StartDecodeThread();
} }
+1 -1
View File
@@ -193,7 +193,7 @@ RString RageSoundDriver_OSS::Init()
if(i != channels) if(i != channels)
return ssprintf( "RageSoundDriver_OSS: Wanted %i channels, got %i instead", channels, i ); return ssprintf( "RageSoundDriver_OSS: Wanted %i channels, got %i instead", channels, i );
i = 44100; i = 48000;
if(ioctl(fd, SNDCTL_DSP_SPEED, &i) == -1 ) if(ioctl(fd, SNDCTL_DSP_SPEED, &i) == -1 )
return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_SPEED, %i): %s", i, strerror(errno) ); return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_SPEED, %i): %s", i, strerror(errno) );
samplerate = i; samplerate = i;
@@ -29,7 +29,7 @@ m_PulseMainLoop(nullptr), m_PulseCtx(nullptr), m_PulseStream(nullptr)
{ {
m_ss.rate = PREFSMAN->m_iSoundPreferredSampleRate; m_ss.rate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_ss.rate == 0 ) if( m_ss.rate == 0 )
m_ss.rate = 44100; m_ss.rate = 48000;
} }
RageSoundDriver_PulseAudio::~RageSoundDriver_PulseAudio() RageSoundDriver_PulseAudio::~RageSoundDriver_PulseAudio()
@@ -133,7 +133,7 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
ss.rate = PREFSMAN->m_iSoundPreferredSampleRate; ss.rate = PREFSMAN->m_iSoundPreferredSampleRate;
if(ss.rate == 0) if(ss.rate == 0)
{ {
ss.rate = 44100; ss.rate = 48000;
} }
/* init channel map */ /* init channel map */
+1 -1
View File
@@ -125,7 +125,7 @@ RString RageSoundDriver_WaveOut::Init()
b_InitSuccess = false; b_InitSuccess = false;
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate; m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 ) if( m_iSampleRate == 0 )
m_iSampleRate = 44100; m_iSampleRate = 48000;
WAVEFORMATEX fmt; WAVEFORMATEX fmt;
fmt.wFormatTag = WAVE_FORMAT_PCM; fmt.wFormatTag = WAVE_FORMAT_PCM;