Bug 233301

Summary: emulators/virtualbox-ose - multimedia issues on 13-current
Product: Ports & Packages Reporter: andy
Component: Individual Port(s)Assignee: Virtualbox Team (Nobody) <vbox>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: Scoobi_doo, d8zNeCFG, david, grahamperrin, jc, kgc, lacey.leanne, lobo, osa, phd_kimberlite, rkoberman, robert.ayrapetyan, rozhuk.im, ruan, sv, swills, tony, transitive
Priority: --- Flags: bugzilla: maintainer-feedback? (vbox)
Version: Latest   
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
Screenshot of YouTube with KDE, Manjaro Linux
none
Screenshot of Vimeo with Lubuntu and with GhostBSD
none
patch which fixes logic error in DrvHostOSSAudio.cpp/ossStreamOpen
none
VBox DrvHostOSSAudio.cpp changes since 5.2.16
none
Reverting upstream revs r73370 r73529 r73689 r73695 r73696 r73838 and r76553
none
Patch for testing audio in guest OS
none
Port patch to fix OSS audio support none

Description andy 2018-11-18 19:50:12 UTC
FreeBSD FBSD_13 13.0-CURRENT FreeBSD 13.0-CURRENT #3 r340586: Sun Nov 18 14:13:13 EST 2018     root@FBSD_13:/usr/obj/usr/src/amd64.amd64/sys/MYKERNEL  amd64 1300003

virtualbox-ose-5.2.22          General-purpose full virtualizer for x86 hardware
virtualbox-ose-kmod-5.2.22     VirtualBox kernel module for FreeBSD

I had several virtual machines running on 12-current and all were working perfectly.  Now on 13-current there seems to be issues with multimedia.  Specifically videos do not play correctly.

Steps to repeat:
open Firefox 63.0.3 in a VM
go to youtube
try to play any video

Does it play successfully?

On the physical host I am able to successfully play any video with sound in Firefox.
Comment 1 Robert Cina 2018-12-13 14:42:54 UTC
I see a similar issue with virtualbox guests on FreeBSD 12 at the moment. As well as youtube videos not playing correctly for me I also don't have any audio.  I'd like to listen to spotify using a virtual machine guest but can't at the moment.  If anyone has any suggestions on what to try to fix this issue I'd be really appreciative. Thanks.
Comment 2 tony@accesslab.com 2019-01-30 20:47:03 UTC
I too have this problem on FreeBSD 12.0-RELEASE-p2. Virtualbox-ose-5.2.22_2 installed from pkg does not play sound inside any guests. Driver OSS is selected for the guest and sound works normally on the host itself, but will not produce any sound from inside the guests.
Comment 3 Eijiro Shibusawa 2019-02-13 09:32:18 UTC
I have similar problem too. I think that workaround to it is to install virtualbox from port and to use different sound server. Virtualbox-ose-5.2.26_1 with pulseaudio configuration works fine on my FreeBSD box (12.0-Release / amd64).
Comment 4 Graham Perrin freebsd_committer freebsd_triage 2019-04-13 08:38:34 UTC
Created attachment 203632 [details]
Screenshot of YouTube with KDE, Manjaro Linux
Comment 5 Graham Perrin freebsd_committer freebsd_triage 2019-04-13 08:42:00 UTC
Created attachment 203633 [details]
Screenshot of Vimeo with Lubuntu and with GhostBSD

Looking For Something on Vimeo
<https://vimeo.com/265045525>
Comment 6 Graham Perrin freebsd_committer freebsd_triage 2019-04-13 08:49:55 UTC
Comment on attachment 203632 [details]
Screenshot of YouTube with KDE, Manjaro Linux

First Image of a Black Hole! - YouTube
<https://www.youtube.com/watch?v=S_GVbuddri8>

Playback ceases before the advertisement ends; the main video does not begin.
Comment 7 Graham Perrin freebsd_committer freebsd_triage 2019-04-13 11:42:27 UTC
(In reply to Eijiro Shibusawa from comment #3)

> … I  think that workaround to it is to install virtualbox 
> from port and to use different sound server. … pulseaudio …

How might I do this with poudriere? 

I experimented with a couple of lines in 
/usr/local/poudriere/ports/default/emulators/virtualbox-ose/Makefile.local
but I guess that my lines were wrong, because the end result is still bugged by stalling after a moment's playback. 

----

grahamperrin@momh167-gjp4-8570p:~ % date ; uname -v
Sat 13 Apr 2019 11:23:39 BST
FreeBSD 13.0-CURRENT r346108 GENERIC-NODEBUG 
grahamperrin@momh167-gjp4-8570p:~ % poudriere jail -i -j head | grep -i version
Jail version:      13.0-CURRENT 1300018
grahamperrin@momh167-gjp4-8570p:~ %
Comment 8 Graham Perrin freebsd_committer freebsd_triage 2019-04-13 13:58:37 UTC
Sorry, ignore my previous comment. I had forgotten to switch from OSS Audio Driver to PulseAudio in host driver preferences for the guest. 

The end result _is_ good. 

Here's my Makefile.local, two lines:

PULSEAUDIO_CONFIGURE_OFF= 
BUILD_DEPENDS+= pulseaudio:audio/pulseaudio
Comment 9 Steve Wills freebsd_committer freebsd_triage 2019-07-10 10:52:29 UTC
I am experiencing this too, so I found this page and turned on the audio debugging it mentions:

https://www.virtualbox.org/wiki/AudioDebug

and in the logs, everything seems to be working, until it shows this:

00:00:18.694520 Audio: Stream '[OSSAudio] Output' could not be created in backend because of missing hardware / drivers

which seems to be from line 3110 of src/VBox/Devices/Audio/DrvAudio.cpp. This is because VERR_AUDIO_STREAM_COULD_NOT_CREATE is getting returned by ossStreamOpen in src/VBox/Devices/Audio/DrvHostOSSAudio.cpp, which sets rc = VERR_AUDIO_STREAM_COULD_NOT_CREATE at the top. This looks like a logic error. Setting rc = VINF_SUCCESS at the top of ossStreamOpen allows further progress.

But still there's no sound, it looks like we're hitting this assert:

    AssertMsgReturn(pCfgAcq->Backend.cfPreBuf <= pCfgAcq->Backend.cfBufferSize,
                    ("Acquired pre-buffering size must be smaller or as big as the buffer size\n"),
                    VERR_INVALID_PARAMETER);

in src/VBox/Devices/Audio/DrvAudio.cpp. I think there's some sort of buffering issue which I don't fully understand. If you play around with the buffer sizes in s_OSSConf in src/VBox/Devices/Audio/DrvHostOSSAudio.cpp you can get sound, but it's choppy and stops working, reporting lots of buffering issues and eventually stops. And that's as far as I've gotten right now. Perhaps someone else can pick it up and find what's going on or perhaps I'll come back to it at another time. I'll post the patch for now.
Comment 10 Steve Wills freebsd_committer freebsd_triage 2019-07-10 10:54:51 UTC
Created attachment 205654 [details]
patch which fixes logic error in DrvHostOSSAudio.cpp/ossStreamOpen

Here's the logic error patch.
Comment 11 Sergey A. Osokin freebsd_committer freebsd_triage 2019-07-11 02:59:54 UTC
Created attachment 205683 [details]
VBox DrvHostOSSAudio.cpp changes since 5.2.16

Hi there,

I've just dug a bit for changes in VBox releases related to the src/VBox/Devices/Audio/DrvAudio.cpp, looks pretty interesting.
Comment 12 Steve Wills freebsd_committer freebsd_triage 2019-07-11 12:51:31 UTC
(In reply to Sergey A. Osokin from comment #11)
Hey, thanks. It seems like those were part of some major changes of the audio stuff. I wonder if we should consider reverting upstream revs r73370 r73529 r73689 r73695 r73696 r73838 and r76553 and see what happens.
Comment 13 Sergey A. Osokin freebsd_committer freebsd_triage 2019-07-11 22:51:08 UTC
(In reply to Steve Wills from comment #12)
Hey Steve,

in a case to revert those revisions the patch looks smaller.
Are there anybody can try it and report?

Thanks in advance.
Comment 14 Sergey A. Osokin freebsd_committer freebsd_triage 2019-07-11 22:52:49 UTC
Created attachment 205706 [details]
Reverting upstream revs r73370 r73529 r73689 r73695 r73696 r73838 and r76553
Comment 15 Ivan Rozhuk 2019-09-16 22:50:17 UTC
(In reply to Sergey A. Osokin from comment #14)

/tmp/ports/usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.2.32/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp:160:21: error: no member named 'cBits' in 'PDMAUDIOPCMPROPS'
            pProps->cBits   = 8;
            ~~~~~~  ^
Comment 16 Ivan Rozhuk 2019-09-17 02:11:33 UTC
In log file:
00:00:07.070098 OSS: Failed to open /dev/dsp: Operation not supported (45)
00:00:07.070110 Audio: Creating stream '[OSSAudio] Line-In' returned an invalid backend configuration, skipping
00:00:07.070127 OSS: Failed to open /dev/dsp: Operation not supported (45)
00:00:07.070130 Audio: Creating stream '[OSSAudio] Mic-In' returned an invalid backend configuration, skipping
00:00:07.073913 AC97: Reset
Comment 17 Ivan Rozhuk 2019-09-17 02:52:04 UTC
Alsa
00:00:06.989808 ALSA: Using output device "default"
00:00:07.004405 ALSA: Failed to set period size 2400 (Invalid argument)
00:00:07.004472 ALSA: Using input device "default"
00:00:07.007188 ALSA: Failed to open "default" as input device: Operation not supported
00:00:07.007242 ALSA: Using input device "default"
00:00:07.010024 ALSA: Failed to open "default" as input device: Operation not supported
00:00:07.014107 AC97: Reset

(default snd device - HDMI out, so input err should ok)
Comment 18 kgc 2019-11-07 23:10:29 UTC
I'd really like to see this fixed too.  For various reasons I'd rather not have to pull in Pulseaudio and maintain local builds of Virtualbox.  If there's anything I can do to keep it moving along.
Comment 19 Andrey Russev 2020-05-23 23:32:56 UTC
Created attachment 214798 [details]
Patch for testing audio in guest OS

This patch solves the problem for me. Can somebody test it?
Comment 20 Mario Lobo 2020-05-24 17:24:25 UTC
I confirm that this patch works!

13.0-CURRENT FreeBSD 13.0-CURRENT #1 r360882
virtualbox-ose-5.2.42

Using OSS.
Comment 21 Eijiro Shibusawa 2020-05-26 03:17:48 UTC
(In reply to Andrey Russev from comment #19)
Hi, 

The patch solves the problem.
I built patched virtualbox-ose-5.2.34_4 by using poudriere.

For applying the patch in jail I used hook that is described the following page.
https://dan.langille.org/2019/08/10/poudriere-hooks/(In reply to Andrey Russev from comment #19)
Comment 22 Anthony Jenkins 2020-06-12 03:54:55 UTC
Adding my "works for me" comment. Even the microphone is picked up; now I can use Gotomeeting in FreeBSD from my Win10 VM!
Comment 23 rkoberman 2020-07-12 01:18:46 UTC
Created attachment 216400 [details]
Port patch to fix OSS audio support

Just tested on 12_Stable and the patched version works.

It's probably unrelated, but I an getting what sounds like static clicks or pops from a vinyl disk. Still, the audio is listenable and it has not been for some time.

I have attached a port patch for this that may be applied to the port in the standard fashion.
Comment 24 Martin Birgmeier 2020-07-12 08:30:13 UTC
The patch works also for resolving the (probably duplicate) bug #237472. See me comments there.

-- Martin
Comment 25 Serge Volkov 2020-08-14 15:49:24 UTC
Why wasn't this patch added to the virtualbox-ose-5.2.44 port? I had no sound in the FreeBSD 12.1 guest system. When I added this patch and recompiled the port, the sound appeared. My host system FreeBSD 12.1 RELEASE-p7 amd64. I wish this patch was added to the virtualbox-ose-5.2.44 port. This patch is working.
Comment 26 Graham Perrin freebsd_committer freebsd_triage 2020-09-22 05:01:16 UTC
I'm confused, how was this 'overcome by events'? 

Re: https://wiki.freebsd.org/Sound#Advanced I'm using virtual_oss and (for example) with Firefox 81 on the host computer media.cubeb.backend set to oss, I do get sound with OSS. However …

… no sound from the VirtualBox guests that are set to OSS Audio Driver. The misbehaviour is as observed when this bug was open; AV content will not play. 

grahamperrin@momh167-gjp4-8570p:~ % date ; uname -v
Tue 22 Sep 2020 05:59:29 BST
FreeBSD 13.0-CURRENT #64 r365364: Sun Sep  6 01:38:18 BST 2020     root@momh167-gjp4-8570p:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBU
grahamperrin@momh167-gjp4-8570p:~ % pkg info -x virtualbox
virtualbox-ose-5.2.44_1
virtualbox-ose-kmod-5.2.44_1
grahamperrin@momh167-gjp4-8570p:~ % pkg query '%o %v %R' virtualbox-ose virtualbox-ose-kmod
emulators/virtualbox-ose 5.2.44_1 FreeBSD
emulators/virtualbox-ose-kmod 5.2.44_1 poudriere
grahamperrin@momh167-gjp4-8570p:~ %
Comment 27 Mario Lobo 2020-09-23 17:51:51 UTC
Make sure that patch-src_VBox_Devices_Audio_DrvHostOSSAudio.cpp is in emulators/virtualbox-ose/files before compiling the port.
Comment 28 Graham Perrin freebsd_committer freebsd_triage 2020-09-25 03:26:28 UTC
(In reply to Graham Perrin from comment #26)

> I'm confused, how was this 'overcome by events'? 

I guess, this makes more sense if I view the symptoms i.e. comment 1 as resulting from more recent bug 237472 with this older bug 233301 as a _duplicate_ of 237472
Comment 29 Jean-Claude MICHOT 2020-09-25 23:25:34 UTC
patch-src_VBox_Devices_Audio_DrvHostOSSAudio.cpp
is unusable with 
% uname -a
FreeBSD flash2.usenet-fr.net 12.1-RELEASE-p6 FreeBSD 12.1-RELEASE-p6 GENERIC  amd64
and up-to-date port tree.
% grep ^PORTVERSION /usr/ports/emulators/virtualbox-ose/Makefile
PORTVERSION=    5.2.44

I have no audio in my FreeBSD virtualbox :(
Comment 30 Graham Perrin freebsd_committer freebsd_triage 2020-09-26 22:57:23 UTC
(In reply to Jean-Claude MICHOT from comment #29)

bug 237472