Bug 101944

Summary: Pulseaudio doesn't list all devices profiles that are listed by alsa
Product: PulseAudio Reporter: Stéphane <mathojojo>
Component: alsaAssignee: pulseaudio-bugs
Status: RESOLVED NOTABUG QA Contact: pulseaudio-bugs
Severity: major    
Priority: medium CC: lennart
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: picture of alsa available profiles in deadbeef

Description Stéphane 2017-07-27 08:07:14 UTC
Hello,

I have an USB M-Audio sound device : M-Audio Fasttrack Ultra.

When I type the command : pacmd list-cards

    index: 2
        name: <alsa_card.usb-M-Audio_Fast_Track_Ultra-00>
        driver: <module-alsa-card.c>
        owner module: 8
        properties:
                alsa.card = "1"
                alsa.card_name = "Fast Track Ultra"
                alsa.long_card_name = "M-Audio Fast Track Ultra at usb-0000:23:00.3-1, high speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:23:00.3-usb-0:1:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:07.1/0000:23:00.3/usb3/3-1/3-1:1.0/sound/card1"
                udev.id = "usb-M-Audio_Fast_Track_Ultra-00"
                device.bus = "usb"
                device.vendor.id = "0763"
                device.vendor.name = "Midiman"
                device.product.id = "2080"
                device.product.name = "M-Audio RunTime DFU"
                device.serial = "M-Audio_Fast_Track_Ultra"
                device.string = "1"
                device.description = "M-Audio RunTime DFU"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        profiles:
                input:multichannel-input: Multicanal Entrée (priority 1, available: unknown)
                output:analog-surround-71: Analog Surround 7.1 Sortie (priority 700, available: unknown)
                output:analog-surround-71+input:multichannel-input: Analog Surround 7.1 Sortie + Multicanal Entrée (priority 701, available: unknown)
                off: Éteint (priority 0, available: unknown)
        active profile: <output:analog-surround-71+input:multichannel-input>
        sinks:
                alsa_output.usb-M-Audio_Fast_Track_Ultra-00.analog-surround-71/#1: M-Audio RunTime DFU Analog Surround 7.1
        sources:
                alsa_output.usb-M-Audio_Fast_Track_Ultra-00.analog-surround-71.monitor/#2: Monitor of M-Audio RunTime DFU Analog Surround 7.1
        ports:
                multichannel-input: Multichannel Input (priority 0, latency offset 0 usec, available: unknown)
                        properties:

                analog-output: Sortie analogique (priority 9900, latency offset 0 usec, available: unknown)
                        properties:


So, for outputs I can only choose between Analog-surround-7, Analog-surround-71+input and off

If I list the alsa devices, I get :

Output devices:
  sysdefault:CARD=Ultra          - Fast Track Ultra, USB Audio - Default Audio Device
  front:CARD=Ultra,DEV=0         - Fast Track Ultra, USB Audio - Front speakers
  surround21:CARD=Ultra,DEV=0    - Fast Track Ultra, USB Audio - 2.1 Surround output to Front and Subwoofer speakers
  surround40:CARD=Ultra,DEV=0    - Fast Track Ultra, USB Audio - 4.0 Surround output to Front and Rear speakers
  surround41:CARD=Ultra,DEV=0    - Fast Track Ultra, USB Audio - 4.1 Surround output to Front, Rear and Subwoofer speakers
  surround50:CARD=Ultra,DEV=0    - Fast Track Ultra, USB Audio - 5.0 Surround output to Front, Center and Rear speakers
  surround51:CARD=Ultra,DEV=0    - Fast Track Ultra, USB Audio - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
  surround71:CARD=Ultra,DEV=0    - Fast Track Ultra, USB Audio - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
  iec958:CARD=Ultra,DEV=0        - Fast Track Ultra, USB Audio - IEC958 (S/PDIF) Digital Audio Output
  dmix:CARD=Ultra,DEV=0          - Fast Track Ultra, USB Audio - Direct sample mixing device
  dsnoop:CARD=Ultra,DEV=0        - Fast Track Ultra, USB Audio - Direct sample snooping device
  hw:CARD=Ultra,DEV=0            - Fast Track Ultra, USB Audio - Direct hardware device without any conversions
  plughw:CARD=Ultra,DEV=0        - Fast Track Ultra, USB Audio - Hardware device with all software conversions
  sysdefault:CARD=U0x46d0x8ad    - USB Device 0x46d:0x8ad, USB Audio - Default Audio Device
  front:CARD=U0x46d0x8ad,DEV=0   - USB Device 0x46d:0x8ad, USB Audio - Front speakers
  surround21:CARD=U0x46d0x8ad,DEV=0 - USB Device 0x46d:0x8ad, USB Audio - 2.1 Surround output to Front and Subwoofer speakers
  surround40:CARD=U0x46d0x8ad,DEV=0 - USB Device 0x46d:0x8ad, USB Audio - 4.0 Surround output to Front and Rear speakers
  surround41:CARD=U0x46d0x8ad,DEV=0 - USB Device 0x46d:0x8ad, USB Audio - 4.1 Surround output to Front, Rear and Subwoofer speakers
  surround50:CARD=U0x46d0x8ad,DEV=0 - USB Device 0x46d:0x8ad, USB Audio - 5.0 Surround output to Front, Center and Rear speakers
  surround51:CARD=U0x46d0x8ad,DEV=0 - USB Device 0x46d:0x8ad, USB Audio - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
  surround71:CARD=U0x46d0x8ad,DEV=0 - USB Device 0x46d:0x8ad, USB Audio - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
  iec958:CARD=U0x46d0x8ad,DEV=0  - USB Device 0x46d:0x8ad, USB Audio - IEC958 (S/PDIF) Digital Audio Output
  dmix:CARD=U0x46d0x8ad,DEV=0    - USB Device 0x46d:0x8ad, USB Audio - Direct sample mixing device
  dsnoop:CARD=U0x46d0x8ad,DEV=0  - USB Device 0x46d:0x8ad, USB Audio - Direct sample snooping device
  hw:CARD=U0x46d0x8ad,DEV=0      - USB Device 0x46d:0x8ad, USB Audio - Direct hardware device without any conversions
  plughw:CARD=U0x46d0x8ad,DEV=0  - USB Device 0x46d:0x8ad, USB Audio - Hardware device with all software conversions


So for my Fasttrack Ultra, i can choose between much more profiles :

Front , Surround 2.1, surround 4.0, Surround 4.1, Surround 5.0, Surround 5.1, Surround 7.1

It's a real problem for common use, like watching surround movies, cause I have only 2 speackers (L+R). As only selectable choice, 7.1 is selected, the differents chanels are sent to differents speackers, and I miss most of the sounds.

So I beg developpers to correct it, and make every alsa profiles detected and selectable.

Thank you.

I you need more info, I will give them (as long as I am able to do it)
Comment 1 Tanu Kaskinen 2017-07-27 18:54:56 UTC
Does "pasuspender -- speaker-test -Dfront:Ultra --channels=2" produce noise?

pasuspender will make pulseaudio not access the alsa devices while speaker-test runs, and speaker-test plays noise to each channel (in this case two channels) in turn. Since pulseaudio doesn't offer a stereo profile, I suspect that the "front" alsa device doesn't work at all.
Comment 2 Stéphane 2017-07-28 02:20:26 UTC
Created attachment 133084 [details]
picture of alsa available profiles in deadbeef
Comment 3 Stéphane 2017-07-28 02:27:09 UTC
(In reply to Tanu Kaskinen from comment #1)
> Does "pasuspender -- speaker-test -Dfront:Ultra --channels=2" produce noise?
> 
> pasuspender will make pulseaudio not access the alsa devices while
> speaker-test runs, and speaker-test plays noise to each channel (in this
> case two channels) in turn. Since pulseaudio doesn't offer a stereo profile,
> I suspect that the "front" alsa device doesn't work at all.

Thank you for your help.

Your command line doesn't work for me. It says :

"The Read device is front:Ultra
The Streams are set to 48000Hz, S16_LE, 2 channels
Using 16 octaves of 'pink noise'
The sample format is unavailable for playback : invalid argument
Failed to set device parameters : invalid argument"

In another hand, I'm used to listen to music with Deadbeef because this player allow me to select ALSA driver (and avoid Pulseaudio when I don't want any resampling and quality discrease). And there, I can select my front:ultra profile (see picture attachment), and it works very well.

The same for squeezelite player, I set it to use the front:Ultra profile, without any problem.

That's why I think the Front:Ultra profile exists and worksn but I don't know why your command fails, and why pulseaudio doesn't make it available.

(Another think I remember to add : In the past (maybe 3 years ago, maybe Ubuntu 14.04, but >I can't be sure now), all profiles were listed with the same Fasttrack Ultra soundcard, and it worked fine. SO.. something changed, but what ?)
Comment 4 Tanu Kaskinen 2017-07-31 03:10:01 UTC
(In reply to Stéphane from comment #3)
> The sample format is unavailable for playback : invalid argument

It looks like the S16_LE format is not supported by the card. Maybe PulseAudio is failing due to wrong format too? I would expect PulseAudio to switch to the correct format automatically, but maybe PA is not as smart as I think.

What does "aplay -Dfront:Ultra -f cd /dev/zero" print? I expect it to fail due to an unavailable format, and list the formats that are available.
Comment 5 Stéphane 2017-07-31 06:27:34 UTC
> It looks like the S16_LE format is not supported by the card. Maybe
> PulseAudio is failing due to wrong format too? I would expect PulseAudio to
> switch to the correct format automatically, but maybe PA is not as smart as
> I think.
> 
> What does "aplay -Dfront:Ultra -f cd /dev/zero" print? I expect it to fail
> due to an unavailable format, and list the formats that are available.


aplay -Dfront:Ultra -f cd /dev/zero
Lecture données brutes '/dev/zero' : Signed 16 bit Little Endian, Fréquence 44100 Hz, Stéréo
aplay: set_params:1233: Ce format d'échantillonage n'est pas disponible
Available formats:
- S24_3LE

Testing with :
"aplay -Dfront:Ultra -f S24_3LE -c7 -r48000 /dev/zero"

Lecture données brutes '/dev/zero' : Signed 24 bit Little Endian in 3bytes, Fréquence 48000 Hz, 7 Canaux
aplay: set_params:1239: Nombre de canaux non disponible

(the last line mean : Number of channels unavailable)

AND

Testing with :
"aplay -Dsurround71:Ultra -f S24_3LE -c7 -r48000 /dev/zero"

Lecture données brutes '/dev/zero' : Signed 24 bit Little Endian in 3bytes, Fréquence 48000 Hz, 7 Canaux

No error in this case.

So the problem might come from an undefined number of channels for all profiles, but surround71.

Is it possible to change that ? where ? (Pulseaudio, alsa, alsa driver snd-audio-usb ???).

I have the feeling the problem could be easy to resolve, but I may be wrong :).

Anyway, thank you for the help.
Comment 6 Stéphane 2017-07-31 07:55:19 UTC
I did a little mistake :

Testing with :
"aplay -Dfront:Ultra -f S24_3LE -c7 -r48000 /dev/zero"

Lecture données brutes '/dev/zero' : Signed 24 bit Little Endian in 3bytes, Fréquence 48000 Hz, 7 Canaux
aplay: set_params:1239: Nombre de canaux non disponible


I replace 7 channels with 2 channels (better for stereo profile):

Testing with :
"aplay -Dfront:Ultra -f S24_3LE -c2 -r48000 /dev/zero"

Lecture données brutes '/dev/zero' : Signed 24 bit Little Endian in 3bytes, Fréquence 48000 Hz, 2 Canaux
aplay: set_params:1239: Nombre de canaux non disponible

But the result is the same : Number of channels unavailable.
Comment 7 Tanu Kaskinen 2017-08-03 04:26:36 UTC
"front" is supposed to be a two-channel device, so either the driver is buggy when it rejects the configuration, or the alsa userspace configuration (that contains the "front" device definition) is buggy by claiming that the "front" device exists for this card.

The remaining mystery is how does deadbeef work? Can you play something with deadbeef using the "front" device, and during playback run this command:

cat /proc/asound/card*/pcm0p/sub0/hw_params

The asterisk is there because I don't know the card index. You can replace it with the correct index, but it doesn't matter much if you just use the asterisk. If all other sound cards are not being used, there will just be one or more lines saying "closed".
Comment 8 Stéphane 2017-08-03 21:15:50 UTC
So, your command :
cat /proc/asound/card*/pcm0p/sub0/hw_params

The output when selecting Front Speakers:

access: RW_INTERLEAVED
format: S24_3LE
subformat: STD
channels: 8
rate: 96000 (96000/1)
period_size: 1024
buffer_size: 8192

The output when selecting Surround71:

access: MMAP_INTERLEAVED
format: S24_3LE
subformat: STD
channels: 8
rate: 96000 (96000/1)
period_size: 1024
buffer_size: 8192

The only difference is with the access output (RW vs MMAP). I don't know what it means.
And the channels output is always 8. Weird for the front speaker profile, no ?

(I talked about deadbeef as an example, but I also use squeezelite which can use  alsa drivers directly without pulseausio as well. and it works too)

And the sound is fine in both case.
Comment 9 Tanu Kaskinen 2017-08-04 09:41:59 UTC
Ok, so deadbeef automatically falls back to using 8 channels when 2 channels doesn't work.

I'll close this as a NOTABUG. If you want, you can report a bug to the alsa developers about the "front" device being present even though it doesn't work (working with 8 channels doesn't count, because the definition of the "front" device is that it's a stereo device).
http://alsa-project.org/main/index.php/Bug_Tracking

You can create a stereo sink in pulseaudio by loading module-remap-sink:

pactl load-module module-remap-sink sink_name=my_stereo_sink master=MASTER_SINK_NAME channels=2 master_channel_map=front-left,front-right channel_map=front-left,front-right remix=no

Replace MASTER_SINK_NAME with the real name of the master sink.

You can put the load-module command in /etc/pulse/default.pa if you have the sound card always plugged in. If it's sometimes unplugged, you need to load the module manually, because pulseaudio doesn't currently provide a mechanism to automatically set up the remap sink when the USB sound card appears.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.