text: Ticket #10695 (closed defect: obsolete)
  [PATCH] OSS Audio driver uses wrong volume for recording, making recording in guest practically impossible if it is used
  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
  Change History
  Changed 4 years ago by Y.K.
  - attachment ossaudio.diff
  added
  comment:1 Changed 4 years ago by frank
  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.
  comment:2 Changed 4 months ago by aeichner
  - Status changed from new to closed
  - Resolution set to obsolete
  Please reopen if still relevant with a recent VirtualBox release.
  Recording fix patch for ossaudio.c