PulseAudio DBUS API ページには、LoadModule への引数が
引数: 名前: 文字列、引数: {文字列 -> 文字列}
また、{String -> String} は文字列キーと文字列値を持つ辞書であるとも述べています。
これを c++ API 経由で送信するにはどうすればよいですか? 通常、私は次のようなことをします:
msg = dbus_message_new_method_call(
"org.PulseAudio1", //Destination
"/org/pulseaudio/core1", //Object path to call on
interfaceStr, //Interface to call on
method); //Method
次に、msg イテレータを作成します。
//append arguments to the LoadModule() method. (String, {String->String})
dbus_message_iter_init_append(msg, &msgIter);
dbus_message_iter_append_basic(&msgIter, DBUS_TYPE_STRING,&moduleName);
//dict entries
dbus_message_iter_open_container(&msgIter, DBUS_TYPE_DICT_ENTRY, NULL, &subIter);
dbus_message_iter_append_basic(&subIter, DBUS_TYPE_STRING, &sourceStr);
dbus_message_iter_append_basic(&subIter, DBUS_TYPE_STRING, &sourcePath);
dbus_message_iter_close_container(&msgIter, &subIter);
dbus_message_iter_open_container(&msgIter, DBUS_TYPE_DICT_ENTRY, NULL, &subIter);
dbus_message_iter_append_basic(&subIter, DBUS_TYPE_STRING, &sinkStr);
dbus_message_iter_append_basic(&subIter, DBUS_TYPE_STRING, &sinkPath);
dbus_message_iter_close_container(&msgIter, &subIter);
これにより、次のようなパラメーター リストが作成されると思います: LoadModule(String, {String->String}, {String->String})
ただし、関数は応答しません。パラメータを正しく作成しているとは思いません。実際、私はそうではないと確信しています。他の人がさまざまなメソッドに配列を使用しているのを見てきましたが、ここではそれを指定していません。何かがキー/値であることを具体的に述べる方法はありますか?
アップデート:
次の行を見つけました:辞書エントリは配列の要素である必要があり、基本的な D-Bus タイプのキーを持つ 2 つの要素のキーと値のペアのみを含む必要があります。GNU Using of D-Bus ページで、役立つ場合があります。私はそれを試して、結果を投稿します。