Bug 208570 - multimedia/qt5-multimedia: ALSA aliases not supported
Summary: multimedia/qt5-multimedia: ALSA aliases not supported
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (Team)
URL: https://reviews.freebsd.org/D13992
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-06 09:17 UTC by Stephen Hurd
Modified: 2018-01-20 13:03 UTC (History)
6 users (show)

See Also:
rakuco: maintainer-feedback+


Attachments
Patch adding ALSA alises to the available devices. (1.58 KB, patch)
2016-04-06 09:17 UTC, Stephen Hurd
no flags Details | Diff
Patch adding ALSA alises to the available devices. (1.97 KB, patch)
2016-04-06 18:06 UTC, Stephen Hurd
no flags Details | Diff
Test application (364 bytes, text/plain)
2016-06-13 09:53 UTC, groot
no flags Details
Patch as submitted upstream (3.40 KB, patch)
2016-06-19 05:26 UTC, Stephen Hurd
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Hurd freebsd_committer 2016-04-06 09:17:44 UTC
Created attachment 169029 [details]
Patch adding ALSA alises to the available devices.

When using ALSA with FreeBSD, the direct snd_device instances are not available, only plugin devices and "default".  For programs which use QAudio, this means there are *no* devices enumerated using QAudio::availableDevices().

The attached patch adds the aliases to the available device list.
Comment 1 Stephen Hurd freebsd_committer 2016-04-06 18:06:12 UTC
Created attachment 169043 [details]
Patch adding ALSA alises to the available devices.

Update with unified diff.
Comment 2 Raphael Kubo da Costa freebsd_committer 2016-04-13 15:46:50 UTC
Does that code also work on Linux? It looks like something that should be reviewed upstream before we start shipping on FreeBSD.
Comment 3 Stephen Hurd freebsd_committer 2016-04-14 18:37:32 UTC
(In reply to Raphael Kubo da Costa from comment #2)

It should, but I'm not in a position to test it.
Comment 4 Raphael Kubo da Costa freebsd_committer 2016-04-14 18:43:56 UTC
OK. In any case, I think the best course of action is to submit it upstream via Gerrit (see https://wiki.qt.io/Qt_Contribution_Guidelines and https://wiki.qt.io/Gerrit_Introduction) so that the Qt folks can take a look at this and also make check if it works fine on Linux.
Comment 5 Stephen Hurd freebsd_committer 2016-04-15 02:36:32 UTC
Submitted to upstream Gerrit...

https://codereview.qt-project.org/155883
Comment 6 Stephen Hurd freebsd_committer 2016-04-21 07:01:58 UTC
Upstream patch greatly simplified...
Comment 7 Jan Beich freebsd_committer 2016-05-01 03:17:05 UTC
ports r414376 may help enumerating pcm devices. "default" is still recommended due to implicit sample format conversion.

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
oss
    Open Sound System
Comment 8 groot 2016-06-13 09:53:33 UTC
Created attachment 171369 [details]
Test application

Here is a test-application showing what QAudioDeviceInfo::availableDevices() shows. It just prints out the names of the devices that are found.

Compile it with:

c++ -o audiolist -fPIC -std=c++11  -I /usr/local/include/qt5  -L /usr/local/lib/ -lQt5Multimedia  -lQt5Core  audiolist.cpp  

(once qt5-multimedia is installed)
Comment 9 groot 2016-06-13 10:09:33 UTC
What is the problem that is being solved here, and what role does ALSA (aplay) have here? For instance, I have a 10-STABLE machine here, with Qt 5.5.1 installed, and alsa-utils-1.1.1.

This is the output of aplay -L:

null
    Discard all samples (playback) or generate zero samples (capture)
oss
    Open Sound System

This is the output of my test application:

AUDIO "oss"
AUDIO "default"

With the patch applied, this is the output:

AUDIO "oss"
AUDIO "oss"
AUDIO "default"

Yes, that's an extra line of "oss". This does not seem to be an improvement.

My /dev/sndstat is this:
pcm0: <Realtek (0x0900) (Rear Analog 7.1/2.0)> (play/rec) default
pcm1: <Realtek (0x0900) (Front Analog)> (play/rec)
pcm2: <Realtek (0x0900) (Onboard Digital)> (play)
pcm3: <Intel (0x2809) (HDMI/DP 8ch)> (play)

Is there some configuration that I would need to do to find these devices either with aplay or with the patched Qt5Multimedia?
Comment 10 Jan Beich freebsd_committer 2016-06-13 12:42:52 UTC
(In reply to groot from comment #9)
> My /dev/sndstat is this:
> pcm0: <Realtek (0x0900) (Rear Analog 7.1/2.0)> (play/rec) default
> pcm1: <Realtek (0x0900) (Front Analog)> (play/rec)
> pcm2: <Realtek (0x0900) (Onboard Digital)> (play)
> pcm3: <Intel (0x2809) (HDMI/DP 8ch)> (play)
>
> Is there some configuration that I would need to do to find these devices
> either with aplay or with the patched Qt5Multimedia?

Only natively[1], better fall back to "default" PCM. 4Front OSS on Linux (e.g. oss4-dkms on Debian) likely has similar issue.

  $ aplay -l
  aplay: device_list:273: no soundcards found...

In-kernel ALSA (i.e. hw:X,Y) exists only on Linux, other systems are limited to userland. OSS from alsa-plugins lacks support for MIDI sequencer, selecting/enumerating devices and probably more. Unlike OpenBSD (sndio) we don't have anyone actively working on adding OSSv4 support in ports/ tree.

[1] http://manuals.opensound.com/developer/SNDCTL_CARDINFO.html (see example)
Comment 11 Stephen Hurd freebsd_committer 2016-06-19 05:14:43 UTC
(In reply to groot from comment #9)

> Is there some configuration that I would need to do to find these devices
> either with aplay or with the patched Qt5Multimedia?

You can create aliases in your ~/.asoundrc... here's mine:

pcm.envy24 {
        type oss
        device /dev/dsp0
}
pcm.mb_rear {
        type oss
        device /dev/dsp4
}
pcm.mb_front {
        type oss
        device /dev/dsp5
}
pcm.ts940 {
        type oss
        device /dev/dsp6
}
ctl.envy24 {
        type oss
        device /dev/mixer0
}
ctl.mb_rear {
        type oss
        device /dev/mixer4
}
ctl.mb_front {
        type oss
        device /dev/mixer5
}
ctl.ts940 {
        type oss
        device /dev/mixer6
}
Comment 12 Stephen Hurd freebsd_committer 2016-06-19 05:25:37 UTC
Using the test application and the current upstream patch, I get this:

AUDIO "default"
AUDIO "envy24"
AUDIO "mb_rear"
AUDIO "mb_front"
AUDIO "ts940"
Comment 13 Stephen Hurd freebsd_committer 2016-06-19 05:26:23 UTC
Created attachment 171561 [details]
Patch as submitted upstream

Adding the currently submitted upstream patch.
Comment 14 Adrian Chadd freebsd_committer 2017-07-15 19:19:32 UTC
hi!

Is it possible to get this committed to our ports repository until the upstream issues are resolved? Otherwise right now we can't easily use multiple sound devices in QT multimedia applications w/ multiple sound cards, like wsjtx.

Thanks!


-adrian
Comment 15 Walter Schwarzenfeld freebsd_triage 2018-01-18 16:31:14 UTC
Any news here?
Comment 16 Adrian Chadd freebsd_committer 2018-01-18 20:48:39 UTC
Hi,

this has been lagging for too long.

I'd like to commit this in 48 hours to unblock things so we can at least get SOME useful behaviour on qt5-multimedia until we get a more comprehensive upstream support plan.
Comment 17 Adriaan de Groot freebsd_committer 2018-01-19 23:01:30 UTC
See review; patch run through makepatch, and dropped one hunk that is no longer needed.
Comment 18 commit-hook freebsd_committer 2018-01-20 12:45:33 UTC
A commit references this bug:

Author: adridg
Date: Sat Jan 20 12:45:13 UTC 2018
New revision: 459518
URL: https://svnweb.freebsd.org/changeset/ports/459518

Log:
  Allow ALSA aliases in the Qt5 sound devices list.

  Patch by Stephen Hurd, seems to be ignored upstream. The new patch describes
  what it does and why it is needed.

  PR:		208570
  Submitted by:	Stephen Hurd
  Reported by:	Stephen Hurd
  Approved by:	tcberner (mentor)
  Differential Revision:	https://reviews.freebsd.org/D13992

Changes:
  head/multimedia/qt5-multimedia/Makefile
  head/multimedia/qt5-multimedia/files/patch-src_plugins_alsa_qalsaaudiodeviceinfo.cpp
Comment 19 Adriaan de Groot freebsd_committer 2018-01-20 13:03:32 UTC
Applied to current Qt 5.9.3 port. Thanks Adrian for prodding.