Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Nov 2013 18:47:13 GMT
From:      Jan Beich <jbeich@tormail.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/184006: [patch] audio/alsa-lib: convert FLOAT samples automatically
Message-ID:  <201311151847.rAFIlD3Q050619@oldred.freebsd.org>
Resent-Message-ID: <201311151850.rAFIo0xU037918@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         184006
>Category:       ports
>Synopsis:       [patch] audio/alsa-lib: convert FLOAT samples automatically
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 15 18:50:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Jan Beich
>Release:        
>Organization:
>Environment:
https://bugzilla.mozilla.org/show_bug.cgi?id=780531
http://www.opensound.com/wiki/index.php/Tips_And_Tricks#ALSA_Emulation

>Description:
Some apps (e.g. linux-firefox with ports/169896) don't check with ALSA
which sample formats are supported and just feed whatever they like,
assuming the underlying device supports it.

While here also fix mixer device for OSS plugin. It should be /dev/dsp
according to 4Front OSS wiki. The only works with ARIFF_OSS enabled
but the volume is reset on close(). audio/oss doesn't work either way:
the new (OSSv4) way to control mixer is via SNDCTL_MIX_* ioctls.

>How-To-Repeat:
# audio/oss is too broken to care
$ mixer
$ amixer
ctl_oss: MIXER_CAPS error: Invalid argument

# without patch
$ amixer
ALSA lib simple_none.c:1549:(simple_add1) helem (MIXER,'Capture Volume',0,0,0) appears twice or more
amixer: Mixer default load error: Invalid argument

# with patch
$ amixer
Simple mixer control 'PCM',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 100
  Mono:
  Front Left: Playback 45 [45%]
  Front Right: Playback 45 [45%]
Simple mixer control 'Capture',0
  Capabilities: cvolume
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 100
  Front Left: Capture 45 [45%]
  Front Right: Capture 45 [45%]

# ARIFF_OSS disable, without patch
$ aplay -v a.wav
Playing WAVE 'a.wav' : Float 32 bit Little Endian, Rate 48000 Hz, Stereo
aplay: set_params:1244: Sample format non available
Available formats:
- U8
- S16_LE
- S16_BE
- MU_LAW

# ARIFF_OSS disable, with patch
$ aplay -v a.wav
Playing WAVE 'a.wav' : Float 32 bit Little Endian, Rate 48000 Hz, Stereo
Plug PCM: Linear Integer <-> Linear Float conversion PCM (S16_LE)
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : FLOAT_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 2097152
  period_size  : 524288
  period_time  : 10922666
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 524288
  period_event : 0
  start_threshold  : 2097152
  stop_threshold   : 2097152
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
Slave: ALSA <-> OSS PCM I/O Plugin
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 2097152
  period_size  : 524288
  period_time  : 10922666
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 524288
  period_event : 0
  start_threshold  : 2097152
  stop_threshold   : 2097152
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
^CAborted by signal Interrupt...

# ARIFF_OSS enabled, without patch
$ aplay -v a.wav
Playing WAVE 'a.wav' : Float 32 bit Little Endian, Rate 48000 Hz, Stereo
aplay: set_params:1244: Sample format non available
Available formats:
- S8
- U8
- S16_LE
- S16_BE
- U16_LE
- U16_BE
- S24_LE
- S24_BE
- U24_LE
- U24_BE
- S32_LE
- S32_BE
- U32_LE
- U32_BE
- MU_LAW
- A_LAW
- S24_3LE
- S24_3BE
- U24_3LE
- U24_3BE
- S20_3LE
- S20_3BE
- U20_3LE
- U20_3BE
- S18_3LE
- S18_3BE
- U18_3LE
- U18_3BE

# ARIFF_OSS enabled, with patch
$ aplay -v foo.wav
Playing WAVE 'foo.wav' : Float 32 bit Little Endian, Rate 48000 Hz, Stereo
Plug PCM: Linear Integer <-> Linear Float conversion PCM (S32_LE)
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : FLOAT_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 16383
  period_size  : 4095
  period_time  : 85333
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 4095
  period_event : 0
  start_threshold  : 16383
  stop_threshold   : 16383
  silence_threshold: 0
  silence_size : 0
  boundary     : 9222809086901354496
Slave: ALSA <-> OSS PCM I/O Plugin
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
  format       : S32_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 16383
  period_size  : 4095
  period_time  : 85333
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 4095
  period_event : 0
  start_threshold  : 16383
  stop_threshold   : 16383
  silence_threshold: 0
  silence_size : 0
  boundary     : 9222809086901354496
^CAborted by signal Interrupt...

>Fix:
--- convert_float.diff begins here ---
Index: audio/alsa-lib/files/asound.conf.sample
===================================================================
--- audio/alsa-lib/files/asound.conf.sample	(revision 333423)
+++ audio/alsa-lib/files/asound.conf.sample	(working copy)
@@ -1,14 +1,21 @@
 #
 # FreeBSD/OSS
 #
+pcm_slave.oss {
+	pcm {
+		type oss
+		device /dev/dsp
+	}
+}
+
 pcm.!default {
-	type oss
-	device /dev/dsp
+	type plug
+	slave pcm_slave.oss
 }
 
 ctl.!default {
 	type oss
-	device /dev/mixer
+	device /dev/dsp
 }
 
 #
@@ -15,28 +22,28 @@ ctl.!default {
 # Remap all possible surround stuffs.
 #
 pcm.!surround40 {
-	type oss
-	device /dev/dsp
+	type plug
+	slave pcm_slave.oss
 }
 
 pcm.!surround41 {
-	type oss
-	device /dev/dsp
+	type plug
+	slave pcm_slave.oss
 }
 
 pcm.!surround50 {
-	type oss
-	device /dev/dsp
+	type plug
+	slave pcm_slave.oss
 }
 
 pcm.!surround51 {
-	type oss
-	device /dev/dsp
+	type plug
+	slave pcm_slave.oss
 }
 
 pcm.!surround71 {
-	type oss
-	device /dev/dsp
+	type plug
+	slave pcm_slave.oss
 }
 
 #
--- convert_float.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311151847.rAFIlD3Q050619>