[pulseaudio-discuss] [PATCH] rtkit: Add client-side testing of properties
To complete the previous patch that implemented properties in rtkit, here's the client-side code that tests that the properties work, and make them more accessible for the casual C programmer. // David From 309659d47396544cd2b8d97ac5dac4460f543723 Mon Sep 17 00:00:00 2001 From: David Henningsson di...@ubuntu.com Date: Sun, 7 Feb 2010 13:18:00 +0100 Subject: [PATCH] Implement client-side testing of property retrieval --- rtkit-test.c | 22 ++-- rtkit.c | 114 ++ rtkit.h | 17 + 3 files changed, 150 insertions(+), 3 deletions(-) diff --git a/rtkit-test.c b/rtkit-test.c index 2841b52..9d2703f 100644 --- a/rtkit-test.c +++ b/rtkit-test.c @@ -76,7 +76,8 @@ static void print_status(const char *t) { int main(int argc, char *argv[]) { DBusError error; DBusConnection *bus; -int r; +int r, r2; +long long r3; struct rlimit rlim; dbus_error_init(error); @@ -86,6 +87,21 @@ int main(int argc, char *argv[]) { return 1; } +if ((r = rtkit_get_max_realtime_priority(bus)) 0) +fprintf(stderr, Failed to retrieve max realtime priority: %s\n, strerror(-r)); +else +printf(Max realtime priority is: %d\n, r); + +if ((r2 = rtkit_get_min_nice_level(bus, r))) +fprintf(stderr, Failed to retrieve min nice level: %s\n, strerror(-r2)); +else +printf(Min nice level is: %d\n, r); + +if ((r3 = rtkit_get_rttime_nsec_max(bus)) 0) +fprintf(stderr, Failed to retrieve rttime limit: %s\n, strerror(-r3)); +else +printf(Rttime limit is: %lld ns\n, r3); + memset(rlim, 0, sizeof(rlim)); rlim.rlim_cur = rlim.rlim_max = 1ULL; /* 100ms */ if ((setrlimit(RLIMIT_RTTIME, rlim) 0)) @@ -96,14 +112,14 @@ int main(int argc, char *argv[]) { if ((r = rtkit_make_high_priority(bus, 0, -10)) 0) fprintf(stderr, Failed to become high priority: %s\n, strerror(-r)); else -printf(Sucessfully became high priority.\n); +printf(Successfully became high priority.\n); print_status(after high priority); if ((r = rtkit_make_realtime(bus, 0, 10)) 0) fprintf(stderr, Failed to become realtime: %s\n, strerror(-r)); else -printf(Sucessfully became realtime.\n); +printf(Successfully became realtime.\n); print_status(after realtime); diff --git a/rtkit.c b/rtkit.c index aecc4e3..181f3de 100644 --- a/rtkit.c +++ b/rtkit.c @@ -2,6 +2,7 @@ /*** Copyright 2009 Lennart Poettering + Copyright 2010 David Henningsson di...@ubuntu.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files @@ -56,6 +57,107 @@ static int translate_error(const char *name) { return -EIO; } + +static long long rtkit_get_int_property(DBusConnection *connection, const char* propname, long long* propval) { +DBusMessage *m = NULL, *r = NULL; +DBusMessageIter iter, subiter; +dbus_int64_t i64; +dbus_int32_t i32; +DBusError error; +int current_type; +long long ret; +const char * interfacestr = org.freedesktop.RealtimeKit1; + +dbus_error_init(error); + +if (!(m = dbus_message_new_method_call( + RTKIT_SERVICE_NAME, + RTKIT_OBJECT_PATH, + org.freedesktop.DBus.Properties, + Get))) { +ret = -ENOMEM; +goto finish; +} + +if (!dbus_message_append_args( +m, +DBUS_TYPE_STRING, interfacestr, +DBUS_TYPE_STRING, propname, +DBUS_TYPE_INVALID)) { +ret = -ENOMEM; +goto finish; +} + +if (!(r = dbus_connection_send_with_reply_and_block(connection, m, -1, error))) { +ret = translate_error(error.name); +goto finish; +} + +if (dbus_set_error_from_message(error, r)) { +ret = translate_error(error.name); +goto finish; +} + + ret = -EBADMSG; +dbus_message_iter_init(r, iter); +while ((current_type = dbus_message_iter_get_arg_type (iter)) != DBUS_TYPE_INVALID) { +if (current_type == DBUS_TYPE_VARIANT) { +dbus_message_iter_recurse(iter, subiter); +while ((current_type = dbus_message_iter_get_arg_type (subiter)) != DBUS_TYPE_INVALID) { +if (current_type == DBUS_TYPE_INT32) { +
[pulseaudio-discuss] My default sound devices are not retained after suspend or reboot
Hello, I'm using ubuntu karmic 9.10 with 2 sound cards and a webcam listed below : p...@pim:~$ cat /proc/asound/cards 0 [EMU0404]: Audigy2 - E-mu 0404b PCI [MAEM8852] E-mu 0404b PCI [MAEM8852] (rev.0, serial:0x40021102) at 0x9f00, irq 19 1 [Intel ]: HDA-Intel - HDA Intel HDA Intel at 0xfbff8000 irq 22 2 [U0x4710x310]: USB-Audio - USB Device 0x471:0x310 USB Device 0x471:0x310 at usb-:00:1a.1-1, full speed p...@pim:~$ cat /proc/asound/modules 0 snd_emu10k1 1 snd_hda_intel 2 snd_usb_audio I'd like to use the sound card EMU0404 as default output device and the Intel sound card as default input device (Line-In as default). I've set-up this in pavucontrol but for some reason, my preferences are not retained after suspend and reboot. I've been searching for 2 days for a solution but I can't find. I'm quite new to linux so I don't know if it's a bug or just a newbie question. To explain things better, I've made some screenshots : http://box10.pulsradio.com/~pim2/pulseaudiout1.png = my settings for output before suspend (default output = SB0404 == what I want). These settings seem to be retained after suspend or reboot. http://box10.pulsradio.com/~pim2/pulseaudioin1.png = my settings for input before suspend (default input = Audio intern - Line In= == What I want. http://box10.pulsradio.com/~pim2/pulseaudioin2.png = my settings for input after suspend (default input changed to EMU404 - Microphone) This is just an exemple because sometimes after reboot, default input is still Intel but switched to mic-in instead of line-in. Maybe it has nothing to do with this problem but I've edited /etc/modprobe.d/alsa-base.conf in order to have always the same order : options snd-emu10k1 index=0 options snd-hda_intel index=1 options snd-usb_audio index=2 Thank you :) ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
[pulseaudio-discuss] system-wide daemon
I am trying to understand PulseAudio, and have some use cases for which it's not clear to me how best to configure the system. In my living room at home, I have a pair of stereo speakers, which are connected to a linux box, which, in turn, has some large disks holding a large music collection. When you wish to play music in my home, you do it by running a program of some sort on this computer. Now, the thing is that this computer has a monitor, keyboard and mouse. Sometimes someone is logged in to this console, doing things on the computer. Sometime no one is logged in at all. Now, as I am typing this very message, I am sitting on my couch in my living room, using my notebook computer. What I would also like to do, for example, is ssh into my living room server, run rythmbox, and play some music. Perhaps my wife is logged in to the console; perhaps she isn't. Perhaps I am. That's irrelevant. My music server is a multi-user system; multiple people can be simultaneously logged in to the system, and all of them should be able to access the audio hardware. It seems to me that this is the sort of thing for which one wants a system-wide pulse daemon. Pulse Audio seems to be tuned towards the idea of having a daemon launched per login session. But I would like multiple users in my home to be able to remotely connect to my music system and run programs that send audio to the speakers. This should be completely independent of who is logged in at the console. On the other hand, I've read the PulseAudio wiki seeking enlightenment, and the wiki very clearly disrecommends using PA in system-daemon mode. It doesn't make a very compelling case of *why* system-daemon mode is a bad idea, it mostly just explains that PA will restrict functionality for security reasons if you obstinately insist on doing so. So, what's the right way to handle the use case I've outlined? -Olin ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] system-wide daemon
While the right way is not system-wide mode, in practice, I find system-wide mode to be very stable and usable on Ubuntu systems that have multiple users trying to send sound to the speakers. It's easy to get Ubuntu Karmic and Lucid to use PulseAudio in system-wide mode. For systems that require rock-solid sound, and which need to share the sound card simultaneously with multiple users, it's what I currently recomend. Long-term, I believe this situation will change, but for now, in Ubuntu, system-wide mode would be my recomendation for you. To set system-wide mode: Edit /etc/defaults/pulseaudio, and change: PULSEAUDIO_SYSTEM_START=0 to PULSEAUDIO_SYSTEM_START=1 Then, edit /etc/pulse/client.conf, and add the line autospawn = no After the line that says '#autospawn = yes'. Then, delete the file /etc/xdg/autostart/pulseaudio.desktop. Finally, disable group-based authentication to use the sound system. Edit /etc/pulse/system.pa. Find the line that reads: load-module module-native-protocol-unix and change it to read: load-module module-native-protocol-unix auth-anonymous=1 Be warned that you open yourself up to a unauthorized sound hacker attacks! Your wife could send perverse audio over your speakers without permission! Your children could spy on you through your mic without your password! If you're a bit confused, join the club. In any case, I my system works very well in system-wide mode, and for my purposes it works far better than user-mode, but I've got multiple programs running as different users that need simultaneous access to the sound card. Bill On Sun, Feb 7, 2010 at 6:54 PM, olin.pulse@shivers.mail0.org wrote: I am trying to understand PulseAudio, and have some use cases for which it's not clear to me how best to configure the system. In my living room at home, I have a pair of stereo speakers, which are connected to a linux box, which, in turn, has some large disks holding a large music collection. When you wish to play music in my home, you do it by running a program of some sort on this computer. Now, the thing is that this computer has a monitor, keyboard and mouse. Sometimes someone is logged in to this console, doing things on the computer. Sometime no one is logged in at all. Now, as I am typing this very message, I am sitting on my couch in my living room, using my notebook computer. What I would also like to do, for example, is ssh into my living room server, run rythmbox, and play some music. Perhaps my wife is logged in to the console; perhaps she isn't. Perhaps I am. That's irrelevant. My music server is a multi-user system; multiple people can be simultaneously logged in to the system, and all of them should be able to access the audio hardware. It seems to me that this is the sort of thing for which one wants a system-wide pulse daemon. Pulse Audio seems to be tuned towards the idea of having a daemon launched per login session. But I would like multiple users in my home to be able to remotely connect to my music system and run programs that send audio to the speakers. This should be completely independent of who is logged in at the console. On the other hand, I've read the PulseAudio wiki seeking enlightenment, and the wiki very clearly disrecommends using PA in system-daemon mode. It doesn't make a very compelling case of *why* system-daemon mode is a bad idea, it mostly just explains that PA will restrict functionality for security reasons if you obstinately insist on doing so. So, what's the right way to handle the use case I've outlined? -Olin ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] system-wide daemon
On Sun, Feb 7, 2010 at 10:54 PM, Bill Cox waywardg...@gmail.com wrote: To set system-wide mode: [...] The method for Jaunty/Karmic differs slightly from that for Lucid, but one can always look in /etc/default/pulseaudio for pointers. I try to keep this file updated. Best, -Dan ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss