Changeset 88917 in vbox for trunk/src/VBox
- Timestamp:
- May 6, 2021 9:24:44 PM (4 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r88916 r88917 121 121 * AUDIOMIXERSINK_STATUS_STR_MAX in length. 122 122 */ 123 static const char *dbgAudioMixerSinkStatusToStr( AUDMIXSINKSTSfStatus, char pszDst[AUDIOMIXERSINK_STATUS_STR_MAX])123 static const char *dbgAudioMixerSinkStatusToStr(uint32_t fStatus, char pszDst[AUDIOMIXERSINK_STATUS_STR_MAX]) 124 124 { 125 125 if (!fStatus) … … 215 215 * @returns VBox status code. 216 216 * @param pcszName Name of the audio mixer. 217 * @param fFlags Creation flags .217 * @param fFlags Creation flags - AUDMIXER_FLAGS_XXX. 218 218 * @param ppMixer Pointer which returns the created mixer object. 219 219 */ … … 531 531 * in some unspecified way (see 532 532 * PDMIAUDIOCONNECTOR::pfnStreamCreate). 533 * @param fFlags Stream flags. Currently unused, set to 0.534 533 * @param pDevIns The device instance to register statistics with. 535 534 * @param ppStream Pointer which receives the newly created audio stream. 536 535 */ 537 536 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg, 538 AUDMIXSTREAMFLAGS fFlags,PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream)537 PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream) 539 538 { 540 539 AssertPtrReturn(pSink, VERR_INVALID_POINTER); 541 540 AssertPtrReturn(pConn, VERR_INVALID_POINTER); 542 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 543 /** @todo Validate fFlags. */ 544 /* ppStream is optional. */ 541 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 542 AssertPtrNullReturn(ppStream, VERR_INVALID_POINTER); 545 543 RT_NOREF(pDevIns); /* we'll probably be adding more statistics */ 546 544 … … 560 558 PAUDMIXSTREAM pMixStream = (PAUDMIXSTREAM)RTMemAllocZ(sizeof(AUDMIXSTREAM)); 561 559 AssertReturn(pMixStream, VERR_NO_MEMORY); 562 563 pMixStream->fFlags = fFlags;564 560 565 561 /* Assign the backend's name to the mixer stream's name for easier identification in the (release) log. */ … … 579 575 if (RT_SUCCESS(rc)) 580 576 { 581 LogFlowFunc(("[%s] fFlags=0x%x (enmDir=%ld, %u bits, %RU8 channels, %RU32Hz)\n", pSink->pszName, fFlags, pCfg->enmDir,577 LogFlowFunc(("[%s] (enmDir=%ld, %u bits, %RU8 channels, %RU32Hz)\n", pSink->pszName, pCfg->enmDir, 582 578 PDMAudioPropsSampleBits(&pCfg->Props), PDMAudioPropsChannels(&pCfg->Props), pCfg->Props.uHz)); 583 579 … … 1000 996 * Returns the current status of a mixer sink. 1001 997 * 1002 * @returns The sink's current status .998 * @returns The sink's current status (AUDMIXSINK_STS_XXX). 1003 999 * @param pSink Mixer sink to return status for. 1004 1000 */ 1005 AUDMIXSINKSTSAudioMixerSinkGetStatus(PAUDMIXSINK pSink)1001 uint32_t AudioMixerSinkGetStatus(PAUDMIXSINK pSink) 1006 1002 { 1007 1003 if (!pSink) … … 1013 1009 1014 1010 /* If the dirty flag is set, there is unprocessed data in the sink. */ 1015 AUDMIXSINKSTS stsSink = pSink->fStatus;1011 uint32_t const fStsSink = pSink->fStatus; 1016 1012 1017 1013 rc2 = RTCritSectLeave(&pSink->CritSect); 1018 1014 AssertRC(rc2); 1019 1015 1020 return stsSink;1016 return fStsSink; 1021 1017 } 1022 1018 -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r88916 r88917 59 59 60 60 61 /** Defines an audio mixer stream's flags. */62 #define AUDMIXSTREAMFLAGS uint32_t63 64 /** No flags specified. */65 #define AUDMIXSTREAM_F_NONE 066 /** The mixing stream is flagged as being enabled (active). */67 #define AUDMIXSTREAM_F_ENABLED RT_BIT(0)68 69 /** Defines an audio mixer stream's internal status. */70 #define AUDMIXSTREAMSTATUS uint32_t71 72 /** @name AUDMIXSTREAM_STATUS_XXX - mixer stream status.73 * (This is a destilled version of PDMAUDIOSTREAM_STS_XXX.)74 * @{ */75 /** No status set. */76 #define AUDMIXSTREAM_STATUS_NONE 077 /** The mixing stream is enabled (active). */78 #define AUDMIXSTREAM_STATUS_ENABLED RT_BIT(0)79 /** The mixing stream can be read from.80 * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */81 #define AUDMIXSTREAM_STATUS_CAN_READ RT_BIT(1)82 /** The mixing stream can be written to.83 * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */84 #define AUDMIXSTREAM_STATUS_CAN_WRITE RT_BIT(2)85 /** @} */86 87 88 61 /** 89 62 * Audio mixer stream. … … 91 64 typedef struct AUDMIXSTREAM 92 65 { 93 /** List node. */66 /** List entry on AUDMIXSINK::lstStreams. */ 94 67 RTLISTNODE Node; 95 68 /** Name of this stream. */ … … 99 72 /** Sink this stream is attached to. */ 100 73 PAUDMIXSINK pSink; 101 /** Stream flags of type AUDMIXSTREAM_F_. */102 uint32_t fFlags;103 74 /** Stream status of type AUDMIXSTREAM_STATUS_. */ 104 75 uint32_t fStatus; … … 119 90 /** The streams's critical section. */ 120 91 RTCRITSECT CritSect; 121 } AUDMIXSTREAM, *PAUDMIXSTREAM; 122 123 /** Defines an audio sink's current status. */ 124 #define AUDMIXSINKSTS uint32_t 125 92 } AUDMIXSTREAM; 93 /** Pointer to an audio mixer stream. */ 94 typedef AUDMIXSTREAM *PAUDMIXSTREAM; 95 96 /** @name AUDMIXSTREAM_STATUS_XXX - mixer stream status. 97 * (This is a destilled version of PDMAUDIOSTREAM_STS_XXX.) 98 * @{ */ 99 /** No status set. */ 100 #define AUDMIXSTREAM_STATUS_NONE UINT32_C(0) 101 /** The mixing stream is enabled (active). */ 102 #define AUDMIXSTREAM_STATUS_ENABLED RT_BIT_32(0) 103 /** The mixing stream can be read from. 104 * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */ 105 #define AUDMIXSTREAM_STATUS_CAN_READ RT_BIT_32(1) 106 /** The mixing stream can be written to. 107 * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */ 108 #define AUDMIXSTREAM_STATUS_CAN_WRITE RT_BIT_32(2) 109 /** @} */ 110 111 112 /** 113 * Audio mixer sink. 114 */ 115 typedef struct AUDMIXSINK 116 { 117 /** List entry on AUDIOMIXER::lstSinks. */ 118 RTLISTNODE Node; 119 /** Pointer to mixer object this sink is bound to. */ 120 PAUDIOMIXER pParent; 121 /** Name of this sink. */ 122 char *pszName; 123 /** The sink direction (either PDMAUDIODIR_IN or PDMAUDIODIR_OUT). */ 124 PDMAUDIODIR enmDir; 125 /** Scratch buffer for multiplexing / mixing. Might be NULL if not needed. */ 126 uint8_t *pabScratchBuf; 127 /** Size (in bytes) of pabScratchBuf. Might be 0 if not needed. */ 128 size_t cbScratchBuf; 129 /** The sink's PCM format. */ 130 PDMAUDIOPCMPROPS PCMProps; 131 /** Sink status bits - AUDMIXSINK_STS_XXX. */ 132 uint32_t fStatus; 133 /** Number of streams assigned. */ 134 uint8_t cStreams; 135 /** List of assigned streams. 136 * @note All streams have the same PCM properties, so the mixer does not do 137 * any conversion. bird: That is *NOT* true any more, the mixer has 138 * encoders/decoder states for each stream (well, input is still a todo). 139 * 140 * @todo Use something faster -- vector maybe? bird: It won't be faster. You 141 * will have a vector of stream pointers (because you cannot have a vector 142 * of full AUDMIXSTREAM structures since they'll move when the vector is 143 * reallocated and we need pointers to them to give out to devices), which 144 * is the same cost as going via Node.pNext/pPrev. */ 145 RTLISTANCHOR lstStreams; 146 /** The volume of this sink. The volume always will 147 * be combined with the mixer's master volume. */ 148 PDMAUDIOVOLUME Volume; 149 /** The volume of this sink, combined with the last set master volume. */ 150 PDMAUDIOVOLUME VolumeCombined; 151 /** Timestamp since last update (in ms). */ 152 uint64_t tsLastUpdatedMs; 153 /** Last read (recording) / written (playback) timestamp (in ns). */ 154 uint64_t tsLastReadWrittenNs; 155 /** Union for input/output specifics. */ 156 union 157 { 158 struct 159 { 160 /** The current recording source. Can be NULL if not set. */ 161 PAUDMIXSTREAM pStreamRecSource; 162 } In; 163 /*struct 164 { 165 } Out; */ 166 }; 167 struct 168 { 169 PAUDIOHLPFILE pFile; 170 } Dbg; 171 /** This sink's mixing buffer, acting as 172 * a parent buffer for all streams this sink owns. */ 173 AUDIOMIXBUF MixBuf; 174 /** The sink's critical section. */ 175 RTCRITSECT CritSect; 176 } AUDMIXSINK; 177 178 /** @name AUDMIXSINK_STS_XXX - Sink status bits. 179 * @{ */ 126 180 /** No status specified. */ 127 181 #define AUDMIXSINK_STS_NONE 0 … … 136 190 * recorded but not transferred to the destination yet. */ 137 191 #define AUDMIXSINK_STS_DIRTY RT_BIT(2) 138 139 /** 140 * Audio input sink specifics. 141 * 142 * Do not use directly. Instead, use AUDMIXSINK. 143 */ 144 typedef struct AUDMIXSINKIN 145 { 146 /** The current recording source. Can be NULL if not set. */ 147 PAUDMIXSTREAM pStreamRecSource; 148 } AUDMIXSINKIN; 149 150 /** 151 * Audio output sink specifics. 152 * 153 * Do not use directly. Instead, use AUDMIXSINK. 154 */ 155 typedef struct AUDMIXSINKOUT 156 { 157 } AUDMIXSINKOUT; 158 159 /** 160 * Audio mixer sink. 161 */ 162 typedef struct AUDMIXSINK 163 { 164 RTLISTNODE Node; 165 /** Pointer to mixer object this sink is bound to. */ 166 PAUDIOMIXER pParent; 167 /** Name of this sink. */ 168 char *pszName; 169 /** The sink direction (either PDMAUDIODIR_IN or PDMAUDIODIR_OUT). */ 170 PDMAUDIODIR enmDir; 171 /** The sink's critical section. */ 172 RTCRITSECT CritSect; 173 /** This sink's mixing buffer, acting as 174 * a parent buffer for all streams this sink owns. */ 175 AUDIOMIXBUF MixBuf; 176 /** Scratch buffer for multiplexing / mixing. Might be NULL if not needed. */ 177 uint8_t *pabScratchBuf; 178 /** Size (in bytes) of pabScratchBuf. Might be 0 if not needed. */ 179 size_t cbScratchBuf; 180 /** Union for input/output specifics. */ 181 union 182 { 183 AUDMIXSINKIN In; 184 AUDMIXSINKOUT Out; 185 }; 186 /** Sink status of type AUDMIXSINK_STS_XXX. */ 187 AUDMIXSINKSTS fStatus; 188 /** The sink's PCM format. */ 189 PDMAUDIOPCMPROPS PCMProps; 190 /** Number of streams assigned. */ 191 uint8_t cStreams; 192 /** List of assigned streams. 193 * @note All streams have the same PCM properties, so the mixer does not do 194 * any conversion. */ 195 /** @todo Use something faster -- vector maybe? */ 196 RTLISTANCHOR lstStreams; 197 /** The volume of this sink. The volume always will 198 * be combined with the mixer's master volume. */ 199 PDMAUDIOVOLUME Volume; 200 /** The volume of this sink, combined with the last set master volume. */ 201 PDMAUDIOVOLUME VolumeCombined; 202 /** Timestamp since last update (in ms). */ 203 uint64_t tsLastUpdatedMs; 204 /** Last read (recording) / written (playback) timestamp (in ns). */ 205 uint64_t tsLastReadWrittenNs; 206 struct 207 { 208 PAUDIOHLPFILE pFile; 209 } Dbg; 210 } AUDMIXSINK; 192 /** @} */ 193 211 194 212 195 /** … … 225 208 } AUDMIXOP; 226 209 210 211 /** @name AUDMIXER_FLAGS_XXX - For AudioMixerCreate(). 212 * @{ */ 227 213 /** No mixer flags specified. */ 228 214 #define AUDMIXER_FLAGS_NONE 0 … … 232 218 /** Validation mask. */ 233 219 #define AUDMIXER_FLAGS_VALID_MASK UINT32_C(0x00000001) 220 /** @} */ 221 234 222 235 223 int AudioMixerCreate(const char *pszName, uint32_t fFlags, PAUDIOMIXER *ppMixer); … … 242 230 int AudioMixerSinkAddStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream); 243 231 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOSTREAMCFG pCfg, 244 AUDMIXSTREAMFLAGS fFlags,PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream);232 PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream); 245 233 int AudioMixerSinkCtl(PAUDMIXSINK pSink, PDMAUDIOSTREAMCMD enmCmd); 246 234 void AudioMixerSinkDestroy(PAUDMIXSINK pSink, PPDMDEVINS pDevIns); … … 249 237 PDMAUDIODIR AudioMixerSinkGetDir(PAUDMIXSINK pSink); 250 238 PAUDMIXSTREAM AudioMixerSinkGetRecordingSource(PAUDMIXSINK pSink); 251 AUDMIXSINKSTSAudioMixerSinkGetStatus(PAUDMIXSINK pSink);239 uint32_t AudioMixerSinkGetStatus(PAUDMIXSINK pSink); 252 240 bool AudioMixerSinkIsActive(PAUDMIXSINK pSink); 253 241 int AudioMixerSinkRead(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead); -
trunk/src/VBox/Devices/Audio/DevHda.cpp
r88916 r88917 2329 2329 2330 2330 PAUDMIXSTREAM pMixStrm = NULL; 2331 int rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, &StreamCfg, 0 /* fFlags */,pDevIns, &pMixStrm);2331 int rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, &StreamCfg, pDevIns, &pMixStrm); 2332 2332 LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, StreamCfg.szName, rc)); 2333 2333 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r88916 r88917 1868 1868 1869 1869 PAUDMIXSTREAM pMixStrm; 1870 rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */,pDevIns, &pMixStrm);1870 rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, pDevIns, &pMixStrm); 1871 1871 LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); 1872 1872 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r88916 r88917 2002 2002 2003 2003 PAUDMIXSTREAM pMixStrm; 2004 rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */,pDevIns, &pMixStrm);2004 rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, pDevIns, &pMixStrm); 2005 2005 LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); 2006 2006 if (RT_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.