VirtualBox

Changeset 87852 in vbox


Ignore:
Timestamp:
Feb 23, 2021 5:45:39 PM (4 years ago)
Author:
vboxsync
Message:

Audio/Mixer: Implemented mixer creation flags to support runtime debugging mode.

Location:
trunk/src/VBox/Devices/Audio
Files:
4 edited

Legend:

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

    r87273 r87852  
    219219 * @returns IPRT status code.
    220220 * @param   pcszName            Name of the audio mixer.
    221  * @param   fFlags              Creation flags. Not used at the moment and must be 0.
     221 * @param   fFlags              Creation flags.
    222222 * @param   ppMixer             Pointer which returns the created mixer object.
    223223 */
    224224int AudioMixerCreate(const char *pcszName, uint32_t fFlags, PAUDIOMIXER *ppMixer)
    225225{
    226     RT_NOREF(fFlags);
    227226    AssertPtrReturn(pcszName, VERR_INVALID_POINTER);
    228     /** @todo Add fFlags validation. */
     227    AssertReturn   (fFlags & AUDMIXER_FLAGS_VALID_MASK, VERR_INVALID_PARAMETER);
    229228    AssertPtrReturn(ppMixer, VERR_INVALID_POINTER);
    230229
     
    245244            pMixer->cSinks = 0;
    246245            RTListInit(&pMixer->lstSinks);
     246
     247            pMixer->fFlags = fFlags;
     248
     249            if (pMixer->fFlags & AUDMIXER_FLAGS_DEBUG)
     250                LogRel(("Audio Mixer: Debug mode enabled\n"));
    247251
    248252            /* Set master volume to the max. */
     
    913917    }
    914918
    915 #ifdef VBOX_AUDIO_MIXER_DEBUG
    916     DrvAudioHlpFileDestroy(pSink->Dbg.pFile);
    917     pSink->Dbg.pFile = NULL;
    918 #endif
     919    if (pSink->pParent->fFlags & AUDMIXER_FLAGS_DEBUG)
     920    {
     921        DrvAudioHlpFileDestroy(pSink->Dbg.pFile);
     922        pSink->Dbg.pFile = NULL;
     923    }
    919924
    920925    if (pSink->pszName)
     
    12661271            pSink->tsLastReadWrittenNs = RTTimeNanoTS();
    12671272
    1268 #ifdef VBOX_AUDIO_MIXER_DEBUG
    1269             int rc2 = DrvAudioHlpFileWrite(pSink->Dbg.pFile, pvBuf, cbRead, 0 /* fFlags */);
    1270             AssertRC(rc2);
    1271 #endif
     1273            if (pSink->pParent->fFlags & AUDMIXER_FLAGS_DEBUG)
     1274            {
     1275                int rc2 = DrvAudioHlpFileWrite(pSink->Dbg.pFile, pvBuf, cbRead, 0 /* fFlags */);
     1276                AssertRC(rc2);
     1277            }
    12721278        }
    12731279    }
     
    14991505    }
    15001506
    1501 #ifdef VBOX_AUDIO_MIXER_DEBUG
    1502     if (RT_SUCCESS(rc))
     1507    if (   RT_SUCCESS(rc)
     1508        && (pSink->pParent->fFlags & AUDMIXER_FLAGS_DEBUG))
    15031509    {
    15041510        DrvAudioHlpFileClose(pSink->Dbg.pFile);
     
    15251531        }
    15261532    }
    1527 #endif
    15281533
    15291534    int rc2 = RTCritSectLeave(&pSink->CritSect);
  • trunk/src/VBox/Devices/Audio/AudioMixer.h

    r87270 r87852  
    5050    /** Number of used audio sinks. */
    5151    uint8_t                 cSinks;
     52    /** Mixer flags. See AUDMIXER_FLAGS_XXX. */
     53    uint32_t                fFlags;
    5254} AUDIOMIXER;
    5355/** Pointer to an audio mixer instance. */
     
    224226    /** Last read (recording) / written (playback) timestamp (in ns). */
    225227    uint64_t                tsLastReadWrittenNs;
    226 #ifdef VBOX_AUDIO_MIXER_DEBUG
    227228    struct
    228229    {
    229230        PPDMAUDIOFILE       pFile;
    230231    } Dbg;
    231 #endif
    232232} AUDMIXSINK;
    233233
     
    250250#define AUDMIXSTRMCTL_F_NONE            0
    251251
    252 int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer);
     252/** No mixer flags specified. */
     253#define AUDMIXER_FLAGS_NONE             0
     254/** Debug mode enabled.
     255 *  This writes .WAV file to the host, usually to the temporary directory. */
     256#define AUDMIXER_FLAGS_DEBUG            RT_BIT(0)
     257/** Validation mask. */
     258#define AUDMIXER_FLAGS_VALID_MASK       UINT32_C(0x00000001)
     259
     260int AudioMixerCreate(const char *pszName, uint32_t fFlags, PAUDIOMIXER *ppMixer);
    253261int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink);
    254262void AudioMixerDestroy(PAUDIOMIXER pMixer);
  • trunk/src/VBox/Devices/Audio/DevHDA.cpp

    r87835 r87852  
    49934993     * Create the mixer.
    49944994     */
    4995     rc = AudioMixerCreate("HDA Mixer", 0 /* uFlags */, &pThisCC->pMixer);
     4995    uint32_t fMixer = AUDMIXER_FLAGS_NONE;
     4996    if (pThisCC->Dbg.fEnabled)
     4997        fMixer |= AUDMIXER_FLAGS_DEBUG;
     4998    rc = AudioMixerCreate("HDA Mixer", fMixer, &pThisCC->pMixer);
    49964999    AssertRCReturn(rc, rc);
    49975000
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r87767 r87852  
    43034303    }
    43044304
     4305    uint32_t fMixer = AUDMIXER_FLAGS_NONE;
     4306    if (pThisCC->Dbg.fEnabled)
     4307        fMixer |= AUDMIXER_FLAGS_DEBUG;
     4308
    43054309    rc = AudioMixerCreate("AC'97 Mixer", 0 /* uFlags */, &pThisCC->pMixer);
    43064310    AssertRCReturn(rc, rc);
     4311
    43074312    rc = AudioMixerCreateSink(pThisCC->pMixer, "[Recording] Line In", AUDMIXSINKDIR_INPUT, &pThisCC->pSinkLineIn);
    43084313    AssertRCReturn(rc, rc);
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