Changeset 88896 in vbox for trunk/src/VBox/Devices
- Timestamp:
- May 6, 2021 11:24:07 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88892 r88896 54 54 /** No flags being set. */ 55 55 #define PDMAUDIOSTREAM_STS_NONE UINT32_C(0) 56 /** Set if the stream is enabled, clear if disabled. */ 57 #define PDMAUDIOSTREAM_STS_ENABLED RT_BIT_32(0) 58 /** Set if the stream is paused. 59 * Requires the ENABLED status to be set when used. */ 60 #define PDMAUDIOSTREAM_STS_PAUSED RT_BIT_32(1) 61 /** Output only: Set when the stream is draining. 62 * Requires the ENABLED status to be set when used. */ 63 #define PDMAUDIOSTREAM_STS_PENDING_DISABLE RT_BIT_32(2) 64 56 65 /** Set if the backend for the stream has been created. 57 66 * 58 * PDMIAUDIOCONNECTOR:This is generally always set after stream creation, but67 * This is generally always set after stream creation, but 59 68 * can be cleared if the re-initialization of the stream fails later on. 60 69 * Asynchronous init may still be incomplete, see 61 * 62 * PDMIHOSTAUDIO: This may not be set immediately if the backend is doing some 63 * of the stream creation asynchronously via PDMIHOSTAUDIO::pfnStreamInitAsync. 64 * The DrvAudio code will not report this to the devices, but keep on 65 * prebuffering till pfnStreamInitAsync is done and this bit is set. */ 66 #define PDMAUDIOSTREAM_STS_INITIALIZED RT_BIT_32(0) 67 /** Set if the stream is enabled, clear if disabled. */ 68 #define PDMAUDIOSTREAM_STS_ENABLED RT_BIT_32(1) 69 /** Set if the stream is paused. 70 * Requires the ENABLED status to be set when used. */ 71 #define PDMAUDIOSTREAM_STS_PAUSED RT_BIT_32(2) 72 /** Output only: Set when the stream is draining. 73 * Requires the ENABLED status to be set when used. 74 * @todo See todo in drvAudioStreamPlay() regarding the suitability of this 75 * for PDMIHOSTAUDIO. */ 76 #define PDMAUDIOSTREAM_STS_PENDING_DISABLE RT_BIT_32(3) 77 78 /** PDMIAUDIOCONNECTOR: Set if the stream needs to be re-initialized by the 79 * device (i.e. call PDMIAUDIOCONNECTOR::pfnStreamReInit). (The other status 80 * bits are preserved and are worked as normal while in this state, so that the 81 * stream can resume operation where it left off.) */ 82 #define PDMAUDIOSTREAM_STS_NEED_REINIT RT_BIT_32(8) 83 /** PDMIAUDIOCONNECTOR: The backend is ready (PDMIHOSTAUDIO::pfnStreamInitAsync done). 84 * Requires the INITIALIZED status to be set. */ 85 #define PDMAUDIOSTREAM_STS_BACKEND_READY RT_BIT_32(9) 70 * PDMAUDIOSTREAM_STS_BACKEND_READY. */ 71 #define PDMAUDIOSTREAM_STS_BACKEND_CREATED RT_BIT_32(3) 72 /** The backend is ready (PDMIHOSTAUDIO::pfnStreamInitAsync is done). 73 * Requires the BACKEND_CREATED status to be set. */ 74 #define PDMAUDIOSTREAM_STS_BACKEND_READY RT_BIT_32(4) 75 /** Set if the stream needs to be re-initialized by the device (i.e. call 76 * PDMIAUDIOCONNECTOR::pfnStreamReInit). (The other status bits are preserved 77 * and are worked as normal while in this state, so that the stream can 78 * resume operation where it left off.) */ 79 #define PDMAUDIOSTREAM_STS_NEED_REINIT RT_BIT_32(5) 86 80 /** Validation mask for PDMIAUDIOCONNECTOR. */ 87 #define PDMAUDIOSTREAM_STS_VALID_MASK UINT32_C(0x00000 30f)81 #define PDMAUDIOSTREAM_STS_VALID_MASK UINT32_C(0x0000003f) 88 82 /** Asserts the validity of the given stream status mask for PDMIAUDIOCONNECTOR. */ 89 83 #define PDMAUDIOSTREAM_STS_ASSERT_VALID(a_fStreamStatus) do { \ … … 91 85 Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_PAUSED) || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_ENABLED)); \ 92 86 Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_PENDING_DISABLE) || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_ENABLED)); \ 93 Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_BACKEND_READY) || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_ INITIALIZED)); \87 Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_BACKEND_READY) || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_BACKEND_CREATED)); \ 94 88 } while (0) 95 89 … … 409 403 static int drvAudioStreamIterateInternal(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx); 410 404 405 411 406 /** Buffer size for drvAudioStreamStatusToStr. */ 412 # define DRVAUDIO_STATUS_STR_MAX sizeof(" INITIALIZED ENABLED PAUSED PENDING_DISABLED NEED_REINIT BACKEND_READY0x12345678")407 # define DRVAUDIO_STATUS_STR_MAX sizeof("BACKEND_CREATED BACKEND_READY ENABLED PAUSED PENDING_DISABLED NEED_REINIT 0x12345678") 413 408 414 409 /** … … 429 424 } s_aFlags[] = 430 425 { 431 { RT_STR_TUPLE("INITIALIZED "), PDMAUDIOSTREAM_STS_INITIALIZED }, 426 { RT_STR_TUPLE("BACKEND_CREATED "), PDMAUDIOSTREAM_STS_BACKEND_CREATED }, 427 { RT_STR_TUPLE("BACKEND_READY "), PDMAUDIOSTREAM_STS_BACKEND_READY }, 432 428 { RT_STR_TUPLE("ENABLED "), PDMAUDIOSTREAM_STS_ENABLED }, 433 429 { RT_STR_TUPLE("PAUSED "), PDMAUDIOSTREAM_STS_PAUSED }, 434 430 { RT_STR_TUPLE("PENDING_DISABLE "), PDMAUDIOSTREAM_STS_PENDING_DISABLE }, 435 431 { RT_STR_TUPLE("NEED_REINIT "), PDMAUDIOSTREAM_STS_NEED_REINIT }, 436 { RT_STR_TUPLE("BACKEND_READY "), PDMAUDIOSTREAM_STS_BACKEND_READY },437 432 }; 438 433 if (!fStatus) … … 492 487 PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus); 493 488 AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false); 494 return (fStatus & ( PDMAUDIOSTREAM_STS_ INITIALIZED489 return (fStatus & ( PDMAUDIOSTREAM_STS_BACKEND_CREATED 495 490 | PDMAUDIOSTREAM_STS_ENABLED 496 491 | PDMAUDIOSTREAM_STS_PAUSED 497 492 | PDMAUDIOSTREAM_STS_NEED_REINIT)) 498 == ( PDMAUDIOSTREAM_STS_ INITIALIZED493 == ( PDMAUDIOSTREAM_STS_BACKEND_CREATED 499 494 | PDMAUDIOSTREAM_STS_ENABLED); 500 495 } … … 511 506 PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus); 512 507 AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false); 513 return (fStatus & ( PDMAUDIOSTREAM_STS_ INITIALIZED508 return (fStatus & ( PDMAUDIOSTREAM_STS_BACKEND_CREATED 514 509 | PDMAUDIOSTREAM_STS_ENABLED 515 510 | PDMAUDIOSTREAM_STS_PAUSED 516 511 | PDMAUDIOSTREAM_STS_PENDING_DISABLE 517 512 | PDMAUDIOSTREAM_STS_NEED_REINIT)) 518 == ( PDMAUDIOSTREAM_STS_ INITIALIZED513 == ( PDMAUDIOSTREAM_STS_BACKEND_CREATED 519 514 | PDMAUDIOSTREAM_STS_ENABLED); 520 515 } … … 531 526 PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus); 532 527 AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false); 533 return (fStatus & ( PDMAUDIOSTREAM_STS_ INITIALIZED528 return (fStatus & ( PDMAUDIOSTREAM_STS_BACKEND_CREATED 534 529 | PDMAUDIOSTREAM_STS_ENABLED 535 530 | PDMAUDIOSTREAM_STS_NEED_REINIT)) 536 == ( PDMAUDIOSTREAM_STS_ INITIALIZED531 == ( PDMAUDIOSTREAM_STS_BACKEND_CREATED 537 532 | PDMAUDIOSTREAM_STS_ENABLED); 538 533 } … … 1243 1238 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1244 1239 { 1245 AssertMsg((pStreamEx->fStatus & PDMAUDIOSTREAM_STS_ INITIALIZED) == 0,1240 AssertMsg((pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED) == 0, 1246 1241 ("Stream '%s' already initialized in backend\n", pStreamEx->Core.szName)); 1247 1242 … … 1281 1276 destroyed (this used to be done at the end of this function, with 1282 1277 several possible early return paths before it). */ 1283 pStreamEx->fStatus |= PDMAUDIOSTREAM_STS_ INITIALIZED;1278 pStreamEx->fStatus |= PDMAUDIOSTREAM_STS_BACKEND_CREATED; 1284 1279 } 1285 1280 else … … 1790 1785 LogFunc(("[%s] fStatus=%s\n", pStreamEx->Core.szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus))); 1791 1786 1792 if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_ INITIALIZED)1787 if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED) 1793 1788 { 1794 1789 AssertPtr(pStreamEx->pBackend); … … 1799 1794 rc = pThis->pHostDrvAudio->pfnStreamDestroy(pThis->pHostDrvAudio, pStreamEx->pBackend); 1800 1795 1801 pStreamEx->fStatus &= ~(PDMAUDIOSTREAM_STS_ INITIALIZED | PDMAUDIOSTREAM_STS_BACKEND_READY);1796 pStreamEx->fStatus &= ~(PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY); 1802 1797 PDMAUDIOSTREAM_STS_ASSERT_VALID(pStreamEx->fStatus); 1803 1798 } … … 2082 2077 * Destroy and re-create stream on backend side. 2083 2078 */ 2084 if ( (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_ INITIALIZED | PDMAUDIOSTREAM_STS_BACKEND_READY))2085 == (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_ INITIALIZED | PDMAUDIOSTREAM_STS_BACKEND_READY))2079 if ( (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY)) 2080 == (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY)) 2086 2081 drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE); 2087 2082 2088 if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_ INITIALIZED)2083 if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED) 2089 2084 drvAudioStreamDestroyInternalBackend(pThis, pStreamEx); 2090 2085 2091 2086 int rc = VERR_AUDIO_STREAM_NOT_READY; 2092 if (!(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_ INITIALIZED))2087 if (!(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED)) 2093 2088 { 2094 2089 drvAudioStreamResetInternal(pStreamEx); … … 2128 2123 * let the worker thread do it after the async init has completed. 2129 2124 */ 2130 if ( (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_BACKEND_READY | PDMAUDIOSTREAM_STS_ INITIALIZED))2131 == (PDMAUDIOSTREAM_STS_BACKEND_READY | PDMAUDIOSTREAM_STS_ INITIALIZED))2125 if ( (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_BACKEND_READY | PDMAUDIOSTREAM_STS_BACKEND_CREATED)) 2126 == (PDMAUDIOSTREAM_STS_BACKEND_READY | PDMAUDIOSTREAM_STS_BACKEND_CREATED)) 2132 2127 { 2133 2128 rc = drvAudioStreamUpdateBackendOnStatus(pThis, pStreamEx, "re-initializing"); 2134 2129 /** @todo not sure if we really need to care about this status code... */ 2135 2130 } 2136 else if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_ INITIALIZED)2131 else if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED) 2137 2132 { 2138 2133 Assert(pStreamEx->hReqInitAsync != NIL_RTREQ); … … 2390 2385 LogFunc(("[%s]\n", pStreamEx->Core.szName)); 2391 2386 2392 pStreamEx->fStatus &= PDMAUDIOSTREAM_STS_ INITIALIZED | PDMAUDIOSTREAM_STS_BACKEND_READY;2387 pStreamEx->fStatus &= PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY; 2393 2388 pStreamEx->Core.fWarningsShown = PDMAUDIOSTREAM_WARN_FLAGS_NONE; 2394 2389 … … 3252 3247 if (!(fStrmStatus & PDMAUDIOSTREAM_STS_NEED_REINIT)) 3253 3248 { 3254 if (fStrmStatus & PDMAUDIOSTREAM_STS_ INITIALIZED)3249 if (fStrmStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED) 3255 3250 { 3256 3251 if ( (fStrmStatus & PDMAUDIOSTREAM_STS_ENABLED)
Note:
See TracChangeset
for help on using the changeset viewer.