PREFSMAN->m_iSoundPreferredSampleRate == 0 means "do what's right for the hardware". We want a 44.1khz default for most systems, but KS should default to 48khz.

This commit is contained in:
Glenn Maynard
2006-12-06 06:26:24 +00:00
parent 650ece9cec
commit 10fa6ceb2e
7 changed files with 19 additions and 3 deletions
@@ -15,6 +15,9 @@
* samplerate to use instead. */
unsigned Alsa9Buf::FindSampleRate( unsigned rate )
{
if( rate == 0 )
rate = 44100;
snd_pcm_hw_params_t *testhw;
dsnd_pcm_hw_params_alloca( &testhw );
dsnd_pcm_hw_params_any( pcm, testhw );
@@ -88,6 +88,8 @@ RString RageSound_AU::Init()
AudioStreamBasicDescription streamFormat;
streamFormat.mSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( streamFormat.mSampleRate == 0 )
streamFormat.mSampleRate = 44100;
streamFormat.mFormatID = kAudioFormatLinearPCM;
streamFormat.mFormatFlags = kFormatFlags;
streamFormat.mBytesPerPacket = kBytesPerPacket;
@@ -160,6 +160,8 @@ RString RageSound_CA::Init()
UInt32 iFirstChannel = min( channels[0], channels[1] );
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 )
m_iSampleRate = 44100;
Float64 nominalSampleRate = m_iSampleRate;
Float64 actualSampleRate;
@@ -95,6 +95,8 @@ RString RageSound_DSound_Software::Init()
/* Create a DirectSound stream, but don't force it into hardware. */
m_pPCM = new DSoundBuf;
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 )
m_iSampleRate = 44100;
sError = m_pPCM->Init( ds, DSoundBuf::HW_DONT_CARE, channels, m_iSampleRate, 16, g_iMaxWriteahead );
if( sError != "" )
return sError;
@@ -29,6 +29,8 @@ int64_t RageSound_Null::GetPosition( const RageSoundBase *snd ) const
RageSound_Null::RageSound_Null()
{
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 )
m_iSampleRate = 44100;
m_iLastCursorPos = GetPosition( NULL );
StartDecodeThread();
}
@@ -111,11 +111,14 @@ RageSound_WaveOut::RageSound_WaveOut()
RString RageSound_WaveOut::Init()
{
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 )
m_iSampleRate = 44100;
WAVEFORMATEX fmt;
fmt.wFormatTag = WAVE_FORMAT_PCM;
fmt.nChannels = channels;
fmt.cbSize = 0;
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
fmt.nSamplesPerSec = m_iSampleRate;
fmt.wBitsPerSample = 16;
fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8;
@@ -710,7 +710,8 @@ WinWdmPin *WinWdmFilter::InstantiateRenderPin(
}
}
aSampleRates.push_back( iPreferredSampleRate );
if( iPreferredSampleRate != 0 )
aSampleRates.push_back( iPreferredSampleRate );
aSampleRates.push_back( 48000 );
aSampleRates.push_back( 44100 );
@@ -720,7 +721,8 @@ WinWdmPin *WinWdmFilter::InstantiateRenderPin(
MoveToBeginning( aSampleRates, 44100 );
MoveToBeginning( aSampleRates, 48000 );
MoveToBeginning( aSampleRates, iPreferredSampleRate );
if( iPreferredSampleRate != 0 )
MoveToBeginning( aSampleRates, iPreferredSampleRate );
}
/* Try WAVE_FORMAT_EXTENSIBLE, then WAVE_FORMAT_PCM. */