Re: [ANNOUNCE] OSS Proxy using CUSE

Previous thread: md (regression): reboot/shutdown hangs by Alistair John Strachan on Thursday, August 28, 2008 - 12:05 pm. (2 messages)

Next thread: Re: [Bugme-new] [Bug 11446] New: Automate "to compile as module" strings by Andrew Morton on Thursday, August 28, 2008 - 12:38 pm. (1 message)
From: Tejun Heo
Date: Thursday, August 28, 2008 - 12:05 pm

Hello again,

So, after all the fuss, here's the state-of-the-art standard-compliant
cloud-computing web-3.0-beta web page for OSS emulation using CUSE.

  http://userweb.kernel.org/~tj/ossp/

It works pretty well here.  :-)

Thanks.

-- 
tejun
--

From: Adrian Bunk
Date: Thursday, August 28, 2008 - 1:01 pm

Sorry for being destructive, but 6 years after ALSA went into the
kernel we are slightly approaching the point where all applications 
support ALSA.

The application you list on your webpage is UML host sound support,
and I'm wondering why you don't fix that instead of working on a

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--

From: Greg KH
Date: Thursday, August 28, 2008 - 3:18 pm

Independant of that, I can see a number of uses for the CUSE code.  One
would be emulating /dev/pilot for old palm pilot software that things it
wants to talk to a serial port, yet really a libusb userspace program
can handle all of the data to the USB device instead.

So don't think that just because this userspace-OSS implementation is
"not what should be done" that CUSE shouldn't be viable.

thanks,

greg k-h
--

From: H. Peter Anvin
Date: Thursday, August 28, 2008 - 4:05 pm

I think that's probably another bad example... I would think serial port 
emulation would be better handled by ptys, and/or a specific serial port 
emulation module.

The big problem with using ptys for serial port emulation is that they 
currently don't handle BREAK at all.

	-hpa
--

From: Greg KH
Date: Thursday, August 28, 2008 - 4:14 pm

Hm, why?  It's a "fake" serial port as it is just a pass-through to the
USB device.  No flow control or line settings work on the device, so the
kernel driver just silently eats them.  But there is old, closed source
software that wants to talk to a serial port, so the kernel driver
remains.  With this code, we could then use the more modern libusb code
instead.

I guess you could hook it up through a pty, and somehow create

For this type of USB device, that's not an issue :)

thanks,

greg k-h
--

From: H. Peter Anvin
Date: Thursday, August 28, 2008 - 4:38 pm

Why?  Because there is a lot of complexity in the tty layer, and there 
is no point in replicating the entire tty layer with all its ioctls 
through a fragile user-space emulator.  For cases like this, a pty is 
easier (your daemon opens /dev/ptmx, and then symlinks the appropriate 

Indeed.  It would be nice to fix, because it would make implementing 
serial ports as ptys+userspace a much more capable replacement.  It's 
not trivial, though, because the interpretation of the BREAK has to be 
done when received, not when sent, which means supporting a 257th value 
in the underlying buffer setup.

	-hpa
--

From: Alan Cox
Date: Thursday, August 28, 2008 - 4:32 pm

That bit of the problem is trivial. Its the rest of the behavioural
differences that are more of a nightmare - parity, flow control
differences, modem line emulation, being able to hook into things like
ldisc change/termios change.

Break is about a half hour job.

Alan
--

From: Tejun Heo
Date: Thursday, August 28, 2008 - 6:33 pm

Yeah, I have to agree it's a bit too late but the exclusion between OSS
and more modern sound systems (be it ALSA or PA) still bugged me quite a
bit.  There always seems this one off app that wasn't quite there - be
it mpg123 for whatever reason I still enjoy to use from time to time,
vmware which is a genuine pain in the ass to get working with LD_PRELOAD
tricks (hopefully 6.5 will finally use ALSA but wait we're all going PA
now...) or scorch-3D (and many other games) where aoss delivers horrible

Other than OSS emulation, CUSE seemed like an idea which might be able
to stand on its own legs, say, for legacy or proprietary device
emulation or just putting what used to be considered kernel-worthy to
userland.

Anyways, the thing is that unlike what was originally expected, dropping
an major programming API doesn't really work too well even after six
years of trying.  Maybe because OSS is still kicking on other unices.

We now have in-kernel OSS emulation which can't mux with other streams,
aoss with its own supported and broken list and can also be routed
through PA by configuring ALSA right and then padsp with its own
supported and broken list and nothing works good enough.  So, if we have
one thing which just works, we can in time put all those to rest.

Thanks.

-- 
tejun
--

From: Adrian Bunk
Date: Thursday, August 28, 2008 - 11:50 pm

Scorched3D gives me sound with native ALSA.


Good ALSA emulation was a hot topic a few years ago when popular 
software like Flash and Skype didn't support ALSA, but the use
cases are becoming rare.

2 out of your 3 examples above were software where native ALSA works,
but your distributions seems to ship you a setup where you thought 
OSS emulation was required.

Which distribution are you using whose makers seem to need

Which Unix with a big userbase uses OSS as primary sound system?

OSS-only applications tend to be older Linux-only applications.

Cross-platform applications either ship half a dozen different sound 
drivers (including ALSA), or more commonly use some library that offers

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--

From: Tejun Heo
Date: Friday, August 29, 2008 - 12:26 am

Heh.. I probably don't have the right plugin.  Oh... it has all the

I'm not sure at all.  It was from openSUSE game repo back in 10.3
earlier this year and it only spoke OSS, but I bet if I try different
games in the current repo, I'll be able to find at least some which

Yeah, that's why I agree it's a bit too late but still better late than
never.  There are just some programs, be it commercial or ancient, which
don't work quite as well as it could.  Requiring update to ALSA took
painfully long years and we're still not in the clear yet.  Now should
we ask people to update to PA?

Then there's arch-um.  Yes, you can teach it to forward ALSA but then it
won't mux.  The only solution would be to link it against libalsa or


Most major ones do, but there are programs and games which just haven't
fared off as well as more popular ones and thus just stopped being
updated and then there are commercial games which won't be updated in
any foreseeable future.  There are reasons why something as brand new as
pulse comes with something like padsp.

And it's not like CUSE adds whole lot to the kernel.  It mostly just
piggy backs on the existing FUSE.  Yeah, ioctl and poll are a bit
complex but with those and CUSE proper combined, it's way smaller than
the in-kernel ALSA OSS emulation which is somewhat painful to use these
days.

ossp is simply a better way to support /dev/dsp on modern systems and
bulk of it lives in userland (and I hope this can be the case for future
deprecations too).  If for nothing else, it'll enable us to do away with
three different emulations at the very least.  I mean we can't of course
do away with padsp and then some still only work with aoss and then we
need in-kernel ALSA OSS emulation as the final fallback when both fail.
 It's a big mess and ossp can basically OSS emulation as good as
in-kernel ALSA OSS w/ muxing.

Thanks.

-- 
tejun
--

From: Miklos Szeredi
Date: Friday, August 29, 2008 - 1:09 am

I have to agree with Tejun, there will always be old executables lying
around and source code that nobody will bother updating that still use
legacy interfaces.

I have a handful of programs that are still OSS only (one of them,
spectemu, being still popular enough to be in several major distros).

I could update them to alsa, but most of them I use once or twice a
year, it doesn't make sense.

In all the world there are probably thousands of such apps, and
porting each and every one to newer interfaces (if it could be done at
all) would probably be a much bigger effort then implementing a
backward compatibility layer for OSS.

Miklos
--

From: Adrian Bunk
Date: Friday, August 29, 2008 - 1:21 am

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--

From: Tejun Heo
Date: Friday, August 29, 2008 - 1:28 am

Hello,


There's an ALSA plugin which connects to PA.  It works pretty well most
of the time although there are some odd ones which break.  Skype didn't
work too well a few months ago.  Dunno how it works these days tho and
it's likely that the next iteration of popular audio apps will do PA

Yeah, and adding midi support to ossp won't add one line of code to the
kernel.  :-)

Thanks.

-- 
tejun
--

From: Pavel Machek
Date: Tuesday, September 2, 2008 - 8:25 am

Did ALSA reach a point where you can support new cards by just
updating the kernel?

I kind of like /dev/dsp interface... and don't see why simple sound
apps should be linked to libalsa... I used to record and play sounds
from shell by cat /dev/dsp...
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--

From: Jan Engelhardt
Date: Thursday, November 27, 2008 - 1:59 pm

Unreal Tournament GOTY/99 does not (seem to). And I doubt someone
is going to fix commercial games. Though being a static binary,
its use of shared libraries that do the sound device open makes
aoss a possibility, if that helps. But it does not support ALSA
natively - and would make a point for CUSE.
--

From: Tejun Heo
Date: Thursday, November 27, 2008 - 7:23 pm

The devel version of ossp (not out yet, waiting for CUSE and mmap
support merge) can do all the quakes (even the dreaded quake1 which
even ALSA OSS emulation or native OSS can't do because of strict
sample/freq requirement which modern devices don't support anymore)
and skype-static-oss are working fine.  The latency is still a tad bit
high due to PA interaction but everything is mostly in place.  I'm
fairly sure UT would work too.  Do you know where I can get a demo of
it?

Thanks.

-- 
tejun
--

From: Jan Engelhardt
Date: Friday, November 28, 2008 - 4:35 am

It has become really difficult to obtain these nowadays, but there it is:

http://download.beyondunreal.com/get.php/2/official/ut/utdemo-linux-x86-348.tar.gz


(BTW, Firefox3 screws up on loading
http://download.beyondunreal.com/fileworks.php/official/ut/utdemo-linux-x86-348.tar.gz
w3m works fine and was used to obtain the nested link above.)
--

From: Tejun Heo
Date: Friday, November 28, 2008 - 5:02 am

Well, it's still nice to just download the stock demo and being able


Thanks.  Will try that.

-- 
tejun
--

From: Jan Engelhardt
Date: Friday, November 28, 2008 - 5:56 am

Yes and Q3 too.
--

From: Takashi Iwai
Date: Friday, August 29, 2008 - 3:40 am

At Thu, 28 Aug 2008 21:05:53 +0200,

Thanks for info.  Just a quick glance, CUSE looks like a good
abstraction for this kind of things.

I've been thinking that the tunneling to an OSS-emulation daemon would
be the best way, too, and I actually made a similar hack (not based on
FUSE but own kernel module).

It was presented in SUSE Labs conference a few years ago.  And the
reaction by audience at that time was what Adrian showed -- why do we
need such a complexity at all?  Well, as long as we have OSS API and
its applications, we should keep supporting them in a good form.

Anyway, my implementation at that time was too hackish and I gave up
soon.  If it can be implemented in a generic framework like CUSE,
it's a good chance to merge to the upstream.

One thing I couldn't find in your code is the mmap support.
The mmap support is crucial for some apps, typically used for games.
Am I missing something?


thanks,

Takashi
--

From: Tejun Heo
Date: Friday, August 29, 2008 - 3:47 am

Hello,


mmap is essential for some apps?  Aiee... I was hoping to skip that one
after reading strong discouragement against it in the OSS programming
manual from 4front.

Adding it shouldn't be too difficult.  I'll give it a shot after other
stuff settles down.

Thanks.

-- 
tejun
--

From: Tejun Heo
Date: Monday, April 13, 2009 - 7:46 pm

Hello,

OSSP 1.2 available.  It now can do mmap for both playback and
recording.  All my quakes and dooms run and sound fine.  :-)

  http://userweb.kernel.org/~tj/ossp/

Thanks.

-- 
tejun
--

From: Miklos Szeredi
Date: Wednesday, April 22, 2009 - 12:58 pm

Xmms with the OSS output plugin doesn't really work.  It plays like 10
times too fast and the output is not really recognizable.

This is the debug output of osspd:

osspd: OSS Proxy v1.2 (C) 2008-2009 by Tejun Heo <teheo@suse.de>
osspd: Creating dsp (14:3), adsp (14:12), mixer (14:0)
osspd DBG0: CREATE mixer(12799)
osspd DBG0: S[1/16744] CREATE slave=16745 /store/git/ossp/ossp-padsp
osspd DBG0: S[1/16744]   client=16744 cmd=7:8 notify=9:10
ossp-padsp[mszeredi:16745] DBG0: requested frag_size (4096) is smaller than mini
mum (4412)
ossp-padsp[mszeredi:16745] DBG0: CREATE PLAY s16le 2ch 44100Hz fsz=4412:25
ossp-padsp[mszeredi:16745] DBG0:   tlen=131072:743 max=139896:793 pre=8192:46
ossp-padsp[mszeredi:16745] DBG0:   u_sd=0 u_fsz=4096:23 u_maxf=32
osspd DBG0: S[1/16744] volume set=-1/-1:-1/-1 get=63/63:0/0
ossp-padsp[mszeredi:16745] DBG0: PLAY stream underrun
ossp-padsp[mszeredi:16745] DBG0: PLAY stream underrun
ossp-padsp[mszeredi:16745] DBG0: PLAY stream underrun
ossp-padsp[mszeredi:16745] DBG0: PLAY stream underrun
ossp-padsp[mszeredi:16745] DBG0: PLAY stream underrun
ossp-padsp[mszeredi:16745] DBG0: PLAY stream underrun
[...message repeated zillion times]

I guess this has something to do with the too small frag size, but
couldn't figure out how all this works in prepare_streams() and
padsp_write().

Thanks,
Miklos
--

From: Tejun Heo
Date: Wednesday, April 22, 2009 - 4:59 pm

Hello, Miklos.




Yeah, it's a bit convoluted.  I'll try xmms.

Thanks.

-- 
tejun
--

From: Tejun Heo
Date: Friday, June 19, 2009 - 11:13 pm

Hello, Mikos.


Finally tried xmms.  It looks like a bug in pulseaudio.  pulseaudio is
throwing away data buffer after playing only fraction of it.
Interestingly, this can be avoided by having pavucontrol or other play
stream running.  Can you please verify that the problem goes away if
you have pavucontrol running?  There's also another problem with xmms.
The current version of ossp blocks mixer commands till the r/w
commands are complete and this makes xmms's UI stutter a bit.  I
modified osspd to lazy execute mixer commands while responding
immediately to the requester.  I'm testing it now and with pavucontrol
open, xmms works quite nicely.

Thanks.

-- 
tejun
--

From: Tejun Heo
Date: Friday, June 19, 2009 - 11:37 pm

Okay pushed v1.3 update to the git tree.

  git://git.kernel.org/pub/scm/linux/kernel/git/tj/ossp.git master
  http://git.kernel.org/?p=linux/kernel/git/tj/ossp.git;a=summary

Thanks.

-- 
tejun
--

From: Miklos Szeredi
Date: Tuesday, April 28, 2009 - 9:01 am

From the README:

| ALSA contains OSS emulation but sadly the emulation is behind
| multiplexing layer (which is in userland) which means that if your
| sound card doesn't support multiple audio streams, only either one of
| ALSA or OSS interface would be usable at any given moment.

This seems to imply (and I was hoping very much) that this won't be a
limitation of a CUSE based OSS Proxy.  But at the moment I'm finding
that while ossp is doing some playback other ALSA apps cannot start
playback and vice versa.

In fact if something else is playing though ALSA and I start a
playback through ossp, then ossp will print some errors, return EIO
and get into a bad state, that it recoveres from only by starting the
playback twice more (after stopping the other playback through ALSA).

ossp-padsp[mszeredi:24123]  ERR: pa_stream_write() failed (Connection terminated)
osspd  ERR: failed to read_fill 16 bytes from fd 7 (Connection reset by peer)
osspd WARN: S[1/24122] communication with slave failed (can't read reply: Connection reset by peer)
E: socket-client.c: socket(): Address family not supported by protocol
E: context.c: waitpid(): No child processes
ossp-padsp[mszeredi:24130]  ERR: failed to connect context, state=5 (Bad state)

Thanks,
Miklos
--

From: Takashi Iwai
Date: Tuesday, April 28, 2009 - 9:42 am

At Tue, 28 Apr 2009 18:01:08 +0200,

Are you using pulse plugin for ALSA, too?
Looks like ossp tries the pulseaudio.  If you are using the native
ALSA, of course it'll block the access by PA...


--

From: Miklos Szeredi
Date: Tuesday, April 28, 2009 - 10:17 am

alsa-plugins-pulse package is installed.  How can I find out if ALSA
is actually using this plugin?

What is the disadvantage of non-native ALSA vs. native ALSA?

Thanks,
Miklos
--

From: Takashi Iwai
Date: Tuesday, April 28, 2009 - 12:32 pm

At Tue, 28 Apr 2009 19:17:14 +0200,

For example, if you start aplay with -v option, it'll show the plugins

Well, the question is rather whether you need PA or not...


Takashi
--

From: Miklos Szeredi
Date: Tuesday, April 28, 2009 - 1:12 pm

OK, it doesn't.  So I have to tweak some config files to make it use
this plugin...

...done.  Well, now things do work, but the sound quality is very
crappy when PA is mixing two or more streams together (loud cracking

Yes, OSSP needs it.  So the question (to Tejun) is why does OSSP use
libpulse API instead of libalsa API?

The former seems to be much more mature and easier to configure than
the latter.

Thanks,
Miklos
--

From: Takashi Iwai
Date: Tuesday, April 28, 2009 - 2:34 pm

At Tue, 28 Apr 2009 22:12:18 +0200,

Or because of older version of PA.  The one in SUSE Factory (or some
OBS repo), version 0.9.14 or newer, might improve it.


Takashi
--

From: Miklos Szeredi
Date: Wednesday, April 29, 2009 - 12:13 am

OK, 0.9.14 is much better than 0.9.12.  Thanks for the help.

Miklos
--

From: Tejun Heo
Date: Tuesday, April 28, 2009 - 4:35 pm

Hello, Miklos.


Which version are you using, it got better and then worse and then

On default installation of any recent major distros, PA is the default
and ALSA via PA is the default too, so the configuration doesn't
matter at all.  I think PA is the way to go (all other guys are
already there) && we're past the point of no return at this point &&
it's nicer to program to and has some features I wanted (per-pgrp
volume for example), so...

Thanks.

-- 
tejun
--

From: Miklos Szeredi
Date: Wednesday, April 29, 2009 - 12:20 am

If distros are committed to making PA the default, and ALSA through PA
doesn't have any major disadvatnages then it sounds like a perfect
solution to everything.

The fact that OpenSUSE-11.1 is not there yet just made me think this
problem is worse than it really is.

Thanks,
Miklos
--

From: Tejun Heo
Date: Wednesday, April 29, 2009 - 12:46 am

SL111 is configured to use PA by default and works just fine (sans
bugs of course).  Even SL110 was fine from configuration POV although
there were more bugs.  I have no idea why ALSA via PA took explicit
configuration on your machine.

Thanks.

-- 
tejun
--

Previous thread: md (regression): reboot/shutdown hangs by Alistair John Strachan on Thursday, August 28, 2008 - 12:05 pm. (2 messages)

Next thread: Re: [Bugme-new] [Bug 11446] New: Automate "to compile as module" strings by Andrew Morton on Thursday, August 28, 2008 - 12:38 pm. (1 message)