VirtualBox

Changeset 33482 in vbox for trunk/src


Ignore:
Timestamp:
Oct 27, 2010 8:31:55 AM (14 years ago)
Author:
vboxsync
Message:

Audio/HDA: don't propogate audio format without verification that format supported by host's backend.

File:
1 edited

Legend:

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

    r33400 r33482  
    19091909    AUD_register_card ("ICH0", &pState->card);
    19101910
    1911     /* @todo: AFG:f00[0xA] -> quemu's voices */
    1912 
     1911    /* 44.1 kHz */
    19131912    as.freq = 44100;
    19141913    as.nchannels = 2;
     
    19191918        AUDIO_FORMAT_SELECTOR((pState), Out, (base), (mult), div) = AUD_open_out(&(pState)->card,                           \
    19201919            AUDIO_FORMAT_SELECTOR(pState, Out, (base), (mult), (div)), name ".out", (pState), (out_callback), &(as));       \
    1921         Assert(AUDIO_FORMAT_SELECTOR(pState, Out, (base), (mult), (div)));                                                  \
    19221920        if (!AUDIO_FORMAT_SELECTOR(pState, Out, (base), (mult), (div)))                                                     \
    19231921            LogRel (("HDAcodec: WARNING: Unable to open PCM OUT(%s)!\n", name ".out"));                                     \
    19241922        AUDIO_FORMAT_SELECTOR(pState, In, (base), (mult), (div)) = AUD_open_in(&(pState)->card,                             \
    19251923            AUDIO_FORMAT_SELECTOR(pState, In, (base), (mult), (div)), name ".in", (pState), (in_callback), &(as));          \
    1926         Assert(AUDIO_FORMAT_SELECTOR((pState), In, (base), (mult), (div)));                                                 \
    19271924        if (!AUDIO_FORMAT_SELECTOR(pState, In, (base), (mult), (div)))                                                      \
    19281925            LogRel (("HDAcodec: WARNING: Unable to open PCM IN(%s)!\n", name ".in"));                                       \
    19291926    } while(0)
     1927    #define IS_FORMAT_SUPPORTED_BY_HOST(pState, base, mult, div) (AUDIO_FORMAT_SELECTOR((pState), Out, (base), (mult), (div)) \
     1928        && AUDIO_FORMAT_SELECTOR((pState), In, (base), (mult), (div)))
    19301929   
     1930    pState->pNodes[1].node.au32F00_param[0xA] = RT_BIT(17); /* 16-bit samples */
    19311931    SETUP_AUDIO_FORMAT(pState, AFMT_HZ_44_1K, AFMT_MULT_X1, AFMT_DIV_X1, "hda44_1", as, pi_callback, po_callback);
    1932     pState->pNodes[1].node.au32F00_param[0xA] = RT_BIT(17)|RT_BIT(5);
     1932    pState->pNodes[1].node.au32F00_param[0xA] |= IS_FORMAT_SUPPORTED_BY_HOST(pState, AFMT_HZ_44_1K, AFMT_MULT_X1, AFMT_MULT_X1) ? RT_BIT(5) : 0;
    19331933
    19341934#ifdef VBOX_WITH_AUDIO_FLEXIBLE_FORMAT
    19351935    as.freq *= 2; /* 2 * 44.1kHz */
    19361936    SETUP_AUDIO_FORMAT(pState, AFMT_HZ_44_1K, AFMT_MULT_X2, AFMT_DIV_X1, "hda44_1_2x", as, pi_callback, po_callback);
    1937     pState->pNodes[1].node.au32F00_param[0xA] |= RT_BIT(7);
     1937    pState->pNodes[1].node.au32F00_param[0xA] |= IS_FORMAT_SUPPORTED_BY_HOST(pState, AFMT_HZ_44_1K, AFMT_MULT_X2, AFMT_MULT_X1) ? RT_BIT(7) : 0;
    19381938
    19391939    as.freq *= 2; /* 4 * 44.1kHz */
    19401940    SETUP_AUDIO_FORMAT(pState, AFMT_HZ_44_1K, AFMT_MULT_X4, AFMT_DIV_X1, "hda44_1_4x", as, pi_callback, po_callback);
    1941     pState->pNodes[1].node.au32F00_param[0xA] |= RT_BIT(9);
     1941    pState->pNodes[1].node.au32F00_param[0xA] |= IS_FORMAT_SUPPORTED_BY_HOST(pState, AFMT_HZ_44_1K, AFMT_MULT_X4, AFMT_MULT_X1) ? RT_BIT(9) : 0;
    19421942
    19431943    as.freq = 48000;
    19441944    SETUP_AUDIO_FORMAT(pState, AFMT_HZ_48K, AFMT_MULT_X1, AFMT_DIV_X1, "hda48", as, pi_callback, po_callback);
    1945     pState->pNodes[1].node.au32F00_param[0xA] |= RT_BIT(6);
     1945    pState->pNodes[1].node.au32F00_param[0xA] |= IS_FORMAT_SUPPORTED_BY_HOST(pState, AFMT_HZ_48K, AFMT_MULT_X1, AFMT_MULT_X1) ? RT_BIT(6) : 0;
    19461946
    19471947# if 0
    19481948    as.freq *= 2; /* 2 * 48kHz */
    19491949    SETUP_AUDIO_FORMAT(pState, AFMT_HZ_48K, AFMT_MULT_X2, AFMT_DIV_X1, "hda48_2x", as, pi_callback, po_callback);
    1950     pState->pNodes[1].node.au32F00_param[0xA] |= RT_BIT(8);
     1950    pState->pNodes[1].node.au32F00_param[0xA] |= IS_FORMAT_SUPPORTED_BY_HOST(pState, AFMT_HZ_48K, AFMT_MULT_X2, AFMT_MULT_X1) ? RT_BIT(8) : 0;
    19511951
    19521952    as.freq *= 2; /* 4 * 48kHz */
    19531953    SETUP_AUDIO_FORMAT(pState, AFMT_HZ_48K, AFMT_MULT_X4, AFMT_DIV_X1, "hda48_4x", as, pi_callback, po_callback);
    1954     pState->pNodes[1].node.au32F00_param[0xA] |= RT_BIT(10);
     1954    pState->pNodes[1].node.au32F00_param[0xA] |= IS_FORMAT_SUPPORTED_BY_HOST(pState, AFMT_HZ_48K, AFMT_MULT_X4, AFMT_MULT_X1) ? RT_BIT(10) : 0;
    19551955# endif
    19561956#endif
    19571957    #undef SETUP_AUDIO_FORMAT
     1958    #undef IS_FORMAT_SUPPORTED_BY_HOST
    19581959
    19591960    codecToAudVolume(&pState->pNodes[pState->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME);
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