- Timestamp:
- Dec 3, 2019 11:27:10 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r82340 r82343 143 143 /** @} */ 144 144 145 /* AC'97 uses 1.5dB steps, we use 0.375dB steps: 1 AC'97 step equals 4 PDM steps. */145 /** AC'97 uses 1.5dB steps, we use 0.375dB steps: 1 AC'97 step equals 4 PDM steps. */ 146 146 #define AC97_DB_FACTOR 4 147 147 … … 265 265 * Structures and Typedefs * 266 266 *********************************************************************************************************************************/ 267 /** The ICH AC'97 (Intel) controller. */ 268 typedef struct AC97STATE *PAC97STATE; 267 269 268 270 /** … … 301 303 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 302 304 /** 303 * Structure keeping the AC'97 stream's state for asynchronous I/O.305 * Asynchronous I/O state for an AC'97 stream. 304 306 */ 305 307 typedef struct AC97STREAMSTATEAIO … … 318 320 volatile bool fEnabled; 319 321 bool afPadding[5]; 320 } AC97STREAMSTATEAIO, *PAC97STREAMSTATEAIO; 322 } AC97STREAMSTATEAIO; 323 /** Pointer to the async I/O state for an AC'97 stream. */ 324 typedef AC97STREAMSTATEAIO *PAC97STREAMSTATEAIO; 321 325 #endif 322 326 323 /** The ICH AC'97 (Intel) controller. */ 324 typedef struct AC97STATE *PAC97STATE; 325 326 /** 327 * Structure for keeping the internal state of an AC'97 stream. 327 328 /** 329 * The internal state of an AC'97 stream. 328 330 */ 329 331 typedef struct AC97STREAMSTATE … … 367 369 368 370 /** 369 * Structure containing AC'97 stream debug stuff, configurable at runtime.370 */ 371 typedef struct AC97STREAMD BGINFORT371 * Runtime configurable debug stuff for an AC'97 stream. 372 */ 373 typedef struct AC97STREAMDEBUGRT 372 374 { 373 375 /** Whether debugging is enabled or not. */ … … 382 384 * whereas for output streams this dumps data being read from the device DMA. */ 383 385 R3PTRTYPE(PPDMAUDIOFILE) pFileDMA; 384 } AC97STREAMD BGINFORT, *PAC97STREAMDBGINFORT;385 386 /** 387 * Structure containing AC'97 stream debug information.388 */ 389 typedef struct AC97STREAMD BGINFO390 { 391 /** Runtime debug info. */392 AC97STREAMD BGINFORTRuntime;393 } AC97STREAMD BGINFO ,*PAC97STREAMDBGINFO;394 395 /** 396 * Structure for an AC'97 stream.386 } AC97STREAMDEBUGRT; 387 388 /** 389 * Debug stuff for an AC'97 stream. 390 */ 391 typedef struct AC97STREAMDEBUG 392 { 393 /** Runtime debug stuff. */ 394 AC97STREAMDEBUGRT Runtime; 395 } AC97STREAMDEBUG; 396 397 /** 398 * An AC'97 stream. 397 399 */ 398 400 typedef struct AC97STREAM … … 410 412 uint32_t Padding1; 411 413 #endif 412 /** Debug information. */413 AC97STREAMD BGINFODbg;414 } AC97STREAM , *PAC97STREAM;414 /** Debug stuff. */ 415 AC97STREAMDEBUG Dbg; 416 } AC97STREAM; 415 417 AssertCompileSizeAlignment(AC97STREAM, 8); 416 418 /** Pointer to an AC'97 stream (registers + state). */ … … 420 422 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 421 423 /** 422 * Structure for the async I/O thread context.424 * Asynchronous I/O thread context (arguments). 423 425 */ 424 426 typedef struct AC97STREAMTHREADCTX … … 426 428 PAC97STATE pThis; 427 429 PAC97STREAM pStream; 428 } AC97STREAMTHREADCTX, *PAC97STREAMTHREADCTX; 430 } AC97STREAMTHREADCTX; 431 /** Pointer to the context for an async I/O thread. */ 432 typedef AC97STREAMTHREADCTX *PAC97STREAMTHREADCTX; 429 433 #endif 430 434 431 435 /** 432 * Structure defining a (host backend) driver stream. 436 * A driver stream (host backend). 437 * 433 438 * Each driver has its own instances of audio mixer streams, which then 434 439 * can go into the same (or even different) audio mixer sinks. … … 438 443 /** Associated mixer stream handle. */ 439 444 R3PTRTYPE(PAUDMIXSTREAM) pMixStrm; 440 } AC97DRIVERSTREAM, *PAC97DRIVERSTREAM; 441 442 /** 443 * Struct for maintaining a host backend driver. 445 } AC97DRIVERSTREAM; 446 /** Pointer to a driver stream. */ 447 typedef AC97DRIVERSTREAM *PAC97DRIVERSTREAM; 448 449 /** 450 * A host backend driver (LUN). 444 451 */ 445 452 typedef struct AC97DRIVER … … 468 475 /** Driver stream for output. */ 469 476 AC97DRIVERSTREAM Out; 470 } AC97DRIVER, *PAC97DRIVER; 471 472 typedef struct AC97STATEDBGINFO 477 } AC97DRIVER; 478 /** Pointer to a host backend driver (LUN). */ 479 typedef AC97DRIVER *PAC97DRIVER; 480 481 /** 482 * Debug settings. 483 */ 484 typedef struct AC97STATEDEBUG 473 485 { 474 486 /** Whether debugging is enabled or not. */ … … 476 488 /** Path where to dump the debug output to. 477 489 * Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH. */ 478 char szOutPath[RTPATH_MAX + 1]; 479 } AC97STATEDBGINFO, *PAC97STATEDBGINFO; 480 481 /** 482 * Structure for maintaining an AC'97 device state. 490 char szOutPath[RTPATH_MAX]; 491 } AC97STATEDEBUG; 492 493 494 /** 495 * The shared AC'97 device state. 483 496 */ 484 497 typedef struct AC97STATE … … 524 537 /** The base interface for LUN\#0. */ 525 538 PDMIBASE IBase; 526 AC97STATEDBGINFO Dbg; 539 /** Debug settings. */ 540 AC97STATEDEBUG Dbg; 527 541 528 542 /** PCI region \#0: NAM I/O ports. */ … … 540 554 } AC97STATE; 541 555 AssertCompileMemberAlignment(AC97STATE, aStreams, 8); 542 /** Pointer to a AC'97 state. */ 543 typedef AC97STATE *PAC97STATE; 556 544 557 545 558 /** … … 633 646 634 647 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 635 static DECLCALLBACK(int) ichac97R3StreamAsyncIOThread(RTTHREAD hThreadSelf, void *pvUser);636 648 static int ichac97R3StreamAsyncIOCreate(PAC97STATE pThis, PAC97STREAM pStream); 637 649 static int ichac97R3StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAM pStream); … … 952 964 RTStrPrintf(szFile, sizeof(szFile), "ac97StreamReadSD%RU8", pStream->u8SD); 953 965 954 char szPath[RTPATH_MAX + 1];966 char szPath[RTPATH_MAX]; 955 967 int rc2 = DrvAudioHlpFileNameGet(szPath, sizeof(szPath), pThis->Dbg.szOutPath, szFile, 956 968 0 /* uInst */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE); … … 1207 1219 RTThreadUserSignal(hThreadSelf); 1208 1220 1221 /** @todo r=bird: What wasn't mentioned by the original author of this 1222 * code, is that pCtx is now invalid as it must be assumed to be out 1223 * of scope in the parent thread. It is a 'ing stack object! */ 1224 1209 1225 LogFunc(("[SD%RU8] Started\n", pStream->u8SD)); 1210 1226 … … 1269 1285 if (RT_SUCCESS(rc)) 1270 1286 { 1287 /** @todo r=bird: Why is Ctx on the stack? There is no mention of this in 1288 * the thread structure. Besides, you only wait 10seconds, if the 1289 * host is totally overloaded, it may go out of scope before the new 1290 * thread has finished with it and it will like crash and burn. 1291 * 1292 * Also, there is RTThreadCreateF for giving threads complicated 1293 * names. 1294 * 1295 * Why aren't this code using the PDM threads (PDMDevHlpThreadCreate)? 1296 * They would help you with managing stuff like VM suspending, resuming 1297 * and powering off. 1298 * 1299 * Finally, just create the threads at construction time. */ 1271 1300 AC97STREAMTHREADCTX Ctx = { pThis, pStream }; 1301 # error "Busted code! Do not pass a structure living on the parent stack to the poor thread!" 1272 1302 1273 1303 char szThreadName[64];
Note:
See TracChangeset
for help on using the changeset viewer.