Changeset 88907 in vbox
- Timestamp:
- May 6, 2021 3:23:35 PM (4 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r88890 r88907 358 358 } 359 359 360 #if 0 /* unused */ 360 361 /** 361 362 * Invalidates all internal data. … … 379 380 AssertRC(rc2); 380 381 } 382 #endif 381 383 382 384 /** … … 436 438 437 439 /** 438 * Removes a formerly attached audio sink for an audio mixer.439 *440 * @returns VBox status code.441 * @param pMixer Mixer to remove sink from.442 * @param pSink Sink to remove.443 */444 void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink)445 {446 int rc2 = RTCritSectEnter(&pMixer->CritSect);447 AssertRC(rc2);448 449 audioMixerSinkRemoveAllStreamsInternal(pSink);450 audioMixerRemoveSinkInternal(pMixer, pSink);451 452 rc2 = RTCritSectLeave(&pMixer->CritSect);453 }454 455 /**456 440 * Sets the mixer's master volume. 457 441 * … … 483 467 } 484 468 469 485 470 /********************************************************************************************************************************* 486 * Mixer Sink implementation. 487 471 * Mixer Sink implementation. * 472 *********************************************************************************************************************************/ 488 473 489 474 /** … … 496 481 int AudioMixerSinkAddStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream) 497 482 { 483 LogFlowFuncEnter(); 498 484 AssertPtrReturn(pSink, VERR_INVALID_POINTER); 499 485 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 500 486 501 487 int rc = RTCritSectEnter(&pSink->CritSect); 502 if (RT_FAILURE(rc)) 503 return rc; 504 505 if (pSink->cStreams == UINT8_MAX) /* 255 streams per sink max. */ 506 { 507 int rc2 = RTCritSectLeave(&pSink->CritSect); 508 AssertRC(rc2); 509 510 return VERR_NO_MORE_HANDLES; 511 } 512 513 LogFlowFuncEnter(); 488 AssertRCReturn(rc, rc); 489 AssertLogRelMsgReturnStmt(pSink->cStreams < UINT8_MAX, ("too many streams!\n"), RTCritSectLeave(&pSink->CritSect), 490 VERR_TOO_MANY_OPEN_FILES); 491 514 492 515 493 /** @todo Check if stream already is assigned to (another) sink. */ … … 581 559 PDMAUDIOBACKENDCFG BackendCfg; 582 560 int rc = pConn->pfnGetConfig(pConn, &BackendCfg); 583 if (RT_FAILURE(rc)) 584 return rc; 561 AssertRCReturn(rc, rc); 585 562 586 563 /* … … 1060 1037 1061 1038 /** 1062 * Returns the sink's (friendly) name.1063 *1064 * @returns The sink's (friendly) name.1065 */1066 const char *AudioMixerSinkGetName(const PAUDMIXSINK pSink)1067 {1068 AssertPtrReturn(pSink, "<Unknown>");1069 1070 return pSink->pszName;1071 }1072 1073 /**1074 * Returns a specific mixer stream from a sink, based on its index.1075 *1076 * @returns Mixer stream if found, or NULL if not found.1077 * @param pSink Sink to retrieve mixer stream from.1078 * @param uIndex Index of the mixer stream to return.1079 */1080 PAUDMIXSTREAM AudioMixerSinkGetStream(PAUDMIXSINK pSink, uint8_t uIndex)1081 {1082 AssertPtrReturn(pSink, NULL);1083 1084 int rc = RTCritSectEnter(&pSink->CritSect);1085 if (RT_FAILURE(rc))1086 return NULL;1087 1088 AssertMsgReturn(uIndex < pSink->cStreams,1089 ("Index %RU8 exceeds stream count (%RU8)", uIndex, pSink->cStreams), NULL);1090 1091 /* Slow lookup, d'oh. */1092 PAUDMIXSTREAM pStream = RTListGetFirst(&pSink->lstStreams, AUDMIXSTREAM, Node);1093 while (uIndex)1094 {1095 pStream = RTListGetNext(&pSink->lstStreams, pStream, AUDMIXSTREAM, Node);1096 uIndex--;1097 }1098 1099 /** @todo Do we need to raise the stream's reference count here? */1100 1101 int rc2 = RTCritSectLeave(&pSink->CritSect);1102 AssertRC(rc2);1103 1104 AssertPtr(pStream);1105 return pStream;1106 }1107 1108 /**1109 1039 * Returns the current status of a mixer sink. 1110 1040 * … … 1131 1061 1132 1062 /** 1133 * Returns the number of attached mixer streams to a mixer sink.1134 *1135 * @returns The number of attached mixer streams.1136 * @param pSink Mixer sink to return number for.1137 */1138 uint8_t AudioMixerSinkGetStreamCount(PAUDMIXSINK pSink)1139 {1140 if (!pSink)1141 return 0;1142 1143 int rc2 = RTCritSectEnter(&pSink->CritSect);1144 if (RT_FAILURE(rc2))1145 return 0;1146 1147 const uint8_t cStreams = pSink->cStreams;1148 1149 rc2 = RTCritSectLeave(&pSink->CritSect);1150 AssertRC(rc2);1151 1152 return cStreams;1153 }1154 1155 /**1156 1063 * Returns whether the sink is in an active state or not. 1157 * Note: The pending disable state also counts as active. 1064 * 1065 * @note The pending disable state also counts as active. 1158 1066 * 1159 1067 * @returns True if active, false if not. … … 1425 1333 1426 1334 audioMixerSinkReset(pSink); 1427 1428 rc2 = RTCritSectLeave(&pSink->CritSect);1429 AssertRC(rc2);1430 }1431 1432 /**1433 * Returns the audio format of a mixer sink.1434 *1435 * @param pSink Sink to retrieve audio format for.1436 * @param pPCMProps Where to the returned audio format.1437 */1438 void AudioMixerSinkGetFormat(PAUDMIXSINK pSink, PPDMAUDIOPCMPROPS pPCMProps)1439 {1440 AssertPtrReturnVoid(pSink);1441 AssertPtrReturnVoid(pPCMProps);1442 1443 int rc2 = RTCritSectEnter(&pSink->CritSect);1444 if (RT_FAILURE(rc2))1445 return;1446 1447 memcpy(pPCMProps, &pSink->PCMProps, sizeof(PDMAUDIOPCMPROPS));1448 1335 1449 1336 rc2 = RTCritSectLeave(&pSink->CritSect); … … 2175 2062 2176 2063 /** 2177 * Controls a mixer stream.2178 *2179 * @returns VBox status code.2180 * @param pMixStream Mixer stream to control.2181 * @param enmCmd Mixer stream command to use.2182 * @param fCtl Additional control flags. Pass 0.2183 */2184 int AudioMixerStreamCtl(PAUDMIXSTREAM pMixStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl)2185 {2186 RT_NOREF(fCtl);2187 AssertPtrReturn(pMixStream, VERR_INVALID_POINTER);2188 /** @todo Validate fCtl. */2189 2190 int rc = RTCritSectEnter(&pMixStream->CritSect);2191 if (RT_FAILURE(rc))2192 return rc;2193 2194 rc = audioMixerStreamCtlInternal(pMixStream, enmCmd, fCtl);2195 2196 int rc2 = RTCritSectLeave(&pMixStream->CritSect);2197 if (RT_SUCCESS(rc))2198 rc = rc2;2199 2200 return rc;2201 }2202 2203 /**2204 2064 * Destroys a mixer stream, internal version. 2205 2065 * -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r88884 r88907 270 270 void AudioMixerDestroy(PAUDIOMIXER pMixer, PPDMDEVINS pDevIns); 271 271 void AudioMixerInvalidate(PAUDIOMIXER pMixer); 272 void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink);273 272 int AudioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol); 274 273 void AudioMixerDebug(PAUDIOMIXER pMixer, PCDBGFINFOHLP pHlp, const char *pszArgs); … … 282 281 uint32_t AudioMixerSinkGetWritable(PAUDMIXSINK pSink); 283 282 AUDMIXSINKDIR AudioMixerSinkGetDir(PAUDMIXSINK pSink); 284 const char *AudioMixerSinkGetName(const PAUDMIXSINK pSink);285 283 PAUDMIXSTREAM AudioMixerSinkGetRecordingSource(PAUDMIXSINK pSink); 286 PAUDMIXSTREAM AudioMixerSinkGetStream(PAUDMIXSINK pSink, uint8_t uIndex);287 284 AUDMIXSINKSTS AudioMixerSinkGetStatus(PAUDMIXSINK pSink); 288 uint8_t AudioMixerSinkGetStreamCount(PAUDMIXSINK pSink);289 285 bool AudioMixerSinkIsActive(PAUDMIXSINK pSink); 290 286 int AudioMixerSinkRead(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead); … … 292 288 void AudioMixerSinkRemoveAllStreams(PAUDMIXSINK pSink); 293 289 void AudioMixerSinkReset(PAUDMIXSINK pSink); 294 void AudioMixerSinkGetFormat(PAUDMIXSINK pSink, PPDMAUDIOPCMPROPS pPCMProps);295 290 int AudioMixerSinkSetFormat(PAUDMIXSINK pSink, PCPDMAUDIOPCMPROPS pPCMProps); 296 291 int AudioMixerSinkSetRecordingSource(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream); … … 299 294 int AudioMixerSinkUpdate(PAUDMIXSINK pSink); 300 295 301 int AudioMixerStreamCtl(PAUDMIXSTREAM pStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl);302 296 void AudioMixerStreamDestroy(PAUDMIXSTREAM pStream, PPDMDEVINS pDevIns); 303 297
Note:
See TracChangeset
for help on using the changeset viewer.