Bug 300853

Summary: phonon-vlc ignores vlc.conf
Product: [Frameworks and Libraries] phonon-backend-vlc Reporter: Franz Trischberger <franz.trischberger>
Component: generalAssignee: Harald Sitter <sitter>
Status: VERIFIED FIXED    
Severity: normal CC: bcooksley, fabo, jb, martin.sandsmark, myriam
Priority: NOR    
Version: unspecified   
Target Milestone: 0.5.1   
Platform: unspecified   
OS: Linux   
See Also: https://trac.videolan.org/vlc/ticket/6900
Latest Commit: Version Fixed In: 0.6
Sentry Crash Report:
Attachments: Add a Default OSS-Device manually
vlc-oss.patch

Description Franz Trischberger 2012-05-30 08:44:42 UTC
I configured vlc to use oss. Works great. But not with phonon-vlc - it wants to load alsa.
I watched the strace-output, and discovered it would like to load "~/.config/Phonon/vlc.conf". I copied over my vlcrc (renamed to vlc.conf, of course), but that still does not work; vlc tries to load alsa, which fails as there are no devices.
I am using vlc-2.0.1. Problem exists with phonon-4.6.0, phonon-vlc-0.5.0 and phonon-vlc-git.

Reproducible: Always
Comment 1 Harald Sitter 2012-05-30 13:58:09 UTC
Phonon has its own sound settings. To get OSS to show there you'll need to entirely disable PulseAudio.
Comment 2 Franz Trischberger 2012-05-30 14:24:31 UTC
I don't even have pulseaudio installed. I now started with a completely fresh user. Setup phonon to use vlc-backend, logout, login, test sound -> vlc still wants to take alsa.

Where should I look at?
Comment 3 Harald Sitter 2012-05-30 14:38:03 UTC
systemsettings
Comment 4 Franz Trischberger 2012-05-30 15:04:59 UTC
:D Where? I only can chose the backend and the devices - but none of the devices listed are working:
* Default
* Discard all samples (playback) or generate zero samples (capture)
Is there some hidden button for extended configuration, where I can explicitly say "oss, please!"?
Comment 5 Harald Sitter 2012-05-30 18:56:05 UTC
might be that you have to remove the kde platform plugin for phonon, that most likely takes preference over the backend dependent listing.

    QList<QByteArray> knownSoundSystems;
    knownSoundSystems << "alsa" << "oss";
Comment 6 Franz Trischberger 2012-05-31 06:51:26 UTC
Tried different things:
I installed vlc without alsa-support -> device list is empty.
I renamed /usr/lib64/kde4/plugins/phonon_platform -> I get back a default-device - which uses phonon-gstreamer instead of vlc, although vlc is selected as preferred backend.
So I uninstalled phonon-gstreamer, leaving an empty device list :(

I also tried with most recent vlc from git, without success.
I am using oss4 (also latest mercurial), linux-3.4.0 (with gentoo-patchset) if that matters.
Comment 7 Franz Trischberger 2012-05-31 09:59:14 UTC
Seems as if vlc does not like to be started with --aout==dummy, when running with oss. I removed the line in libvlc.cpp, and I get sound :D
But still the devices list in systemsettings is empty.
Comment 8 Franz Trischberger 2012-06-01 07:21:55 UTC
simple test-programm:

#include <iostream>
#include <vlc/vlc.h>
#include <cstdio>
using namespace std;

int main() {
    libvlc_instance_t* libvlc = libvlc_new(0,0);
    libvlc_audio_output_t *first = libvlc_audio_output_list_get(libvlc);
    for( libvlc_audio_output_t *aout = first; aout; aout = aout->p_next) {
        char const* ss_nm = aout->psz_name;
        const int dev_cnt = libvlc_audio_output_device_count(libvlc, ss_nm);
        cout << ss_nm << " offers devices: " << dev_cnt << endl;
    }
    libvlc_audio_output_list_release(first);
}

output (I reenabled alsa in vlc):
alsa offers devices: 2
oss offers devices: 0
aout_file offers devices: 0
adummy offers devices: 0
amem offers devices: 0

So this is eather a problem in vlc, or in oss4.
Comment 9 Franz Trischberger 2012-06-01 12:45:53 UTC
I reported this upstream:
https://trac.videolan.org/vlc/ticket/6900
Comment 10 Franz Trischberger 2012-06-03 07:03:50 UTC
Created attachment 71529 [details]
Add a Default OSS-Device manually

Upstream says, that device_count of 0 is valid. So populating the devices by device_count won't work (at least for oss, JACK, Pulse). The patch attached adds an OSS-Device manually.
I hardcoded idName and longName to "/dev/dsp" and "Default OSS", because I don't know the vlc-API and if there is a function to determine if the user configured to use something else.

But another problem remains: I need to compile vlc without alsa-support, because if phonon-vlc recognizes the availability of alsa, it seems to discard any other sound system. Is there a way to determine, which sound system the user runs? Check the existence of /dev/oss \ /dev/snd \ /dev/dsp? As there are only alsa and oss (->knownSoundSystems) to be checked, I think this won't be too difficult.
Comment 11 Franz Trischberger 2012-06-03 08:31:44 UTC
> Check the existence of /dev/oss \ /dev/snd \ /dev/dsp? As there are
> only alsa and oss (->knownSoundSystems) to be checked, I think this won't be
> too difficult. 

The attached patch checks for existence of /dev/dsp and /dev/snd/ and sets 
preferredSoundSystem accordingly. The debug()-statements would better be 
QMessageBoxes or system notifications.
I tested it on two computers, one running alsa, the other one oss4, both with 
vlc-support for alsa and oss, both having no problem to set up working 
devices.
Comment 12 Franz Trischberger 2012-06-03 08:31:44 UTC
Created attachment 71531 [details]
vlc-oss.patch
Comment 13 Franz Trischberger 2012-06-03 10:27:29 UTC
Thinking about the solution, emulation came in my mind. alsa can emulate oss-devices, so the existance of /dev/dsp also could mean that alsa is running with oss-emulation turned on. I did not look at alsa-emulation in oss, but I know it exists.
So to see if native oss is running, a check for /proc/opensound/ is more meaningful (/proc/asound for native alsa).

>>> QDir("/proc/asound").exists()
False
>>> QDir("/proc/opensound").exists()
True

The question that remains is whether to offer the user to chose those emulated devices ("OSS Emulation" if /proc/asound and /dev/dsp exist).

If you like the approach, I can modify the patch. If you don't just tell me how it would be done better :)
Comment 14 Harald Sitter 2012-06-03 21:49:23 UTC
Please verify that current pvlc master fixes the issue, we don't have setups to test that sort of stuff.
Comment 15 Franz Trischberger 2012-06-04 06:35:08 UTC
(In reply to comment #14)
> Please verify that current pvlc master fixes the issue, we don't have setups
> to test that sort of stuff.

Yes, it works (after changing the preferred device to oss). Thanks for the fix!