allow specifying ALSA device to use
This commit is contained in:
@@ -247,6 +247,7 @@ void PrefsManager::Init()
|
|||||||
* specify numbers directly.) This is purely a troubleshooting option
|
* specify numbers directly.) This is purely a troubleshooting option
|
||||||
* and is not honored by all sound drivers. */
|
* and is not honored by all sound drivers. */
|
||||||
m_iSoundWriteAhead = 0;
|
m_iSoundWriteAhead = 0;
|
||||||
|
m_iSoundDevice = "";
|
||||||
m_fSoundVolume = DEFAULT_SOUND_VOLUME;
|
m_fSoundVolume = DEFAULT_SOUND_VOLUME;
|
||||||
m_iSoundResampleQuality = RageSoundReader_Resample::RESAMP_NORMAL;
|
m_iSoundResampleQuality = RageSoundReader_Resample::RESAMP_NORMAL;
|
||||||
|
|
||||||
@@ -441,6 +442,7 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
|
|||||||
ini.GetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
|
ini.GetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
|
||||||
ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers );
|
ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers );
|
||||||
ini.GetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead );
|
ini.GetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead );
|
||||||
|
ini.GetValue( "Options", "SoundDevice", m_iSoundDevice );
|
||||||
ini.GetValue( "Options", "MovieDrivers", m_sMovieDrivers );
|
ini.GetValue( "Options", "MovieDrivers", m_sMovieDrivers );
|
||||||
ini.GetValue( "Options", "EasterEggs", m_bEasterEggs );
|
ini.GetValue( "Options", "EasterEggs", m_bEasterEggs );
|
||||||
ini.GetValue( "Options", "MarvelousTiming", (int&)m_iMarvelousTiming );
|
ini.GetValue( "Options", "MarvelousTiming", (int&)m_iMarvelousTiming );
|
||||||
@@ -770,6 +772,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
|
|||||||
ini.SetValue( "Options", "SignProfileData", m_bSignProfileData );
|
ini.SetValue( "Options", "SignProfileData", m_bSignProfileData );
|
||||||
|
|
||||||
ini.SetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead );
|
ini.SetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead );
|
||||||
|
ini.SetValue( "Options", "SoundDevice", m_iSoundDevice );
|
||||||
|
|
||||||
ini.SetValue( "Editor", "ShowBGChangesPlay", m_bEditorShowBGChangesPlay );
|
ini.SetValue( "Editor", "ShowBGChangesPlay", m_bEditorShowBGChangesPlay );
|
||||||
|
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ public:
|
|||||||
bool m_bSmoothLines;
|
bool m_bSmoothLines;
|
||||||
CString m_sSoundDrivers;
|
CString m_sSoundDrivers;
|
||||||
int m_iSoundWriteAhead;
|
int m_iSoundWriteAhead;
|
||||||
|
CString m_iSoundDevice;
|
||||||
float m_fSoundVolume;
|
float m_fSoundVolume;
|
||||||
int m_iSoundResampleQuality;
|
int m_iSoundResampleQuality;
|
||||||
CString m_sMovieDrivers;
|
CString m_sMovieDrivers;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "ALSA9Helpers.h"
|
#include "ALSA9Helpers.h"
|
||||||
#include "SDL_utils.h"
|
#include "SDL_utils.h"
|
||||||
#include "ALSA9Dynamic.h"
|
#include "ALSA9Dynamic.h"
|
||||||
|
#include "PrefsManager.h"
|
||||||
|
|
||||||
/* int err; must be defined before using this macro */
|
/* int err; must be defined before using this macro */
|
||||||
#define ALSA_CHECK(x) \
|
#define ALSA_CHECK(x) \
|
||||||
@@ -153,6 +154,13 @@ void Alsa9Buf::InitializeErrorHandler()
|
|||||||
dsnd_lib_error_set_handler( ErrorHandler );
|
dsnd_lib_error_set_handler( ErrorHandler );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CString DeviceName()
|
||||||
|
{
|
||||||
|
if( !PREFSMAN->m_iSoundDevice.empty() )
|
||||||
|
return PREFSMAN->m_iSoundDevice;
|
||||||
|
return "hw:0";
|
||||||
|
}
|
||||||
|
|
||||||
void Alsa9Buf::GetSoundCardDebugInfo()
|
void Alsa9Buf::GetSoundCardDebugInfo()
|
||||||
{
|
{
|
||||||
static bool done = false;
|
static bool done = false;
|
||||||
@@ -219,9 +227,10 @@ void Alsa9Buf::GetSoundCardDebugInfo()
|
|||||||
|
|
||||||
if( card == 0 )
|
if( card == 0 )
|
||||||
LOG->Info( "No ALSA sound cards were found.");
|
LOG->Info( "No ALSA sound cards were found.");
|
||||||
}
|
|
||||||
|
|
||||||
static CString DeviceName = "hw:0";
|
if( !PREFSMAN->m_iSoundDevice.empty() )
|
||||||
|
LOG->Info( "ALSA device overridden to \"%s\"", PREFSMAN->m_iSoundDevice.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
Alsa9Buf::Alsa9Buf( hw hardware, int channels_ )
|
Alsa9Buf::Alsa9Buf( hw hardware, int channels_ )
|
||||||
{
|
{
|
||||||
@@ -240,9 +249,9 @@ Alsa9Buf::Alsa9Buf( hw hardware, int channels_ )
|
|||||||
/* Open the device. */
|
/* Open the device. */
|
||||||
int err;
|
int err;
|
||||||
// err = dsnd_pcm_open( &pcm, "dmix", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK );
|
// 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)
|
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() )
|
if( !SetHWParams() )
|
||||||
{
|
{
|
||||||
@@ -433,7 +442,7 @@ CString Alsa9Buf::GetHardwareID( CString name )
|
|||||||
InitializeErrorHandler();
|
InitializeErrorHandler();
|
||||||
|
|
||||||
if( name.empty() )
|
if( name.empty() )
|
||||||
name = DeviceName;
|
name = DeviceName();
|
||||||
|
|
||||||
snd_ctl_t *handle;
|
snd_ctl_t *handle;
|
||||||
int err;
|
int err;
|
||||||
|
|||||||
Reference in New Issue
Block a user