VirtualBox

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

PDM/Audio: Removed old audio architecture.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
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