You are not logged in.
I need to play audio from some old binary that relies on OSS (/dev/dsp). I currently use PulseAudio. I tried to use padsp and ossp/osspd, all failed.
I use sox to test the audio output (the binary I want to use is some other, comercial one)
$ sox /tmp/00.mp3 -t ossdsp /dev/dsp
which works with the alsa or pulseaudio target (-t).
Using osspd as daemon, running above command gives the following errors in journalctl:
Oct 17 18:15:23 ultraskunk osspd[295]: osspd: OSS Proxy v1.3.2 (C) 2008-2010 by Tejun Heo <teheo@suse.de>
Oct 17 18:15:23 ultraskunk osspd[295]: osspd: Creating dsp (14:3), adsp (14:12), mixer (14:0)
Oct 17 18:16:14 ultraskunk osspd[295]: ossp-padsp[skunk:646] WARN: pa_context_subscribe() failed (Bad state)
Oct 17 18:16:14 ultraskunk osspd[295]: ossp-padsp[skunk:646] WARN: failed to subscribe to context events (Bad state)
Oct 17 18:16:14 ultraskunk osspd[295]: ossp-padsp[skunk:646] ERR: failed to connect context, state=5 (Bad state)
Launching osspd directly with the verbosity flag yields
# /usr/bin/osspd -v -f
osspd: OSS Proxy v1.3.2 (C) 2008-2010 by Tejun Heo <teheo@suse.de>
osspd: Creating dsp (14:3), adsp (14:12), mixer (14:0)
osspd DBG0: CREATE mixer(940)
osspd DBG0: S[1/940] CREATE slave=941 /usr/bin/ossp-padsp
osspd DBG0: S[1/940] client=940 cmd=7:8 notify=9:10 mmap=-1:0x100000:1048576
ossp-padsp[skunk:941] WARN: pa_context_subscribe() failed (Bad state)
ossp-padsp[skunk:941] WARN: failed to subscribe to context events (Bad state)
ossp-padsp[skunk:941] ERR: failed to connect context, state=5 (Bad state)
osspd DBG0: S[1/940] removing 9 from notify poll list
osspd DBG0: S[1/940] DESTROY
And finally, running sox with padsp yields
% padsp -d sox /tmp/00.mp3 -t ossdsp /dev/dsp
utils/padsp.c: dsp_open()
utils/padsp.c: fd_info_new()
utils/padsp.c: dsp_open() succeeded, fd=4
utils/padsp.c: SNDCTL_DSP_RESET
utils/padsp.c: SNDCTL_DSP_GETFMTS
utils/padsp.c: SNDCTL_DSP_SETFMT: 16
utils/padsp.c: SNDCTL_DSP_STEREO: 1
utils/padsp.c: SNDCTL_DSP_SPEED: 44100
utils/padsp.c: ss: s16le 2ch 44100Hz
utils/padsp.c: SNDCTL_DSP_SYNC
utils/padsp.c: Draining.
/tmp/00.mp3:
File Size: 2.91M Bit Rate: 128k
Encoding: MPEG audio
Channels: 2 @ 16-bit
Samplerate: 44100Hz
Replaygain: off
Duration: 00:03:02.05
In:0.00% 00:00:00.00 [00:03:02.05] Out:0 [ | ] Clip:0 utils/padsp.c: sample spec: s16le 2ch 44100Hz
utils/padsp.c: fixated metrics to 12 fragments, 7350 bytes each.
utils/padsp.c: stream established.
utils/padsp.c: pa_stream_write(): Invalid argument
sox FAIL sox: `/dev/dsp' Error writing to device: Connection reset by peer
Done.
utils/padsp.c: freeing fd info (fd=4)
utils/padsp.c: Draining.
I would be grateful for any help.
It would be fine, also, if there were any scripts/wrappers, that can redirect the output of my program to file
It's not a bug -- it's a feature!
Offline
Hello!
:: Edit, it looks the last step - cookie is persistent problem, see lower post.
I was experiencing this problem on current Debian Stable, with absolutely no one capable to help in the internet.
I am VERY SURE that this problem should be addressed in Archlinux' pulseaudio wiki page! I was also a ArchLinux user in the past, just that currently Debian suits my tastes better.
Neverless THIS VERY post depicts the exact situation I was in, so replying to this will hopefully fix this problem for everyone who encounters it in the future - because search engine will bring them here too.
I tried to solve this problem for two days and finally only just now I came up with the solution that fixed it and now I have sound.
The osspd now works perfectly well!
From my understanding, a variety of reasons lead to this:
- incorrectly configured kernel
- wrong permissions
- running pulseaudio as root via su, which blocks socket
Here I solve them all, step by step.
Prerequisites:
Have two terminal windows open, to run two commands check and see the outcome by running CNTL.
The basic check is (referred as "check" further on):
$ echo asdasdas > /dev/dsp
It is very important to do this as regular user. Never address soundcard with elevated privileges, because this breaks permissions on cookies!
The control is (referred to as "CNTL" in the future) checking demon status, including last entry in system log:
# systemctl status osspd
Solution steps:
1.
Make sure your kernel has disabled oss core preclaim. If set, this causes kernel to grab OSS devices (/dev/dsp) for itself, effectively preventing osspd to work.
$ cat /boot/config-yourkernel | grep -i "oss_core"
should read:
# CONFIG_SOUND_OSS_CORE_PRECLAIM is not set
If you don't have kernel configuration as separate file, you can obtain a copy of configuration:
$ zcat /proc/config.gz > ./config-yourkernel
If this is enabled (=y) instead, you should disable it and recompile your kernel.
Its possible to override this via kernel cheat and possibly via modprobe (I am not sure about this one though).
Add kernel parameter "soundcore.preclaim_oss=0" in /etc/default/grub in cause you use Grub2, or similarly for other boot loaders.
Then reboot.
2.
blacklist all the kernel OSS emulation. Uninstall alsa-oss and oss-compat packages (Arch equivalents), because they are conflicting.
To blacklist add this to /etc/modprobe.d/osspd.conf:
blacklist snd-pcm-oss
blacklist snd-mixer-oss
blacklist snd-seq-oss
3.
The "CNTL" should show, that osspd is running even when nothing is played:
● osspd.service - OSS Proxy Daemon
Loaded: loaded (/lib/systemd/system/osspd.service; enabled)
Active: active (running) since Sun 2016-05-08 xxxxx; xxxxx ago
Main PID: 2704 (osspd)
CGroup: /system.slice/osspd.service
├─2704 /usr/sbin/osspd -f --dsp-slave=/usr/lib/osspd/ossp-slave
If its not then, make sure that cuse module is loaded and that it creates all devices.
# lsmod | grep cuse
should read:
cuse 16384 7
fuse 98304 2 cuse
if its not:
# insmod cuse
Also, make sure that regular users have access to /dev/dsp ( $ls -alh /dev/dsp)
crw-rw-rw- 1 root root 14, 3 May 7 19:40 /dev/dsp
4.
Now "CNTL" shows:
[pulseaudio] socket-server.c: bind(): Address already in use
[pulseaudio] module.c: Failed to load module "module-esound-protocol-unix" (argument: ""): initialization failed.
[pulseaudio] main.c: Module load failed.
[pulseaudio] main.c: Failed to initialize daemon.
[pulseaudio] main.c: Daemon startup failed.
ERR: failed to connect context, state=5 (Bad state)
I did this:
4.1 remove .esd_auth cookie in your home directory. This will be auto-recreated upon server restart.
# rm /home/your_user_account/.esd_auth
4.2 remove pulseaudio socket. This will also be auto-recreated.
This socket is possibly the reason of refuse, because its permissions will be trashed if at any time you try "check" via sudo.
# rm /tmp/.esd-1000/socket
this assumes your uid is 1000 (can be any value), check the owner attribute of directory with "ls -alh /tmp/.esd*"
5.
If you done above step, the "CNTL" output will change to:
[pulseaudio] main.c: D-Bus name org.PulseAudio1 already taken.
[pulseaudio] main.c: Daemon startup failed.
ERR: failed to connect context, state=5 (Bad state)
This means, everything works, yet a copy of PulseAudio is already running.
Re-login and do a "check" again.
It should work now! All your OSS applications should now have sound.
Last edited by lin545 (2016-05-08 01:32:25)
Offline
Update:
It looks I was overhyped.
After the machine reboot, the "/dev/dsp: Input/output error" on $ echo > /dev/dsp with "Failed to load module "module-esound-protocol-unix" (argument: ""): initialization failed." reappeared.
Removing the pulse socket, as above, and relogin, it was fixed.
Another machine reboot, and again same issue. I have no idea why the pulse socket prevents osspd to work and removing it fixes it.
I have checked the permissions and they are drwx------ user:user on /tmp/.esd-1000 , and srwxrwxrwx user:user on the "socket".
Any ideas welcome...
Update 2:
These are probably related: (1) (2)
The bug seem to be unfixed.
TL;DR version, the "pulse-esound-compat" module, leaves the /tmp/.esd-$UID/ directory when shutting down. But it should instead delete it.
The osspd (OSS proxy daemon package) feeds the audio to pulse via esd.
Update 3:
Yes, this seem to be indeed the bug.
The patch was NOT integrated. The only thing patch does is:
-# if defined(USE_PROTOCOL_ESOUND) && !defined(USE_PER_USER_ESOUND_SOCKET)
+# if defined(USE_PROTOCOL_ESOUND)
if (u->socket_path) {
char *p = pa_parent_dir(u->socket_path);
rmdir(p);
ie, it forces .esd-socket sanitazation for global AND local pulseaudio setup.
By default it happens only on global, and global pa use is basically prohibited anyway.
What I did by removing the socket, is basically done in the patch.
It would be superawesome if someone submits this patch upstream.
Update 4:
Just noticed that removing socket and re-login, that essentially this causes osspd to bypass usual pulseaudio interfaces...
The soundstream from osspd is simply not displayed in KMix...
Last edited by lin545 (2016-05-08 15:01:09)
Offline
Okay, this can really be closed as resolved. This was a problem of older version of Pulseaudio, which refused to accept connections. This should not happen anymore in more recent Pulseaudio. If it happens - upgrade your PA installation.
If you are on Debian Stable, set up backports repository and tick "Prefered source: backports", then upgrade the Pulseaudio.
From #debian-next IRC chat, a guy has generously offered the help to test the ossp package on current Debian Testing.
Below are the two distict logs. We "echo asdasd>/dev/dsp" and then check "#systemctl status osspd".
One from older Pulseaudio(current Debian stable, like Arch minus 1-2 years ago), and one from Debian Testing (like current Arch):
Debian Stable (old Pulseaudio), osspd refuses to play the sound. It says "input/output error", its clearly seen that it fails to attach itself to Pulseaudio.
● osspd.service - OSS Proxy Daemon
Loaded: loaded (/lib/systemd/system/osspd.service; enabled)
Active: active (running) since Sun 2016-05-08 19:30:41 CEST; 6min ago
Main PID: 5031 (osspd)
CGroup: /system.slice/osspd.service
└─5031 /usr/sbin/osspd -f --dsp-slave=/usr/lib/osspd/ossp-slave
May 08 19:30:41 tiger osspd[5031]: osspd: OSS Proxy v1.3.2 (C) 2008-2010 by Tejun Heo <teheo@suse.de>
May 08 19:30:41 tiger osspd[5031]: osspd: Creating dsp (14:3), adsp (14:12), mixer (14:0)
May 08 19:36:40 tiger pulseaudio[6382]: [pulseaudio] sink.c: Default and alternate sample rates are the same.
May 08 19:36:40 tiger pulseaudio[6382]: [pulseaudio] socket-server.c: bind(): Address already in use
May 08 19:36:40 tiger pulseaudio[6382]: [pulseaudio] module.c: Failed to load module "module-esound-protocol-unix" (argument: ""): initialization failed.
May 08 19:36:40 tiger pulseaudio[6382]: [pulseaudio] main.c: Module load failed.
May 08 19:36:40 tiger pulseaudio[6382]: [pulseaudio] main.c: Failed to initialize daemon.
May 08 19:36:40 tiger pulseaudio[6379]: [pulseaudio] main.c: Daemon startup failed.
May 08 19:36:40 tiger osspd[5031]: ossp-padsp[builder:6377] ERR: failed to connect context, state=5 (Bad state)
Debian Testing (new Pulseaudio), osspd sound plays OK!
● osspd.service - OSS Proxy Daemon
Loaded: loaded (/lib/systemd/system/osspd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2016-05-08 16:03:53 ADT; 18min ago
Main PID: 26793 (osspd)
Tasks: 16 (limit: 512)
CGroup: /system.slice/osspd.service
├─26793 /usr/sbin/osspd -f --dsp-slave=/usr/lib/osspd/ossp-slave
└─27005 /usr/bin/pulseaudio --start --log-target=syslog
May 08 16:03:53 zancas systemd[1]: Started OSS Proxy Daemon.
May 08 16:03:53 zancas osspd[26793]: osspd: OSS Proxy v1.3.2 (C) 2008-2010 by Tejun Heo <teheo@suse.de>
May 08 16:03:53 zancas osspd[26793]: osspd: Creating dsp (14:3), adsp (14:12), mixer (14:0)
Debian Stable Backports(a bit older, but newer Pulseaudio than on stable), the sound plays via osspd OK!
● osspd.service - OSS Proxy Daemon
Loaded: loaded (/lib/systemd/system/osspd.service; enabled)
Active: active (running) since Mon 2016-05-09 01:24:10 CEST; 13min ago
Main PID: 1034 (osspd)
CGroup: /system.slice/osspd.service
├─1034 /usr/sbin/osspd -f --dsp-slave=/usr/lib/osspd/ossp-slave
└─2200 /usr/lib/osspd/ossp-slave -u 1000 -g 1000 -c 8 -n 10 -m -1 -o 0x100000 -s 0x100000 -l 4
May 09 01:24:11 tiger osspd[1034]: osspd: OSS Proxy v1.3.2 (C) 2008-2010 by Tejun Heo <teheo@suse.de>
May 09 01:24:11 tiger osspd[1034]: osspd: Creating dsp (14:3), adsp (14:12), mixer (14:0)
If you can't upgrade Pulseaudio, your only solution is to delete the socket and relogin, to bypass Pulseaudio.
This thread can really be marked as SOLVED.
I hope this will be of some use to someone on the internet with similar problem.
Offline