Changeset 73621 in vbox
- Timestamp:
- Aug 10, 2018 3:25:09 PM (6 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
-
Devices/Audio/DevIchAc97.cpp (modified) (17 diffs)
-
Main/src-client/ConsoleImpl2.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r73529 r73621 324 324 325 325 /** 326 * Structure containing AC'97 stream debug stuff, configurable at runtime. 327 */ 328 typedef struct AC97STREAMDBGINFORT 329 { 330 /** Whether debugging is enabled or not. */ 331 bool fEnabled; 332 uint8_t Padding[7]; 333 /** File for dumping stream reads / writes. 334 * For input streams, this dumps data being written to the device FIFO, 335 * whereas for output streams this dumps data being read from the device FIFO. */ 336 R3PTRTYPE(PPDMAUDIOFILE) pFileStream; 337 /** File for dumping DMA reads / writes. 338 * For input streams, this dumps data being written to the device DMA, 339 * whereas for output streams this dumps data being read from the device DMA. */ 340 R3PTRTYPE(PPDMAUDIOFILE) pFileDMA; 341 } AC97STREAMDBGINFORT, *PAC97STREAMDBGINFORT; 342 343 /** 344 * Structure containing AC'97 stream debug information. 345 */ 346 typedef struct AC97STREAMDBGINFO 347 { 348 /** Runtime debug info. */ 349 AC97STREAMDBGINFORT Runtime; 350 } AC97STREAMDBGINFO ,*PAC97STREAMDBGINFO; 351 352 /** 326 353 * Structure for an AC'97 stream. 327 354 */ … … 329 356 { 330 357 /** Stream number (SDn). */ 331 uint8_t u8SD;332 uint8_t abPadding[7];358 uint8_t u8SD; 359 uint8_t abPadding[7]; 333 360 /** Bus master registers of this stream. */ 334 AC97BMREGS Regs;361 AC97BMREGS Regs; 335 362 /** Internal state of this stream. */ 336 AC97STREAMSTATE State; 363 AC97STREAMSTATE State; 364 /** Debug information. */ 365 AC97STREAMDBGINFO Dbg; 337 366 } AC97STREAM, *PAC97STREAM; 338 367 AssertCompileSizeAlignment(AC97STREAM, 8); … … 399 428 AC97DRIVERSTREAM Out; 400 429 } AC97DRIVER, *PAC97DRIVER; 430 431 typedef struct AC97STATEDBGINFO 432 { 433 /** Whether debugging is enabled or not. */ 434 bool fEnabled; 435 /** Path where to dump the debug output to. 436 * Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH. */ 437 char szOutPath[RTPATH_MAX + 1]; 438 } AC97STATEDBGINFO, *PAC97STATEDBGINFO; 401 439 402 440 /** … … 478 516 /** The base interface for LUN\#0. */ 479 517 PDMIBASE IBase; 518 AC97STATEDBGINFO Dbg; 480 519 } AC97STATE; 481 520 AssertCompileMemberAlignment(AC97STATE, StreamLineIn, 8); … … 621 660 static void ichac97R3StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable); 622 661 # endif 662 663 DECLINLINE(PDMAUDIODIR) ichac97GetDirFromSD(uint8_t uSD); 623 664 #endif /* IN_RING3 */ 624 625 665 626 666 static void ichac97WarmReset(PAC97STATE pThis) … … 803 843 804 844 rc = ichac97R3StreamOpen(pThis, pStream); 845 if (RT_SUCCESS(rc)) 846 { 847 if (!DrvAudioHlpFileIsOpen(pStream->Dbg.Runtime.pFileStream)) 848 { 849 int rc2 = DrvAudioHlpFileOpen(pStream->Dbg.Runtime.pFileStream, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, 850 &pStream->State.Cfg.Props); 851 AssertRC(rc2); 852 } 853 854 if (!DrvAudioHlpFileIsOpen(pStream->Dbg.Runtime.pFileDMA)) 855 { 856 int rc2 = DrvAudioHlpFileOpen(pStream->Dbg.Runtime.pFileDMA, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, 857 &pStream->State.Cfg.Props); 858 AssertRC(rc2); 859 } 860 } 805 861 } 806 862 else … … 891 947 rc = RTCircBufCreate(&pStream->State.pCircBuf, _4K); /** @todo Make this configurable. */ 892 948 949 pStream->Dbg.Runtime.fEnabled = pThis->Dbg.fEnabled; 950 951 if (pStream->Dbg.Runtime.fEnabled) 952 { 953 char szFile[64]; 954 955 if (ichac97GetDirFromSD(pStream->u8SD) == PDMAUDIODIR_IN) 956 RTStrPrintf(szFile, sizeof(szFile), "ac97StreamWriteSD%RU8", pStream->u8SD); 957 else 958 RTStrPrintf(szFile, sizeof(szFile), "ac97StreamReadSD%RU8", pStream->u8SD); 959 960 char szPath[RTPATH_MAX + 1]; 961 int rc2 = DrvAudioHlpFileNameGet(szPath, sizeof(szPath), pThis->Dbg.szOutPath, szFile, 962 0 /* uInst */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE); 963 AssertRC(rc2); 964 rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szPath, PDMAUDIOFILE_FLAG_NONE, &pStream->Dbg.Runtime.pFileStream); 965 AssertRC(rc2); 966 967 if (ichac97GetDirFromSD(pStream->u8SD) == PDMAUDIODIR_IN) 968 RTStrPrintf(szFile, sizeof(szFile), "ac97DMAWriteSD%RU8", pStream->u8SD); 969 else 970 RTStrPrintf(szFile, sizeof(szFile), "ac97DMAReadSD%RU8", pStream->u8SD); 971 972 rc2 = DrvAudioHlpFileNameGet(szPath, sizeof(szPath), pThis->Dbg.szOutPath, szFile, 973 0 /* uInst */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE); 974 AssertRC(rc2); 975 976 rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szPath, PDMAUDIOFILE_FLAG_NONE, &pStream->Dbg.Runtime.pFileDMA); 977 AssertRC(rc2); 978 979 /* Delete stale debugging files from a former run. */ 980 DrvAudioHlpFileDelete(pStream->Dbg.Runtime.pFileStream); 981 DrvAudioHlpFileDelete(pStream->Dbg.Runtime.pFileDMA); 982 } 983 893 984 return rc; 894 985 } … … 921 1012 # endif 922 1013 1014 if (pStream->Dbg.Runtime.fEnabled) 1015 { 1016 DrvAudioHlpFileDestroy(pStream->Dbg.Runtime.pFileStream); 1017 pStream->Dbg.Runtime.pFileStream = NULL; 1018 1019 DrvAudioHlpFileDestroy(pStream->Dbg.Runtime.pFileDMA); 1020 pStream->Dbg.Runtime.pFileDMA = NULL; 1021 } 1022 923 1023 LogFlowFuncLeave(); 924 1024 } … … 1008 1108 AssertRC(rc2); 1009 1109 1010 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 1011 RTFILE fh; 1012 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ichac97StreamWrite.pcm", 1013 RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE); 1014 RTFileWrite(fh, pvDst, cbRead, NULL); 1015 RTFileClose(fh); 1016 # endif 1110 if (pDstStream->Dbg.Runtime.fEnabled) 1111 DrvAudioHlpFileWrite(pDstStream->Dbg.Runtime.pFileStream, pvDst, cbRead, 0 /* fFlags */); 1017 1112 } 1018 1113 … … 1062 1157 if (cbSrc) 1063 1158 { 1064 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 1065 RTFILE fh; 1066 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97StreamRead.pcm", 1067 RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE); 1068 RTFileWrite(fh, pvSrc, cbSrc, NULL); 1069 RTFileClose(fh); 1070 # endif 1159 if (pSrcStream->Dbg.Runtime.fEnabled) 1160 DrvAudioHlpFileWrite(pSrcStream->Dbg.Runtime.pFileStream, pvSrc, cbSrc, 0 /* fFlags */); 1161 1071 1162 rc = AudioMixerSinkWrite(pDstMixSink, AUDMIXOP_COPY, pvSrc, (uint32_t)cbSrc, &cbWritten); 1072 1163 if (RT_SUCCESS(rc)) … … 2022 2113 } 2023 2114 2115 /** 2116 * Returns the audio direction of a specified stream descriptor. 2117 * 2118 * @return Audio direction. 2119 */ 2120 DECLINLINE(PDMAUDIODIR) ichac97GetDirFromSD(uint8_t uSD) 2121 { 2122 switch (uSD) 2123 { 2124 case AC97SOUNDSOURCE_PI_INDEX: return PDMAUDIODIR_IN; 2125 case AC97SOUNDSOURCE_PO_INDEX: return PDMAUDIODIR_OUT; 2126 case AC97SOUNDSOURCE_MC_INDEX: return PDMAUDIODIR_IN; 2127 } 2128 2129 return PDMAUDIODIR_UNKNOWN; 2130 } 2131 2024 2132 #endif /* IN_RING3 */ 2025 2133 … … 2471 2579 AssertRC(rc2); 2472 2580 2473 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 2474 RTFILE fh; 2475 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97DMARead.pcm", 2476 RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE); 2477 RTFileWrite(fh, pvDst, cbDst, NULL); 2478 RTFileClose(fh); 2479 # endif 2581 if (pStream->Dbg.Runtime.fEnabled) 2582 DrvAudioHlpFileWrite(pStream->Dbg.Runtime.pFileDMA, pvDst, cbDst, 0 /* fFlags */); 2480 2583 } 2481 2584 … … 2501 2604 AssertRC(rc2); 2502 2605 2503 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA 2504 RTFILE fh; 2505 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97DMAWrite.pcm", 2506 RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE); 2507 RTFileWrite(fh, pvSrc, cbSrc, NULL); 2508 RTFileClose(fh); 2509 # endif 2606 if (pStream->Dbg.Runtime.fEnabled) 2607 DrvAudioHlpFileWrite(pStream->Dbg.Runtime.pFileDMA, pvSrc, cbSrc, 0 /* fFlags */); 2510 2608 } 2511 2609 … … 3813 3911 * Validations. 3814 3912 */ 3815 if (!CFGMR3AreValuesValid(pCfg, 3816 "RZEnabled\0" 3817 "Codec\0" 3818 "TimerHz\0")) 3913 if (!CFGMR3AreValuesValid(pCfg, "RZEnabled\0" 3914 "Codec\0" 3915 "TimerHz\0" 3916 "DebugEnabled\0" 3917 "DebugPathOut\0")) 3819 3918 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 3820 3919 N_("Invalid configuration for the AC'97 device")); … … 3826 3925 if (RT_FAILURE(rc)) 3827 3926 return PDMDEV_SET_ERROR(pDevIns, rc, 3828 N_(" HDAconfiguration error: failed to read RCEnabled as boolean"));3927 N_("AC'97 configuration error: failed to read RCEnabled as boolean")); 3829 3928 3830 3929 char szCodec[20]; … … 3840 3939 return PDMDEV_SET_ERROR(pDevIns, rc, 3841 3940 N_("AC'97 configuration error: failed to read Hertz (Hz) rate as unsigned integer")); 3941 3942 if (uTimerHz != AC97_TIMER_HZ) 3943 LogRel(("AC97: Using custom device timer rate (%RU16Hz)\n", uTimerHz)); 3842 3944 # endif 3945 3946 rc = CFGMR3QueryBoolDef(pCfg, "DebugEnabled", &pThis->Dbg.fEnabled, false); 3947 if (RT_FAILURE(rc)) 3948 return PDMDEV_SET_ERROR(pDevIns, rc, 3949 N_("AC97 configuration error: failed to read debugging enabled flag as boolean")); 3950 3951 rc = CFGMR3QueryStringDef(pCfg, "DebugPathOut", pThis->Dbg.szOutPath, sizeof(pThis->Dbg.szOutPath), 3952 VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH); 3953 if (RT_FAILURE(rc)) 3954 return PDMDEV_SET_ERROR(pDevIns, rc, 3955 N_("AC97 configuration error: failed to read debugging output path flag as string")); 3956 3957 if (!strlen(pThis->Dbg.szOutPath)) 3958 RTStrPrintf(pThis->Dbg.szOutPath, sizeof(pThis->Dbg.szOutPath), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH); 3959 3960 if (pThis->Dbg.fEnabled) 3961 LogRel2(("AC97: Debug output will be saved to '%s'\n", pThis->Dbg.szOutPath)); 3843 3962 3844 3963 /* … … 4151 4270 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, "/Devices/AC97/BytesWritten", STAMUNIT_BYTES, "Bytes written to AC97 emulation."); 4152 4271 } 4153 # endif4154 4155 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA4156 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97DMARead.pcm");4157 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97DMAWrite.pcm");4158 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97StreamRead.pcm");4159 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "ac97StreamWrite.pcm");4160 4272 # endif 4161 4273 -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r73612 r73621 2835 2835 default: AssertFailedBreak(); 2836 2836 } 2837 InsertConfigInteger(pCfg, "DebugEnabled", fDebugEnabled); 2838 InsertConfigString (pCfg, "DebugPathOut", strDebugPathOut); 2837 2839 break; 2838 2840 }
Note:
See TracChangeset
for help on using the changeset viewer.

