最近、手元で gWaoN が動かなくなっている問題。
最近は、家で coding してないので、ずっと放置状態だった問題。
今の開発環境は OS X の macports なので、 ライブラリの整合性とか、そういう副次的な問題なのかなぁ、というのも、 放置の原因の一つ。
しかし、一方で、音楽やりたい熱が高まってきていて、 どこが問題を起こしているのかだけでも突き止めよう、という気になった。
症状は、 gWaoN でファイルを開こうとすると、 file selector で「OK」ボタンを押した後に落ちる、というもの。
% ./gwaon
Xlib: extension "RANDR" missing on display "/tmp/launch-Re9uRs/:0".
/somewhere/check.wav
channels = 2
samplerate = 44100
frames = 5906304
Segmentation fault
で、調査の結果、以下の通り:
というように、 libao の ao_device を作る部分で問題が起きていた。(gtk とは関係ありませんでした。)
% ./gwaon
Xlib: extension "RANDR" missing on display "/tmp/launch-Re9uRs/:0".
#以下は gwaon-menu.c の on_file_open_wav_sel_ok の中
/somewhere/check.wav
channels = 2
samplerate = 44100
frames = 5906304
#ここで gwaon-wav.c の create_wav に飛ぶ
# check ao device
0 : type : 1
0 : name : MacOS X AUHAL output
0 : short name : macosx
0 : driver comment :
1 : type : 1
1 : name : Null output
1 : short name : null
1 : driver comment : This driver does nothing.
2 : type : 2
2 : name : WAV file output
2 : short name : wav
2 : driver comment : Sends output to a .wav file
3 : type : 2
3 : name : RAW sample output
3 : short name : raw
3 : driver comment : Writes raw audio samples to a file
4 : type : 2
4 : name : AU file output
4 : short name : au
4 : driver comment : Sends output to a .au file
#この後 ao-wrapper.c の ao_init_16_stereo に飛ぶ
#この後 ao_open_live を call した後に "Segmentation fault" となる
ここで、コードの情報を一杯書き出すようにすると、あれれ、うまくいった。 (なんか、メモリ関係があやしいという症状だな)
で、問題なく window が生成された。
% ./gwaon
中略
#ここで gwaon-wav.c の create_wav に飛ぶ
中略
# samplerate = 44100
#この後 ao_init_16_stereo に飛ぶ
#以下は ao_open_live の出したメッセージ
ao_macosx ERROR: Unrecognized channel name "D?" in channel matrix "D?"
ao_macosx WARNING: Input channel matrix invalid; ignoring.
#以下は print_ao_info のメッセージ (verbose にしたので)
[ao] type : 1
[ao] name : MacOS X AUHAL output
[ao] short name : macosx
[ao] driver comment :
ってことで、怪しそうな fprintf や verbose option をいくつか元に戻してみると、 うーむ、今度は動くぞ。
面倒だが、1つ1つ、追加して行ったコメント表示 statements を消して行くと、 見つけた。
という所で、時間切れ。
3/3/2013: 問題、解決!