Changeset 88059 in vbox
- Timestamp:
- Mar 9, 2021 3:33:52 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r88057 r88059 1244 1244 typedef struct PDMAUDIOSTREAM *PPDMAUDIOSTREAMCTX; 1245 1245 1246 /** @name PDMAUDIOSTREAM_WARN_FLAGS_XXX 1247 * @{ */ 1246 1248 /** No stream warning flags set. */ 1247 1249 #define PDMAUDIOSTREAM_WARN_FLAGS_NONE 0 1248 1250 /** Warned about a disabled stream. */ 1249 1251 #define PDMAUDIOSTREAM_WARN_FLAGS_DISABLED RT_BIT(0) 1252 /** @} */ 1250 1253 1251 1254 /** … … 1254 1257 typedef struct PDMAUDIOSTREAM 1255 1258 { 1256 /** List node. 1257 * @todo s/Node/ListEntry/ */ 1258 RTLISTNODE Node; 1259 /** @todo add magic (some jazz pianist). */ 1259 /** Magic value (PDMAUDIOSTREAM_MAGIC). */ 1260 uint32_t uMagic; 1261 /** Size (in bytes) of the backend-specific stream data. */ 1262 uint32_t cbBackend; 1263 /** List entry (some DrvAudio internal list). */ 1264 RTLISTNODE ListEntry; 1260 1265 /** Number of references to this stream. 1261 1266 * Only can be destroyed when the reference count reaches 0. */ … … 1264 1269 uint32_t cTriesReInit; 1265 1270 /** Warnings shown already in the release log. 1266 * See PDMAUDIOSTREAM_WARN_FLAGS_XXX defines. */1271 * See PDMAUDIOSTREAM_WARN_FLAGS_XXX. */ 1267 1272 uint32_t fWarningsShown; 1268 1273 /** Stream status flag. */ … … 1295 1300 * That way the backends do not have access to the audio connector's data. */ 1296 1301 void *pvBackend; 1297 /** Size (in bytes) of the backend-specific stream data. */1298 size_t cbBackend;1299 1302 1300 1303 /** Name of this stream. */ … … 1308 1311 } RT_UNION_NM(u); 1309 1312 } PDMAUDIOSTREAM; 1313 1314 /** Magic value for PDMAUDIOSTREAM. (Ahmad Jamal) */ 1315 #define PDMAUDIOSTREAM_MAGIC UINT32_C(0x19300702) 1310 1316 1311 1317 -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88057 r88059 564 564 * Init host stream. 565 565 */ 566 pStream->uMagic = PDMAUDIOSTREAM_MAGIC; 566 567 567 568 /* Set the host's default audio data layout. */ … … 762 763 static void drvAudioStreamFree(PPDMAUDIOSTREAM pStream) 763 764 { 764 if (!pStream) 765 return; 766 767 LogFunc(("[%s]\n", pStream->szName)); 768 769 if (pStream->pvBackend) 770 { 771 Assert(pStream->cbBackend); 772 RTMemFree(pStream->pvBackend); 773 pStream->pvBackend = NULL; 774 } 775 776 RTMemFree(pStream); 777 pStream = NULL; 765 if (pStream) 766 { 767 LogFunc(("[%s]\n", pStream->szName)); 768 Assert(pStream->uMagic == PDMAUDIOSTREAM_MAGIC); 769 pStream->uMagic = ~PDMAUDIOSTREAM_MAGIC; 770 771 if (pStream->pvBackend) 772 { 773 Assert(pStream->cbBackend); 774 RTMemFree(pStream->pvBackend); 775 pStream->pvBackend = NULL; 776 } 777 778 RTMemFree(pStream); 779 } 778 780 } 779 781 … … 794 796 /* Mark all host streams to re-initialize. */ 795 797 PPDMAUDIOSTREAM pStream; 796 RTListForEach(&pThis->lstStreams, pStream, PDMAUDIOSTREAM, Node)798 RTListForEach(&pThis->lstStreams, pStream, PDMAUDIOSTREAM, ListEntry) 797 799 { 798 800 pStream->fStatus |= PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT; … … 2295 2297 { 2296 2298 PPDMAUDIOSTREAM pStream; 2297 RTListForEach(&pThis->lstStreams, pStream, PDMAUDIOSTREAM, Node)2299 RTListForEach(&pThis->lstStreams, pStream, PDMAUDIOSTREAM, ListEntry) 2298 2300 drvAudioStreamControlInternal(pThis, pStream, enmCmd); 2299 2301 } … … 2537 2539 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamCreate} 2538 2540 */ 2539 static DECLCALLBACK(int) drvAudioStreamCreate(PPDMIAUDIOCONNECTOR pInterface, 2540 PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest, 2541 PPDMAUDIOSTREAM *ppStream) 2541 static DECLCALLBACK(int) drvAudioStreamCreate(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfgHost, 2542 PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream) 2542 2543 { 2543 2544 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 2562 2563 #define RC_BREAK(x) { rc = x; break; } 2563 2564 2564 do 2565 do /* this is not a loop, just a construct to make the code more difficult to follow. */ 2565 2566 { 2566 2567 if ( !DrvAudioHlpStreamCfgIsValid(pCfgHost) … … 2599 2600 cbHstStrm = pThis->BackendCfg.cbStreamOut; 2600 2601 } 2602 AssertBreakStmt(cbHstStrm < _16M, rc = VERR_OUT_OF_RANGE); 2601 2603 2602 2604 /* 2603 2605 * Allocate and initialize common state. 2604 2606 */ 2605 2606 2607 pStream = (PPDMAUDIOSTREAM)RTMemAllocZ(sizeof(PDMAUDIOSTREAM)); 2607 2608 AssertPtrBreakStmt(pStream, rc = VERR_NO_MEMORY); … … 2623 2624 * Allocate and init backend-specific data. 2624 2625 */ 2625 2626 2626 if (cbHstStrm) /* High unlikely that backends do not have an own space for data, but better check. */ 2627 2627 { 2628 2628 pStream->pvBackend = RTMemAllocZ(cbHstStrm); 2629 Assert PtrBreakStmt(pStream->pvBackend, rc = VERR_NO_MEMORY);2630 2631 pStream->cbBackend = cbHstStrm;2629 AssertBreakStmt(pStream->pvBackend, rc = VERR_NO_MEMORY); 2630 2631 pStream->cbBackend = (uint32_t)cbHstStrm; 2632 2632 } 2633 2633 … … 2635 2635 * Try to init the rest. 2636 2636 */ 2637 2638 2637 rc = drvAudioStreamInitInternal(pThis, pStream, pCfgHost, pCfgGuest); 2639 if (RT_FAILURE(rc))2640 break;2641 2638 2642 2639 } while (0); … … 2660 2657 { 2661 2658 /* Append the stream to our stream list. */ 2662 RTListAppend(&pThis->lstStreams, &pStream-> Node);2659 RTListAppend(&pThis->lstStreams, &pStream->ListEntry); 2663 2660 2664 2661 /* Set initial reference counts. */ … … 2777 2774 2778 2775 PPDMAUDIOSTREAM pStream; 2779 RTListForEach(&pThis->lstStreams, pStream, PDMAUDIOSTREAM, Node)2776 RTListForEach(&pThis->lstStreams, pStream, PDMAUDIOSTREAM, ListEntry) 2780 2777 { 2781 2778 if (pStream->enmDir != enmDir) /* Skip unwanted streams. */ … … 3085 3082 { 3086 3083 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 3087 AssertPtrReturn(pStream, VERR_INVALID_POINTER);3088 3089 3084 PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface); 3090 3085 3086 if (!pStream) 3087 return VINF_SUCCESS; 3088 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 3089 Assert(pStream->uMagic == PDMAUDIOSTREAM_MAGIC); 3090 3091 3091 int rc = RTCritSectEnter(&pThis->CritSect); 3092 AssertRC (rc);3092 AssertRCReturn(rc, rc); 3093 3093 3094 3094 LogRel2(("Audio: Destroying stream '%s'\n", pStream->szName)); 3095 3095 3096 3096 LogFlowFunc(("[%s] cRefs=%RU32\n", pStream->szName, pStream->cRefs)); 3097 if (pStream->cRefs > 1) 3097 if (pStream->cRefs < 1) 3098 { 3099 rc = drvAudioStreamUninitInternal(pThis, pStream); 3100 if (RT_SUCCESS(rc)) 3101 { 3102 if (pStream->enmDir == PDMAUDIODIR_IN) 3103 pThis->In.cStreamsFree++; 3104 else /* Out */ 3105 pThis->Out.cStreamsFree++; 3106 3107 RTListNodeRemove(&pStream->ListEntry); 3108 3109 drvAudioStreamFree(pStream); 3110 pStream = NULL; 3111 } 3112 else 3113 LogRel(("Audio: Uninitializing stream '%s' failed with %Rrc\n", pStream->szName, rc)); 3114 } 3115 else 3098 3116 rc = VERR_WRONG_ORDER; 3099 3100 if (RT_SUCCESS(rc))3101 {3102 rc = drvAudioStreamUninitInternal(pThis, pStream);3103 if (RT_FAILURE(rc))3104 LogRel(("Audio: Uninitializing stream '%s' failed with %Rrc\n", pStream->szName, rc));3105 }3106 3107 if (RT_SUCCESS(rc))3108 {3109 if (pStream->enmDir == PDMAUDIODIR_IN)3110 {3111 pThis->In.cStreamsFree++;3112 }3113 else /* Out */3114 {3115 pThis->Out.cStreamsFree++;3116 }3117 3118 RTListNodeRemove(&pStream->Node);3119 3120 drvAudioStreamFree(pStream);3121 pStream = NULL;3122 }3123 3117 3124 3118 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 3560 3554 * in drvAudioDestruct(). */ 3561 3555 PPDMAUDIOSTREAM pStream; 3562 RTListForEach(&pThis->lstStreams, pStream, PDMAUDIOSTREAM, Node)3556 RTListForEach(&pThis->lstStreams, pStream, PDMAUDIOSTREAM, ListEntry) 3563 3557 { 3564 3558 drvAudioStreamControlInternalBackend(pThis, pStream, PDMAUDIOSTREAMCMD_DISABLE); … … 3705 3699 3706 3700 PPDMAUDIOSTREAM pStream, pStreamNext; 3707 RTListForEachSafe(&pThis->lstStreams, pStream, pStreamNext, PDMAUDIOSTREAM, Node)3701 RTListForEachSafe(&pThis->lstStreams, pStream, pStreamNext, PDMAUDIOSTREAM, ListEntry) 3708 3702 { 3709 3703 rc2 = drvAudioStreamUninitInternal(pThis, pStream); 3710 3704 if (RT_SUCCESS(rc2)) 3711 3705 { 3712 RTListNodeRemove(&pStream-> Node);3706 RTListNodeRemove(&pStream->ListEntry); 3713 3707 3714 3708 drvAudioStreamFree(pStream);
Note:
See TracChangeset
for help on using the changeset viewer.