VirtualBox

Changeset 56085 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
May 26, 2015 4:39:58 PM (10 years ago)
Author:
vboxsync
Message:

PDM/Audio: Removed old audio architecture.

Location:
trunk/src/VBox/Devices/Audio
Files:
19 deleted
6 edited

Legend:

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

    r55920 r56085  
    3030
    3131#include "VBoxDD.h"
    32 
    33 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    34 # include "AudioMixer.h"
    35 #else
    36  extern "C" {
    37   #include "audio.h"
    38  }
    39 #endif
     32#include "AudioMixer.h"
    4033
    4134#ifdef LOG_GROUP
     
    6053
    6154#ifdef VBOX
    62 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    63 #  define SOFT_VOLUME /** @todo Get rid of this crap. */
    64 # else
    65 #  undef  SOFT_VOLUME
    66 # endif
     55# define SOFT_VOLUME /** @todo Get rid of this crap. */
    6756#else
    68 # define  SOFT_VOLUME
     57# define SOFT_VOLUME
    6958#endif
    7059
     
    211200typedef AC97BusMasterRegs *PAC97BMREG;
    212201
    213 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    214202typedef struct AC97INPUTSTREAM
    215203{
     
    264252    AC97OUTPUTSTREAM                   Out;
    265253} AC97DRIVER, *PAC97DRIVER;
    266 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    267254
    268255typedef struct AC97STATE
     
    280267    AC97BusMasterRegs       bm_regs[3];
    281268    uint8_t                 mixer_data[256];
    282 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    283269    /** The emulation timer for handling the attached
    284270     *  LUN drivers. */
     
    286272    /** Timer ticks for handling the LUN drivers. */
    287273    uint64_t                uTicks;
    288 # ifdef VBOX_WITH_STATISTICS
     274#ifdef VBOX_WITH_STATISTICS
    289275    STAMPROFILE             StatTimer;
    290276    STAMCOUNTER             StatBytesRead;
    291277    STAMCOUNTER             StatBytesWritten;
    292 # endif
     278#endif
    293279    /** List of associated LUN drivers. */
    294280    RTLISTANCHOR            lstDrv;
     
    301287    /** Audio sink for microphone input. */
    302288    R3PTRTYPE(PAUDMIXSINK)  pSinkMicIn;
    303 #else
    304     QEMUSoundCard           card;
    305     /** PCM in */
    306     SWVoiceIn              *voice_pi;
    307     /** PCM out */
    308     SWVoiceOut             *voice_po;
    309     /** Mic in */
    310     SWVoiceIn              *voice_mc;
    311 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    312289    uint8_t                 silence[128];
    313290    int                     bup_flag;
     
    370347#define GET_BM(a_idx)   ( ((a_idx) >> 4) & 3 )
    371348
    372 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    373349static DECLCALLBACK(void) ichac97Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);
    374350static int ichac97TransferAudio(PAC97STATE pThis, int index, uint32_t cbElapsed);
    375 #else
    376 static void ichac97OutputCallback(void *pvContext, int cbFree);
    377 static void ichac97InputCallback(void *pvContext, int cbAvail);
    378 static void ichac97MicInCallback(void *pvContext, int cbAvail);
    379 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    380351
    381352static void ichac97WarmReset(PAC97STATE pThis)
     
    464435    LogFlowFunc(("index=%d, on=%d\n", bm_index, on));
    465436
    466 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    467437    PAC97DRIVER pDrv;
    468438    switch (bm_index)
     
    490460            break;
    491461    }
    492 #else
    493     switch (bm_index)
    494     {
    495         case PI_INDEX: AUD_set_active_in( pThis->voice_pi, on); break;
    496         case PO_INDEX: AUD_set_active_out(pThis->voice_po, on); break;
    497         case MC_INDEX: AUD_set_active_in( pThis->voice_mc, on); break;
    498         default:       AssertFailed (); break;
    499     }
    500 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    501462}
    502463
     
    550511    int rc;
    551512
    552 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    553513    PAC97DRIVER pDrv;
    554514    uint8_t uLUN = 0;
     
    714674
    715675    AudioMixerInvalidate(pThis->pMixer);
    716 #else
    717     if (freq)
    718     {
    719         audsettings_t as;
    720         as.freq       = freq;
    721         as.nchannels  = 2;
    722         as.fmt        = AUD_FMT_S16;
    723         as.endianness = 0;
    724 
    725         switch (index)
    726         {
    727             case PI_INDEX: /* PCM in */
    728                 pThis->voice_pi = AUD_open_in(&pThis->card, pThis->voice_pi, "ac97.pi", pThis, ichac97InputCallback, &as);
    729 #ifdef LOG_VOICES
    730                 LogRel(("AC97: open PI freq=%d (%s)\n", freq, pThis->voice_pi ? "ok" : "FAIL"));
    731 #endif
    732                 rc = pThis->voice_pi ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
    733                 break;
    734 
    735             case PO_INDEX: /* PCM out */
    736                 pThis->voice_po = AUD_open_out(&pThis->card, pThis->voice_po, "ac97.po", pThis, ichac97OutputCallback, &as);
    737 #ifdef LOG_VOICES
    738                 LogRel(("AC97: open PO freq=%d (%s)\n", freq, pThis->voice_po ? "ok" : "FAIL"));
    739 #endif
    740                 rc = pThis->voice_po ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
    741                 break;
    742 
    743             case MC_INDEX: /* Mic in */
    744                 pThis->voice_mc = AUD_open_in(&pThis->card, pThis->voice_mc, "ac97.mc", pThis, ichac97MicInCallback, &as);
    745 #ifdef LOG_VOICES
    746                 LogRel(("AC97: open MC freq=%d (%s)\n", freq, pThis->voice_mc ? "ok" : "FAIL"));
    747 #endif
    748                 rc = pThis->voice_mc ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
    749                 break;
    750         }
    751     }
    752     else
    753     {
    754         switch (index)
    755         {
    756             case PI_INDEX:
    757                 AUD_close_in(&pThis->card, pThis->voice_pi);
    758                 pThis->voice_pi = NULL;
    759 #ifdef LOG_VOICES
    760                 LogRel(("AC97: Closing PCM IN\n"));
    761 #endif
    762                 break;
    763 
    764             case PO_INDEX:
    765                 AUD_close_out(&pThis->card, pThis->voice_po);
    766                 pThis->voice_po = NULL;
    767 #ifdef LOG_VOICES
    768                 LogRel(("AC97: Closing PCM OUT\n"));
    769 #endif
    770                 break;
    771 
    772             case MC_INDEX:
    773                 AUD_close_in(&pThis->card, pThis->voice_mc);
    774                 pThis->voice_mc = NULL;
    775 #ifdef LOG_VOICES
    776                 LogRel(("AC97: Closing MIC IN\n"));
    777 #endif
    778                 break;
    779         }
    780 
    781         rc = VINF_SUCCESS;
    782     }
    783 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    784676
    785677    LogFlowFuncLeaveRC(rc);
     
    795687    ichac97OpenStream(pThis, PI_INDEX, uFreq);
    796688
    797 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    798689    PAC97DRIVER pDrv;
    799690    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    800691        pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->LineIn.pStrmIn, fEnable);
    801 #else
    802     AUD_set_active_in(pThis->voice_pi, active[PI_INDEX]);
    803 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    804692
    805693    uFreq = ichac97MixerLoad(pThis, AC97_PCM_Front_DAC_Rate);
     
    809697    ichac97OpenStream(pThis, PO_INDEX, uFreq);
    810698
    811 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    812699    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    813700        pDrv->pConnector->pfnEnableOut(pDrv->pConnector, pDrv->Out.pStrmOut, fEnable);
    814 #else
    815     AUD_set_active_out(pThis->voice_po, active[PO_INDEX]);
    816 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    817701
    818702    uFreq = ichac97MixerLoad(pThis, AC97_MIC_ADC_Rate);
     
    822706    ichac97OpenStream(pThis, MC_INDEX, uFreq);
    823707
    824 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    825708    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    826709        pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->MicIn.pStrmIn, fEnable);
    827 #else
    828     AUD_set_active_in(pThis->voice_mc, active[MC_INDEX]);
    829 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    830 }
    831 
    832 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     710}
     711
    833712static void ichac97SetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL mt, uint32_t val)
    834 #else
    835 static void ichac97SetVolume(PAC97STATE pThis, int index, audmixerctl_t mt, uint32_t val)
    836 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    837713{
    838714    int mute = (val >> MUTE_SHIFT) & 1;
     
    856732
    857733#ifdef SOFT_VOLUME
    858 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    859734    if (pThis->pMixer) /* Device can be in reset state, so no mixer available. */
    860735    {
     
    882757        }
    883758    }
    884 # else /* !VBOX_WITH_PDM_AUDIO_DRIVER */
    885     if (index == AC97_Master_Volume_Mute)
    886         AUD_set_volume_out(pThis->voice_po, mute, lvol, rvol);
    887     else
    888         AUD_set_volume(mt, &mute, &lvol, &rvol);
    889 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    890 
    891 #else /* !SOFT_VOLUME */
    892     AUD_set_volume(mt, &mute, &lvol, &rvol);
    893759#endif /* SOFT_VOLUME */
    894760
     
    966832    RT_ZERO(pThis->mixer_data);
    967833
    968 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    969834    PAC97DRIVER pDrv;
    970 
    971835    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    972836    {
     
    1012876        AssertRC(rc2);
    1013877    }
    1014 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    1015878
    1016879    ichac97MixerStore(pThis, AC97_Reset                   , 0x0000); /* 6940 */
     
    1048911    }
    1049912    ichac97RecordSelect(pThis, 0);
    1050 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     913
    1051914    ichac97SetVolume(pThis, AC97_Master_Volume_Mute,  PDMAUDIOMIXERCTL_VOLUME,  0x8000);
    1052915    ichac97SetVolume(pThis, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_PCM,     0x8808);
    1053916    ichac97SetVolume(pThis, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8808);
    1054 # else
    1055     ichac97SetVolume(pThis, AC97_Master_Volume_Mute,  AUD_MIXER_VOLUME,  0x8000);
    1056     ichac97SetVolume(pThis, AC97_PCM_Out_Volume_Mute, AUD_MIXER_PCM,     0x8808);
    1057     ichac97SetVolume(pThis, AC97_Line_In_Volume_Mute, AUD_MIXER_LINE_IN, 0x8808);
    1058 # endif
    1059917
    1060918    /* Reset all streams. */
     
    1104962        PDMDevHlpPhysRead(pDevIns, addr, pThis->pvReadWriteBuf, cbToRead); /** @todo Check rc? */
    1105963
    1106 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1107964        uint32_t cbWritten;
    1108965
     
    1121978            LogFlowFunc(("\tLUN#%RU8: cbWritten=%RU32, cWrittenMin=%RU32\n", pDrv->uLUN, cbWritten, cbWrittenMin));
    1122979        }
    1123 #else
    1124         cbWrittenMin = AUD_write(pThis->voice_po, pThis->pvReadWriteBuf, cbToRead);
    1125 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
     980
    1126981        LogFlowFunc(("\tcbToRead=%RU32, cbWrittenMin=%RU32, cbToWrite=%RU32, cbLeft=%RU32\n",
    1127982                     cbToRead, cbWrittenMin, cbToWrite, cbToWrite - cbWrittenMin));
     
    11861041        while (cbToWrite)
    11871042        {
    1188 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    11891043            PAC97DRIVER pDrv;
    11901044            uint32_t cbWritten;
     
    11981052                cbWrittenMin = RT_MIN(cbWrittenMin, cbWritten);
    11991053            }
    1200 #else
    1201             cbWrittenMin = AUD_write(pThis->voice_po, pThis->silence, cbToWrite);
    1202 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    12031054
    12041055            if (!cbWrittenMin)
     
    12241075    int rc;
    12251076
    1226 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    12271077    /* Select audio sink to process. */
    12281078    PAUDMIXSINK pSink = (pReg - pThis->bm_regs) == MC_INDEX ? pThis->pSinkMicIn : pThis->pSinkLineIn;
     
    12631113
    12641114    return rc;
    1265 #else
    1266     rc = VINF_SUCCESS;
    1267 
    1268     uint32_t    addr = pReg->bd.addr;
    1269     uint32_t    temp = pReg->picb << 1;
    1270     uint32_t    nread = 0;
    1271     int         to_copy = 0;
    1272 
    1273     SWVoiceIn  *voice = (pReg - pThis->bm_regs) == MC_INDEX ? pThis->voice_mc : pThis->voice_pi;
    1274 
    1275     temp = audio_MIN(temp, (uint32_t)cbMax);
    1276     if (!temp)
    1277     {
    1278         *pcbRead = 0;
    1279         return VINF_EOF;
    1280     }
    1281 
    1282     uint8_t tmpbuf[4096];
    1283     while (temp)
    1284     {
    1285         int acquired;
    1286         to_copy = audio_MIN(temp, sizeof(tmpbuf));
    1287         acquired = AUD_read(voice, tmpbuf, to_copy);
    1288         if (!acquired)
    1289         {
    1290             rc = VERR_GENERAL_FAILURE; /* Not worth fixing anymore. */
    1291             break;
    1292         }
    1293         PDMDevHlpPCIPhysWrite(pDevIns, addr, tmpbuf, acquired);
    1294         temp  -= acquired;
    1295         addr  += acquired;
    1296         nread += acquired;
    1297     }
    1298 
    1299     pReg->bd.addr = addr;
    1300 
    1301     if (RT_SUCCESS(rc))
    1302         *pcbRead = nread;
    1303 
    1304     return rc;
    1305 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    1306 }
    1307 
    1308 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     1115}
     1116
    13091117static DECLCALLBACK(void) ichac97Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    13101118{
     
    13821190    STAM_PROFILE_STOP(&pThis->StatTimer, a);
    13831191}
    1384 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    13851192
    13861193static int ichac97TransferAudio(PAC97STATE pThis, int index, uint32_t cbElapsed)
     
    15171324    return rc;
    15181325}
    1519 
    1520 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
    1521 static void ichac97InputCallback(void *pvContext, int cbAvail)
    1522 {
    1523     ichac97TransferAudio((AC97STATE *)pvContext, PI_INDEX, cbAvail);
    1524 }
    1525 
    1526 static void ichac97MicInCallback(void *pvContext, int cbAvail)
    1527 {
    1528     ichac97TransferAudio((AC97STATE *)pvContext, MC_INDEX, cbAvail);
    1529 }
    1530 
    1531 static void ichac97OutputCallback(void *pvContext, int cbFree)
    1532 {
    1533     ichac97TransferAudio((AC97STATE *)pvContext, PO_INDEX, cbFree);
    1534 }
    1535 #endif
    15361326
    15371327/**
     
    19111701                    break;
    19121702                case AC97_Master_Volume_Mute:
    1913 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    19141703                    ichac97SetVolume(pThis, index, PDMAUDIOMIXERCTL_VOLUME, u32);
    1915 #else
    1916                     ichac97SetVolume(pThis, index, AUD_MIXER_VOLUME, u32);
    1917 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    19181704                    break;
    19191705                case AC97_PCM_Out_Volume_Mute:
    1920 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    19211706                    ichac97SetVolume(pThis, index, PDMAUDIOMIXERCTL_PCM, u32);
    1922 #else
    1923                     ichac97SetVolume(pThis, index, AUD_MIXER_PCM, u32);
    1924 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    19251707                    break;
    19261708                case AC97_Line_In_Volume_Mute:
    1927 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    19281709                    ichac97SetVolume(pThis, index, PDMAUDIOMIXERCTL_LINE_IN, u32);
    1929 #else
    1930                     ichac97SetVolume(pThis, index, AUD_MIXER_LINE_IN, u32);
    1931 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    19321710                    break;
    19331711                case AC97_Record_Select:
     
    20701848    uint8_t active[LAST_INDEX];
    20711849
    2072 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    20731850    PAC97DRIVER pDrv;
    20741851    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
     
    20801857        active[MC_INDEX] = pCon->pfnIsActiveIn (pCon, pDrv->MicIn.pStrmIn)  ? 1 : 0;
    20811858    }
    2082 #else
    2083     active[PI_INDEX] = AUD_is_active_in( pThis->voice_pi) ? 1 : 0;
    2084     active[PO_INDEX] = AUD_is_active_out(pThis->voice_po) ? 1 : 0;
    2085     active[MC_INDEX] = AUD_is_active_in( pThis->voice_mc) ? 1 : 0;
    2086 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    20871859
    20881860    SSMR3PutMem(pSSM, active, sizeof(active));
     
    21271899    ichac97RecordSelect(pThis, ichac97MixerLoad(pThis, AC97_Record_Select));
    21281900# define V_(a, b) ichac97SetVolume(pThis, a, b, ichac97MixerLoad(pThis, a))
    2129 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    21301901    V_(AC97_Master_Volume_Mute,  PDMAUDIOMIXERCTL_VOLUME);
    21311902    V_(AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_PCM);
    21321903    V_(AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN);
    2133 # else
    2134     V_(AC97_Master_Volume_Mute,  AUD_MIXER_VOLUME);
    2135     V_(AC97_PCM_Out_Volume_Mute, AUD_MIXER_PCM);
    2136     V_(AC97_Line_In_Volume_Mute, AUD_MIXER_LINE_IN);
    2137 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    21381904# undef V_
    21391905    ichac97ResetStreams(pThis, active);
     
    21941960    LogFlowFuncEnter();
    21951961
    2196 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    21971962    PAC97DRIVER pDrv;
    21981963    while (!RTListIsEmpty(&pThis->lstDrv))
     
    22091974        pThis->pMixer = NULL;
    22101975    }
    2211 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    22121976
    22131977    if (pThis->pvReadWriteBuf)
     
    22231987
    22241988
    2225 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    22261989/**
    22271990 * Attach command.
     
    22952058    return rc;
    22962059}
    2297 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    22982060
    22992061
     
    23052067    PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE);
    23062068
    2307 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    23082069    /* NB: This must be done *before* any possible failure (and running the destructor). */
    23092070    RTListInit(&pThis->lstDrv);
    2310 #endif
    23112071
    23122072    Assert(iInstance == 0);
     
    24042164     * Attach driver.
    24052165     */
    2406 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    24072166    uint8_t uLUN;
    24082167    for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
     
    24212180
    24222181    LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc));
    2423 #else
    2424     rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Audio Driver Port");
    2425     if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    2426         LogFunc(("ac97: No attached driver!\n"));
    2427     else if (RT_FAILURE(rc))
    2428     {
    2429         AssertMsgFailed(("Failed to attach AC97 LUN #0! rc=%Rrc\n", rc));
    2430         return rc;
    2431     }
    2432 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    2433 
    2434 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
    2435     AUD_register_card("ICH0", &pThis->card);
    2436 #endif
     2182
    24372183    ac97Reset(pDevIns);
    24382184
    2439 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    24402185    PAC97DRIVER pDrv;
    24412186    uLUN = 0;
     
    25092254        }
    25102255    }
    2511 #else
    2512     if (!AUD_is_host_voice_in_ok(pThis->voice_pi))
    2513         LogRel(("AC97: WARNING: Unable to open PCM IN!\n"));
    2514     if (!AUD_is_host_voice_in_ok(pThis->voice_mc))
    2515         LogRel(("AC97: WARNING: Unable to open PCM MC!\n"));
    2516     if (!AUD_is_host_voice_out_ok(pThis->voice_po))
    2517         LogRel(("AC97: WARNING: Unable to open PCM OUT!\n"));
    2518 
    2519     if (   !AUD_is_host_voice_in_ok( pThis->voice_pi)
    2520         && !AUD_is_host_voice_out_ok(pThis->voice_po)
    2521         && !AUD_is_host_voice_in_ok( pThis->voice_mc))
    2522     {
    2523         AUD_close_in(&pThis->card, pThis->voice_pi);
    2524         AUD_close_out(&pThis->card, pThis->voice_po);
    2525         AUD_close_in(&pThis->card, pThis->voice_mc);
    2526 
    2527         pThis->voice_po = NULL;
    2528         pThis->voice_pi = NULL;
    2529         pThis->voice_mc = NULL;
    2530         AUD_init_null();
    2531         ac97Reset(pDevIns);
    2532 
    2533         PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
    2534             N_("No audio devices could be opened. Selecting the NULL audio backend "
    2535                "with the consequence that no sound is audible"));
    2536     }
    2537     else if (   !AUD_is_host_voice_in_ok( pThis->voice_pi)
    2538              || !AUD_is_host_voice_out_ok(pThis->voice_po)
    2539              || !AUD_is_host_voice_in_ok( pThis->voice_mc))
    2540     {
    2541         char   szMissingVoices[128];
    2542         size_t len = 0;
    2543         if (!AUD_is_host_voice_in_ok(pThis->voice_pi))
    2544             len = RTStrPrintf(szMissingVoices, sizeof(szMissingVoices), "PCM_in");
    2545         if (!AUD_is_host_voice_out_ok(pThis->voice_po))
    2546             len += RTStrPrintf(szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_out" : "PCM_out");
    2547         if (!AUD_is_host_voice_in_ok(pThis->voice_mc))
    2548             len += RTStrPrintf(szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_mic" : "PCM_mic");
    2549 
    2550         PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
    2551             N_("Some audio devices (%s) could not be opened. Guest applications generating audio "
    2552                "output or depending on audio input may hang. Make sure your host audio device "
    2553                "is working properly. Check the logfile for error messages of the audio "
    2554                "subsystem"), szMissingVoices);
    2555     }
    2556 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    25572256
    25582257    if (RT_SUCCESS(rc))
     
    25642263    }
    25652264
    2566 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    25672265    if (RT_SUCCESS(rc))
    25682266    {
     
    25952293    }
    25962294# endif
    2597 
    2598 #endif
    25992295
    26002296    return VINF_SUCCESS;
  • trunk/src/VBox/Devices/Audio/DevIchHda.cpp

    r55920 r56085  
    4545#include "VBoxDD.h"
    4646
    47 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    48 # include "AudioMixer.h"
    49 #else
    50  extern "C" {
    51   #include "audio.h"
    52  }
    53 #endif
     47#include "AudioMixer.h"
    5448#include "DevIchHdaCodec.h"
    5549
     
    551545} HDASTREAMTRANSFERDESC, *PHDASTREAMTRANSFERDESC;
    552546
    553 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    554547typedef struct HDAINPUTSTREAM
    555548{
     
    608601    HDAOUTPUTSTREAM                    Out;
    609602} HDADRIVER, *PHDADRIVER;
    610 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    611603
    612604/**
     
    655647    /** Flag whether the RC part is enabled. */
    656648    bool                               fRCEnabled;
    657 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    658649    /** The emulation timer for handling the attached
    659650     *  LUN drivers. */
     
    686677    /** Audio mixer sink for microphone input. */
    687678    R3PTRTYPE(PAUDMIXSINK)             pSinkMicIn;
    688 #else /* !VBOX_WITH_PDM_AUDIO_DRIVER */
    689     /** The HDA codec to use. */
    690     R3PTRTYPE(PHDACODEC)               pCodec;
    691 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    692679    uint64_t                           u64BaseTS;
    693680    /** 1.2.3.4.5.6.7. - someone please tell me what I'm counting! - .8.9.10... */
    694681    uint8_t                            u8Counter;
    695 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    696682    uint8_t                            au8Padding[7];
    697 #else
    698     uint8_t                            au8Padding[7];
    699 #endif
    700683} HDASTATE;
    701684/** Pointer to the ICH Intel HD Audio Controller state. */
     
    749732static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
    750733
    751 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    752734static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);
    753735static int hdaTransfer(PHDASTATE pThis, ENMSOUNDSOURCE enmSrc, uint32_t cbAvail);
    754 #else
    755 static int hdaTransfer(PHDACODEC pCodec, ENMSOUNDSOURCE enmSource, int cbAvail);
    756 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    757736
    758737#ifdef IN_RING3
     
    15311510                pBdle = &pThis->StInBdle;
    15321511                break;
    1533 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1534 # ifdef VBOX_WITH_HDA_MIC_IN
     1512#ifdef VBOX_WITH_HDA_MIC_IN
    15351513            case HDA_REG_SD2CTL:
    15361514                u8Strm = 2;
    15371515                pBdle = &pThis->StMicBdle;
    15381516                break;
    1539 # endif
    15401517#endif
    15411518            case HDA_REG_SD4CTL:
     
    15631540            Assert((!fReset && !fInReset));
    15641541
    1565 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    15661542            PHDADRIVER pDrv;
    1567 # endif
    15681543            switch (iReg)
    15691544            {
    15701545                case HDA_REG_SD0CTL:
    1571 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     1546                {
    15721547                    RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    15731548                        pDrv->pConnector->pfnEnableIn(pDrv->pConnector,
    15741549                                                      pDrv->LineIn.pStrmIn, fRun);
    1575 # else
    1576                     AUD_set_active_in(pThis->pCodec->SwVoiceIn, fRun);
    1577 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    15781550                    break;
    1579 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1580 #  ifdef VBOX_WITH_HDA_MIC_IN
     1551                }
     1552# ifdef VBOX_WITH_HDA_MIC_IN
    15811553                case HDA_REG_SD2CTL:
     1554                {
    15821555                    RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    15831556                        pDrv->pConnector->pfnEnableIn(pDrv->pConnector,
    15841557                                                      pDrv->MicIn.pStrmIn, fRun);
    1585 #  endif
    1586 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    15871558                    break;
     1559                }
     1560# endif
    15881561                case HDA_REG_SD4CTL:
    1589 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     1562                {
    15901563                    RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    15911564                        pDrv->pConnector->pfnEnableOut(pDrv->pConnector,
    15921565                                                       pDrv->Out.pStrmOut, fRun);
    1593 # else
    1594                     AUD_set_active_out(pThis->pCodec->SwVoiceOut, fRun);
    1595 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    15961566                    break;
     1567                }
    15971568                default:
    15981569                    AssertMsgFailed(("Changing RUN bit on non-attached stream, register %RU32\n", iReg));
     
    16821653
    16831654#ifdef IN_RING3
    1684 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    16851655static int hdaSdFmtToAudSettings(uint32_t u32SdFmt, PPDMAUDIOSTREAMCFG pCfg)
    1686 #else
    1687 static int hdaSdFmtToAudSettings(uint32_t u32SdFmt, audsettings_t *pCfg)
    1688 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    16891656{
    16901657    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
     
    17271694    }
    17281695
    1729 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    17301696    PDMAUDIOFMT enmFmt = AUD_FMT_S16; /* Default to 16-bit signed. */
    1731 #else
    1732     audfmt_e enmFmt = AUD_FMT_S16; /* Default to 16-bit signed. */
    1733 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    1734 
    17351697    switch (EXTRACT_VALUE(u32SdFmt, HDA_SDFMT_BITS_MASK, HDA_SDFMT_BITS_SHIFT))
    17361698    {
    17371699        case 0:
    1738             LogFunc(("%s requested 8-bit\n", __FUNCTION__));
    1739 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     1700            LogFunc(("Requested 8-bit\n"));
    17401701            enmFmt = AUD_FMT_S8;
    1741 #else
    1742             enmFmt = AUD_FMT_S8;
    1743 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    17441702            break;
    17451703        case 1:
    1746             LogFunc(("%s requested 16-bit\n", __FUNCTION__));
    1747 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     1704            LogFunc(("Requested 16-bit\n"));
    17481705            enmFmt = AUD_FMT_S16;
    1749 #else
    1750             enmFmt = AUD_FMT_S16;
    1751 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    17521706            break;
    17531707        case 2:
    1754             LogFunc(("%s requested 20-bit\n", __FUNCTION__));
     1708            LogFunc(("Requested 20-bit\n"));
    17551709            break;
    17561710        case 3:
    1757             LogFunc(("%s requested 24-bit\n", __FUNCTION__));
     1711            LogFunc(("Requested 24-bit\n"));
    17581712            break;
    17591713        case 4:
    1760             LogFunc(("%s requested 32-bit\n", __FUNCTION__));
    1761 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     1714            LogFunc(("Requested 32-bit\n"));
    17621715            enmFmt = AUD_FMT_S32;
    1763 #else
    1764             enmFmt = AUD_FMT_S32;
    1765 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    17661716            break;
    17671717        default:
     
    17741724    if (RT_SUCCESS(rc))
    17751725    {
    1776 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    17771726        pCfg->uHz = u32Hz * u32HzMult / u32HzDiv;
    17781727        pCfg->cChannels = (u32SdFmt & 0xf) + 1;
    17791728        pCfg->enmFormat = enmFmt;
    17801729        pCfg->enmEndianness = PDMAUDIOHOSTENDIANNESS;
    1781 #else
    1782         pCfg->nchannels = (u32SdFmt & 0xf) + 1;
    1783         pCfg->fmt = enmFmt;
    1784         pCfg->endianness = 0;
    1785 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    17861730    }
    17871731
     
    18121756                rc = hdaCodecOpenStream(pThis->pCodec, PI_INDEX, &as);
    18131757            break;
    1814 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1815 # ifdef VBOX_WITH_HDA_MIC_IN
     1758#  ifdef VBOX_WITH_HDA_MIC_IN
    18161759        case HDA_REG_SD2FMT:
    18171760            RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    18181761                rc = hdaCodecOpenStream(pThis->pCodec, MC_INDEX, &as);
    18191762            break;
    1820 # endif
    1821 #endif
     1763#  endif
    18221764        default:
    18231765            LogFunc(("Warning: Attempt to change format on register %d\n", iReg));
     
    18271769    /** @todo r=andy rc gets lost; needs fixing. */
    18281770    return hdaRegWriteU16(pThis, iReg, u32Value);
    1829 # else
     1771# else /* !VBOX_WITH_HDA_CODEC_EMU */
    18301772    return hdaRegWriteU16(pThis, iReg, u32Value);
    18311773# endif
    1832 #else
     1774#else /* !IN_RING3 */
    18331775    return VINF_IOM_R3_MMIO_WRITE;
    18341776#endif
     
    21842126}
    21852127
    2186 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    21872128/**
    21882129 * hdaReadAudio - copies samples from audio backend to DMA.
     
    22442185    return rc;
    22452186}
    2246 #else
    2247 static int hdaReadAudio(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc,
    2248                         uint32_t u32CblLimit, uint32_t *pu32Avail, uint32_t *pcbRead)
    2249 {
    2250     PHDABDLEDESC pBdle = &pThis->StInBdle;
    2251 
    2252     uint32_t cbTransferred = 0;
    2253     uint32_t cb2Copy = 0;
    2254     uint32_t cbBackendCopy = 0;
    2255 
    2256     int rc;
    2257 
    2258     Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
    2259 
    2260     cb2Copy = hdaCalculateTransferBufferLength(pBdle, pStreamDesc, *pu32Avail, u32CblLimit);
    2261     if (!cb2Copy)
    2262     {
    2263         /* if we enter here we can't report "unreported bits" */
    2264         rc = VINF_EOF;
    2265     }
    2266     else
    2267     {
    2268         /*
    2269          * read from backend input line to the last unreported position or at the begining.
    2270          */
    2271         cbBackendCopy = AUD_read(pThis->pCodec->SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy);
    2272 
    2273         /*
    2274          * write the HDA DMA buffer
    2275          */
    2276         PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer,
    2277                               cbBackendCopy);
    2278 
    2279         /* Don't see any reason why cb2Copy would differ from cbBackendCopy */
    2280         Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */
    2281 
    2282         if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pThis, 0))
    2283         {
    2284             hdaBackendReadTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail);
    2285             rc = VINF_SUCCESS;
    2286         }
    2287         else
    2288         {
    2289             hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cbBackendCopy, pu32Avail);
    2290             rc = VINF_EOF;
    2291         }
    2292     }
    2293 
    2294     Assert((cbTransferred <= (SDFIFOS(pThis, 0) + 1)));
    2295     Log(("hda:ra: CVI(pos:%d, len:%d) cbTransferred: %d\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred));
    2296 
    2297     if (pcbRead)
    2298         *pcbRead = cbTransferred;
    2299 
    2300     return rc;
    2301 }
    2302 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    23032187
    23042188static int hdaWriteAudio(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t u32CblLimit,
     
    23302214                          pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos,
    23312215                          pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy);
    2332 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     2216
     2217#ifdef VBOX_WITH_STATISTICS
    23332218        STAM_COUNTER_ADD(&pThis->StatBytesRead, cb2Copy);
    23342219#endif
     
    23392224        if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(pThis, pStreamDesc))
    23402225        {
    2341 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    23422226            uint32_t cbWritten;
    23432227            cbWrittenMin = UINT32_MAX;
     
    23632247            if (cbWrittenMin == UINT32_MAX)
    23642248                cbWrittenMin = 0;
    2365 #else
    2366             cbWrittenMin = AUD_write (pThis->pCodec->SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW);
    2367 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    23682249
    23692250            hdaBackendWriteTransferReported(pBdle, cb2Copy, cbWrittenMin, &cbTransferred, pcbAvail);
     
    24372318}
    24382319
    2439 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    24402320static DECLCALLBACK(int) hdaOpenIn(PHDASTATE pThis,
    24412321                                   const char *pszName, PDMAUDIORECSOURCE enmRecSource,
     
    25482428    return rc;
    25492429}
    2550 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    2551 
    2552 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     2430
    25532431static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    25542432{
     
    26292507
    26302508    LogFlowFunc(("pThis=%p, cbAvail=%RU32\n", pThis, cbAvail));
    2631 #else
    2632 static DECLCALLBACK(int) hdaTransfer(PHDACODEC pCodec, ENMSOUNDSOURCE enmSrc, uint32_t cbAvail)
    2633 {
    2634     AssertPtrReturn(pCodec, VERR_INVALID_POINTER);
    2635     PHDASTATE pThis = pCodec->pHDAState;
    2636     AssertPtrReturn(pThis, VERR_INVALID_POINTER);
    2637 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    26382509
    26392510    uint8_t      u8Strm;
     
    26902561        LogFunc(("CBL=%RU32, LPIB=%RU32\n", StreamDesc.u32Cbl, *StreamDesc.pu32Lpib));
    26912562
    2692 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    26932563        PAUDMIXSINK pSink;
    2694 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    26952564        uint32_t cbWritten = 0;
    26962565        switch (enmSrc)
    26972566        {
    26982567            case PI_INDEX:
    2699 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    27002568                pSink = pThis->pSinkLineIn;
    27012569                rc = hdaReadAudio(pThis, pSink, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten);
    2702 #else
    2703                 rc = hdaReadAudio(pThis, &StreamDesc, u32CblLimit, (uint32_t *)&cbAvail, &cbWritten);
    2704 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    27052570                break;
    27062571            case PO_INDEX:
    27072572                rc = hdaWriteAudio(pThis, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten);
    27082573                break;
    2709 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    2710 # ifdef VBOX_WITH_HDA_MIC_IN
     2574#ifdef VBOX_WITH_HDA_MIC_IN
    27112575            case MC_INDEX:
    27122576                pSink = pThis->pSinkMicIn;
    27132577                rc = hdaReadAudio(pThis, pSink, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten);
    27142578                break;
    2715 # endif
    2716 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
     2579#endif
    27172580            default:
    27182581                AssertMsgFailed(("Unsupported source index %ld\n", enmSrc));
     
    32473110    bool fEnableOut   = RT_BOOL(SDCTL(pThis, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
    32483111
    3249 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    32503112    PHDADRIVER pDrv;
    32513113    RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
     
    32613123            break;
    32623124    }
    3263 #else
    3264     AUD_set_active_in(pThis->pCodec->SwVoiceIn, SDCTL(pThis, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
    3265     AUD_set_active_out(pThis->pCodec->SwVoiceOut, SDCTL(pThis, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
    3266 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    32673125
    32683126    if (RT_SUCCESS(rc))
     
    35083366    LogFunc(("Resetting ...\n"));
    35093367
    3510 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    35113368    /* Stop any audio currently playing. */
    35123369    PHDADRIVER pDrv;
     
    35203377        /* Ditto. */
    35213378    }
    3522 #else
    3523     AUD_set_active_in(pThis->pCodec->SwVoiceIn, false);
    3524     AUD_set_active_out(pThis->pCodec->SwVoiceOut, false);
    3525 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    35263379
    35273380    pThis->cbCorbBuf = 256 * sizeof(uint32_t);
     
    35773430    PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
    35783431
    3579 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    35803432    PHDADRIVER pDrv;
    35813433    while (!RTListIsEmpty(&pThis->lstDrv))
     
    35923444        pThis->pMixer = NULL;
    35933445    }
    3594 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    35953446
    35963447    if (pThis->pCodec)
     
    36123463}
    36133464
    3614 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    36153465/**
    36163466 * Attach command.
     
    36923542    LogFlowFuncEnter();
    36933543}
    3694 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    36953544
    36963545/**
     
    38353684        return rc;
    38363685
    3837 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    38383686    RTListInit(&pThis->lstDrv);
    38393687
     
    38923740
    38933741    LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc));
    3894 #else
    3895     /*
    3896      * Attach driver.
    3897      */
    3898     rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Audio Driver Port");
    3899     if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    3900         Log(("hda: No attached driver!\n"));
    3901     else if (RT_FAILURE(rc))
    3902     {
    3903         AssertMsgFailed(("Failed to attach Intel HDA LUN #0! rc=%Rrc\n", rc));
    3904         return rc;
    3905     }
    3906 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    39073742
    39083743    if (RT_SUCCESS(rc))
     
    39133748            return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Out of memory allocating HDA codec state"));
    39143749
    3915 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    39163750        /* Audio driver callbacks for multiplexing. */
    39173751        pThis->pCodec->pfnCloseIn   = hdaCloseIn;
     
    39193753        pThis->pCodec->pfnOpenIn    = hdaOpenIn;
    39203754        pThis->pCodec->pfnOpenOut   = hdaOpenOut;
     3755        pThis->pCodec->pfnReset     = hdaCodecReset;
    39213756        pThis->pCodec->pfnSetVolume = hdaSetVolume;
    3922 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    39233757
    39243758        pThis->pCodec->pHDAState = pThis; /* Assign HDA controller state to codec. */
     
    39353769        PCIDevSetSubSystemVendorId(&pThis->PciDev, pThis->pCodec->u16VendorId); /* 2c ro - intel.) */
    39363770        PCIDevSetSubSystemId(      &pThis->PciDev, pThis->pCodec->u16DeviceId); /* 2e ro. */
    3937 
    3938 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
    3939         pThis->pCodec->pfnTransfer = hdaTransfer;
    3940 #endif
    3941         pThis->pCodec->pfnReset    = hdaCodecReset;
    39423771    }
    39433772
     
    40223851    }
    40233852
    4024 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    40253853    if (RT_SUCCESS(rc))
    40263854    {
     
    40553883    }
    40563884# endif
    4057 
    4058 #endif
    40593885
    40603886    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/Devices/Audio/DevIchHdaCodec.cpp

    r55521 r56085  
    3535
    3636#include "VBoxDD.h"
    37 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
    38 extern "C" {
    39 #include "audio.h"
    40 }
    41 #endif
    4237#include "DevIchHdaCodec.h"
    4338
     
    11671162 * Misc helpers.
    11681163 */
    1169 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    11701164static int hdaCodecToAudVolume(PHDACODEC pThis, AMPLIFIER *pAmp, PDMAUDIOMIXERCTL mt)
    1171 #else
    1172 static int hdaCodecToAudVolume(AMPLIFIER *pAmp, audmixerctl_t mt)
    1173 #endif
    11741165{
    11751166    uint32_t dir = AMPLIFIER_OUT;
     
    11771168    switch (mt)
    11781169    {
    1179 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    11801170        case PDMAUDIOMIXERCTL_PCM:
    11811171            enmSrc = PO_INDEX;
    1182 #else
    1183         case AUD_MIXER_VOLUME:
    1184         case AUD_MIXER_PCM:
    1185 #endif
    11861172            dir = AMPLIFIER_OUT;
    11871173            break;
    1188 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    11891174        case PDMAUDIOMIXERCTL_LINE_IN:
    11901175            enmSrc = PI_INDEX;
    1191 #else
    1192         case AUD_MIXER_LINE_IN:
    1193 #endif
    11941176            dir = AMPLIFIER_IN;
    11951177            break;
     
    12141196    rVol = (rVol + 1) * (2 * 255) / 256;
    12151197
    1216 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1217     /** @todo In SetVolume no passing audmixerctl_in as its not used in DrvAudio.cpp. */
    1218     pThis->pfnSetVolume(pThis->pHDAState, enmSrc, RT_BOOL(mute), lVol, rVol);
    1219 #else
    1220     AUD_set_volume(mt, &mute, &lVol, &rVol);
    1221 #endif
    1222     return VINF_SUCCESS;
     1198    return pThis->pfnSetVolume(pThis->pHDAState, enmSrc, RT_BOOL(mute), lVol, rVol);
    12231199}
    12241200
     
    13601336
    13611337        /** @todo Fix ID of u8AdcVolsLineIn! */
    1362 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    13631338        hdaCodecToAudVolume(pThis, pAmplifier, PDMAUDIOMIXERCTL_LINE_IN);
    1364 #else
    1365         hdaCodecToAudVolume(pAmplifier, AUD_MIXER_LINE_IN);
    1366 #endif
    13671339    }
    13681340    if (fIsOut)
     
    13741346
    13751347        /** @todo Fix ID of u8DacLineOut! */
    1376 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    13771348        hdaCodecToAudVolume(pThis, pAmplifier, PDMAUDIOMIXERCTL_PCM);
    1378 #else
    1379         hdaCodecToAudVolume(pAmplifier, AUD_MIXER_VOLUME);
    1380 #endif
    13811349    }
    13821350
     
    22752243}
    22762244
    2277 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
    2278 static void pi_callback(void *opaque, int avail)
    2279 {
    2280     PHDACODEC pThis = (PHDACODEC)opaque;
    2281     pThis->pfnTransfer(pThis, PI_INDEX, avail);
    2282 }
    2283 
    2284 static void po_callback(void *opaque, int avail)
    2285 {
    2286     PHDACODEC pThis = (PHDACODEC)opaque;
    2287     pThis->pfnTransfer(pThis, PO_INDEX, avail);
    2288 }
    2289 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    2290 
    22912245/*
    22922246 * APIs exposed to DevHDA.
    22932247 */
    2294 
    22952248
    22962249/**
     
    23022255 *       format) before enabling.
    23032256 */
    2304 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    23052257int hdaCodecOpenStream(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, PPDMAUDIOSTREAMCFG pCfg)
    2306 #else
    2307 int hdaCodecOpenStream(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings)
     2258{
     2259    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     2260
     2261    int rc;
     2262
     2263    switch (enmSoundSource)
     2264    {
     2265        case PI_INDEX:
     2266            rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in", PDMAUDIORECSOURCE_LINE_IN, pCfg);
     2267            break;
     2268
     2269        case PO_INDEX:
     2270            rc = pThis->pfnOpenOut(pThis->pHDAState, "hda.out", pCfg);
     2271            break;
     2272
     2273#ifdef VBOX_WITH_HDA_MIC_IN
     2274        case MC_INDEX:
     2275            rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc", PDMAUDIORECSOURCE_MIC, pCfg);
     2276            break;
    23082277#endif
    2309 {
    2310     AssertPtrReturn(pThis, VERR_INVALID_POINTER);
    2311 
    2312     int rc;
    2313 
    2314     switch (enmSoundSource)
    2315     {
    2316         case PI_INDEX:
    2317 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    2318                 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in",
    2319                                       PDMAUDIORECSOURCE_LINE_IN, pCfg);
    2320 #else
    2321                 pThis->SwVoiceIn = AUD_open_in(&pThis->card, pThis->SwVoiceIn, "hda.in", pThis, pi_callback, pAudioSettings);
    2322                 rc = pThis->SwVoiceIn ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
    2323 #endif
    2324             break;
    2325 
    2326         case PO_INDEX:
    2327 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    2328             rc = pThis->pfnOpenOut(pThis->pHDAState, "hda.out", pCfg);
    2329 #else
    2330             pThis->SwVoiceOut = AUD_open_out(&pThis->card, pThis->SwVoiceOut, "hda.out", pThis, po_callback, pAudioSettings);
    2331             rc = pThis->SwVoiceOut ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
    2332 #endif
    2333             break;
    2334 
    2335 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    2336 # ifdef VBOX_WITH_HDA_MIC_IN
    2337         case MC_INDEX:
    2338             rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc",
    2339                                   PDMAUDIORECSOURCE_MIC, pCfg);
    2340             break;
    2341 # endif
    2342 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    2343 
    23442278        default:
    23452279            AssertMsgFailed(("Index %ld not implemented\n", enmSoundSource));
     
    24162350     */
    24172351    if (hdaCodecIsDacNode(pThis, pThis->u8DacLineOut))
    2418 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    24192352        hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_PCM);
    2420 #else
    2421         hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME);
    2422 #endif
    24232353    else if (hdaCodecIsSpdifOutNode(pThis, pThis->u8DacLineOut))
    2424 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    24252354        hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].spdifout.B_params, PDMAUDIOMIXERCTL_PCM);
    24262355    hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
    2427 #else
    2428         hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].spdifout.B_params, AUD_MIXER_VOLUME);
    2429     hdaCodecToAudVolume(&pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, AUD_MIXER_LINE_IN);
    2430 #endif
    24312356
    24322357    return VINF_SUCCESS;
     
    24682393    pThis->paNodes[1].afg.u32F20_param = CODEC_MAKE_F20(pThis->u16VendorId, pThis->u8BSKU, pThis->u8AssemblyId);
    24692394
    2470 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    24712395    /* 44.1 kHz. */
    24722396    PDMAUDIOSTREAMCFG as;
     
    24752399    as.enmFormat     = AUD_FMT_S16;
    24762400    as.enmEndianness = PDMAUDIOHOSTENDIANNESS;
    2477 #else
    2478     AUD_register_card("ICH0", &pThis->card);
    2479 
    2480     /* 44.1 kHz */
    2481     audsettings_t as;
    2482     as.freq = 44100;
    2483     as.nchannels = 2;
    2484     as.fmt = AUD_FMT_S16;
    2485     as.endianness = 0;
    2486 #endif
    24872401
    24882402    pThis->paNodes[1].node.au32F00_param[0xA] = CODEC_F00_0A_16_BIT;
     
    24902404    hdaCodecOpenStream(pThis, PI_INDEX, &as);
    24912405    hdaCodecOpenStream(pThis, PO_INDEX, &as);
    2492 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    2493 # ifdef VBOX_WITH_HDA_MIC_IN
     2406#ifdef VBOX_WITH_HDA_MIC_IN
    24942407    hdaCodecOpenStream(pThis, MC_INDEX, &as);
    2495 # endif
    2496 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
     2408#endif
    24972409
    24982410    pThis->paNodes[1].node.au32F00_param[0xA] |= CODEC_F00_0A_44_1KHZ;
     
    25052417        pThis->pfnCodecNodeReset(pThis, i, &pThis->paNodes[i]);
    25062418
    2507 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    25082419    hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_PCM);
    25092420    hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
    25102421
    2511 
    2512 #else
    2513     hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME);
    2514     hdaCodecToAudVolume(&pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, AUD_MIXER_LINE_IN);
    2515 
    2516     if (!AUD_is_host_voice_in_ok(pThis->SwVoiceIn))
    2517         LogRel (("HDA: WARNING: Unable to open PCM IN!\n"));
    2518     if (!AUD_is_host_voice_out_ok(pThis->SwVoiceOut))
    2519         LogRel (("HDA: WARNING: Unable to open PCM OUT!\n"));
    2520 
    2521     if (   !AUD_is_host_voice_in_ok(pThis->SwVoiceIn)
    2522         && !AUD_is_host_voice_out_ok(pThis->SwVoiceOut))
    2523     {
    2524         AUD_close_in(&pThis->card, pThis->SwVoiceIn);
    2525         AUD_close_out(&pThis->card, pThis->SwVoiceOut);
    2526 
    2527         pThis->SwVoiceOut = NULL;
    2528         pThis->SwVoiceIn = NULL;
    2529 
    2530         AUD_init_null ();
    2531 
    2532         PDMDevHlpVMSetRuntimeError (pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
    2533             N_ ("No audio devices could be opened. Selecting the NULL audio backend "
    2534                 "with the consequence that no sound is audible"));
    2535     }
    2536     else if (   !AUD_is_host_voice_in_ok(pThis->SwVoiceIn)
    2537              || !AUD_is_host_voice_out_ok(pThis->SwVoiceOut))
    2538     {
    2539         char   szMissingVoices[128];
    2540         size_t len = 0;
    2541 
    2542         if (!AUD_is_host_voice_in_ok(pThis->SwVoiceIn))
    2543             len = RTStrPrintf (szMissingVoices, sizeof(szMissingVoices), "PCM_in");
    2544         if (!AUD_is_host_voice_out_ok(pThis->SwVoiceOut))
    2545             len += RTStrPrintf (szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_out" : "PCM_out");
    2546 
    2547         PDMDevHlpVMSetRuntimeError (pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
    2548             N_ ("Some audio devices (%s) could not be opened. Guest applications generating audio "
    2549                 "output or depending on audio input may hang. Make sure your host audio device "
    2550                 "is working properly. Check the logfile for error messages of the audio "
    2551                 "subsystem"), szMissingVoices);
    2552     }
    2553 #endif
    2554 
    2555     return VINF_SUCCESS;
    2556 }
    2557 
     2422    return VINF_SUCCESS;
     2423}
     2424
  • trunk/src/VBox/Devices/Audio/DevIchHdaCodec.h

    r55404 r56085  
    110110    const uint8_t           u8DacLineOut;
    111111#endif
    112 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    113112    /* Callbacks to the HDA controller, mostly used for multiplexing to the various host backends. */
    114113    DECLR3CALLBACKMEMBER(void, pfnCloseIn, (PHDASTATE pThis, PDMAUDIORECSOURCE enmRecSource));
     
    117116    DECLR3CALLBACKMEMBER(int, pfnOpenOut, (PHDASTATE pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg));
    118117    DECLR3CALLBACKMEMBER(int, pfnSetVolume, (PHDASTATE pThis, ENMSOUNDSOURCE enmSource, bool fMute, uint8_t uVolLeft, uint8_t uVolRight));
    119 #else
    120     QEMUSoundCard           card;
    121     /** PCM in */
    122     SWVoiceIn              *SwVoiceIn;
    123     /** PCM out */
    124     SWVoiceOut             *SwVoiceOut;
    125     /* Callbacks for host driver backends. */
    126     DECLR3CALLBACKMEMBER(int, pfnTransfer, (PHDACODEC pCodec, ENMSOUNDSOURCE enmSource, uint32_t cbAvail));
    127 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    128118    /* Callbacks by codec implementation. */
    129119    DECLR3CALLBACKMEMBER(int, pfnLookup, (PHDACODEC pThis, uint32_t verb, PPFNHDACODECVERBPROCESSOR));
     
    139129int hdaCodecSaveState(PHDACODEC pThis, PSSMHANDLE pSSM);
    140130int hdaCodecLoadState(PHDACODEC pThis, PSSMHANDLE pSSM, uint32_t uVersion);
    141 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    142131int hdaCodecOpenStream(PHDACODEC pThis, PDMAUDIORECSOURCE enmRecSource, PDMAUDIOSTREAMCFG *pAudioSettings);
    143 #else
    144 int hdaCodecOpenVoice(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings);
    145 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    146132
    147133#define HDA_SSM_VERSION   4
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r55920 r56085  
    6060#include <VBox/log.h>
    6161
    62 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    63 # include "AudioMixer.h"
    64 #else
    65  extern "C" {
    66   #include "audio.h"
    67  }
    68 #endif
     62#include "AudioMixer.h"
    6963
    7064/** Current saved state version. */
     
    8377static const char e3[] = "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992.";
    8478
    85 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    8679typedef struct SB16OUTPUTSTREAM
    8780{
     
    124117    SB16OUTPUTSTREAM                   Out;
    125118} SB16DRIVER, *PSB16DRIVER;
    126 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    127119
    128120typedef struct SB16STATE
     
    150142    int fmt_signed;
    151143    int fmt_bits;
    152 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    153144    PDMAUDIOFMT fmt;
    154 #else
    155     audfmt_e fmt;
    156     QEMUSoundCard card;
    157 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    158145    int dma_auto;
    159146    int block_size;
     
    191178    int align;
    192179
    193 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    194180    RTLISTANCHOR                   lstDrv;
    195181    /** The device' software mixer. */
     
    201187    /** Timer ticks for handling the LUN drivers. */
    202188    uint64_t                       uTicksIO;
    203 #else
    204     uint32_t audio_free;
    205     SWVoiceOut *voice;
    206 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    207189
    208190    PTMTIMER  pTimerIRQ;
     
    216198} SB16STATE, *PSB16STATE;
    217199
    218 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    219200static int sb16OpenOut(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg);
    220 #endif
    221 
    222 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     201
    223202/**
    224203 * Attach command.
     
    292271    return rc;
    293272}
    294 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    295 
    296 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     273
    297274static void sb16AudioCallback(void *pvContext, uint32_t cbFree);
    298 #else
    299 static void sb16AudioCallback(void *pvContext, int cbFree);
    300 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    301275
    302276static int magic_of_irq(int irq)
     
    368342    LogFlowFunc(("hold %d high %d dma %d\n", hold, pThis->use_hdma, dma));
    369343
    370 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    371344    PSB16DRIVER pDrv;
    372 # endif
    373345    if (hold)
    374346    {
    375347        PDMDevHlpDMASetDREQ (pThis->pDevIns, dma, 1);
    376348        PDMDevHlpDMASchedule (pThis->pDevIns);
    377 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    378349        RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node)
    379350            pDrv->pConnector->pfnEnableOut(pDrv->pConnector,
    380351                                           pDrv->Out.pStrmOut, true /* fEnable */);
    381 # else
    382         AUD_set_active_out (pThis->voice, 1);
    383 # endif
    384352    }
    385353    else
    386354    {
    387355        PDMDevHlpDMASetDREQ (pThis->pDevIns, dma, 0);
    388 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    389356        RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node)
    390357            pDrv->pConnector->pfnEnableOut(pDrv->pConnector,
    391358                                           pDrv->Out.pStrmOut, false /* fEnable */);
    392 # else
    393         AUD_set_active_out (pThis->voice, 0);
    394 # endif
    395359    }
    396360}
     
    410374    if (pThis->freq > 0)
    411375    {
    412 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    413376        PDMAUDIOSTREAMCFG streamCfg;
    414377        streamCfg.uHz           = pThis->freq;
     
    419382        int rc = sb16OpenOut(pThis, &streamCfg);
    420383        AssertRC(rc);
    421 #else
    422         pThis->audio_free = 0;
    423 
    424         audsettings_t streamCfg;
    425         streamCfg.freq = pThis->freq;
    426         streamCfg.nchannels = 1 << pThis->fmt_stereo;
    427         streamCfg.fmt = pThis->fmt;
    428         streamCfg.endianness = 0;
    429         pThis->voice = AUD_open_out (
    430             &pThis->card,
    431             pThis->voice,
    432             "sb16",
    433             pThis,
    434             sb16AudioCallback,
    435             &streamCfg
    436             );
    437 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    438384    }
    439385
     
    563509    if (pThis->freq)
    564510    {
    565 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    566511        PDMAUDIOSTREAMCFG streamCfg;
    567512        streamCfg.uHz           = pThis->freq;
     
    572517        int rc = sb16OpenOut(pThis, &streamCfg);
    573518        AssertRC(rc);
    574 #else
    575         pThis->audio_free = 0;
    576 
    577         audsettings_t streamCfg;
    578         streamCfg.freq = pThis->freq;
    579         streamCfg.nchannels = 1 << pThis->fmt_stereo;
    580         streamCfg.fmt = pThis->fmt;
    581         streamCfg.endianness = 0;
    582         pThis->voice = AUD_open_out (
    583             &pThis->card,
    584             pThis->voice,
    585             "sb16",
    586             pThis,
    587             sb16AudioCallback,
    588             &streamCfg
    589             );
    590 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    591519    }
    592520
     
    1070998static void sb16SetMasterVolume(PSB16STATE pThis)
    1071999{
    1072 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    10731000    /* There's no mute switch, only volume controls. */
    10741001    uint8_t lvol = sb16MixRegToVol(pThis, 0x30);
     
    10761003    PDMAUDIOVOLUME vol = { false, lvol, rvol };
    10771004    AudioMixerSetMasterVolume(pThis->pMixer, &vol);
    1078 #else
    1079     int     mute = 0;
    1080     uint8_t lvol = pThis->mixer_regs[0x30];
    1081     uint8_t rvol = pThis->mixer_regs[0x31];
    1082 
    1083     AUD_set_volume(AUD_MIXER_VOLUME, &mute, &lvol, &rvol);
    1084 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    10851005}
    10861006
    10871007static void sb16SetPcmOutVolume(PSB16STATE pThis)
    10881008{
    1089 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    10901009    /* There's no mute switch, only volume controls. */
    10911010    uint8_t lvol = sb16MixRegToVol(pThis, 0x32);
     
    10931012    PDMAUDIOVOLUME vol = { false, lvol, rvol };
    10941013    AudioMixerSetSinkVolume(pThis->pSinkOutput, &vol);
    1095 #else
    1096     int     mute = 0;
    1097     uint8_t lvol = pThis->mixer_regs[0x32];
    1098     uint8_t rvol = pThis->mixer_regs[0x33];
    1099 
    1100     AUD_set_volume(AUD_MIXER_PCM, &mute, &lvol, &rvol);
    1101 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    11021014}
    11031015
     
    11091021    pThis->fmt_stereo = 0;
    11101022
    1111 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    11121023    PDMAUDIOSTREAMCFG streamCfg;
    11131024    streamCfg.uHz           = pThis->freq;
     
    11161027    streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
    11171028
    1118     int rc = sb16OpenOut(pThis, &streamCfg);
    1119     AssertRC(rc);
    1120 #else
    1121     audsettings_t streamCfg;
    1122     streamCfg.freq = pThis->freq;
    1123     streamCfg.nchannels = 1;
    1124     streamCfg.fmt = AUD_FMT_U8;
    1125     streamCfg.endianness = 0;
    1126     pThis->voice = AUD_open_out (
    1127         &pThis->card,
    1128         pThis->voice,
    1129         "sb16",
    1130         pThis,
    1131         sb16AudioCallback,
    1132         &streamCfg
    1133         );
    1134 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    1135 
    1136     /* Not sure about that... */
    1137     /* AUD_set_active_out (pThis->voice, 1); */
     1029    int rc2 = sb16OpenOut(pThis, &streamCfg);
     1030    AssertRC(rc2);
    11381031}
    11391032
     
    13381231static void sb16MixerReset(PSB16STATE pThis)
    13391232{
    1340 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    13411233    PSB16DRIVER pDrv;
    13421234
     
    13511243        pThis->pMixer = NULL;
    13521244    }
    1353 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    1354 
    1355     memset (pThis->mixer_regs, 0xff, 0x7f);
    1356     memset (pThis->mixer_regs + 0x83, 0xff, sizeof (pThis->mixer_regs) - 0x83);
     1245
     1246    memset(pThis->mixer_regs, 0xff, 0x7f);
     1247    memset(pThis->mixer_regs + 0x83, 0xff, sizeof (pThis->mixer_regs) - 0x83);
    13571248
    13581249    pThis->mixer_regs[0x02] = 4;    /* master volume 3bits */
     
    13821273        pThis->mixer_regs[i] = 0x80;
    13831274
    1384 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    13851275    int rc2 = AudioMixerCreate("SB16 Mixer", 0 /* uFlags */, &pThis->pMixer);
    13861276    if (RT_SUCCESS(rc2))
     
    14011291        AssertRC(rc2);
    14021292    }
    1403 #endif
    14041293
    14051294    /* Update the master (mixer) and PCM out volumes. */
     
    14171306}
    14181307
    1419 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1420 uint32_t popcount (uint32_t u) /** @todo r=andy WTF? */
     1308uint32_t popcount(uint32_t u) /** @todo r=andy WTF? */
    14211309{
    14221310    u = ((u&0x55555555) + ((u>>1)&0x55555555));
     
    14281316}
    14291317
    1430 uint32_t lsbindex (uint32_t u)
    1431 {
    1432     return popcount ((u & -(int32_t)u) - 1);
    1433 }
    1434 #endif
     1318uint32_t lsbindex(uint32_t u)
     1319{
     1320    return popcount((u & -(int32_t)u) - 1);
     1321}
    14351322
    14361323/* Convert SB16 to SB Pro mixer volume (left). */
     
    16561543        AssertMsgRC(rc, ("DMAReadMemory -> %Rrc\n", rc));
    16571544
    1658 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    16591545        uint32_t cbWritten;
    16601546
     
    16731559            LogFlowFunc(("\tLUN#%RU8: cbWritten=%RU32, cWrittenMin=%RU32\n", pDrv->uLUN, cbWritten, cbWrittenMin));
    16741560        }
    1675 #else
    1676         cbWrittenMin = AUD_write (pThis->voice, tmpbuf, cbToRead);
    1677 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    16781561
    16791562        Assert(cbToWrite >= cbWrittenMin);
     
    17041587        pThis->left_till_irq = pThis->block_size;
    17051588
    1706 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    17071589    PSB16DRIVER pDrv;
    17081590
     
    17281610            return dma_pos;
    17291611    }
    1730 #else
    1731     if (pThis->voice)
    1732     {
    1733         free = pThis->audio_free & ~pThis->align;
    1734         if ((free <= 0) || !dma_len)
    1735             return dma_pos;
    1736     }
    1737     else
    1738         free = dma_len;
    1739 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    17401612
    17411613    copy = free;
     
    17861658}
    17871659
    1788 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
    1789 static void sb16AudioCallback(void *pvContext, int cbFree)
    1790 {
    1791     PSB16STATE pState = (PSB16STATE)pvContext;
    1792     AssertPtrReturnVoid(pState);
    1793     pState->audio_free = cbFree;
    1794     /* New space available, see if we can transfer more. There is no cyclic DMA timer in VBox. */
    1795     PDMDevHlpDMASchedule(pState->pDevIns);
    1796 }
    1797 #else
    17981660static DECLCALLBACK(void) sb16TimerIO(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    17991661{
     
    18621724    TMTimerSet(pThis->pTimerIO, TMTimerGet(pThis->pTimerIO) + pThis->uTicksIO);
    18631725}
    1864 #endif /* !VBOX_WITH_PDM_AUDIO_DRIVER */
    18651726
    18661727static void sb16Save(PSSMHANDLE pSSM, PSB16STATE pThis)
     
    19701831    SSMR3GetMem(pSSM, pThis->mixer_regs, 256);
    19711832
    1972 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    19731833#if 0
    19741834    PSB16DRIVER pDrv;
     
    19821842    }
    19831843#endif
    1984 #else
    1985     AUD_close_out (&pThis->card, pThis->voice);
    1986     pThis->voice = NULL;
    1987 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    19881844
    19891845    if (pThis->dma_running)
     
    19911847        if (pThis->freq)
    19921848        {
    1993 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    19941849            PDMAUDIOSTREAMCFG streamCfg;
    19951850            streamCfg.uHz           = pThis->freq;
     
    20001855            int rc = sb16OpenOut(pThis, &streamCfg);
    20011856            AssertRC(rc);
    2002 #else
    2003             pThis->audio_free = 0;
    2004 
    2005             audsettings_t as;
    2006             as.freq = pThis->freq;
    2007             as.nchannels = 1 << pThis->fmt_stereo;
    2008             as.fmt = pThis->fmt;
    2009             as.endianness = 0;
    2010             pThis->voice = AUD_open_out (
    2011                 &pThis->card,
    2012                 pThis->voice,
    2013                 "sb16",
    2014                 pThis,
    2015                 sb16AudioCallback,
    2016                 &as
    2017                 );
    2018 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    20191857        }
    20201858
     
    20961934}
    20971935
    2098 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    20991936static int sb16OpenOut(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg)
    21001937{
     
    21421979    return rc;
    21431980}
    2144 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    21451981
    21461982/**
     
    21962032    PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE);
    21972033
    2198 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    21992034    PSB16DRIVER pDrv;
    22002035
     
    22092044        pThis->pMixer = NULL;
    22102045    }
    2211 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    22122046
    22132047    return VINF_SUCCESS;
     
    22842118    pThis->csp_regs[9]             = 0xf8;
    22852119
    2286 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    22872120    RTListInit(&pThis->lstDrv);
    2288 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    22892121
    22902122    sb16MixerReset(pThis);
     
    23232155     * Attach driver.
    23242156     */
    2325 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    23262157    uint8_t uLUN;
    23272158    for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
     
    23402171
    23412172    LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc));
    2342 #else
    2343     rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Audio Driver Port");
    2344     if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    2345         LogFunc(("SB16: No attached driver!\n"));
    2346     else if (RT_FAILURE(rc))
    2347     {
    2348         AssertMsgFailed(("Failed to attach SB16 LUN #0! rc=%Rrc\n", rc));
    2349         return rc;
    2350     }
    2351 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    2352 
    2353 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     2173
    23542174    sb16ResetLegacy(pThis);
    23552175
     
    24092229        }
    24102230    }
    2411 #else
    2412     AUD_register_card("sb16", &pThis->card);
    2413     sb16ResetLegacy(pThis);
    2414 
    2415     if (!AUD_is_host_voice_out_ok(pThis->voice))
    2416     {
    2417         LogRel (("SB16: WARNING: Unable to open PCM OUT!\n"));
    2418         AUD_close_out (&pThis->card, pThis->voice);
    2419         pThis->voice = NULL;
    2420 
    2421         AUD_init_null();
    2422 
    2423         PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
    2424             N_("No audio devices could be opened. Selecting the NULL audio backend "
    2425                "with the consequence that no sound is audible"));
    2426     }
    2427 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    24282231
    24292232    return VINF_SUCCESS;
  • trunk/src/VBox/Devices/Audio/testcase/Makefile.kmk

    r53442 r56085  
    55
    66#
    7 # Copyright (C) 2014 Oracle Corporation
     7# Copyright (C) 2014-2015 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919include $(KBUILD_PATH)/subheader.kmk
    2020
    21 if defined(VBOX_WITH_TESTCASES) && !defined(VBOX_ONLY_ADDITIONS) && !defined(VBOX_ONLY_SDK) && defined(VBOX_WITH_PDM_AUDIO_DRIVER)
     21if defined(VBOX_WITH_TESTCASES) && !defined(VBOX_ONLY_ADDITIONS) && !defined(VBOX_ONLY_SDK)
    2222
    2323 PROGRAMS += tstAudioMixBuffer
     
    2525
    2626 tstAudioMixBuffer_TEMPLATE = VBOXR3TSTEXE
    27  tstAudioMixBuffer_DEFS    += TESTCASE VBOX_WITH_PDM_AUDIO_DRIVER
     27 tstAudioMixBuffer_DEFS    += TESTCASE
    2828 tstAudioMixBuffer_SOURCES  = \
    2929        tstAudioMixBuffer.cpp \
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