試験運用中なLinux備忘録・旧記事

はてなダイアリーで公開していた2007年5月-2015年3月の記事を保存しています。

GNU/Linux上のStepManiaにおけるサウンド出力と追加データの配置について

サウンド出力について

StepManiaSDLを使用しているが、SDLサウンド出力の仕組みは使用せずに独自にOSごとのサウンドシステム向けのコードを用意している。GNU/Linux向けにはALSAのhwプラグイン*1OSS(/dev/dsp)のみが用意されている。

サウンドデーモンが使えない?

つまり、PulseAudioやJACK Audio Connection Kitといったサウンドデーモンが動作しているときには音を出すことができず、初期化失敗により起動もできないことがある。PulseAudioのように、どのアプリケーションも音を出していない状態のときにデバイスを解放してくれるものの場合はそのときに起動すればよいが、解放されない場合は一時的にサウンドデーモンを止めてからStepManiaを起動して、終了後にサウンドデーモンを起動し直すという作業が必要な場合もある。
ALSAサウンドシステムにおいては「ALSA PCMデバイスとしてJACK Audio Connection Kitを使用」や「Wine上の音声をPulseAudioへ渡す」のようにサウンドデーモンへ音声を出力するためのプラグインを利用することによりサウンドデーモンを利用する方法もあり、本家版ではData/StepMania.iniMandriva Linuxのパッケージでは${HOME}/.StepMania/StepMania.iniの「SoundDevice」の値により任意のALSA PCMデバイス名を出力先に指定することができるのを利用してプラグイン経由でサウンドデーモンを使用できるかを試したが、残念ながらJACKもPulseAudioも失敗した。JACKのほうは音が出ることは出るのだが、動作は非常に不安定で、突然音が切れたりもする。また、JACKのポートを大量に作成してしまうのも厄介。PulseAudioに出力するプラグインでは下のようなメッセージを出力した。

$ stepmania    
StepMania 3.9
Log starting xxxx-xx-xx xx:xx:xx
Loading window: gtk
OS: Linux ver 020627
Crash backtrace component: x86 custom backtrace
Crash lookup component: dladdr
Crash demangle component: cxa_demangle
Runtime library: glibc 2.8
Threads library: NPTL 2.8
TLS is available
ALSA: Advanced Linux Sound Architecture Driver Version 1.0.18rc3.
ALSA Driver: 0: HDA ULI M5461 [M5461], device 0: ALC883 Analog [ALC883 Analog], 0/1 subdevices avail
ALSA device overridden to "[PulseAudioを使用するためのPCMデバイス名]"
ALSA: dsnd_pcm_hw_params_set_access: Invalid argument
(大量にこのメッセージが繰り返される)
ALSA: dsnd_pcm_hw_params_set_access: Invalid argument
ALSA: Got 32 hardware buffers
Sound driver: ALSA
ptrace failed: Operation not permitted
ptrace failed: Operation not permitted

StepMania has crashed.  Debug information has been output to

    /tmp/crashinfo.txt

Please report a bug at:

    http://sourceforge.net/tracker/?func=add&group_id=37892&atid=421366

$ cat /tmp/crashinfo.txt
StepMania 3.9 crash report
--------------------------------------

Crash reason: pcm && params
Crashed thread: Main thread

Checkpoints:
Thread: Main thread
        BannerCache.cpp:282 Courses/Samples/Tortoise and the Hare.png
        BannerCache.cpp:70 BannerCache::LoadBanner: Cache/Banners/585729452
        BannerCache.cpp:282 Courses/Samples/Trickyrandom.png
        BannerCache.cpp:70 BannerCache::LoadBanner: Cache/Banners/1654699250
        pcm_params.c:2259 Assertion failure: snd_pcm_hw_refine: pcm && params
Thread: RageSound_ALSA9
Thread: MusicThread

Thread: 
000000000071e6d4: ForceCrashHandler(char const*) 
(大量にこのメッセージが繰り返される)
000000000071e6d4: ForceCrashHandler(char const*) 

Static log:
StepMania 3.9
Log starting xxxx-xx-xx xx:xx:xx
Loading window: gtk
OS: Linux ver 020627
Crash backtrace component: x86 custom backtrace
Crash lookup component: dladdr
Crash demangle component: cxa_demangle
Runtime library: glibc 2.8
Threads library: NPTL 2.8
TLS is available
ALSA: Advanced Linux Sound Architecture Driver Version 1.0.18rc3.
ALSA Driver: 0: HDA ULI M5461 [M5461], device 0: ALC883 Analog [ALC883 Analog], 0/1 subdevices avail
ALSA device overridden to "[PulseAudioを使用するためのPCMデバイス名]"
ALSA: dsnd_pcm_hw_params_set_access: Invalid argument
(大量にこのメッセージが繰り返される)
ALSA: dsnd_pcm_hw_params_set_access: Invalid argument
ALSA: Got 32 hardware buffers
Sound driver: ALSA
Language: english
Theme: default

Partial log:
00:01.835: Course::LoadFromCRSFile( 'Courses/Samples/Tortoise and the Hare.crs' )
00:01.844: Course::LoadFromCRSFile( 'Courses/Samples/Tournamix 4 Sample.crs' )
00:01.847: Course file 'Courses/Samples/Tournamix 4 Sample.crs' contains a fixed song entry 'Help me Dr. Dick' that does not exist. This entry will be ignored.
00:01.848: Course file 'Courses/Samples/Tournamix 4 Sample.crs' contains a fixed song entry 'DOO-BE-DI-BOY (KCP MIX)' that does not exist. This entry will be ignored.
00:01.850: Course file 'Courses/Samples/Tournamix 4 Sample.crs' contains a fixed song entry 'Laugh and Beats' that does not exist. This entry will be ignored.
00:01.851: Course file 'Courses/Samples/Tournamix 4 Sample.crs' contains a fixed song entry 'Baby Got Back' that does not exist. This entry will be ignored.
00:01.852: Course::LoadFromCRSFile( 'Courses/Samples/TrickyRandom.crs' )
00:01.860: Writing Data/Catalog.xml ...
00:02.150: Done.
00:02.193: RageSound::LoadSound( 'Themes/default/Sounds/MemoryCardManager ready.ogg' )

-- End of report

また、padspOSS向けアプリケーションの音声をPulseAudioに出力できるが、これも失敗した。

$ padsp stepmania
StepMania 3.9
Log starting xxxx-xx-xx xx:xx:xx
Loading window: gtk
OS: Linux ver 020627
Crash backtrace component: x86 custom backtrace
Crash lookup component: dladdr
Crash demangle component: cxa_demangle
Runtime library: glibc 2.8
Threads library: NPTL 2.8
TLS is available
ALSA: Advanced Linux Sound Architecture Driver Version 1.0.18rc3.
ALSA Driver: 0: HDA ULI M5461 [M5461], device 0: ALC883 Analog [ALC883 Analog], 0/1 subdevices avail
Couldn't load driver ALSA: dsnd_pcm_open(hw:0): Device or resource busy
Mixing 0.000000 ahead in 0 Mix() calls
Couldn't load driver ALSA-sw: dsnd_pcm_open(hw:0): Device or resource busy
/////////////////////////////////////////
WARNING: OSS_GETVERSION failed: Invalid argument
/////////////////////////////////////////
terminate called after throwing an instance of 'RageException'
  what():  write didn't: 4032 ()
ptrace failed: Operation not permitted
ptrace failed: Operation not permitted
Sound driver: OSS

StepMania has crashed.  Debug information has been output to

    /tmp/crashinfo.txt

Please report a bug at:

    http://sourceforge.net/tracker/?func=add&group_id=37892&atid=421366

$ cat /tmp/crashinfo.txt
StepMania 3.9 crash report
--------------------------------------

Crash reason: Aborted - Unknown code -6
Crashed thread: RageSound_OSS

Checkpoints:
Thread: Main thread
        IniFile.cpp:10 Reading 'Characters/default/character.ini'
        IniFile.cpp:10 Reading 'Data/GamePrefs.ini'
        IniFile.cpp:10 Reading 'Data/Static.ini'
        IniFile.cpp:10 Reading 'Themes/default/metrics.ini'
        IniFile.cpp:10 Reading 'Themes/default/Languages/english.ini'
Thread: Decode thread
Thread: RageSound_OSS
Thread: MusicThread

Thread: RageSound_OSS
00007f06c5ed3955: 
00007f06c5ed5183: 
00007f06c5ed5183: 
00007f06c8504038: 
00007f06c64de744: 
00007f06c64dcb46: 
00007f06c5f1a891: 
00007f06c672fa69: 
0000000000707bbc: RageSound_OSS::GetData() 
0000000000707c28: RageSound_OSS::MixerThread() 
0000000000707cb9: RageSound_OSS::MixerThread_start(void*) 
0000000000721445: 
00007f06c5f7ef0d: 

Static log:
StepMania 3.9
Log starting xxxx-xx-xx xx:xx:xx
Loading window: gtk
OS: Linux ver 020627
Crash backtrace component: x86 custom backtrace
Crash lookup component: dladdr
Crash demangle component: cxa_demangle
Runtime library: glibc 2.8
Threads library: NPTL 2.8
TLS is available
ALSA: Advanced Linux Sound Architecture Driver Version 1.0.18rc3.
ALSA Driver: 0: HDA ULI M5461 [M5461], device 0: ALC883 Analog [ALC883 Analog], 0/1 subdevices avail
Couldn't load driver ALSA: dsnd_pcm_open(hw:0): Device or resource busy
Mixing 0.000000 ahead in 0 Mix() calls
Couldn't load driver ALSA-sw: dsnd_pcm_open(hw:0): Device or resource busy
WARNING: OSS_GETVERSION failed: Invalid argument
Sound driver: OSS
Language: english
Theme: default

Partial log:
00:00.284: RageSound_OSS: sample rate 44100
00:00.284: Starting thread: Decode thread
00:00.284: Starting thread: RageSound_OSS
00:00.292: 
00:00.292: //////////////////////////////////////////////////////
00:00.292: Exception: write didn't: 4032 ()
00:00.292: //////////////////////////////////////////////////////
00:00.292: 
00:00.327: Sound driver: OSS
00:00.327: Starting thread: MusicThread

-- End of report

Mandriva Linuxのパッケージのメニュー項目ではsoundwrapper経由で起動されるようになっているが、デバイスが解放されていなければこのパターンで失敗する。
(2009/4/21)PulseAudioでうまくデバイスが解放されない場合

$ pasuspender stepmania

のようにpasuspenderを使用する方法もあるようだ。

Windows版について

Windows版をWineで動かすことは可能で、その際のサウンド出力はWineのサウンド出力先となる。*2ただし、動作はGNU/Linux版より重くなってしまう。また、起動時にはデータ読み込み後にメインウィンドウが出たらすぐにフォーカスしてEnterキーを押しっぱなしにしておかないと「Mute on」と出て曲の音声が出なくなるので注意が必要。

データの配置について

本家版では実行ファイルのあるディレクトリ以下に存在ある幾つかのディレクトリの中に、対応するレイアウトで追加のデータ(曲やテーマなど)を配置していく。
Mandriva Linuxのパッケージを使用した場合、${HOME}/StepMania以下にこれらと同じ名前のディレクトリ(AnnouncersSongsThemesなど)を作成して配置していく(ユーザごとに作成できる)。/usr/share/games/StepMania/以下のディレクトリ名を参考にすることもできる。

関連記事:

使用したバージョン:

  • stepmania 3.9-9mdv2009.0
  • jackit 0.116.1-1.1mdv2009.0
  • pulseaudio 0.9.10-11.1mdv2009.0
  • lib64alsa-plugins-{jack,pulseaudio} 1.0.18-0.rc3.3.1mdv2009.0

*1:ALSAサウンドシステムにおいて、音声を加工せずに直接サウンドバイスに出力するプラグイン

*2:つまり、設定しだいでPulseAudioに出力することはできる