VirtualBox

Ticket #10695 (new defect)

Opened 22 months ago

Last modified 18 months ago

[PATCH] OSS Audio driver uses wrong volume for recording, making recording in guest practically impossible if it is used

Reported by: Y.K. Owned by:
Priority: minor Component: audio
Version: VirtualBox 4.1.16 Keywords: audio oss recording
Cc: Guest type: all
Host type: other

Description (last modified by frank) (diff)

When recording in guest while OSS audio driver is used, nothing is recieved. This affects the FreeBSD and Solaris hosts, and also Linux hosts under certain configurations.

src/VBox/Devices/Audio/ossaudio.c includes the following:

#ifndef VBOX

hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift,

&nominal_volume);

#else

hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift,

&pcm_in_volume);

#endif

VBox is usually defined when compiling, so pcm_in_volume is used. But pcm_in_volume is almost never set (it's set by the AUD_set_volume() method which is almost never called - only the SB16 driver calls it [The ICH driver also has it, but under an #ifdef which is not usually defined]). So pcm_in_volume is zero, and programs on the guest recieve nothing at all...

The suggested fix is to do like most other audio drivers (ALSA and Pulse's drivers come to mind) and use nominal_volume exclusively. The patch below has been tested and fixes the problem on my end and for another user. Note that some other drivers use pcm_in_volume (solaudio.c and dsoundaudio.c) and may require this change as well.

--- ossaudio.c.old	2012-06-22 23:29:17.854555530 +0300
+++ ossaudio.c	2012-06-22 23:38:53.797799295 +0300
@@ -795,13 +795,8 @@
                            hw->info.align + 1);
                 }
                 read_samples += nread >> hwshift;
-#ifndef VBOX
                 hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift,
                           &nominal_volume);
-#else
-                hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift,
-                          &pcm_in_volume);
-#endif
             }
 
             if (bufs[i].len - nread) {

Attachments

ossaudio.diff Download (573 bytes) - added by Y.K. 22 months ago.
Recording fix patch for ossaudio.c

Change History

Changed 22 months ago by Y.K.

Recording fix patch for ossaudio.c

comment:1 Changed 18 months ago by frank

  • Description modified (diff)

Your observation is partly correct. It is true that other backends use the nominal_volume rather than the pcm_in_volume. But it is not true that pcm_in_volume is not changed. It is set in DevIchAc97 using set_volume(s, index, AUD_MIXER_LINE_IN, u32) and this just corresponds to the line-in mixer of the guest. The current behavior is that with OSS, the line-in mixer has to be set accordingly to get a proper recording volume. This is not necessary with other backends. I have to think what's the correct solution here.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use