Discussion:
Broken ALSA surround sound with OpenALSoft 1.12 and newer
Martin Egge
2012-02-24 13:44:10 UTC
Permalink
Hi,

I've discovered a problem with OpenALSoft 1.12 and newer on my Ubuntu Linux
11.04 Natty. If I configure OpenAL to use the ALSA device surround51 [1] and
run my sample application [2] I get the following error:

Using device: ALSA Software
AL lib: alsa.c:743: set buffer time near failed: Invalid argument
Error: Could not create the audio context!
Error: Audio format not supported (more the 2 channels)
AL lib: ALc.c:1879: exit(): closing 1 Device


Everything is fine with OpenALSoft 1.11 and older.


Has anyone an idea, what to do?


Greetz,
Martin


[1] www.fh-wedel.de/~eg/files/alsoft.conf
[2] www.fh-wedel.de/~eg/files/main.cpp
Chris Robinson
2012-02-25 00:40:52 UTC
Permalink
On Friday, February 24, 2012 2:44:10 PM Martin Egge wrote:
> Hi,
>
> I've discovered a problem with OpenALSoft 1.12 and newer on my Ubuntu Linux
> 11.04 Natty. If I configure OpenAL to use the ALSA device surround51 [1] and
> run my sample application [2] I get the following error:
>
> Using device: ALSA Software
> AL lib: alsa.c:743: set buffer time near failed: Invalid argument
> Error: Could not create the audio context!
> Error: Audio format not supported (more the 2 channels)
> AL lib: ALc.c:1879: exit(): closing 1 Device

I really wish I knew why the snd_pcm_hw_params_set_*_near functions can fail
from an unsupported value. Both the function name and the documentation
suggest it'll select the value nearest to the request, meaning the only reason
it could fail is if there's no supported value (otherwise there has to be a
value nearest to the target, regardless of how different it actually is). But
I know that's not the case.

> Everything is fine with OpenALSoft 1.11 and older.
>
>
> Has anyone an idea, what to do?

You can try modifying the 'periods' setting in alsoft.conf. The default is 4,
but you can try setting it to 2 or 3 to reduce the buffer size.

Out of curiousity, what audio hardware do you have? ALSA's surround51 device
will use hardware access, meaning nothing else will be able to access the
device unless it supports hardware mixing. If it doesn't support hardware
mixing, it may be worthwhile to define a dmix device for 5.1 output (I can
provide examples for this if you need).
Martin Egge
2012-02-27 10:00:20 UTC
Permalink
Hello Chris,

Am Samstag, 25. Februar 2012, 01:40:52 schrieb Chris Robinson:
> On Friday, February 24, 2012 2:44:10 PM Martin Egge wrote:
> > I've discovered a problem with OpenALSoft 1.12 and newer on my Ubuntu
> > Linux 11.04 Natty. If I configure OpenAL to use the ALSA device
> > surround51 [1] and run my sample application [2] I get the following
> > error:
> >
> > Using device: ALSA Software
> > AL lib: alsa.c:743: set buffer time near failed: Invalid argument
> > Error: Could not create the audio context!
> > Error: Audio format not supported (more the 2 channels)
> > AL lib: ALc.c:1879: exit(): closing 1 Device
>
> I really wish I knew why the snd_pcm_hw_params_set_*_near functions can
> fail from an unsupported value. Both the function name and the
> documentation suggest it'll select the value nearest to the request,
> meaning the only reason it could fail is if there's no supported value
> (otherwise there has to be a value nearest to the target, regardless of
> how different it actually is). But I know that's not the case.
>
> > Everything is fine with OpenALSoft 1.11 and older.

What has changed beetween 1.11 and 1.12 and might have broken the 5.1 output
here?

> > Has anyone an idea, what to do?
>
> You can try modifying the 'periods' setting in alsoft.conf. The default is
> 4, but you can try setting it to 2 or 3 to reduce the buffer size.

That didn't change anything.

> Out of curiousity, what audio hardware do you have?

Output of lspci -vv

07:00.0 Multimedia audio controller: Creative Labs CA0106 Soundblaster
Subsystem: Creative Labs SB0410 SBLive! 24-bit
Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr-
Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort-
<TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 64 (500ns min, 5000ns max)
Interrupt: pin A routed to IRQ 10
Region 0: I/O ports at ec00 [size=32]
Capabilities: [dc] Power Management version 2
Flags: PMEClk- DSI+ D1+ D2+ AuxCurrent=0mA
PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Kernel driver in use: CA0106
Kernel modules: snd-ca0106


> ALSA's surround51
> device will use hardware access, meaning nothing else will be able to
> access the device unless it supports hardware mixing. If it doesn't
> support hardware mixing, it may be worthwhile to define a dmix device for
> 5.1 output (I can provide examples for this if you need).

Yes, please send me an example.


Greetz,
Martin
Chris Robinson
2012-02-27 11:27:15 UTC
Permalink
On Monday, February 27, 2012 11:00:20 AM Martin Egge wrote:
> What has changed beetween 1.11 and 1.12 and might have broken the 5.1 output
> here?

The only related thing that changed is that, instead of setting the number of
periods and the period size in sample frames (or the nearest possible; the
buffer size is then inferred from period_size * periods), it sets the buffer
size and period size in microseconds (or the nearest possible; periods is then
inferred from buffer_size / period_size) so that it better scales if the
sample rate was changed.

I don't see any reason for the changes to cause a failure, though. The
functions snd_pcm_hw_params_set_buffer_time_near and
snd_pcm_hw_params_set_period_time_near are supposed to set values closest to
what the device is capable of.

> > You can try modifying the 'periods' setting in alsoft.conf. The default is
> > 4, but you can try setting it to 2 or 3 to reduce the buffer size.
>
> That didn't change anything.

What about setting 'mmap' to 'false' under the [alsa] section?

Do you have a ~/.alsoftrc (and if so, what's in it)?

> > Out of curiousity, what audio hardware do you have?
>
> Output of lspci -vv
>
> 07:00.0 Multimedia audio controller: Creative Labs CA0106 Soundblaster
> Subsystem: Creative Labs SB0410 SBLive! 24-bit

Okay, so you have a real sound card. Pretty sure that does hardware mixing, so
you don't need dmix.

> Yes, please send me an example.

I've attached an /etc/asound.conf I use to define a 'dmix6' device. It plays
back at 48khz and has an 18ms period size and 90ms buffer size, and accepts
CARD, DEV, and SUBDEV arguments similar the the default dmix.
Martin Egge
2012-02-27 13:11:22 UTC
Permalink
Hi Chris,

Am Montag, 27. Februar 2012, 12:27:15 schrieb Chris Robinson:
> On Monday, February 27, 2012 11:00:20 AM Martin Egge wrote:
> What about setting 'mmap' to 'false' under the [alsa] section?

That didn't change anything.

> Do you have a ~/.alsoftrc (and if so, what's in it)?

No, there's no ~/.alsoftrc and no /etc/asound.conf

> I've attached an /etc/asound.conf I use to define a 'dmix6' device. It
> plays back at 48khz and has an 18ms period size and 90ms buffer size, and
> accepts CARD, DEV, and SUBDEV arguments similar the the default dmix.

With that file an device=dmix6 my openal application is running. But there is
only sound from the front speakers if I play a 5.1 WAV file. Same with
device=default

Greetz,
Martin
Chris Robinson
2012-02-27 14:18:36 UTC
Permalink
On Monday, February 27, 2012 2:11:22 PM Martin Egge wrote:
> With that file an device=dmix6 my openal application is running. But there
> is only sound from the front speakers if I play a 5.1 WAV file. Same with
> device=default

That's with the device=dmix6 under the alsa section and
format=AL_FORMAT_51CHN16? What app are you using to play the file?
m***@martin.egge.info
2012-02-28 09:02:32 UTC
Permalink
Hi Chris,

Am 2012-02-27 15:18, schrieb Chris Robinson:
> On Monday, February 27, 2012 2:11:22 PM Martin Egge wrote:
>> With that file an device=dmix6 my openal application is running. But there
>> is only sound from the front speakers if I play a 5.1 WAV file. Same with
>> device=default

Sorry, I was wrong. The only missing output is the subwoofer output.
FL, FR, C, BL and BR are ok.

> That's with the device=dmix6 under the alsa section and
> format=AL_FORMAT_51CHN16?

That's right

> What app are you using to play the file?

I'm using my simple demo application
(http://www.fh-wedel.de/~eg/files/main.cpp)


Greetz,
Martin
Chris Robinson
2012-02-28 12:02:11 UTC
Permalink
On Tuesday, February 28, 2012 10:02:32 AM ***@martin.egge.info wrote:
> Sorry, I was wrong. The only missing output is the subwoofer output.
> FL, FR, C, BL and BR are ok.

OpenAL Soft doesn't explicitly generate an LFE signal. It will only output to
the LFE channel if playing a 5.1, 6.1, or 7.1 buffer that contains some data
for it. Otherwise, it relies on your hardware/speakers to play something on
the subwoofer.

Does the wave file contain some audio on the LFE channel? Is it possible to
put it up somewhere for me to check? I tried your program using the
fiveptone.wav found in Creative's SDK and it worked here, LFE and all.
m***@martin.egge.info
2012-02-28 13:35:42 UTC
Permalink
Hi Chris,

Am 2012-02-28 13:02, schrieb Chris Robinson:
> On Tuesday, February 28, 2012 10:02:32 AM
> ***@martin.egge.info wrote:
>> Sorry, I was wrong. The only missing output is the subwoofer output.
>> FL, FR, C, BL and BR are ok.
>
> OpenAL Soft doesn't explicitly generate an LFE signal. It will only
> output to
> the LFE channel if playing a 5.1, 6.1, or 7.1 buffer that contains some data
> for it. Otherwise, it relies on your hardware/speakers to play something on
> the subwoofer.
>
> Does the wave file contain some audio on the LFE channel? Is it possible to
> put it up somewhere for me to check? I tried your program using the
> fiveptone.wav found in Creative's SDK and it worked here, LFE and all.

I did some tests with
http://seeautz-projekt1.googlecode.com/svn/trunk/seeautz/Additional%20Libraries/OpenAL%201.1%20SDK/samples/media/fiveptone.wav

Results:
OpenAL 1.11.753 and surround51: everything ok
OpenAL 1.11.753 and dmix6: no LFE sound

OpenAL 1.12.854 and surround51: alsa.c:743: set buffer time near
failed: Invalid argument
OpenAL 1.11.753 and dmix6: no LFE sound


Greetz,
Martin
Chris Robinson
2012-03-01 15:24:15 UTC
Permalink
On Tuesday, February 28, 2012 2:35:42 PM ***@martin.egge.info wrote:
> I did some tests with
> http://seeautz-projekt1.googlecode.com/svn/trunk/seeautz/Additional%20Librar
> ies/OpenAL%201.1%20SDK/samples/media/fiveptone.wav
>
> Results:
> OpenAL 1.11.753 and surround51: everything ok
> OpenAL 1.11.753 and dmix6: no LFE sound
>
> OpenAL 1.12.854 and surround51: alsa.c:743: set buffer time near
> failed: Invalid argument
> OpenAL 1.11.753 and dmix6: no LFE sound

Double-check to make sure dmix6 specifies 'channels 6', and not 'channels 5'
or something. Other than that, I don't know. What alsa-plugins version do you
have?

For surround51, perhaps you could try setting 'period_size = 884' in
alsoft.conf. That will give a nice round 20000us, as opposed to the
23219.955us that 1024 gives.
Martin Egge
2012-03-13 13:22:22 UTC
Permalink
Hi Chris,

I just got back from vacation.

Am Donnerstag, 1. März 2012, 16:24:15 schrieb Chris Robinson:
> Double-check to make sure dmix6 specifies 'channels 6', and not 'channels
> 5' or something. Other than that, I don't know.

I'm using the dmix6 definition you send me two weeks ago. It specifies
'channels 6'.

> What alsa-plugins version do you have?

It's the version shipped with Ubuntu 11.04. So it should be alsa 1.0.24.

> For surround51, perhaps you could try setting 'period_size = 884' in
> alsoft.conf. That will give a nice round 20000us, as opposed to the
> 23219.955us that 1024 gives.


That doesn't change anything.


Greetz,
Martin
Loading...