VirtualBox

Changeset 355 in vbox for trunk


Ignore:
Timestamp:
Jan 26, 2007 2:14:21 PM (18 years ago)
Author:
vboxsync
Message:

activated soft volume mixing

Location:
trunk/src/VBox/Devices/Audio
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r332 r355  
    4040
    4141#undef LOG_VOICES
     42#ifndef VBOX
    4243//#define USE_MIXER
     44#else
     45#define USE_MIXER
     46#endif
    4347
    4448#define AC97_SSM_VERSION 1
     
    7983};
    8084
     85#ifndef VBOX
    8186#define SOFT_VOLUME
     87#else
     88#undef  SOFT_VOLUME
     89#endif
    8290#define SR_FIFOE BIT(4)          /* rwc, fifo error */
    8391#define SR_BCIS  BIT(3)          /* rwc, buffer completion interrupt status */
     
    499507    rvol = VOL_MASK - ((VOL_MASK * rvol) / 255);
    500508    lvol = VOL_MASK - ((VOL_MASK * lvol) / 255);
     509
     510#ifdef VBOX
     511    /*
     512     * From AC'97 SoundMax Codec AD1981A: "Because AC '97 defines 6-bit volume registers, to
     513     * maintain compatibility whenever the D5 or D13 bits are set to `1,' their respective
     514     * lower five volume bits are automatically set to `1' by the Codec logic. On readback,
     515     * all lower 5 bits will read ones whenever these bits are set to `1.'"
     516     *
     517     *  Linux ALSA depends on this behavior.
     518     */
     519    if (val & BIT(5))
     520        val |= BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0);
     521    if (val & BIT(13))
     522        val |= BIT(12) | BIT(11) | BIT(10) | BIT(9) | BIT(8);
     523#endif
     524
    501525    mixer_store (s, index, val);
    502526}
  • trunk/src/VBox/Devices/Audio/audio.c

    r1 r355  
    133133};
    134134
     135#ifdef VBOX
     136volume_t pcm_out_volume =
     137{
     138    0,
     139    UINT_MAX,
     140    UINT_MAX
     141};
     142#endif
     143
    135144/* http://www.df.lth.se/~john_e/gems/gem002d.html */
    136145/* http://www.multi-platforms.com/Tips/PopCount.htm */
     
    885894    swlim = audio_MIN (swlim, samples);
    886895    if (swlim) {
     896#ifndef VBOX
    887897        sw->conv (sw->buf, buf, swlim, &sw->vol);
     898#else
     899        sw->conv (sw->buf, buf, swlim, &pcm_out_volume);
     900#endif
    888901    }
    889902
     
    16991712        }
    17001713    }
     1714}
     1715
     1716void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol)
     1717{
     1718    if (sw)
     1719    {
     1720        sw->vol.mute = mute;
     1721        sw->vol.l    = (uint32_t)lvol * 0x808080; /* maximum is INT_MAX = 0x7fffffff */
     1722        sw->vol.r    = (uint32_t)rvol * 0x808080; /* maximum is INT_MAX = 0x7fffffff */
     1723    }
     1724}
     1725
     1726void AUD_set_volume (audmixerctl_t mt, int *mute, uint8_t *lvol, uint8_t *rvol)
     1727{
     1728    volume_t *vol = NULL;
     1729    const char *name;
     1730
     1731    switch (mt)
     1732    {
     1733        case AUD_MIXER_VOLUME:
     1734            name = "MASTER";
     1735            vol = &pcm_out_volume;
     1736            break;
     1737        case AUD_MIXER_PCM:
     1738            name = "PCM_OUT";
     1739            break;
     1740        case AUD_MIXER_LINE_IN:
     1741            name = "LINE_IN";
     1742            break;
     1743        default:
     1744            return;
     1745
     1746    }
     1747
     1748    if (vol)
     1749    {
     1750        vol->mute  = *mute;
     1751        vol->l     = ((uint32_t)*lvol) * 0x808080; /* maximum is INT_MAX = 0x7fffffff */
     1752        vol->r     = ((uint32_t)*rvol) * 0x808080; /* maximum is INT_MAX = 0x7fffffff */
     1753    }
     1754#if 0
     1755    LogRel(("AUDIO: Set '%s' volume to %d%%/%d%%\n", name, (*lvol*100)/255, (*rvol*100)/255l));
     1756#endif
     1757}
     1758
     1759void AUD_set_record_source (audrecsource_t *ars, audrecsource_t *als)
     1760{
     1761    LogRel(("AUDIO: set_record_source ars=%d als=%d (not implemented)\n", *ars, *als));
    17011762}
    17021763
  • trunk/src/VBox/Devices/Audio/audio.h

    r1 r355  
    5555    AUD_CNOTIFY_DISABLE
    5656} audcnotification_e;
     57
     58typedef enum
     59{
     60    AUD_MIXER_VOLUME,
     61    AUD_MIXER_PCM,
     62    AUD_MIXER_LINE_IN
     63} audmixerctl_t;
     64
     65typedef enum
     66{
     67    AUD_REC_MIC,
     68    AUD_REC_CD,
     69    AUD_REC_VIDEO,
     70    AUD_REC_AUX,
     71    AUD_REC_LINE_IN,
     72    AUD_REC_PHONE
     73} audrecsource_t;
    5774
    5875struct audio_capture_ops {
     
    141158uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
    142159
     160void AUD_set_volume_out (SWVoiceOut *po, int mute, uint8_t lvol, uint8_t rvol);
     161void AUD_set_volume (audmixerctl_t mt, int *mute, uint8_t *lvol, uint8_t *rvol);
     162void AUD_set_record_source (audrecsource_t *ars, audrecsource_t *als);
     163
    143164static inline void *advance (void *p, int incr)
    144165{
     
    159180    __typeof (b) tb = b;                        \
    160181    ((ta)>(tb)?(tb):(ta));                      \
    161 }))
     182 }))
    162183
    163184#define audio_MAX(a, b) ( __extension__ ({      \
     
    165186    __typeof (b) tb = b;                        \
    166187    ((ta)<(tb)?(tb):(ta));                      \
    167 }))
     188 }))
    168189#else
    169190#define audio_MIN(a, b) ((a)>(b)?(b):(a))
  • trunk/src/VBox/Devices/Audio/audio_int.h

    r1 r355  
    2626
    2727#ifdef CONFIG_COREAUDIO
     28#ifndef VBOX
    2829#define FLOAT_MIXENG
     30#else
     31#undef  FLOAT_MIXENG
     32#endif
    2933/* #define RECIPROCAL */
    3034#endif
  • trunk/src/VBox/Devices/Audio/mixeng.c

    r1 r355  
    2828#include "audio.h"
    2929#include <iprt/alloc.h>
     30#ifdef VBOX
     31#include <iprt/asm.h>
     32#endif
    3033
    3134#define AUDIO_CAP "mixeng"
    3235#include "audio_int.h"
    3336
     37#ifndef VBOX
    3438#define NOVOL
     39#endif
    3540
    3641/* 8 bit */
  • trunk/src/VBox/Devices/Audio/mixeng.h

    r1 r355  
    2727struct HWVoiceOut;
    2828
     29#ifdef VBOX
     30/* use faster ASMMult2xS32RetS64 */
     31typedef struct { int mute;  uint32_t r; uint32_t l; } volume_t;
     32typedef struct { int64_t l; int64_t r; } st_sample_t;
     33#else /* !VBOX */
    2934#ifdef FLOAT_MIXENG
    3035typedef float real_t;
     
    3540typedef struct { int64_t l; int64_t r; } st_sample_t;
    3641#endif
     42#endif /* VBOX */
    3743
    3844typedef void (t_sample) (st_sample_t *dst, const void *src,
  • trunk/src/VBox/Devices/Audio/mixeng_template.h

    r1 r355  
    3535#define VOL(a, b) a
    3636#else
     37#ifdef VBOX
     38#ifdef SIGNED
     39#define VOL(a, b) ((ASMMult2xS32RetS64(a, b) >> 31))
     40#else
     41#define VOL(a, b) ((ASMMult2xU32RetU64(a, b) >> 31))
     42#endif
     43#else /* !VBOX */
    3744#ifdef FLOAT_MIXENG
    3845#define VOL(a, b) ((a) * (b))
     
    4148#endif
    4249#endif
     50#endif /* !VBOX */
    4351
    4452#define ET glue (ENDIAN_CONVERSION, glue (_, IN_T))
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette