VirtualBox

Ignore:
Timestamp:
Jan 7, 2016 11:57:56 AM (9 years ago)
Author:
vboxsync
Message:

Audio: Don't crash if backend is unable to initialize (bugref:8180).

File:
1 edited

Legend:

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

    r59257 r59275  
    99
    1010/*
    11  * Copyright (C) 2006-2015 Oracle Corporation
     11 * Copyright (C) 2006-2016 Oracle Corporation
    1212 *
    1313 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    26072607
    26082608    int rc;
    2609 
    26102609    switch (enmSoundSource)
    26112610    {
    26122611        case PI_INDEX:
    2613             rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in", PDMAUDIORECSOURCE_LINE_IN, pCfg);
     2612            rc = pThis->pfnOpenIn(pThis->pHDAState,  "hda.in", PDMAUDIORECSOURCE_LINE_IN, pCfg);
    26142613            break;
    2615 
     2614#ifdef VBOX_WITH_HDA_MIC_IN
     2615        case MC_INDEX:
     2616            rc = pThis->pfnOpenIn(pThis->pHDAState,  "hda.mc", PDMAUDIORECSOURCE_MIC, pCfg);
     2617            break;
     2618#endif
    26162619        case PO_INDEX:
    26172620            rc = pThis->pfnOpenOut(pThis->pHDAState, "hda.out", pCfg);
    26182621            break;
    26192622
    2620 #ifdef VBOX_WITH_HDA_MIC_IN
    2621         case MC_INDEX:
    2622             rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc", PDMAUDIORECSOURCE_MIC, pCfg);
    2623             break;
    2624 #endif
    26252623        default:
    26262624            AssertMsgFailed(("Index %ld not implemented\n", enmSoundSource));
     
    27312729    pThis->paVerbs   = &g_aCodecVerbs[0];
    27322730    pThis->cVerbs    = RT_ELEMENTS(g_aCodecVerbs);
     2731
    27332732    pThis->pfnLookup       = codecLookup;
    27342733#ifdef DEBUG
     
    27472746    pThis->paNodes[1].afg.u32F20_param = CODEC_MAKE_F20(pThis->u16VendorId, pThis->u8BSKU, pThis->u8AssemblyId);
    27482747
    2749     /* 44.1 kHz. */
    2750     PDMAUDIOSTREAMCFG as;
    2751     as.uHz           = 44100;
    2752     as.cChannels     = 2;
    2753     as.enmFormat     = AUD_FMT_S16;
    2754     as.enmEndianness = PDMAUDIOHOSTENDIANNESS;
    2755 
    2756     pThis->paNodes[1].node.au32F00_param[0xA] = CODEC_F00_0A_16_BIT;
    2757 
    2758     hdaCodecOpenStream(pThis, PI_INDEX, &as);
    2759     hdaCodecOpenStream(pThis, PO_INDEX, &as);
     2748    /* This codec uses a fixed setting (44.1 kHz, 16-bit signed, 2 channels). */
     2749    pThis->strmCfg.uHz           = 44100;
     2750    pThis->strmCfg.cChannels     = 2;
     2751    pThis->strmCfg.enmFormat     = AUD_FMT_S16;
     2752    pThis->strmCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
     2753
     2754    hdaCodecOpenStream(pThis, PI_INDEX, &pThis->strmCfg);
    27602755#ifdef VBOX_WITH_HDA_MIC_IN
    2761     hdaCodecOpenStream(pThis, MC_INDEX, &as);
     2756    hdaCodecOpenStream(pThis, MC_INDEX, &pThis->strmCfg);
    27622757#endif
    2763 
    2764     pThis->paNodes[1].node.au32F00_param[0xA] |= CODEC_F00_0A_44_1KHZ;
    2765 
    2766     uint8_t i;
    2767     Assert(pThis->paNodes);
    2768     Assert(pThis->pfnCodecNodeReset);
    2769 
    2770     for (i = 0; i < pThis->cTotalNodes; ++i)
     2758    hdaCodecOpenStream(pThis, PO_INDEX, &pThis->strmCfg);
     2759
     2760    /* Initialize the AFG node with the fixed setting. */
     2761    pThis->paNodes[1].node.au32F00_param[0xA] = CODEC_F00_0A_44_1KHZ | CODEC_F00_0A_16_BIT;
     2762
     2763    AssertPtr(pThis->paNodes);
     2764    AssertPtr(pThis->pfnCodecNodeReset);
     2765
     2766    for (uint8_t i = 0; i < pThis->cTotalNodes; i++)
    27712767        pThis->pfnCodecNodeReset(pThis, i, &pThis->paNodes[i]);
    27722768
    2773     hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_PCM);
     2769    hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params,       PDMAUDIOMIXERCTL_PCM);
    27742770    hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
    27752771
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