VirtualBox

Changeset 88026 in vbox


Ignore:
Timestamp:
Mar 8, 2021 6:41:53 PM (4 years ago)
Author:
vboxsync
Message:

Audio: Preparing to move some of the DrvAudio.h stuff into PDM. bugref:9890

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r87990 r88026  
    299299    PDMAUDIODIR_OUT,
    300300    /** Duplex handling. */
    301     PDMAUDIODIR_ANY,
     301    PDMAUDIODIR_DUPLEX,
    302302    /** Hack to blow the type up to 32-bit. */
    303303    PDMAUDIODIR_32BIT_HACK = 0x7fffffff
     
    14371437     * @returns Status of the host audio backend.
    14381438     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1439      * @param   enmDir          Audio direction to check host audio backend for. Specify PDMAUDIODIR_ANY for the overall
     1439     * @param   enmDir          Audio direction to check host audio backend for. Specify PDMAUDIODIR_DUPLEX for the overall
    14401440     *                          backend status.
    14411441     */
     
    16461646     * @returns PDMAUDIOBACKENDSTS enum.
    16471647     * @param   pInterface          Pointer to the interface structure containing the called function pointer.
    1648      * @param   enmDir              Audio direction to get status for. Pass PDMAUDIODIR_ANY for overall status.
     1648     * @param   enmDir              Audio direction to get status for. Pass PDMAUDIODIR_DUPLEX for overall status.
    16491649     */
    16501650    DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir));
  • trunk/src/VBox/Devices/Audio/AudioMixer.cpp

    r88025 r88026  
    580580    /* ppStream is optional. */
    581581
    582     if (pConn->pfnGetStatus(pConn, PDMAUDIODIR_ANY) == PDMAUDIOBACKENDSTS_NOT_ATTACHED)
     582    if (pConn->pfnGetStatus(pConn, PDMAUDIODIR_DUPLEX) == PDMAUDIOBACKENDSTS_NOT_ATTACHED)
    583583        return VERR_AUDIO_BACKEND_NOT_ATTACHED;
    584584
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r88025 r88026  
    469469
    470470    LogRel2(("Audio: %s stream '%s' in backend (%s is %s)\n", PDMAudioStrmCmdGetName(enmStreamCmd), pStream->szName,
    471                                                               DrvAudioHlpAudDirToStr(pStream->enmDir),
     471                                                              PDMAudioDirGetName(pStream->enmDir),
    472472                                                              fEnabled ? "enabled" : "disabled"));
    473473    switch (enmStreamCmd)
     
    938938    AssertMsg(pStream->enmDir == PDMAUDIODIR_OUT,
    939939              ("Stream '%s' is not an output stream and therefore cannot be written to (direction is '%s')\n",
    940                pStream->szName, DrvAudioHlpAudDirToStr(pStream->enmDir)));
     940               pStream->szName, PDMAudioDirGetName(pStream->enmDir)));
    941941
    942942    AssertMsg(PDMAudioPropsIsSizeAligned(&pStream->Guest.Cfg.Props, cbBuf),
     
    21692169
    21702170                    LogRel(("Audio: Device '%s':\n", pDev->szName));
    2171                     LogRel(("Audio: \tUsage           = %s\n",   DrvAudioHlpAudDirToStr(pDev->enmUsage)));
     2171                    LogRel(("Audio: \tUsage           = %s\n",   PDMAudioDirGetName(pDev->enmUsage)));
    21722172                    LogRel(("Audio: \tFlags           = %s\n",   pszFlags ? pszFlags : "<NONE>"));
    21732173                    LogRel(("Audio: \tInput channels  = %RU8\n", pDev->cMaxInputChannels));
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r88025 r88026  
    187187/** @name Audio format helper methods.
    188188 * @{ */
    189 const char *DrvAudioHlpAudDirToStr(PDMAUDIODIR enmDir);
    190 const char *DrvAudioHlpAudFmtToStr(PDMAUDIOFMT enmFmt);
     189const char *PDMAudioDirGetName(PDMAUDIODIR enmDir);
     190const char *PDMAudioFormatGetName(PDMAUDIOFMT enmFmt);
    191191bool        PDMAudioFormatIsSigned(PDMAUDIOFMT enmFmt);
    192192uint8_t     PDMAudioFormatGetBits(PDMAUDIOFMT enmFmt);
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r88025 r88026  
    336336 * @param   pDstDevEnm          Destination enumeration to store enumeration entries into.
    337337 * @param   pSrcDevEnm          Source enumeration to use.
    338  * @param   enmUsage            Which entries to copy. Specify PDMAUDIODIR_ANY to copy all entries.
     338 * @param   enmUsage            Which entries to copy. Specify PDMAUDIODIR_DUPLEX to copy all entries.
    339339 * @param   fCopyUserData       Whether to also copy the user data portion or not.
    340340 */
     
    350350    RTListForEach(&pSrcDevEnm->lstDevices, pSrcDev, PDMAUDIODEVICE, Node)
    351351    {
    352         if (   enmUsage != PDMAUDIODIR_ANY
     352        if (   enmUsage != PDMAUDIODIR_DUPLEX
    353353            && enmUsage != pSrcDev->enmUsage)
    354354        {
     
    383383int DrvAudioHlpDeviceEnumCopy(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm)
    384384{
    385     return DrvAudioHlpDeviceEnumCopyEx(pDstDevEnm, pSrcDevEnm, PDMAUDIODIR_ANY, false /* fCopyUserData */);
     385    return DrvAudioHlpDeviceEnumCopyEx(pDstDevEnm, pSrcDevEnm, PDMAUDIODIR_DUPLEX, false /* fCopyUserData */);
    386386}
    387387
     
    401401    RTListForEach(&pDevEnm->lstDevices, pDev, PDMAUDIODEVICE, Node)
    402402    {
    403         if (enmUsage != PDMAUDIODIR_ANY)
     403        if (enmUsage != PDMAUDIODIR_DUPLEX)
    404404        {
    405405            if (enmUsage != pDev->enmUsage) /* Wrong usage? Skip. */
     
    425425    AssertPtrReturn(pDevEnm, 0);
    426426
    427     if (enmUsage == PDMAUDIODIR_ANY)
     427    if (enmUsage == PDMAUDIODIR_DUPLEX)
    428428        return pDevEnm->cDevices;
    429429
     
    459459
    460460        LogFunc(("Device '%s':\n", pDev->szName));
    461         LogFunc(("\tUsage           = %s\n",             DrvAudioHlpAudDirToStr(pDev->enmUsage)));
     461        LogFunc(("\tUsage           = %s\n",             PDMAudioDirGetName(pDev->enmUsage)));
    462462        LogFunc(("\tFlags           = %s\n",             pszFlags ? pszFlags : "<NONE>"));
    463463        LogFunc(("\tInput channels  = %RU8\n",           pDev->cMaxInputChannels));
     
    471471
    472472/**
    473  * Converts an audio direction to a string.
    474  *
    475  * @returns Stringified audio direction, or "Unknown", if not found.
    476  * @param   enmDir              Audio direction to convert.
    477  */
    478 const char *DrvAudioHlpAudDirToStr(PDMAUDIODIR enmDir)
     473 * Gets the name of an audio direction enum value.
     474 *
     475 * @returns Pointer to read-only name string on success, "Unknown" if
     476 *          passed an invalid enum value.
     477 * @param   enmDir  The audio direction value to name.
     478 */
     479const char *PDMAudioDirGetName(PDMAUDIODIR enmDir)
    479480{
    480481    switch (enmDir)
     
    483484        case PDMAUDIODIR_IN:      return "Input";
    484485        case PDMAUDIODIR_OUT:     return "Output";
    485         case PDMAUDIODIR_ANY:     return "Duplex";
    486         default:                  break;
    487     }
    488 
    489     AssertMsgFailed(("Invalid audio direction %ld\n", enmDir));
    490     return "Unknown";
     486        case PDMAUDIODIR_DUPLEX:  return "Duplex";
     487
     488        /* no default */
     489        case PDMAUDIODIR_INVALID:
     490        case PDMAUDIODIR_32BIT_HACK:
     491            break;
     492    }
     493    AssertMsgFailedReturn(("Invalid audio direction %d\n", enmDir), "Unknown");
    491494}
    492495
     
    615618
    616619/**
    617  * Returns wether the given audio format has signed bits or not.
    618  *
    619  * @return  IPRT status code.
    620  * @return  bool                @c true for signed bits, @c false for unsigned.
    621  * @param   enmFmt              Audio format to retrieve value for.
     620 * Checks whether the audio format is signed.
     621 *
     622 * @returns @c true for signed format, @c false for unsigned.
     623 * @param   enmFmt  The audio format.
    622624 */
    623625bool PDMAudioFormatIsSigned(PDMAUDIOFMT enmFmt)
     
    635637            return false;
    636638
    637         default:
     639        /* no default */
     640        case PDMAUDIOFMT_INVALID:
     641        case PDMAUDIOFMT_32BIT_HACK:
    638642            break;
    639643    }
    640 
    641     AssertMsgFailed(("Bogus audio format %ld\n", enmFmt));
    642     return false;
    643 }
    644 
    645 /**
    646  * Returns the bits of a given audio format.
    647  *
    648  * @return  IPRT status code.
    649  * @return  uint8_t             Bits of audio format.
    650  * @param   enmFmt              Audio format to retrieve value for.
     644    AssertMsgFailedReturn(("Bogus audio format %ld\n", enmFmt), false);
     645}
     646
     647/**
     648 * Gets the encoding width in bits of the give audio format.
     649 *
     650 * @returns Bit count. 0 if invalid input.
     651 * @param   enmFmt      The audio format.
    651652 */
    652653uint8_t PDMAudioFormatGetBits(PDMAUDIOFMT enmFmt)
     
    666667            return 32;
    667668
    668         default:
     669        /* no default */
     670        case PDMAUDIOFMT_INVALID:
     671        case PDMAUDIOFMT_32BIT_HACK:
    669672            break;
    670673    }
    671 
    672     AssertMsgFailed(("Bogus audio format %ld\n", enmFmt));
    673     return 0;
    674 }
    675 
    676 /**
    677  * Converts an audio format to a string.
    678  *
    679  * @returns Stringified audio format, or "Unknown", if not found.
    680  * @param   enmFmt              Audio format to convert.
    681  */
    682 const char *DrvAudioHlpAudFmtToStr(PDMAUDIOFMT enmFmt)
     674    AssertMsgFailedReturn(("Bogus audio format %ld\n", enmFmt), 0);
     675}
     676
     677/**
     678 * Gets the name of an audio format enum value.
     679 *
     680 * @returns Pointer to read-only name on success, returns "Unknown" on if
     681 *          invalid enum value.
     682 * @param   enmFmt      The audio format to name.
     683 */
     684const char *PDMAudioFormatGetName(PDMAUDIOFMT enmFmt)
    683685{
    684686    switch (enmFmt)
    685687    {
    686         case PDMAUDIOFMT_U8:
    687             return "U8";
    688 
    689         case PDMAUDIOFMT_U16:
    690             return "U16";
    691 
    692         case PDMAUDIOFMT_U32:
    693             return "U32";
    694 
    695         case PDMAUDIOFMT_S8:
    696             return "S8";
    697 
    698         case PDMAUDIOFMT_S16:
    699             return "S16";
    700 
    701         case PDMAUDIOFMT_S32:
    702             return "S32";
    703 
    704         default:
     688        case PDMAUDIOFMT_U8:    return "U8";
     689        case PDMAUDIOFMT_U16:   return "U16";
     690        case PDMAUDIOFMT_U32:   return "U32";
     691        case PDMAUDIOFMT_S8:    return "S8";
     692        case PDMAUDIOFMT_S16:   return "S16";
     693        case PDMAUDIOFMT_S32:   return "S32";
     694        /* no default */
     695        case PDMAUDIOFMT_INVALID:
     696        case PDMAUDIOFMT_32BIT_HACK:
    705697            break;
    706698    }
    707 
    708     AssertMsgFailed(("Bogus audio format %ld\n", enmFmt));
    709     return "Unknown";
     699    AssertMsgFailedReturn(("Bogus audio format %d\n", enmFmt), "Unknown");
    710700}
    711701
  • trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp

    r88023 r88026  
    785785                        if (pDevSrcInData->deviceID == pDevSrcOutData->deviceID)
    786786                        {
    787                             pDevDst->enmUsage           = PDMAUDIODIR_ANY;
     787                            pDevDst->enmUsage           = PDMAUDIODIR_DUPLEX;
    788788                            pDevDst->cMaxOutputChannels = pDevSrcOut->cMaxOutputChannels;
    789789
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