Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 613980 - >=www-client/firefox-52: Add support for media-sound/apulse
Summary: >=www-client/firefox-52: Add support for media-sound/apulse
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Mozilla Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-27 00:02 UTC by Zdeněk Žamberský
Modified: 2017-06-01 20:51 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
firefox-52-eclass-remove-duplicit-pulseaudio-dependency.patch (firefox-52-eclass-remove-duplicit-pulseaudio-dependency.patch,517 bytes, patch)
2017-04-22 16:02 UTC, Zdeněk Žamberský
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdeněk Žamberský 2017-03-27 00:02:31 UTC
As firefox 52 dropped alsa support you could consider adding apulse flag to firefox-bin pakcage. This would allow using apulse library as an alternative to pulseaudio as a sound backend for firefox on alsa-only system. Something similar is already possible for net-im/skype package.

It would require following changes (in ebuild):
1. add apulse flag
2. add conditional dependency on media-sound/apulse ( if apulse flag is set )
3. change last command in /usr/bin/firefox-bin script to: exec apulse /opt/firefox/firefox "$@" ( if apulse flag is set )

I have already tried to do the change to /usr/bin/firefox-bin script as mentioned higher ( installed package ) and it fixed problem with missing sound in firefox-bin-52.0.1 on alsa-only system.


Reproducible: Always
Comment 1 Arfrever Frehtes Taifersar Arahesis 2017-03-28 04:09:19 UTC
Potentially useful also for www-client/firefox (which provides /usr/bin/firefox symlink which could be replaced by a simple script).
Comment 2 Zdeněk Žamberský 2017-04-12 23:13:50 UTC
As description of bug was changed to also include non binary firefox , I thought I could say few things to that.

First of all while adding apulse support to firefox-bin is relatively strait forward, doing the same for regular firefox could be much more problematic. (This is also why I originally created bug just for firefox-bin.)

Issue is, when building from source, we need header files and dynamic libraries, which we want to build against. Howerver media-sound/apulse package is not just drop-in replacement (full alternative) for media-sound/pulseaudio. Currently apulse package does not contain header files and installs itself in a way, that it is normally not found by linker (apulse subdir in /usr/lib [2]).

There are some options to solve these problems coming to my mind, but none of them is without issues.

1. Leave media-sound/pulseaudio as build-time dependency. With alsa-plugin flag disabled, it should be installable alongside media-sound/apulse ( btw. alsa-plugin is to make alsa-lib use pulseaudio and therefore preventing programs bypassing pulseaudio ). First problem is, that pulseaudio still needs to be installed (even if not otherwise used => its server remains disabled). Another problem could be that some programs may want to use this "dummy" pulseaudio library, which could break audio in such programs. For example, as I understand it, google chrome uses pulseaudio as preferred backend and alsa as fallback [1]. ( But I did not actually tested such scenario. )

2. Add flag to media-sound/apulse to install pulseaudio header files. They are present in apulse sources in 3rdparty directory [3]. ( File collisions would need to be avoided by forbidding installation of media-sound/pulseaudio, when flag is selected or placing them to another dir or something... ). Compiler flags for firefox would then need to be modified to use these headers and to link against apulse libraries (which are not on default path), and make sure they are found by dynamic linker on runtime (don't know how difficult this would be).

3. Transforming media-sound/apulse to regular alternative (drop-in replacement) to media-sound/pulseaudio (by installing its libraries (and headers) directly in place of pulseaudio's). However this is problematic because apulse does not fully implement pulseaudio libraries. And programs which prefer pulseaudio to alsa (as mentioned higher), would use "incomplete" apulse library instead of alsa backend ( See [1] [2] ). This problem could became less serious in future as apulse improves over time and adds fixes for more programs.


This is of course not firefox specific issue. Adding support for apulse to any other package, which is built from source, would need to face these issues (but I don't know about any other).

[1] https://github.com/i-rinat/apulse/issues/15
[2] https://bugs.gentoo.org/show_bug.cgi?id=529098
[3] https://github.com/i-rinat/apulse
Comment 3 Zdeněk Žamberský 2017-04-12 23:35:49 UTC
Add to 1.
I also don't know if some desktop environments wouldn't want to start pulseaudio as part of user session, when it is installed, since system wide server is not normally recommended [1]. But that's just baseless apprehension. I don't have much experience with pulseaudio, so I don't know.

[1] https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/
Comment 4 Ian Stakenvicius (RETIRED) gentoo-dev 2017-04-13 01:44:52 UTC
Since we have bug 615000 for the specific firefox-bin usage of apulse, I'm going to make this one for the full source package, especially since the discussion is related a lot more to that and what happens when alsa support no longer works.
Comment 5 Arfrever Frehtes Taifersar Arahesis 2017-04-13 12:40:30 UTC
(In reply to Zdeněk Žamberský from comment #2)

For now, I suggest to make media-sound/apulse install headers to another directory (not colliding with media-sound/pulseaudio) and pass -I${path_to_that_directory} to compiler when building www-client/firefox.
Comment 6 Ian Stakenvicius (RETIRED) gentoo-dev 2017-04-13 12:47:11 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #5)
> (In reply to Zdeněk Žamberský from comment #2)
> 
> For now, I suggest to make media-sound/apulse install headers to another
> directory (not colliding with media-sound/pulseaudio) and pass
> -I${path_to_that_directory} to compiler when building www-client/firefox.

This would be entirely up to the apulse maintainers but I don't think apulse should be installing headers at all.  I will be landing commits as part of the firefox-52.0.2 bump that will require media-video/pulseaudio at compile time but not runtime, so any user that doesn't want to use pulseaudio can still do so with apulse, while still building and linking firefox against the API it's meant to be built against.
Comment 7 Ian Stakenvicius (RETIRED) gentoo-dev 2017-04-14 02:25:35 UTC
media-sound/apulse is added as of today with firefix-52.0.2 in the gentoo repo.  Note that it is not automatically used, it is likely still better to stick with alsa if you don't want to use the full pulseaudio.

There is a version on the mozilla overlay that contains an attempt at making the apulse libs available to firefox but it's not ready yet IMO for the main tree.  I likely won't bring it in until alsa stops working.

I'll keep this bug in-progress until apulse is a drop-in pulseaudio replacement at runtime.
Comment 8 Zdeněk Žamberský 2017-04-22 16:01:08 UTC
Btw, I have noticed, that you probably accidentally added pulseaudio/apulse twice to RDEPEND in mozconfig-v6.52.eclass. Once directly in RDEPEND and then again lower using RDEPEND+=... . But I don't think it affects anything other than readability though... :)
Comment 9 Zdeněk Žamberský 2017-04-22 16:02:38 UTC
Created attachment 470674 [details, diff]
firefox-52-eclass-remove-duplicit-pulseaudio-dependency.patch
Comment 10 Arfrever Frehtes Taifersar Arahesis 2017-04-29 03:17:35 UTC
Please make code synchronized between various ebuilds.
E.g. firefox-52.1.0::gentoo contains:
if use pulseaudio && [ -d "${EROOT}"usr/$(get_libdir)/apulse ] ; then

While firefox-53.0::gentoo contains:
if use pulseaudio && [ -d "${EPREFIX}"/usr/$(get_libdir)/apulse ] ; then


Additional message is present in pkg_postinst() in firefox-53.0::gentoo, but is absent in firefox-52.1.0::gentoo.


For checking if media-sound/apulse is installed, please use has_version() function. Example:
if use pulseaudio && has_version media-sound/apulse; then


In that loop in pkg_preinst(), please ${EROOT} instead of just ${EPREFIX}:
for lib in "${EROOT}"usr/$(get_libdir)/apulse/libpulse* ; do


Currently absolute symlinks are created. Please make them relative:
ln -rs "${lib}" || die
    ^
Comment 11 Arfrever Frehtes Taifersar Arahesis 2017-04-29 03:24:07 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #10)
> Currently absolute symlinks are created. Please make them relative:
> ln -rs "${lib}" || die

It will not work, since at that time current directory is in ${ED} instead of ${EROOT}. Maybe the following will work:
ln -s "../apulse/${lib##*/}" || die
Comment 12 Ian Stakenvicius (RETIRED) gentoo-dev 2017-04-29 16:49:00 UTC
commit 19e2bb19b7e61a15fcf2b840ac5e7520cc282fc3
Author: Ian Stakenvicius <axs@gentoo.org>
Date:   Sat Apr 29 12:45:58 2017 -0400

    www-client/firefox: improve and unify apulse support
    
    Create relative symlinks to a defined set of apulse libs instead of
    iterating over what libraries are installed on disk and using absolute
    symlinks.  Also sync the code between 52.1 and 53.0 ebuilds
    
    Bug: http://bugs.gentoo.org/613980