allow specifying ALSA device to use

This commit is contained in:
Glenn Maynard
2004-07-17 21:22:36 +00:00
parent c81e737d85
commit 8a3fb77328
3 changed files with 18 additions and 5 deletions
+3
View File
@@ -247,6 +247,7 @@ void PrefsManager::Init()
* specify numbers directly.) This is purely a troubleshooting option
* and is not honored by all sound drivers. */
m_iSoundWriteAhead = 0;
m_iSoundDevice = "";
m_fSoundVolume = DEFAULT_SOUND_VOLUME;
m_iSoundResampleQuality = RageSoundReader_Resample::RESAMP_NORMAL;
@@ -441,6 +442,7 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
ini.GetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers );
ini.GetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead );
ini.GetValue( "Options", "SoundDevice", m_iSoundDevice );
ini.GetValue( "Options", "MovieDrivers", m_sMovieDrivers );
ini.GetValue( "Options", "EasterEggs", m_bEasterEggs );
ini.GetValue( "Options", "MarvelousTiming", (int&)m_iMarvelousTiming );
@@ -770,6 +772,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
ini.SetValue( "Options", "SignProfileData", m_bSignProfileData );
ini.SetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead );
ini.SetValue( "Options", "SoundDevice", m_iSoundDevice );
ini.SetValue( "Editor", "ShowBGChangesPlay", m_bEditorShowBGChangesPlay );
+1
View File
@@ -245,6 +245,7 @@ public:
bool m_bSmoothLines;
CString m_sSoundDrivers;
int m_iSoundWriteAhead;
CString m_iSoundDevice;
float m_fSoundVolume;
int m_iSoundResampleQuality;
CString m_sMovieDrivers;
+14 -5
View File
@@ -4,6 +4,7 @@
#include "ALSA9Helpers.h"
#include "SDL_utils.h"
#include "ALSA9Dynamic.h"
#include "PrefsManager.h"
/* int err; must be defined before using this macro */
#define ALSA_CHECK(x) \
@@ -153,6 +154,13 @@ void Alsa9Buf::InitializeErrorHandler()
dsnd_lib_error_set_handler( ErrorHandler );
}
static CString DeviceName()
{
if( !PREFSMAN->m_iSoundDevice.empty() )
return PREFSMAN->m_iSoundDevice;
return "hw:0";
}
void Alsa9Buf::GetSoundCardDebugInfo()
{
static bool done = false;
@@ -219,10 +227,11 @@ void Alsa9Buf::GetSoundCardDebugInfo()
if( card == 0 )
LOG->Info( "No ALSA sound cards were found.");
if( !PREFSMAN->m_iSoundDevice.empty() )
LOG->Info( "ALSA device overridden to \"%s\"", PREFSMAN->m_iSoundDevice.c_str() );
}
static CString DeviceName = "hw:0";
Alsa9Buf::Alsa9Buf( hw hardware, int channels_ )
{
GetSoundCardDebugInfo();
@@ -240,9 +249,9 @@ Alsa9Buf::Alsa9Buf( hw hardware, int channels_ )
/* Open the device. */
int err;
// err = dsnd_pcm_open( &pcm, "dmix", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK );
err = dsnd_pcm_open( &pcm, DeviceName, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK );
err = dsnd_pcm_open( &pcm, DeviceName(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK );
if (err < 0)
RageException::ThrowNonfatal("dsnd_pcm_open: %s", dsnd_strerror(err));
RageException::ThrowNonfatal("dsnd_pcm_open(%s): %s", DeviceName().c_str(), dsnd_strerror(err));
if( !SetHWParams() )
{
@@ -433,7 +442,7 @@ CString Alsa9Buf::GetHardwareID( CString name )
InitializeErrorHandler();
if( name.empty() )
name = DeviceName;
name = DeviceName();
snd_ctl_t *handle;
int err;