Changeset 82357 in vbox
- Timestamp:
- Dec 3, 2019 10:30:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r82356 r82357 396 396 397 397 /** 398 * An AC'97 stream.398 * The shared AC'97 stream state. 399 399 */ 400 400 typedef struct AC97STREAM … … 405 405 /** Bus master registers of this stream. */ 406 406 AC97BMREGS Regs; 407 /** The timer for pumping data thru the attached LUN drivers. */ 408 TMTIMERHANDLE hTimer; 409 } AC97STREAM; 410 AssertCompileSizeAlignment(AC97STREAM, 8); 411 /** Pointer to a shared AC'97 stream state. */ 412 typedef AC97STREAM *PAC97STREAM; 413 414 415 /** 416 * The ring-3 AC'97 stream state. 417 */ 418 typedef struct AC97STREAMR3 419 { 420 /** Stream number (SDn). */ 421 uint8_t u8SD; 422 uint8_t abPadding0[7]; 407 423 /** Internal state of this stream. */ 408 424 AC97STREAMSTATE State; 409 /** Pointer to parent (AC'97 state). */410 R3PTRTYPE(PAC97STATE) pAC97State;411 #if HC_ARCH_BITS == 32412 uint32_t Padding1;413 #endif414 /** The timer for pumping data thru the attached LUN drivers. */415 TMTIMERHANDLE hTimer;416 425 /** Debug stuff. */ 417 426 AC97STREAMDEBUG Dbg; 418 } AC97STREAM ;419 AssertCompileSizeAlignment(AC97STREAM , 8);420 /** Pointer to an AC'97 stream (registers + state). */421 typedef AC97STREAM *PAC97STREAM;422 423 typedef struct AC97STATE *PAC97STATE; 427 } AC97STREAMR3; 428 AssertCompileSizeAlignment(AC97STREAMR3, 8); 429 /** Pointer to an AC'97 stream state for ring-3. */ 430 typedef AC97STREAMR3 *PAC97STREAMR3; 431 432 424 433 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 425 434 /** … … 456 465 /** Node for storing this driver in our device driver list of AC97STATE. */ 457 466 RTLISTNODER3 Node; 458 /** Pointer to AC97 controller (state). */459 R3PTRTYPE(PAC97STATE) pAC97State;460 467 /** Driver flags. */ 461 468 PDMAUDIODRVFLAGS fFlags; … … 501 508 /** Critical section protecting the AC'97 state. */ 502 509 PDMCRITSECT CritSect; 503 /** R3 pointer to the device instance. */504 PPDMDEVINSR3 pDevInsR3;505 510 /** Global Control (Bus Master Control Register). */ 506 511 uint32_t glob_cnt; … … 511 516 uint32_t last_samp; 512 517 uint8_t mixer_data[256]; 513 /** Array of AC'97 streams . */518 /** Array of AC'97 streams (parallel to AC97STATER3::aStreams). */ 514 519 AC97STREAM aStreams[AC97_MAX_STREAMS]; 515 520 /** The device timer Hz rate. Defaults to AC97_TIMER_HZ_DEFAULT_DEFAULT. */ 516 521 uint16_t uTimerHz; 517 522 uint16_t au16Padding1[3]; 523 uint8_t silence[128]; 524 int32_t bup_flag; 525 /** Codec model. */ 526 uint32_t uCodecModel; 527 528 /** PCI region \#0: NAM I/O ports. */ 529 IOMIOPORTHANDLE hIoPortsNam; 530 /** PCI region \#0: NANM I/O ports. */ 531 IOMIOPORTHANDLE hIoPortsNabm; 532 533 #ifdef VBOX_WITH_STATISTICS 534 STAMPROFILE StatTimer; 535 STAMPROFILE StatIn; 536 STAMPROFILE StatOut; 537 STAMCOUNTER StatBytesRead; 538 STAMCOUNTER StatBytesWritten; 539 #endif 540 } AC97STATE; 541 AssertCompileMemberAlignment(AC97STATE, aStreams, 8); 542 543 544 /** 545 * The ring-3 AC'97 device state. 546 */ 547 typedef struct AC97STATER3 548 { 549 /** Array of AC'97 streams (parallel to AC97STATE:aStreams). */ 550 AC97STREAMR3 aStreams[AC97_MAX_STREAMS]; 551 /** R3 pointer to the device instance. */ 552 PPDMDEVINSR3 pDevIns; 518 553 /** List of associated LUN drivers (AC97DRIVER). */ 519 554 RTLISTANCHORR3 lstDrv; … … 526 561 /** Audio sink for microphone input. */ 527 562 R3PTRTYPE(PAUDMIXSINK) pSinkMicIn; 528 uint8_t silence[128];529 int32_t bup_flag;530 /** Codec model. */531 uint32_t uCodecModel;532 563 /** The base interface for LUN\#0. */ 533 564 PDMIBASE IBase; 534 565 /** Debug settings. */ 535 566 AC97STATEDEBUG Dbg; 536 537 /** PCI region \#0: NAM I/O ports. */ 538 IOMIOPORTHANDLE hIoPortsNam; 539 /** PCI region \#0: NANM I/O ports. */ 540 IOMIOPORTHANDLE hIoPortsNabm; 541 542 #ifdef VBOX_WITH_STATISTICS 543 STAMPROFILE StatTimer; 544 STAMPROFILE StatIn; 545 STAMPROFILE StatOut; 546 STAMCOUNTER StatBytesRead; 547 STAMCOUNTER StatBytesWritten; 548 #endif 549 } AC97STATE; 550 AssertCompileMemberAlignment(AC97STATE, aStreams, 8); 567 } AC97STATER3; 568 AssertCompileMemberAlignment(AC97STATER3, aStreams, 8); 569 /** Pointer to the ring-3 AC'97 device state. */ 570 typedef AC97STATER3 *PAC97STATER3; 551 571 552 572 … … 616 636 #ifdef IN_RING3 617 637 static int ichac97R3StreamCreate(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8Strm); 618 static void ichac97R3StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream); 619 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce); 620 static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce); 621 static int ichac97R3StreamClose(PAC97STATE pThis, PAC97STREAM pStream); 622 static void ichac97R3StreamReset(PAC97STATE pThis, PAC97STREAM pStream); 623 static void ichac97R3StreamLock(PAC97STREAM pStream); 624 static void ichac97R3StreamUnlock(PAC97STREAM pStream); 625 static uint32_t ichac97R3StreamGetUsed(PAC97STREAM pStream); 626 static uint32_t ichac97R3StreamGetFree(PAC97STREAM pStream); 627 static int ichac97R3StreamTransfer(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbToProcessMax); 628 static void ichac97R3StreamUpdate(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, bool fInTimer); 638 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fForce); 639 static int ichac97R3StreamClose(PAC97STREAM pStream); 640 static void ichac97R3StreamLock(PAC97STREAMR3 pStreamCC); 641 static void ichac97R3StreamUnlock(PAC97STREAMR3 pStreamCC); 642 static uint32_t ichac97R3StreamGetUsed(PAC97STREAMR3 pStreamCC); 643 static uint32_t ichac97R3StreamGetFree(PAC97STREAMR3 pStreamCC); 644 static int ichac97R3StreamTransfer(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, 645 PAC97STREAMR3 pStreamCC, uint32_t cbToProcessMax); 646 static void ichac97R3StreamUpdate(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, 647 PAC97STREAMR3 pStreamCC, bool fInTimer); 629 648 630 649 static DECLCALLBACK(void) ichac97R3Reset(PPDMDEVINS pDevIns); … … 632 651 static DECLCALLBACK(void) ichac97R3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 633 652 634 static int ichac97R3MixerAddDrv(PAC97STATE pThis, PAC97DRIVER pDrv); 635 static int ichac97R3MixerAddDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv); 636 static int ichac97R3MixerAddDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg); 637 static void ichac97R3MixerRemoveDrv(PAC97STATE pThis, PAC97DRIVER pDrv); 638 static void ichac97R3MixerRemoveDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc, PAC97DRIVER pDrv); 639 static void ichac97R3MixerRemoveDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc); 653 static void ichac97R3MixerRemoveDrvStreams(PAC97STATER3 pThisCC, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, 654 PDMAUDIODSTSRCUNION dstSrc); 640 655 641 656 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 642 657 static int ichac97R3StreamAsyncIOCreate(PAC97STATE pThis, PAC97STREAM pStream); 643 658 static int ichac97R3StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAM pStream); 644 static int ichac97R3StreamAsyncIONotify(PAC97STATE pThis, PAC97STREAM pStream);645 659 static void ichac97R3StreamAsyncIOLock(PAC97STREAM pStream); 646 660 static void ichac97R3StreamAsyncIOUnlock(PAC97STREAM pStream); … … 649 663 650 664 DECLINLINE(PDMAUDIODIR) ichac97GetDirFromSD(uint8_t uSD); 651 652 # ifdef LOG_ENABLED653 static void ichac97R3BDLEDumpAll(PAC97STATE pThis, uint64_t u64BDLBase, uint16_t cBDLE);654 # endif655 665 DECLINLINE(void) ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97STREAM pStream, uint64_t cTicksToDeadline); 656 666 #endif /* IN_RING3 */ … … 672 682 * 673 683 * @returns Pointer to audio mixer sink if found, or NULL if not found / invalid. 674 * @param pThis 684 * @param pThisCC The ring-3 AC'97 state. 675 685 * @param uIndex Stream index to get audio mixer sink for. 676 686 */ 677 DECLINLINE(PAUDMIXSINK) ichac97R3IndexToSink(PAC97STATE pThis, uint8_t uIndex)687 DECLINLINE(PAUDMIXSINK) ichac97R3IndexToSink(PAC97STATER3 pThisCC, uint8_t uIndex) 678 688 { 679 689 switch (uIndex) 680 690 { 681 case AC97SOUNDSOURCE_PI_INDEX: return pThis->pSinkLineIn; 682 case AC97SOUNDSOURCE_PO_INDEX: return pThis->pSinkOut; 683 case AC97SOUNDSOURCE_MC_INDEX: return pThis->pSinkMicIn; 684 default: break; 685 } 686 687 AssertMsgFailed(("Wrong index %RU8\n", uIndex)); 688 return NULL; 691 case AC97SOUNDSOURCE_PI_INDEX: return pThisCC->pSinkLineIn; 692 case AC97SOUNDSOURCE_PO_INDEX: return pThisCC->pSinkOut; 693 case AC97SOUNDSOURCE_MC_INDEX: return pThisCC->pSinkMicIn; 694 default: 695 AssertMsgFailedReturn(("Wrong index %RU8\n", uIndex), NULL); 696 } 689 697 } 690 698 … … 693 701 * 694 702 * @returns IPRT status code. 695 * @param p This AC'97 state.703 * @param pDevIns The device instance. 696 704 * @param pStream AC'97 stream to fetch BDLE for. 697 705 * 698 706 * @remark Uses CIV as BDLE index. 699 707 */ 700 static void ichac97R3StreamFetchBDLE(PAC97STATE pThis, PAC97STREAM pStream) 701 { 702 PPDMDEVINS pDevIns = ICHAC97STATE_2_DEVINS(pThis); 703 PAC97BMREGS pRegs = &pStream->Regs; 708 static void ichac97R3StreamFetchBDLE(PPDMDEVINS pDevIns, PAC97STREAM pStream) 709 { 710 PAC97BMREGS pRegs = &pStream->Regs; 704 711 705 712 AC97BDLE BDLE; … … 727 734 * 728 735 * @param pDevIns The device instance. 729 * @param pThis AC'97 state.736 * @param pThis The shared AC'97 state. 730 737 * @param pStream AC'97 stream to update SR for. 731 738 * @param new_sr New value for status register (SR). … … 784 791 * 785 792 * @param pDevIns The device instance. 786 * @param pThis AC'97 device state.793 * @param pThis The shared AC'97 device state. 787 794 * @param pStream Stream to update SR for. 788 795 * @param u32Val New value to set the stream's SR to. … … 804 811 * 805 812 * @returns IPRT status code. 806 * @param pThis 813 * @param pThisCC The ring-3 AC'97 device state. 807 814 * @param pStream Stream to return status for. 808 815 */ 809 static bool ichac97R3StreamIsEnabled(PAC97STATE pThis, PAC97STREAM pStream)810 { 811 PAUDMIXSINK pSink = ichac97R3IndexToSink(pThis , pStream->u8SD);816 static bool ichac97R3StreamIsEnabled(PAC97STATER3 pThisCC, PAC97STREAM pStream) 817 { 818 PAUDMIXSINK pSink = ichac97R3IndexToSink(pThisCC, pStream->u8SD); 812 819 bool fIsEnabled = RT_BOOL(AudioMixerSinkGetStatus(pSink) & AUDMIXSINK_STS_RUNNING); 813 820 … … 820 827 * 821 828 * @returns IPRT status code. 822 * @param pThis AC'97 state. 823 * @param pStream AC'97 stream to enable or disable. 829 * @param pThis The shared AC'97 state. 830 * @param pThisCC The ring-3 AC'97 state. 831 * @param pStream The AC'97 stream to enable or disable (shared 832 * state). 833 * @param pStreamCC The ring-3 stream state (matching to @a pStream). 824 834 * @param fEnable Whether to enable or disable the stream. 825 835 * 826 836 */ 827 static int ichac97R3StreamEnable(PAC97STATE pThis, PAC97STREAM pStream, bool fEnable) 828 { 829 ichac97R3StreamLock(pStream); 837 static int ichac97R3StreamEnable(PAC97STATE pThis, PAC97STATER3 pThisCC, 838 PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fEnable) 839 { 840 ichac97R3StreamLock(pStreamCC); 830 841 831 842 int rc = VINF_SUCCESS; … … 840 851 if (fEnable) 841 852 { 842 if (pStream->State.pCircBuf) 843 RTCircBufReset(pStream->State.pCircBuf); 844 845 rc = ichac97R3StreamOpen(pThis, pStream, false /* fForce */); 846 847 if (pStream->Dbg.Runtime.fEnabled) 848 { 849 if (!DrvAudioHlpFileIsOpen(pStream->Dbg.Runtime.pFileStream)) 853 if (pStreamCC->State.pCircBuf) 854 RTCircBufReset(pStreamCC->State.pCircBuf); 855 856 rc = ichac97R3StreamOpen(pThis, pThisCC, pStream, pStreamCC, false /* fForce */); 857 858 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) 859 { /* likely */ } 860 else 861 { 862 if (!DrvAudioHlpFileIsOpen(pStreamCC->Dbg.Runtime.pFileStream)) 850 863 { 851 int rc2 = DrvAudioHlpFileOpen(pStream ->Dbg.Runtime.pFileStream, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS,852 &pStream ->State.Cfg.Props);864 int rc2 = DrvAudioHlpFileOpen(pStreamCC->Dbg.Runtime.pFileStream, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, 865 &pStreamCC->State.Cfg.Props); 853 866 AssertRC(rc2); 854 867 } 855 868 856 if (!DrvAudioHlpFileIsOpen(pStream ->Dbg.Runtime.pFileDMA))869 if (!DrvAudioHlpFileIsOpen(pStreamCC->Dbg.Runtime.pFileDMA)) 857 870 { 858 int rc2 = DrvAudioHlpFileOpen(pStream ->Dbg.Runtime.pFileDMA, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS,859 &pStream ->State.Cfg.Props);871 int rc2 = DrvAudioHlpFileOpen(pStreamCC->Dbg.Runtime.pFileDMA, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, 872 &pStreamCC->State.Cfg.Props); 860 873 AssertRC(rc2); 861 874 } … … 863 876 } 864 877 else 865 rc = ichac97R3StreamClose(p This, pStream);878 rc = ichac97R3StreamClose(pStream); 866 879 867 880 if (RT_SUCCESS(rc)) 868 881 { 869 882 /* First, enable or disable the stream and the stream's sink, if any. */ 870 rc = AudioMixerSinkCtl(ichac97R3IndexToSink(pThis , pStream->u8SD),883 rc = AudioMixerSinkCtl(ichac97R3IndexToSink(pThisCC, pStream->u8SD), 871 884 fEnable ? AUDMIXSINKCMD_ENABLE : AUDMIXSINKCMD_DISABLE); 872 885 } … … 877 890 878 891 /* Make sure to leave the lock before (eventually) starting the timer. */ 879 ichac97R3StreamUnlock(pStream );892 ichac97R3StreamUnlock(pStreamCC); 880 893 881 894 LogFunc(("[SD%RU8] fEnable=%RTbool, rc=%Rrc\n", pStream->u8SD, fEnable, rc)); … … 886 899 * Resets an AC'97 stream. 887 900 * 888 * @param pThis AC'97 state.889 * @param pStream AC'97 stream to reset.890 * 891 */ 892 static void ichac97R3StreamReset(PAC97STATE pThis, PAC97STREAM pStream )893 { 894 ichac97R3StreamLock(pStream );901 * @param pThis The shared AC'97 state. 902 * @param pStream The AC'97 stream to reset (shared). 903 * @param pStreamCC The AC'97 stream to reset (ring-3). 904 */ 905 static void ichac97R3StreamReset(PAC97STATE pThis, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC) 906 { 907 ichac97R3StreamLock(pStreamCC); 895 908 896 909 LogFunc(("[SD%RU8]\n", pStream->u8SD)); 897 910 898 if (pStream ->State.pCircBuf)899 RTCircBufReset(pStream ->State.pCircBuf);911 if (pStreamCC->State.pCircBuf) 912 RTCircBufReset(pStreamCC->State.pCircBuf); 900 913 901 914 PAC97BMREGS pRegs = &pStream->Regs; … … 912 925 RT_ZERO(pThis->silence); 913 926 914 ichac97R3StreamUnlock(pStream );927 ichac97R3StreamUnlock(pStreamCC); 915 928 } 916 929 … … 919 932 * 920 933 * @returns IPRT status code. 921 * @param pThis AC'97 state. 922 * @param pStream AC'97 stream to create. 934 * @param pThisCC The ring-3 AC'97 state. 935 * @param pStream The AC'97 stream to create (shared). 936 * @param pStreamCC The AC'97 stream to create (ring-3). 923 937 * @param u8SD Stream descriptor number to assign. 924 938 */ 925 static int ichac97R3StreamCreate(PAC97STATE pThis, PAC97STREAM pStream, uint8_t u8SD) 926 { 927 RT_NOREF(pThis); 928 939 static int ichac97R3StreamCreate(PAC97STATER3 pThisCC, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, uint8_t u8SD) 940 { 929 941 LogFunc(("[SD%RU8] pStream=%p\n", u8SD, pStream)); 930 942 931 943 AssertReturn(u8SD < AC97_MAX_STREAMS, VERR_INVALID_PARAMETER); 932 944 pStream->u8SD = u8SD; 933 pStream ->pAC97State = pThis;934 935 int rc = RTCritSectInit(&pStream ->State.CritSect);945 pStreamCC->u8SD = u8SD; 946 947 int rc = RTCritSectInit(&pStreamCC->State.CritSect); 936 948 AssertRCReturn(rc, rc); 937 949 938 pStream->Dbg.Runtime.fEnabled = pThis->Dbg.fEnabled; 939 940 if (pStream->Dbg.Runtime.fEnabled) 950 pStreamCC->Dbg.Runtime.fEnabled = pThisCC->Dbg.fEnabled; 951 952 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) 953 { /* likely */ } 954 else 941 955 { 942 956 char szFile[64]; … … 948 962 949 963 char szPath[RTPATH_MAX]; 950 int rc2 = DrvAudioHlpFileNameGet(szPath, sizeof(szPath), pThis ->Dbg.szOutPath, szFile,964 int rc2 = DrvAudioHlpFileNameGet(szPath, sizeof(szPath), pThisCC->Dbg.szOutPath, szFile, 951 965 0 /* uInst */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE); 952 966 AssertRC(rc2); 953 rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szPath, PDMAUDIOFILE_FLAGS_NONE, &pStream ->Dbg.Runtime.pFileStream);967 rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szPath, PDMAUDIOFILE_FLAGS_NONE, &pStreamCC->Dbg.Runtime.pFileStream); 954 968 AssertRC(rc2); 955 969 … … 959 973 RTStrPrintf(szFile, sizeof(szFile), "ac97DMAReadSD%RU8", pStream->u8SD); 960 974 961 rc2 = DrvAudioHlpFileNameGet(szPath, sizeof(szPath), pThis ->Dbg.szOutPath, szFile,975 rc2 = DrvAudioHlpFileNameGet(szPath, sizeof(szPath), pThisCC->Dbg.szOutPath, szFile, 962 976 0 /* uInst */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE); 963 977 AssertRC(rc2); 964 978 965 rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szPath, PDMAUDIOFILE_FLAGS_NONE, &pStream ->Dbg.Runtime.pFileDMA);979 rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szPath, PDMAUDIOFILE_FLAGS_NONE, &pStreamCC->Dbg.Runtime.pFileDMA); 966 980 AssertRC(rc2); 967 981 968 982 /* Delete stale debugging files from a former run. */ 969 DrvAudioHlpFileDelete(pStream ->Dbg.Runtime.pFileStream);970 DrvAudioHlpFileDelete(pStream ->Dbg.Runtime.pFileDMA);983 DrvAudioHlpFileDelete(pStreamCC->Dbg.Runtime.pFileStream); 984 DrvAudioHlpFileDelete(pStreamCC->Dbg.Runtime.pFileDMA); 971 985 } 972 986 … … 978 992 * 979 993 * @returns IPRT status code. 980 * @param pThis AC'97 state. 981 * @param pStream AC'97 stream to destroy. 982 */ 983 static void ichac97R3StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream) 994 * @param pThis The shared AC'97 state. 995 * @param pStream The AC'97 stream to destroy (shared). 996 * @param pStreamCC The AC'97 stream to destroy (ring-3). 997 */ 998 static void ichac97R3StreamDestroy(PAC97STATE pThis, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC) 984 999 { 985 1000 LogFlowFunc(("[SD%RU8]\n", pStream->u8SD)); 986 1001 987 ichac97R3StreamClose(p This, pStream);988 989 int rc2 = RTCritSectDelete(&pStream ->State.CritSect);1002 ichac97R3StreamClose(pStream); 1003 1004 int rc2 = RTCritSectDelete(&pStreamCC->State.CritSect); 990 1005 AssertRC(rc2); 991 1006 … … 997 1012 # endif 998 1013 999 if (pStream->Dbg.Runtime.fEnabled) 1000 { 1001 DrvAudioHlpFileDestroy(pStream->Dbg.Runtime.pFileStream); 1002 pStream->Dbg.Runtime.pFileStream = NULL; 1003 1004 DrvAudioHlpFileDestroy(pStream->Dbg.Runtime.pFileDMA); 1005 pStream->Dbg.Runtime.pFileDMA = NULL; 1006 } 1007 1008 if (pStream->State.pCircBuf) 1009 { 1010 RTCircBufDestroy(pStream->State.pCircBuf); 1011 pStream->State.pCircBuf = NULL; 1014 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) 1015 { /* likely */ } 1016 else 1017 { 1018 DrvAudioHlpFileDestroy(pStreamCC->Dbg.Runtime.pFileStream); 1019 pStreamCC->Dbg.Runtime.pFileStream = NULL; 1020 1021 DrvAudioHlpFileDestroy(pStreamCC->Dbg.Runtime.pFileDMA); 1022 pStreamCC->Dbg.Runtime.pFileDMA = NULL; 1023 } 1024 1025 if (pStreamCC->State.pCircBuf) 1026 { 1027 RTCircBufDestroy(pStreamCC->State.pCircBuf); 1028 pStreamCC->State.pCircBuf = NULL; 1012 1029 } 1013 1030 … … 1018 1035 * Destroys all AC'97 audio streams of the device. 1019 1036 * 1020 * @param pThis AC'97 state. 1021 */ 1022 static void ichac97R3StreamsDestroy(PAC97STATE pThis) 1037 * @param pThis The shared AC'97 state. 1038 * @param pThisCC The ring-3 AC'97 state. 1039 */ 1040 static void ichac97R3StreamsDestroy(PAC97STATE pThis, PAC97STATER3 pThisCC) 1023 1041 { 1024 1042 LogFlowFuncEnter(); … … 1028 1046 */ 1029 1047 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++) 1030 ichac97R3StreamDestroy(pThis, &pThis->aStreams[i] );1048 ichac97R3StreamDestroy(pThis, &pThis->aStreams[i], &pThisCC->aStreams[i]); 1031 1049 1032 1050 /* … … 1035 1053 1036 1054 PDMAUDIODSTSRCUNION dstSrc; 1037 if (pThis ->pSinkLineIn)1055 if (pThisCC->pSinkLineIn) 1038 1056 { 1039 1057 dstSrc.enmSrc = PDMAUDIORECSRC_LINE; 1040 ichac97R3MixerRemoveDrvStreams(pThis , pThis->pSinkLineIn, PDMAUDIODIR_IN, dstSrc);1041 1042 AudioMixerSinkDestroy(pThis ->pSinkLineIn);1043 pThis ->pSinkLineIn = NULL;1044 } 1045 1046 if (pThis ->pSinkMicIn)1058 ichac97R3MixerRemoveDrvStreams(pThisCC, pThisCC->pSinkLineIn, PDMAUDIODIR_IN, dstSrc); 1059 1060 AudioMixerSinkDestroy(pThisCC->pSinkLineIn); 1061 pThisCC->pSinkLineIn = NULL; 1062 } 1063 1064 if (pThisCC->pSinkMicIn) 1047 1065 { 1048 1066 dstSrc.enmSrc = PDMAUDIORECSRC_MIC; 1049 ichac97R3MixerRemoveDrvStreams(pThis , pThis->pSinkMicIn, PDMAUDIODIR_IN, dstSrc);1050 1051 AudioMixerSinkDestroy(pThis ->pSinkMicIn);1052 pThis ->pSinkMicIn = NULL;1053 } 1054 1055 if (pThis ->pSinkOut)1067 ichac97R3MixerRemoveDrvStreams(pThisCC, pThisCC->pSinkMicIn, PDMAUDIODIR_IN, dstSrc); 1068 1069 AudioMixerSinkDestroy(pThisCC->pSinkMicIn); 1070 pThisCC->pSinkMicIn = NULL; 1071 } 1072 1073 if (pThisCC->pSinkOut) 1056 1074 { 1057 1075 dstSrc.enmDst = PDMAUDIOPLAYBACKDST_FRONT; 1058 ichac97R3MixerRemoveDrvStreams(pThis , pThis->pSinkOut, PDMAUDIODIR_OUT, dstSrc);1059 1060 AudioMixerSinkDestroy(pThis ->pSinkOut);1061 pThis ->pSinkOut = NULL;1076 ichac97R3MixerRemoveDrvStreams(pThisCC, pThisCC->pSinkOut, PDMAUDIODIR_OUT, dstSrc); 1077 1078 AudioMixerSinkDestroy(pThisCC->pSinkOut); 1079 pThisCC->pSinkOut = NULL; 1062 1080 } 1063 1081 } … … 1067 1085 * 1068 1086 * @returns IPRT status code. 1069 * @param pThis AC'97 state. 1070 * @param pDstStream AC'97 stream to write to. 1087 * @param pDstStreamCC The AC'97 stream to write to (ring-3). 1071 1088 * @param pSrcMixSink Mixer sink to get audio data to write from. 1072 1089 * @param cbToWrite Number of bytes to write. 1073 1090 * @param pcbWritten Number of bytes written. Optional. 1074 1091 */ 1075 static int ichac97R3StreamWrite(PAC97STATE pThis, PAC97STREAM pDstStream, PAUDMIXSINK pSrcMixSink, uint32_t cbToWrite, 1076 uint32_t *pcbWritten) 1077 { 1078 RT_NOREF(pThis); 1092 static int ichac97R3StreamWrite(PAC97STREAMR3 pDstStreamCC, PAUDMIXSINK pSrcMixSink, uint32_t cbToWrite, uint32_t *pcbWritten) 1093 { 1094 AssertPtrReturn(pSrcMixSink, VERR_INVALID_POINTER); 1079 1095 AssertReturn(cbToWrite > 0, VERR_INVALID_PARAMETER); 1080 1096 /* pcbWritten is optional. */ 1081 1097 1082 PRTCIRCBUF pCircBuf = pDstStream ->State.pCircBuf;1098 PRTCIRCBUF pCircBuf = pDstStreamCC->State.pCircBuf; 1083 1099 AssertPtr(pCircBuf); 1084 1100 1085 void *pvDst;1086 size_t cbDst;1087 1088 1101 uint32_t cbRead = 0; 1089 1102 1103 void *pvDst; 1104 size_t cbDst; 1090 1105 RTCircBufAcquireWriteBlock(pCircBuf, cbToWrite, &pvDst, &cbDst); 1091 1106 … … 1095 1110 AssertRC(rc2); 1096 1111 1097 if (pDstStream->Dbg.Runtime.fEnabled) 1098 DrvAudioHlpFileWrite(pDstStream->Dbg.Runtime.pFileStream, pvDst, cbRead, 0 /* fFlags */); 1112 if (RT_LIKELY(!pDstStreamCC->Dbg.Runtime.fEnabled)) 1113 { /* likely */ } 1114 else 1115 DrvAudioHlpFileWrite(pDstStreamCC->Dbg.Runtime.pFileStream, pvDst, cbRead, 0 /* fFlags */); 1099 1116 } 1100 1117 … … 1111 1128 * 1112 1129 * @returns IPRT status code. 1113 * @param pThis AC'97 state. 1114 * @param pSrcStream AC'97 stream to read audio data from. 1130 * @param pSrcStreamCC AC'97 stream to read audio data from (ring-3). 1115 1131 * @param pDstMixSink Mixer sink to write audio data to. 1116 1132 * @param cbToRead Number of bytes to read. 1117 1133 * @param pcbRead Number of bytes read. Optional. 1118 1134 */ 1119 static int ichac97R3StreamRead(PAC97STATE pThis, PAC97STREAM pSrcStream, PAUDMIXSINK pDstMixSink, uint32_t cbToRead, 1120 uint32_t *pcbRead) 1121 { 1122 RT_NOREF(pThis); 1135 static int ichac97R3StreamRead(PAC97STREAMR3 pSrcStreamCC, PAUDMIXSINK pDstMixSink, uint32_t cbToRead, uint32_t *pcbRead) 1136 { 1137 AssertPtrReturn(pDstMixSink, VERR_INVALID_POINTER); 1123 1138 AssertReturn(cbToRead > 0, VERR_INVALID_PARAMETER); 1124 1139 /* pcbRead is optional. */ 1125 1140 1126 PRTCIRCBUF pCircBuf = pSrcStream ->State.pCircBuf;1141 PRTCIRCBUF pCircBuf = pSrcStreamCC->State.pCircBuf; 1127 1142 AssertPtr(pCircBuf); 1128 1143 … … 1143 1158 if (cbSrc) 1144 1159 { 1145 if (pSrcStream->Dbg.Runtime.fEnabled) 1146 DrvAudioHlpFileWrite(pSrcStream->Dbg.Runtime.pFileStream, pvSrc, cbSrc, 0 /* fFlags */); 1160 if (RT_LIKELY(!pSrcStreamCC->Dbg.Runtime.fEnabled)) 1161 { /* likely */ } 1162 else 1163 DrvAudioHlpFileWrite(pSrcStreamCC->Dbg.Runtime.pFileStream, pvSrc, cbSrc, 0 /* fFlags */); 1147 1164 1148 1165 rc = AudioMixerSinkWrite(pDstMixSink, AUDMIXOP_COPY, pvSrc, (uint32_t)cbSrc, &cbWritten); … … 1150 1167 1151 1168 Assert(cbSrc >= cbWritten); 1152 Log3Func(("[SD%RU8] %RU32/%zu bytes read\n", pSrcStream ->u8SD, cbWritten, cbSrc));1169 Log3Func(("[SD%RU8] %RU32/%zu bytes read\n", pSrcStreamCC->u8SD, cbWritten, cbSrc)); 1153 1170 } 1154 1171 … … 1192 1209 AssertPtr(pStream); 1193 1210 1194 PAC97STREAMSTATEAIO pAIO = &pCtx->pStream ->State.AIO;1211 PAC97STREAMSTATEAIO pAIO = &pCtx->pStreamCC->State.AIO; 1195 1212 1196 1213 ASMAtomicXchgBool(&pAIO->fStarted, true); … … 1224 1241 } 1225 1242 1226 ichac97R3StreamUpdate(pDevIns, pThis, p Stream, false /* fInTimer */);1243 ichac97R3StreamUpdate(pDevIns, pThis, pThisCC, pStream, pStreamCC, false /* fInTimer */); 1227 1244 1228 1245 int rc3 = RTCritSectLeave(&pAIO->CritSect); … … 1244 1261 * 1245 1262 * @returns IPRT status code. 1246 * @param pThis AC'97 state.1263 * @param pThis The shared AC'97 state. 1247 1264 * @param pStream AC'97 audio stream to create the async I/O thread for. 1248 1265 */ 1249 1266 static int ichac97R3StreamAsyncIOCreate(PAC97STATE pThis, PAC97STREAM pStream) 1250 1267 { 1251 PAC97STREAMSTATEAIO pAIO = &pStream ->State.AIO;1268 PAC97STREAMSTATEAIO pAIO = &pStreamCC->State.AIO; 1252 1269 1253 1270 int rc; … … 1298 1315 1299 1316 /** 1317 * Lets the stream's async I/O thread know that there is some data to process. 1318 * 1319 * @returns IPRT status code. 1320 * @param pStreamCC The AC'97 stream to notify async I/O thread 1321 * for (ring-3). 1322 */ 1323 static int ichac97R3StreamAsyncIONotify(PAC97STREAM pStreamCC) 1324 { 1325 LogFunc(("[SD%RU8]\n", pStreamCC->u8SD)); 1326 return RTSemEventSignal(pStreamCC->State.AIO.Event); 1327 } 1328 1329 /** 1300 1330 * Destroys the async I/O thread of a specific AC'97 audio stream. 1301 1331 * 1302 1332 * @returns IPRT status code. 1303 * @param pThis AC'97 state.1333 * @param pThis The shared AC'97 state. 1304 1334 * @param pStream AC'97 audio stream to destroy the async I/O thread for. 1305 1335 */ 1306 1336 static int ichac97R3StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAM pStream) 1307 1337 { 1308 PAC97STREAMSTATEAIO pAIO = &pStream ->State.AIO;1338 PAC97STREAMSTATEAIO pAIO = &pStreamCC->State.AIO; 1309 1339 1310 1340 if (!ASMAtomicReadBool(&pAIO->fStarted)) … … 1313 1343 ASMAtomicWriteBool(&pAIO->fShutdown, true); 1314 1344 1315 int rc = ichac97R3StreamAsyncIONotify(p This, pStream);1345 int rc = ichac97R3StreamAsyncIONotify(pStreamCC); 1316 1346 AssertRC(rc); 1317 1347 … … 1338 1368 1339 1369 /** 1340 * Lets the stream's async I/O thread know that there is some data to process.1341 *1342 * @returns IPRT status code.1343 * @param pThis AC'97 state.1344 * @param pStream AC'97 stream to notify async I/O thread for.1345 */1346 static int ichac97R3StreamAsyncIONotify(PAC97STATE pThis, PAC97STREAM pStream)1347 {1348 RT_NOREF(pThis);1349 1350 LogFunc(("[SD%RU8]\n", pStream->u8SD));1351 return RTSemEventSignal(pStream->State.AIO.Event);1352 }1353 1354 /**1355 1370 * Locks the async I/O thread of a specific AC'97 audio stream. 1356 1371 * … … 1359 1374 static void ichac97R3StreamAsyncIOLock(PAC97STREAM pStream) 1360 1375 { 1361 PAC97STREAMSTATEAIO pAIO = &pStream ->State.AIO;1376 PAC97STREAMSTATEAIO pAIO = &pStreamCC->State.AIO; 1362 1377 1363 1378 if (!ASMAtomicReadBool(&pAIO->fStarted)) … … 1375 1390 static void ichac97R3StreamAsyncIOUnlock(PAC97STREAM pStream) 1376 1391 { 1377 PAC97STREAMSTATEAIO pAIO = &pStream ->State.AIO;1392 PAC97STREAMSTATEAIO pAIO = &pStreamCC->State.AIO; 1378 1393 1379 1394 if (!ASMAtomicReadBool(&pAIO->fStarted)) … … 1395 1410 static void ichac97R3StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable) 1396 1411 { 1397 PAC97STREAMSTATEAIO pAIO = &pStream ->State.AIO;1412 PAC97STREAMSTATEAIO pAIO = &pStreamCC->State.AIO; 1398 1413 ASMAtomicXchgBool(&pAIO->fEnabled, fEnable); 1399 1414 } … … 1402 1417 1403 1418 # ifdef LOG_ENABLED 1404 static void ichac97R3BDLEDumpAll(P AC97STATE pThis, uint64_t u64BDLBase, uint16_t cBDLE)1419 static void ichac97R3BDLEDumpAll(PPDMDEVINS pDevIns, uint64_t u64BDLBase, uint16_t cBDLE) 1405 1420 { 1406 1421 LogFlowFunc(("BDLEs @ 0x%x (%RU16):\n", u64BDLBase, cBDLE)); … … 1412 1427 { 1413 1428 AC97BDLE BDLE; 1414 PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), u64BDLBase + i * sizeof(AC97BDLE), &BDLE, sizeof(AC97BDLE));1429 PDMDevHlpPhysRead(pDevIns, u64BDLBase + i * sizeof(AC97BDLE), &BDLE, sizeof(AC97BDLE)); 1415 1430 1416 1431 # ifndef RT_LITTLE_ENDIAN … … 1450 1465 * 1451 1466 * @param pDevIns The device instance. 1452 * @param pThis AC'97 state. 1453 * @param pStream AC'97 stream to update. 1467 * @param pThis The shared AC'97 state. 1468 * @param pThisCC The ring-3 AC'97 state. 1469 * @param pStream The AC'97 stream to update (shared). 1470 * @param pStreamCC The AC'97 stream to update (ring-3). 1454 1471 * @param fInTimer Whether to this function was called from the timer 1455 1472 * context or an asynchronous I/O stream thread (if supported). 1456 1473 */ 1457 static void ichac97R3StreamUpdate(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, bool fInTimer) 1474 static void ichac97R3StreamUpdate(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STATER3 pThisCC, 1475 PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fInTimer) 1458 1476 { 1459 1477 RT_NOREF(fInTimer); 1460 1478 1461 PAUDMIXSINK pSink = ichac97R3IndexToSink(pThis , pStream->u8SD);1479 PAUDMIXSINK pSink = ichac97R3IndexToSink(pThisCC, pStream->u8SD); 1462 1480 AssertPtr(pSink); 1463 1481 … … 1467 1485 int rc2; 1468 1486 1469 if (pStream ->State.Cfg.enmDir == PDMAUDIODIR_OUT) /* Output (SDO). */1487 if (pStreamCC->State.Cfg.enmDir == PDMAUDIODIR_OUT) /* Output (SDO). */ 1470 1488 { 1471 1489 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO … … 1473 1491 # endif 1474 1492 { 1475 const uint32_t cbStreamFree = ichac97R3StreamGetFree(pStream );1493 const uint32_t cbStreamFree = ichac97R3StreamGetFree(pStreamCC); 1476 1494 if (cbStreamFree) 1477 1495 { 1478 1496 Log3Func(("[SD%RU8] PICB=%zu (%RU64ms), cbFree=%zu (%RU64ms), cbTransferChunk=%zu (%RU64ms)\n", 1479 1497 pStream->u8SD, 1480 (pStream->Regs.picb << 1), DrvAudioHlpBytesToMilli((pStream->Regs.picb << 1), &pStream ->State.Cfg.Props),1481 cbStreamFree, DrvAudioHlpBytesToMilli(cbStreamFree, &pStream ->State.Cfg.Props),1482 pStream ->State.cbTransferChunk, DrvAudioHlpBytesToMilli(pStream->State.cbTransferChunk, &pStream->State.Cfg.Props)));1498 (pStream->Regs.picb << 1), DrvAudioHlpBytesToMilli((pStream->Regs.picb << 1), &pStreamCC->State.Cfg.Props), 1499 cbStreamFree, DrvAudioHlpBytesToMilli(cbStreamFree, &pStreamCC->State.Cfg.Props), 1500 pStreamCC->State.cbTransferChunk, DrvAudioHlpBytesToMilli(pStreamCC->State.cbTransferChunk, &pStreamCC->State.Cfg.Props))); 1483 1501 1484 1502 /* Do the DMA transfer. */ 1485 rc2 = ichac97R3StreamTransfer(pDevIns, pThis, pStream, RT_MIN(pStream->State.cbTransferChunk, cbStreamFree)); 1503 rc2 = ichac97R3StreamTransfer(pDevIns, pThis, pStream, pStreamCC, 1504 RT_MIN(pStreamCC->State.cbTransferChunk, cbStreamFree)); 1486 1505 AssertRC(rc2); 1487 1506 1488 pStream ->State.tsLastUpdateNs = RTTimeNanoTS();1507 pStreamCC->State.tsLastUpdateNs = RTTimeNanoTS(); 1489 1508 } 1490 1509 } … … 1493 1512 1494 1513 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1495 rc2 = ichac97R3StreamAsyncIONotify(p This, pStream);1514 rc2 = ichac97R3StreamAsyncIONotify(pStreamCC); 1496 1515 AssertRC(rc2); 1497 1516 # endif … … 1502 1521 # endif 1503 1522 const uint32_t cbSinkWritable = AudioMixerSinkGetWritable(pSink); 1504 const uint32_t cbStreamReadable = ichac97R3StreamGetUsed(pStream );1523 const uint32_t cbStreamReadable = ichac97R3StreamGetUsed(pStreamCC); 1505 1524 const uint32_t cbToReadFromStream = RT_MIN(cbStreamReadable, cbSinkWritable); 1506 1525 … … 1510 1529 { 1511 1530 /* Read (guest output) data and write it to the stream's sink. */ 1512 rc2 = ichac97R3StreamRead(p This, pStream, pSink, cbToReadFromStream, NULL /* pcbRead */);1531 rc2 = ichac97R3StreamRead(pStreamCC, pSink, cbToReadFromStream, NULL /* pcbRead */); 1513 1532 AssertRC(rc2); 1514 1533 } … … 1534 1553 1535 1554 /* How much (guest input) data is available for writing at the moment for the AC'97 stream? */ 1536 uint32_t cbStreamFree = ichac97R3StreamGetFree(pStream );1555 uint32_t cbStreamFree = ichac97R3StreamGetFree(pStreamCC); 1537 1556 1538 1557 Log3Func(("[SD%RU8] cbSinkReadable=%RU32, cbStreamFree=%RU32\n", pStream->u8SD, cbSinkReadable, cbStreamFree)); … … 1546 1565 { 1547 1566 /* Write (guest input) data to the stream which was read from stream's sink before. */ 1548 rc2 = ichac97R3StreamWrite(p This, pStream, pSink, cbSinkReadable, NULL /* pcbWritten */);1567 rc2 = ichac97R3StreamWrite(pStreamCC, pSink, cbSinkReadable, NULL /* pcbWritten */); 1549 1568 AssertRC(rc2); 1550 1569 } … … 1557 1576 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1558 1577 const uint64_t tsNowNs = RTTimeNanoTS(); 1559 if (tsNowNs - pStream ->State.tsLastUpdateNs >= pStream->State.Cfg.Device.cMsSchedulingHint * RT_NS_1MS)1578 if (tsNowNs - pStreamCC->State.tsLastUpdateNs >= pStreamCC->State.Cfg.Device.cMsSchedulingHint * RT_NS_1MS) 1560 1579 { 1561 rc2 = ichac97R3StreamAsyncIONotify(p This, pStream);1580 rc2 = ichac97R3StreamAsyncIONotify(pStreamCC); 1562 1581 AssertRC(rc2); 1563 1582 1564 pStream ->State.tsLastUpdateNs = tsNowNs;1583 pStreamCC->State.tsLastUpdateNs = tsNowNs; 1565 1584 } 1566 1585 # endif 1567 1586 1568 const uint32_t cbStreamUsed = ichac97R3StreamGetUsed(pStream );1587 const uint32_t cbStreamUsed = ichac97R3StreamGetUsed(pStreamCC); 1569 1588 if (cbStreamUsed) 1570 1589 { 1571 1590 /* When running synchronously, do the DMA data transfers here. 1572 1591 * Otherwise this will be done in the stream's async I/O thread. */ 1573 rc2 = ichac97R3StreamTransfer(pDevIns, pThis, pStream, cbStreamUsed);1592 rc2 = ichac97R3StreamTransfer(pDevIns, pThis, pStream, pStreamCC, cbStreamUsed); 1574 1593 AssertRC(rc2); 1575 1594 } … … 1586 1605 * 1587 1606 * @returns IPRT status code. 1588 * @param pThis AC'97 state.1607 * @param pThis The shared AC'97 state. 1589 1608 * @param uMixerIdx Mixer control to set value for. 1590 1609 * @param uVal Value to set. … … 1606 1625 * 1607 1626 * @returns Retrieved mixer control value. 1608 * @param pThis AC'97 state.1627 * @param pThis The shared AC'97 state. 1609 1628 * @param uMixerIdx Mixer control to get value for. 1610 1629 */ … … 1623 1642 * 1624 1643 * @returns Pointer to driver stream if found, or NULL if not found. 1625 * @param pThis AC'97 state.1626 1644 * @param pDrv Driver to retrieve driver stream for. 1627 1645 * @param enmDir Stream direction to retrieve. 1628 1646 * @param dstSrc Stream destination / source to retrieve. 1629 1647 */ 1630 static PAC97DRIVERSTREAM ichac97R3MixerGetDrvStream(PAC97STATE pThis, PAC97DRIVER pDrv, 1631 PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc) 1632 { 1633 RT_NOREF(pThis); 1634 1648 static PAC97DRIVERSTREAM ichac97R3MixerGetDrvStream(PAC97DRIVER pDrv, PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc) 1649 { 1635 1650 PAC97DRIVERSTREAM pDrvStream = NULL; 1636 1651 … … 1676 1691 * 1677 1692 * @returns IPRT status code. 1678 * @param pThis AC'97 state.1679 1693 * @param pMixSink Mixer sink to add driver stream to. 1680 1694 * @param pCfg Stream configuration to use. 1681 1695 * @param pDrv Driver stream to add. 1682 1696 */ 1683 static int ichac97R3MixerAddDrvStream(PA C97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv)1697 static int ichac97R3MixerAddDrvStream(PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv) 1684 1698 { 1685 1699 AssertPtrReturn(pMixSink, VERR_INVALID_POINTER); … … 1699 1713 int rc; 1700 1714 1701 PAC97DRIVERSTREAM pDrvStream = ichac97R3MixerGetDrvStream(p This, pDrv, pStreamCfg->enmDir, pStreamCfg->u);1715 PAC97DRIVERSTREAM pDrvStream = ichac97R3MixerGetDrvStream(pDrv, pStreamCfg->enmDir, pStreamCfg->u); 1702 1716 if (pDrvStream) 1703 1717 { … … 1758 1772 * 1759 1773 * @returns IPRT status code. 1760 * @param pThis AC'97 state.1774 * @param pThis The shared AC'97 state. 1761 1775 * @param pMixSink Mixer sink to add stream to. 1762 1776 * @param pCfg Stream configuration to use. 1763 1777 */ 1764 static int ichac97R3MixerAddDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg)1778 static int ichac97R3MixerAddDrvStreams(PAC97STATER3 pThisCC, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg) 1765 1779 { 1766 1780 AssertPtrReturn(pMixSink, VERR_INVALID_POINTER); … … 1774 1788 1775 1789 PAC97DRIVER pDrv; 1776 RTListForEach(&pThis ->lstDrv, pDrv, AC97DRIVER, Node)1777 { 1778 int rc2 = ichac97R3MixerAddDrvStream(p This, pMixSink, pCfg, pDrv);1790 RTListForEach(&pThisCC->lstDrv, pDrv, AC97DRIVER, Node) 1791 { 1792 int rc2 = ichac97R3MixerAddDrvStream(pMixSink, pCfg, pDrv); 1779 1793 if (RT_FAILURE(rc2)) 1780 1794 LogFunc(("Attaching stream failed with %Rrc\n", rc2)); … … 1792 1806 * 1793 1807 * @return IPRT status code. 1794 * @param pThis AC'97state.1795 * @param pDrv AC'97 driver to add.1796 */ 1797 static int ichac97R3MixerAddDrv(PAC97STATE pThis, PAC97DRIVER pDrv)1808 * @param pThis The ring-3 AC'97 device state. 1809 * @param pDrv The AC'97 driver to add. 1810 */ 1811 static int ichac97R3MixerAddDrv(PAC97STATER3 pThisCC, PAC97DRIVER pDrv) 1798 1812 { 1799 1813 int rc = VINF_SUCCESS; 1800 1814 1801 if (DrvAudioHlpStreamCfgIsValid(&pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg)) 1802 { 1803 int rc2 = ichac97R3MixerAddDrvStream(pThis, pThis->pSinkLineIn, 1804 &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg, pDrv); 1815 if (DrvAudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg)) 1816 rc = ichac97R3MixerAddDrvStream(pThisCC->pSinkLineIn, &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg, pDrv); 1817 1818 if (DrvAudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg)) 1819 { 1820 int rc2 = ichac97R3MixerAddDrvStream(pThisCC->pSinkOut, &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg, pDrv); 1805 1821 if (RT_SUCCESS(rc)) 1806 1822 rc = rc2; 1807 1823 } 1808 1824 1809 if (DrvAudioHlpStreamCfgIsValid(&pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg)) 1810 { 1811 int rc2 = ichac97R3MixerAddDrvStream(pThis, pThis->pSinkOut, 1812 &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg, pDrv); 1825 if (DrvAudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg)) 1826 { 1827 int rc2 = ichac97R3MixerAddDrvStream(pThisCC->pSinkMicIn, &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg, pDrv); 1813 1828 if (RT_SUCCESS(rc)) 1814 1829 rc = rc2; 1815 1830 } 1816 1831 1817 if (DrvAudioHlpStreamCfgIsValid(&pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg))1818 {1819 int rc2 = ichac97R3MixerAddDrvStream(pThis, pThis->pSinkMicIn,1820 &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg, pDrv);1821 if (RT_SUCCESS(rc))1822 rc = rc2;1823 }1824 1825 1832 return rc; 1826 1833 } … … 1830 1837 * associated streams. 1831 1838 * 1832 * @param pThis AC'97state.1839 * @param pThis The ring-3 AC'97 device state. 1833 1840 * @param pDrv AC'97 driver to remove. 1834 1841 */ 1835 static void ichac97R3MixerRemoveDrv(PAC97STATE pThis, PAC97DRIVER pDrv)1842 static void ichac97R3MixerRemoveDrv(PAC97STATER3 pThisCC, PAC97DRIVER pDrv) 1836 1843 { 1837 1844 if (pDrv->MicIn.pMixStrm) 1838 1845 { 1839 if (AudioMixerSinkGetRecordingSource(pThis ->pSinkMicIn) == pDrv->MicIn.pMixStrm)1840 AudioMixerSinkSetRecordingSource(pThis ->pSinkMicIn, NULL);1841 1842 AudioMixerSinkRemoveStream(pThis ->pSinkMicIn, pDrv->MicIn.pMixStrm);1846 if (AudioMixerSinkGetRecordingSource(pThisCC->pSinkMicIn) == pDrv->MicIn.pMixStrm) 1847 AudioMixerSinkSetRecordingSource(pThisCC->pSinkMicIn, NULL); 1848 1849 AudioMixerSinkRemoveStream(pThisCC->pSinkMicIn, pDrv->MicIn.pMixStrm); 1843 1850 AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm); 1844 1851 pDrv->MicIn.pMixStrm = NULL; … … 1847 1854 if (pDrv->LineIn.pMixStrm) 1848 1855 { 1849 if (AudioMixerSinkGetRecordingSource(pThis ->pSinkLineIn) == pDrv->LineIn.pMixStrm)1850 AudioMixerSinkSetRecordingSource(pThis ->pSinkLineIn, NULL);1851 1852 AudioMixerSinkRemoveStream(pThis ->pSinkLineIn, pDrv->LineIn.pMixStrm);1856 if (AudioMixerSinkGetRecordingSource(pThisCC->pSinkLineIn) == pDrv->LineIn.pMixStrm) 1857 AudioMixerSinkSetRecordingSource(pThisCC->pSinkLineIn, NULL); 1858 1859 AudioMixerSinkRemoveStream(pThisCC->pSinkLineIn, pDrv->LineIn.pMixStrm); 1853 1860 AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm); 1854 1861 pDrv->LineIn.pMixStrm = NULL; … … 1857 1864 if (pDrv->Out.pMixStrm) 1858 1865 { 1859 AudioMixerSinkRemoveStream(pThis ->pSinkOut, pDrv->Out.pMixStrm);1866 AudioMixerSinkRemoveStream(pThisCC->pSinkOut, pDrv->Out.pMixStrm); 1860 1867 AudioMixerStreamDestroy(pDrv->Out.pMixStrm); 1861 1868 pDrv->Out.pMixStrm = NULL; … … 1868 1875 * Removes a driver stream from a specific mixer sink. 1869 1876 * 1870 * @param pThis AC'97 state.1871 1877 * @param pMixSink Mixer sink to remove audio streams from. 1872 1878 * @param enmDir Stream direction to remove. … … 1874 1880 * @param pDrv Driver stream to remove. 1875 1881 */ 1876 static void ichac97R3MixerRemoveDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, 1877 PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc, PAC97DRIVER pDrv) 1878 { 1879 PAC97DRIVERSTREAM pDrvStream = ichac97R3MixerGetDrvStream(pThis, pDrv, enmDir, dstSrc); 1882 static void ichac97R3MixerRemoveDrvStream(PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc, PAC97DRIVER pDrv) 1883 { 1884 PAC97DRIVERSTREAM pDrvStream = ichac97R3MixerGetDrvStream(pDrv, enmDir, dstSrc); 1880 1885 if (pDrvStream) 1881 1886 { … … 1893 1898 * Removes all driver streams from a specific mixer sink. 1894 1899 * 1895 * @param pThis AC'97 state.1900 * @param pThis The ring-3 AC'97 state. 1896 1901 * @param pMixSink Mixer sink to remove audio streams from. 1897 1902 * @param enmDir Stream direction to remove. 1898 1903 * @param dstSrc Stream destination / source to remove. 1899 1904 */ 1900 static void ichac97R3MixerRemoveDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink,1905 static void ichac97R3MixerRemoveDrvStreams(PAC97STATER3 pThisCC, PAUDMIXSINK pMixSink, 1901 1906 PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc) 1902 1907 { … … 1904 1909 1905 1910 PAC97DRIVER pDrv; 1906 RTListForEach(&pThis ->lstDrv, pDrv, AC97DRIVER, Node)1907 { 1908 ichac97R3MixerRemoveDrvStream(p This, pMixSink, enmDir, dstSrc, pDrv);1911 RTListForEach(&pThisCC->lstDrv, pDrv, AC97DRIVER, Node) 1912 { 1913 ichac97R3MixerRemoveDrvStream(pMixSink, enmDir, dstSrc, pDrv); 1909 1914 } 1910 1915 } … … 1915 1920 * @returns Calculated ticks 1916 1921 * @param pDevIns The device instance. 1917 * @param pStream AC'97 stream to calculate ticks for. 1922 * @param pStream AC'97 stream to calculate ticks for (shared). 1923 * @param pStreamCC AC'97 stream to calculate ticks for (ring-3). 1918 1924 * @param cbBytes Bytes to calculate ticks for. 1919 1925 */ 1920 static uint64_t ichac97R3StreamTransferCalcNext(PPDMDEVINS pDevIns, PAC97STREAM pStream, uint32_t cbBytes)1926 static uint64_t ichac97R3StreamTransferCalcNext(PPDMDEVINS pDevIns, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, uint32_t cbBytes) 1921 1927 { 1922 1928 if (!cbBytes) 1923 1929 return 0; 1924 1930 1925 const uint64_t usBytes = DrvAudioHlpBytesToMicro(cbBytes, &pStream ->State.Cfg.Props);1931 const uint64_t usBytes = DrvAudioHlpBytesToMicro(cbBytes, &pStreamCC->State.Cfg.Props); 1926 1932 const uint64_t cTransferTicks = PDMDevHlpTimerFromMicro(pDevIns, pStream->hTimer, usBytes); 1927 1933 1928 1934 Log3Func(("[SD%RU8] Timer %uHz, cbBytes=%RU32 -> usBytes=%RU64, cTransferTicks=%RU64\n", 1929 pStream->u8SD, pStream ->State.uTimerHz, cbBytes, usBytes, cTransferTicks));1935 pStream->u8SD, pStreamCC->State.uTimerHz, cbBytes, usBytes, cTransferTicks)); 1930 1936 1931 1937 return cTransferTicks; … … 1936 1942 * 1937 1943 * @param pDevIns The device instance. 1938 * @param pStream AC'97 stream to update. 1944 * @param pStream The AC'97 stream to update (shared). 1945 * @param pStreamCC The AC'97 stream to update (ring-3). 1939 1946 * @param cbBytes Bytes to update next transfer for. 1940 1947 */ 1941 static void ichac97R3StreamTransferUpdate(PPDMDEVINS pDevIns, PAC97STREAM pStream, uint32_t cbBytes)1948 static void ichac97R3StreamTransferUpdate(PPDMDEVINS pDevIns, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, uint32_t cbBytes) 1942 1949 { 1943 1950 if (!cbBytes) … … 1946 1953 /* Calculate the bytes we need to transfer to / from the stream's DMA per iteration. 1947 1954 * This is bound to the device's Hz rate and thus to the (virtual) timing the device expects. */ 1948 pStream ->State.cbTransferChunk = cbBytes;1955 pStreamCC->State.cbTransferChunk = cbBytes; 1949 1956 1950 1957 /* Update the transfer ticks. */ 1951 pStream->State.cTransferTicks = ichac97R3StreamTransferCalcNext(pDevIns, pStream, pStream->State.cbTransferChunk); 1952 Assert(pStream->State.cTransferTicks); /* Paranoia. */ 1958 pStreamCC->State.cTransferTicks = ichac97R3StreamTransferCalcNext(pDevIns, pStream, pStreamCC, 1959 pStreamCC->State.cbTransferChunk); 1960 Assert(pStreamCC->State.cTransferTicks); /* Paranoia. */ 1953 1961 } 1954 1962 … … 1960 1968 * 1961 1969 * @returns IPRT status code. 1962 * @param pThis AC'97 device state. 1963 * @param pStream AC'97 stream to open. 1970 * @param pThis The shared AC'97 device state (shared). 1971 * @param pThisCC The shared AC'97 device state (ring-3). 1972 * @param pStream The AC'97 stream to open (shared). 1973 * @param pStreamCC The AC'97 stream to open (ring-3). 1964 1974 * @param fForce Whether to force re-opening the stream or not. 1965 1975 * Otherwise re-opening only will happen if the PCM properties have changed. 1966 1976 */ 1967 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce) 1968 { 1969 int rc = VINF_SUCCESS; 1970 1977 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fForce) 1978 { 1971 1979 PDMAUDIOSTREAMCFG Cfg; 1972 1980 RT_ZERO(Cfg); 1973 1974 PAUDMIXSINK pMixSink = NULL;1975 1976 1981 Cfg.Props.cChannels = 2; 1977 1982 Cfg.Props.cbSample = 2 /* 16-bit */; … … 1979 1984 Cfg.Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(Cfg.Props.cbSample, Cfg.Props.cChannels); 1980 1985 1986 int rc = VINF_SUCCESS; 1987 PAUDMIXSINK pMixSink; 1981 1988 switch (pStream->u8SD) 1982 1989 { … … 1989 1996 RTStrCopy(Cfg.szName, sizeof(Cfg.szName), "Line-In"); 1990 1997 1991 pMixSink = pThis ->pSinkLineIn;1998 pMixSink = pThisCC->pSinkLineIn; 1992 1999 break; 1993 2000 } … … 2001 2008 RTStrCopy(Cfg.szName, sizeof(Cfg.szName), "Mic-In"); 2002 2009 2003 pMixSink = pThis ->pSinkMicIn;2010 pMixSink = pThisCC->pSinkMicIn; 2004 2011 break; 2005 2012 } … … 2013 2020 RTStrCopy(Cfg.szName, sizeof(Cfg.szName), "Output"); 2014 2021 2015 pMixSink = pThis ->pSinkOut;2022 pMixSink = pThisCC->pSinkOut; 2016 2023 break; 2017 2024 } … … 2019 2026 default: 2020 2027 rc = VERR_NOT_SUPPORTED; 2028 pMixSink = NULL; 2021 2029 break; 2022 2030 } … … 2026 2034 /* Only (re-)create the stream (and driver chain) if we really have to. 2027 2035 * Otherwise avoid this and just reuse it, as this costs performance. */ 2028 if ( !DrvAudioHlpPCMPropsAreEqual(&Cfg.Props, &pStream ->State.Cfg.Props)2036 if ( !DrvAudioHlpPCMPropsAreEqual(&Cfg.Props, &pStreamCC->State.Cfg.Props) 2029 2037 || fForce) 2030 2038 { … … 2044 2052 { 2045 2053 if (Cfg.Props.uHz > 44100) /* E.g. 48000 Hz. */ 2046 pStream ->State.uTimerHz = 200;2054 pStreamCC->State.uTimerHz = 200; 2047 2055 else /* Just take the global Hz rate otherwise. */ 2048 pStream ->State.uTimerHz = pThis->uTimerHz;2056 pStreamCC->State.uTimerHz = pThis->uTimerHz; 2049 2057 } 2050 2058 else 2051 pStream ->State.uTimerHz = pThis->uTimerHz;2059 pStreamCC->State.uTimerHz = pThis->uTimerHz; 2052 2060 2053 2061 /* Set scheduling hint (if available). */ 2054 if (pStream ->State.uTimerHz)2055 Cfg.Device.cMsSchedulingHint = 1000 /* ms */ / pStream ->State.uTimerHz;2056 2057 if (pStream ->State.pCircBuf)2062 if (pStreamCC->State.uTimerHz) 2063 Cfg.Device.cMsSchedulingHint = 1000 /* ms */ / pStreamCC->State.uTimerHz; 2064 2065 if (pStreamCC->State.pCircBuf) 2058 2066 { 2059 RTCircBufDestroy(pStream ->State.pCircBuf);2060 pStream ->State.pCircBuf = NULL;2067 RTCircBufDestroy(pStreamCC->State.pCircBuf); 2068 pStreamCC->State.pCircBuf = NULL; 2061 2069 } 2062 2070 2063 rc = RTCircBufCreate(&pStream ->State.pCircBuf, DrvAudioHlpMilliToBytes(100 /* ms */, &Cfg.Props)); /** @todo Make this configurable. */2071 rc = RTCircBufCreate(&pStreamCC->State.pCircBuf, DrvAudioHlpMilliToBytes(100 /* ms */, &Cfg.Props)); /** @todo Make this configurable. */ 2064 2072 if (RT_SUCCESS(rc)) 2065 2073 { 2066 ichac97R3MixerRemoveDrvStreams(pThis , pMixSink, Cfg.enmDir, Cfg.u);2067 2068 rc = ichac97R3MixerAddDrvStreams(pThis , pMixSink, &Cfg);2074 ichac97R3MixerRemoveDrvStreams(pThisCC, pMixSink, Cfg.enmDir, Cfg.u); 2075 2076 rc = ichac97R3MixerAddDrvStreams(pThisCC, pMixSink, &Cfg); 2069 2077 if (RT_SUCCESS(rc)) 2070 rc = DrvAudioHlpStreamCfgCopy(&pStream ->State.Cfg, &Cfg);2078 rc = DrvAudioHlpStreamCfgCopy(&pStreamCC->State.Cfg, &Cfg); 2071 2079 } 2072 2080 } … … 2084 2092 * 2085 2093 * @returns IPRT status code. 2086 * @param pThis AC'97 state. 2087 * @param pStream AC'97 stream to close. 2088 */ 2089 static int ichac97R3StreamClose(PAC97STATE pThis, PAC97STREAM pStream) 2090 { 2091 RT_NOREF(pThis, pStream); 2092 2094 * @param pStream The AC'97 stream to close (shared). 2095 */ 2096 static int ichac97R3StreamClose(PAC97STREAM pStream) 2097 { 2098 RT_NOREF(pStream); 2093 2099 LogFlowFunc(("[SD%RU8]\n", pStream->u8SD)); 2094 2095 2100 return VINF_SUCCESS; 2096 2101 } … … 2101 2106 * 2102 2107 * @returns IPRT status code. 2103 * @param pThis AC'97 device state. 2104 * @param pStream AC'97 stream to re-open. 2108 * @param pThis The shared AC'97 device state. 2109 * @param pThisCC The ring-3 AC'97 device state. 2110 * @param pStream The AC'97 stream to re-open (shared). 2111 * @param pStreamCC The AC'97 stream to re-open (ring-3). 2105 2112 * @param fForce Whether to force re-opening the stream or not. 2106 2113 * Otherwise re-opening only will happen if the PCM properties have changed. 2107 2114 */ 2108 static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream, bool fForce) 2115 static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STATER3 pThisCC, 2116 PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fForce) 2109 2117 { 2110 2118 LogFlowFunc(("[SD%RU8]\n", pStream->u8SD)); 2111 2112 int rc = ichac97R3StreamClose(pThis, pStream); 2119 Assert(pStream->u8SD == pStreamCC->u8SD); 2120 Assert(pStream - &pThis->aStreams[0] == pStream->u8SD); 2121 Assert(pStreamCC - &pThisCC->aStreams[0] == pStream->u8SD); 2122 2123 int rc = ichac97R3StreamClose(pStream); 2113 2124 if (RT_SUCCESS(rc)) 2114 rc = ichac97R3StreamOpen(pThis, p Stream, fForce);2125 rc = ichac97R3StreamOpen(pThis, pThisCC, pStream, pStreamCC, fForce); 2115 2126 2116 2127 return rc; … … 2121 2132 * 2122 2133 * @returns IPRT status code. 2123 * @param pStream AC'97 stream to lock.2124 */ 2125 static void ichac97R3StreamLock(PAC97STREAM pStream)2126 { 2127 int rc2 = RTCritSectEnter(&pStream ->State.CritSect);2134 * @param pStreamCC The AC'97 stream to lock (ring-3). 2135 */ 2136 static void ichac97R3StreamLock(PAC97STREAMR3 pStreamCC) 2137 { 2138 int rc2 = RTCritSectEnter(&pStreamCC->State.CritSect); 2128 2139 AssertRC(rc2); 2129 2140 } … … 2133 2144 * 2134 2145 * @returns IPRT status code. 2135 * @param pStream AC'97 stream to unlock.2136 */ 2137 static void ichac97R3StreamUnlock(PAC97STREAM pStream)2138 { 2139 int rc2 = RTCritSectLeave(&pStream ->State.CritSect);2146 * @param pStreamCC The AC'97 stream to unlock (ring-3). 2147 */ 2148 static void ichac97R3StreamUnlock(PAC97STREAMR3 pStreamCC) 2149 { 2150 int rc2 = RTCritSectLeave(&pStreamCC->State.CritSect); 2140 2151 AssertRC(rc2); 2141 2152 } … … 2145 2156 * 2146 2157 * @returns Available data (in bytes). 2147 * @param pStream AC'97 stream to retrieve size for.2148 */ 2149 static uint32_t ichac97R3StreamGetUsed(PAC97STREAM pStream)2150 { 2151 if (!pStream ->State.pCircBuf)2158 * @param pStreamCC The AC'97 stream to retrieve size for (ring-3). 2159 */ 2160 static uint32_t ichac97R3StreamGetUsed(PAC97STREAMR3 pStreamCC) 2161 { 2162 if (!pStreamCC->State.pCircBuf) 2152 2163 return 0; 2153 2164 2154 return (uint32_t)RTCircBufUsed(pStream ->State.pCircBuf);2165 return (uint32_t)RTCircBufUsed(pStreamCC->State.pCircBuf); 2155 2166 } 2156 2167 … … 2161 2172 * @param pStream AC'97 stream to retrieve size for. 2162 2173 */ 2163 static uint32_t ichac97R3StreamGetFree(PAC97STREAM pStream)2164 { 2165 if (!pStream ->State.pCircBuf)2174 static uint32_t ichac97R3StreamGetFree(PAC97STREAMR3 pStreamCC) 2175 { 2176 if (!pStreamCC->State.pCircBuf) 2166 2177 return 0; 2167 2178 2168 return (uint32_t)RTCircBufFree(pStream ->State.pCircBuf);2179 return (uint32_t)RTCircBufFree(pStreamCC->State.pCircBuf); 2169 2180 } 2170 2181 … … 2175 2186 * 2176 2187 * @returns IPRT status code. 2177 * @param pThis AC'97 state. 2188 * @param pThis The shared AC'97 state. 2189 * @param pThisCC The ring-3 AC'97 state. 2178 2190 * @param index AC'97 mixer index to set volume for. 2179 2191 * @param enmMixerCtl Corresponding audio mixer sink. 2180 2192 * @param uVal Volume value to set. 2181 2193 */ 2182 static int ichac97R3MixerSetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL enmMixerCtl, uint32_t uVal)2194 static int ichac97R3MixerSetVolume(PAC97STATE pThis, PAC97STATER3 pThisCC, int index, PDMAUDIOMIXERCTL enmMixerCtl, uint32_t uVal) 2183 2195 { 2184 2196 /* … … 2234 2246 int rc = VINF_SUCCESS; 2235 2247 2236 if (pThis ->pMixer) /* Device can be in reset state, so no mixer available. */2248 if (pThisCC->pMixer) /* Device can be in reset state, so no mixer available. */ 2237 2249 { 2238 2250 PDMAUDIOVOLUME Vol = { fCtlMuted, lVol, rVol }; … … 2242 2254 { 2243 2255 case PDMAUDIOMIXERCTL_VOLUME_MASTER: 2244 rc = AudioMixerSetMasterVolume(pThis ->pMixer, &Vol);2256 rc = AudioMixerSetMasterVolume(pThisCC->pMixer, &Vol); 2245 2257 break; 2246 2258 2247 2259 case PDMAUDIOMIXERCTL_FRONT: 2248 pSink = pThis ->pSinkOut;2260 pSink = pThisCC->pSinkOut; 2249 2261 break; 2250 2262 … … 2278 2290 * 2279 2291 * @returns IPRT status code. 2280 * @param pThis AC'97 state. 2292 * @param pThis The shared AC'97 state. 2293 * @param pThisCC The ring-3 AC'97 state. 2281 2294 * @param index AC'97 mixer index to set volume for. 2282 2295 * @param enmMixerCtl Corresponding audio mixer sink. 2283 2296 * @param uVal Volume value to set. 2284 2297 */ 2285 static int ichac97R3MixerSetGain(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL enmMixerCtl, uint32_t uVal)2298 static int ichac97R3MixerSetGain(PAC97STATE pThis, PAC97STATER3 pThisCC, int index, PDMAUDIOMIXERCTL enmMixerCtl, uint32_t uVal) 2286 2299 { 2287 2300 /* … … 2317 2330 int rc = VINF_SUCCESS; 2318 2331 2319 if (pThis ->pMixer) /* Device can be in reset state, so no mixer available. */2332 if (pThisCC->pMixer) /* Device can be in reset state, so no mixer available. */ 2320 2333 { 2321 2334 PDMAUDIOVOLUME Vol = { fCtlMuted, lVol, rVol }; … … 2325 2338 { 2326 2339 case PDMAUDIOMIXERCTL_MIC_IN: 2327 pSink = pThis ->pSinkMicIn;2340 pSink = pThisCC->pSinkMicIn; 2328 2341 break; 2329 2342 2330 2343 case PDMAUDIOMIXERCTL_LINE_IN: 2331 pSink = pThis ->pSinkLineIn;2344 pSink = pThisCC->pSinkLineIn; 2332 2345 break; 2333 2346 … … 2345 2358 * NB: The codecs we support do not have the dedicated microphone control. 2346 2359 */ 2347 if ((pSink == pThis ->pSinkLineIn) && pThis->pSinkMicIn)2360 if ((pSink == pThisCC->pSinkLineIn) && pThisCC->pSinkMicIn) 2348 2361 rc = AudioMixerSinkSetVolume(pSink, &Vol); 2349 2362 } … … 2432 2445 * source. 2433 2446 * 2434 * @param pThis AC'97 state.2447 * @param pThis The shared AC'97 state. 2435 2448 * @param val AC'97 recording source index to set. 2436 2449 */ … … 2455 2468 * 2456 2469 * @returns IPRT status code. 2457 * @param pThis AC'97 state. 2458 */ 2459 static int ichac97R3MixerReset(PAC97STATE pThis) 2470 * @param pThis The shared AC'97 state. 2471 * @param pThisCC The ring-3 AC'97 state. 2472 */ 2473 static int ichac97R3MixerReset(PAC97STATE pThis, PAC97STATER3 pThisCC) 2460 2474 { 2461 2475 LogFlowFuncEnter(); … … 2515 2529 2516 2530 /* The default value is 8000h, which corresponds to 0 dB attenuation with mute on. */ 2517 ichac97R3MixerSetVolume(pThis, AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER, 0x8000);2531 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER, 0x8000); 2518 2532 2519 2533 /* The default value for stereo registers is 8808h, which corresponds to 0 dB gain with mute on.*/ 2520 ichac97R3MixerSetVolume(pThis, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT, 0x8808);2521 ichac97R3MixerSetVolume(pThis, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8808);2522 ichac97R3MixerSetVolume(pThis, AC97_Mic_Volume_Mute, PDMAUDIOMIXERCTL_MIC_IN, 0x8008);2534 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT, 0x8808); 2535 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8808); 2536 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_Mic_Volume_Mute, PDMAUDIOMIXERCTL_MIC_IN, 0x8008); 2523 2537 2524 2538 /* The default for record controls is 0 dB gain with mute on. */ 2525 ichac97R3MixerSetGain(pThis, AC97_Record_Gain_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8000);2526 ichac97R3MixerSetGain(pThis, AC97_Record_Gain_Mic_Mute, PDMAUDIOMIXERCTL_MIC_IN, 0x8000);2539 ichac97R3MixerSetGain(pThis, pThisCC, AC97_Record_Gain_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8000); 2540 ichac97R3MixerSetGain(pThis, pThisCC, AC97_Record_Gain_Mic_Mute, PDMAUDIOMIXERCTL_MIC_IN, 0x8000); 2527 2541 2528 2542 return VINF_SUCCESS; … … 2554 2568 uint32_t cbWrittenToStream; 2555 2569 2556 int rc2 = AudioMixerSinkWrite(pThis ->pSinkOut, AUDMIXOP_COPY,2570 int rc2 = AudioMixerSinkWrite(pThisCC->pSinkOut, AUDMIXOP_COPY, 2557 2571 pThis->silence, cbToWrite, &cbWrittenToStream); 2558 2572 if (RT_SUCCESS(rc2)) … … 2576 2590 static DECLCALLBACK(void) ichac97R3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2577 2591 { 2578 PAC97STATE pThis= PDMDEVINS_2_DATA(pDevIns, PAC97STATE);2592 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 2579 2593 STAM_PROFILE_START(&pThis->StatTimer, a); 2580 PAC97STREAM pStream = (PAC97STREAM)pvUser; 2594 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 2595 PAC97STREAM pStream = (PAC97STREAM)pvUser; 2596 PAC97STREAMR3 pStreamCC = &RT_SAFE_SUBSCRIPT8(pThisCC->aStreams, pStream->u8SD); 2581 2597 RT_NOREF(pTimer); 2582 2598 2583 Assert Ptr(pStream);2599 Assert(pStream - &pThis->aStreams[0] == pStream->u8SD); 2584 2600 Assert(PDMDevHlpCritSectIsOwner(pDevIns, &pThis->CritSect)); 2585 2601 Assert(PDMDevHlpTimerIsLockOwner(pDevIns, pStream->hTimer)); 2586 2602 2587 ichac97R3StreamUpdate(pDevIns, pThis, p Stream, true /* fInTimer */);2588 2589 PAUDMIXSINK pSink = ichac97R3IndexToSink(pThis , pStream->u8SD);2603 ichac97R3StreamUpdate(pDevIns, pThis, pThisCC, pStream, pStreamCC, true /* fInTimer */); 2604 2605 PAUDMIXSINK pSink = ichac97R3IndexToSink(pThisCC, pStream->u8SD); 2590 2606 if (pSink && AudioMixerSinkIsActive(pSink)) 2591 2607 { 2592 ichac97R3StreamTransferUpdate(pDevIns, pStream, pStream ->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */2593 ichac97R3TimerSet(pDevIns, pStream, pStream ->State.cTransferTicks);2608 ichac97R3StreamTransferUpdate(pDevIns, pStream, pStreamCC, pStream->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */ 2609 ichac97R3TimerSet(pDevIns, pStream, pStreamCC->State.cTransferTicks); 2594 2610 } 2595 2611 … … 2602 2618 * 2603 2619 * @param pDevIns The device instance. 2604 * @param pThis AC'97 state.2620 * @param pThis The shared AC'97 state. 2605 2621 * @param pStream AC'97 stream to set timer for. 2606 2622 * @param cTicksToDeadline The number of ticks to the new deadline. … … 2626 2642 * @returns IPRT status code. 2627 2643 * @param pDevIns The device instance. 2628 * @param pThis AC'97 state. 2629 * @param pStream AC'97 stream to update. 2644 * @param pThis The shared AC'97 state. 2645 * @param pStream The AC'97 stream to update (shared). 2646 * @param pStreamCC The AC'97 stream to update (ring-3). 2630 2647 * @param cbToProcessMax Maximum of data (in bytes) to process. 2631 2648 */ 2632 static int ichac97R3StreamTransfer(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint32_t cbToProcessMax) 2649 static int ichac97R3StreamTransfer(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, 2650 PAC97STREAMR3 pStreamCC, uint32_t cbToProcessMax) 2633 2651 { 2634 2652 if (!cbToProcessMax) … … 2636 2654 2637 2655 #ifdef VBOX_STRICT 2638 const unsigned cbFrame = DrvAudioHlpPCMPropsBytesPerFrame(&pStream ->State.Cfg.Props);2656 const unsigned cbFrame = DrvAudioHlpPCMPropsBytesPerFrame(&pStreamCC->State.Cfg.Props); 2639 2657 #endif 2640 2658 … … 2642 2660 Assert(cbToProcessMax % cbFrame == 0); 2643 2661 2644 ichac97R3StreamLock(pStream );2662 ichac97R3StreamLock(pStreamCC); 2645 2663 2646 2664 PAC97BMREGS pRegs = &pStream->Regs; … … 2661 2679 } 2662 2680 2663 ichac97R3StreamUnlock(pStream );2681 ichac97R3StreamUnlock(pStreamCC); 2664 2682 return VINF_SUCCESS; 2665 2683 } … … 2670 2688 Log3Func(("[SD%RU8] BCIS set\n", pStream->u8SD)); 2671 2689 2672 ichac97R3StreamUnlock(pStream );2690 ichac97R3StreamUnlock(pStreamCC); 2673 2691 return VINF_SUCCESS; 2674 2692 } … … 2677 2695 uint32_t cbProcessedTotal = 0; 2678 2696 2679 PRTCIRCBUF pCircBuf = pStream ->State.pCircBuf;2697 PRTCIRCBUF pCircBuf = pStreamCC->State.pCircBuf; 2680 2698 AssertPtr(pCircBuf); 2681 2699 … … 2703 2721 pRegs->piv = (pRegs->piv + 1) % AC97_MAX_BDLE; 2704 2722 2705 ichac97R3StreamFetchBDLE(p This, pStream);2723 ichac97R3StreamFetchBDLE(pDevIns, pStream); 2706 2724 continue; 2707 2725 } … … 2720 2738 if (cbDst) 2721 2739 { 2722 int rc2 = PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), pRegs->bd.addr, (uint8_t *)pvDst, cbDst);2740 int rc2 = PDMDevHlpPhysRead(pDevIns, pRegs->bd.addr, (uint8_t *)pvDst, cbDst); 2723 2741 AssertRC(rc2); 2724 2742 2725 if (pStream->Dbg.Runtime.fEnabled) 2726 DrvAudioHlpFileWrite(pStream->Dbg.Runtime.pFileDMA, pvDst, cbDst, 0 /* fFlags */); 2743 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) 2744 { /* likely */ } 2745 else 2746 DrvAudioHlpFileWrite(pStreamCC->Dbg.Runtime.pFileDMA, pvDst, cbDst, 0 /* fFlags */); 2727 2747 } 2728 2748 … … 2745 2765 /** @todo r=bird: Just curious, DevHDA uses PDMDevHlpPCIPhysWrite here. So, 2746 2766 * is AC97 not subject to PCI busmaster enable/disable? */ 2747 int rc2 = PDMDevHlpPhysWrite(p This->CTX_SUFF(pDevIns), pRegs->bd.addr, (uint8_t *)pvSrc, cbSrc);2767 int rc2 = PDMDevHlpPhysWrite(pDevIns, pRegs->bd.addr, (uint8_t *)pvSrc, cbSrc); 2748 2768 AssertRC(rc2); 2749 2769 2750 if (pStream->Dbg.Runtime.fEnabled) 2751 DrvAudioHlpFileWrite(pStream->Dbg.Runtime.pFileDMA, pvSrc, cbSrc, 0 /* fFlags */); 2770 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) 2771 { /* likely */ } 2772 else 2773 DrvAudioHlpFileWrite(pStreamCC->Dbg.Runtime.pFileDMA, pvSrc, cbSrc, 0 /* fFlags */); 2752 2774 } 2753 2775 … … 2805 2827 pRegs->civ = pRegs->piv; 2806 2828 pRegs->piv = (pRegs->piv + 1) % AC97_MAX_BDLE; 2807 ichac97R3StreamFetchBDLE(p This, pStream);2829 ichac97R3StreamFetchBDLE(pDevIns, pStream); 2808 2830 } 2809 2831 … … 2820 2842 } 2821 2843 2822 ichac97R3StreamUnlock(pStream );2844 ichac97R3StreamUnlock(pStreamCC); 2823 2845 2824 2846 LogFlowFuncLeaveRC(rc); … … 2999 3021 ichac97IoPortNabmWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 3000 3022 { 3001 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3023 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3024 #ifdef IN_RING3 3025 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3026 #endif 3002 3027 RT_NOREF(pvUser); 3003 3028 3004 PAC97STREAM pStream = NULL; 3005 PAC97BMREGS pRegs = NULL; 3029 #ifdef IN_RING3 3030 PAC97STREAMR3 pStreamCC = NULL; 3031 #endif 3032 PAC97STREAM pStream = NULL; 3033 PAC97BMREGS pRegs = NULL; 3006 3034 if (AC97_PORT2IDX(offPort) < AC97_MAX_STREAMS) 3007 3035 { 3008 pStream = &pThis->aStreams[AC97_PORT2IDX(offPort)]; 3009 pRegs = &pStream->Regs; 3036 #ifdef IN_RING3 3037 pStreamCC = &pThisCC->aStreams[AC97_PORT2IDX(offPort)]; 3038 #endif 3039 pStream = &pThis->aStreams[AC97_PORT2IDX(offPort)]; 3040 pRegs = &pStream->Regs; 3010 3041 3011 3042 DEVAC97_LOCK_BOTH_RETURN(pDevIns, pThis, pStream, VINF_IOM_R3_IOPORT_WRITE); … … 3062 3093 Assert((pRegs->cr & AC97_CR_RPBM) == 0); 3063 3094 3064 ichac97R3StreamEnable(pThis, p Stream, false /* fEnable */);3065 ichac97R3StreamReset(pThis, pStream );3095 ichac97R3StreamEnable(pThis, pThisCC, pStream, pStreamCC, false /* fEnable */); 3096 ichac97R3StreamReset(pThis, pStream, pStreamCC); 3066 3097 3067 3098 ichac97StreamUpdateSR(pDevIns, pThis, pStream, AC97_SR_DCH); /** @todo Do we need to do that? */ … … 3075 3106 Log3Func(("[SD%RU8] Disable\n", pStream->u8SD)); 3076 3107 3077 ichac97R3StreamEnable(pThis, p Stream, false /* fEnable */);3108 ichac97R3StreamEnable(pThis, pThisCC, pStream, pStreamCC, false /* fEnable */); 3078 3109 3079 3110 pRegs->sr |= AC97_SR_DCH; … … 3089 3120 3090 3121 /* Fetch the initial BDLE descriptor. */ 3091 ichac97R3StreamFetchBDLE(p This, pStream);3122 ichac97R3StreamFetchBDLE(pDevIns, pStream); 3092 3123 # ifdef LOG_ENABLED 3093 ichac97R3BDLEDumpAll(p This, pStream->Regs.bdbar, pStream->Regs.lvi + 1);3124 ichac97R3BDLEDumpAll(pDevIns, pStream->Regs.bdbar, pStream->Regs.lvi + 1); 3094 3125 # endif 3095 ichac97R3StreamEnable(pThis, p Stream, true /* fEnable */);3126 ichac97R3StreamEnable(pThis, pThisCC, pStream, pStreamCC, true /* fEnable */); 3096 3127 3097 3128 /* Arm the timer for this stream. */ 3098 3129 /** @todo r=bird: This function returns bool, not VBox status! */ 3099 ichac97R3TimerSet(pDevIns, pStream, pStream ->State.cTransferTicks);3130 ichac97R3TimerSet(pDevIns, pStream, pStreamCC->State.cTransferTicks); 3100 3131 } 3101 3132 } … … 3242 3273 ichac97IoPortNamWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 3243 3274 { 3244 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3275 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3276 #ifdef IN_RING3 3277 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3278 #endif 3245 3279 RT_NOREF(pvUser); 3246 3280 … … 3264 3298 case AC97_Reset: 3265 3299 #ifdef IN_RING3 3266 ichac97R3Reset(p This->CTX_SUFF(pDevIns));3300 ichac97R3Reset(pDevIns); 3267 3301 #else 3268 3302 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3281 3315 } 3282 3316 #ifdef IN_RING3 3283 ichac97R3MixerSetVolume(pThis, offPort, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32);3317 ichac97R3MixerSetVolume(pThis, pThisCC, offPort, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32); 3284 3318 #else 3285 3319 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3293 3327 /* Register controls PCM (front) outputs. */ 3294 3328 #ifdef IN_RING3 3295 ichac97R3MixerSetVolume(pThis, offPort, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32);3329 ichac97R3MixerSetVolume(pThis, pThisCC, offPort, PDMAUDIOMIXERCTL_VOLUME_MASTER, u32); 3296 3330 #else 3297 3331 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3302 3336 case AC97_PCM_Out_Volume_Mute: 3303 3337 #ifdef IN_RING3 3304 ichac97R3MixerSetVolume(pThis, offPort, PDMAUDIOMIXERCTL_FRONT, u32);3338 ichac97R3MixerSetVolume(pThis, pThisCC, offPort, PDMAUDIOMIXERCTL_FRONT, u32); 3305 3339 #else 3306 3340 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3309 3343 case AC97_Line_In_Volume_Mute: 3310 3344 #ifdef IN_RING3 3311 ichac97R3MixerSetVolume(pThis, offPort, PDMAUDIOMIXERCTL_LINE_IN, u32);3345 ichac97R3MixerSetVolume(pThis, pThisCC, offPort, PDMAUDIOMIXERCTL_LINE_IN, u32); 3312 3346 #else 3313 3347 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3325 3359 /* Newer Ubuntu guests rely on that when controlling gain and muting 3326 3360 * the recording (capturing) levels. */ 3327 ichac97R3MixerSetGain(pThis, offPort, PDMAUDIOMIXERCTL_LINE_IN, u32);3361 ichac97R3MixerSetGain(pThis, pThisCC, offPort, PDMAUDIOMIXERCTL_LINE_IN, u32); 3328 3362 #else 3329 3363 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3333 3367 #ifdef IN_RING3 3334 3368 /* Ditto; see note above. */ 3335 ichac97R3MixerSetGain(pThis, offPort, PDMAUDIOMIXERCTL_MIC_IN, u32);3369 ichac97R3MixerSetGain(pThis, pThisCC, offPort, PDMAUDIOMIXERCTL_MIC_IN, u32); 3336 3370 #else 3337 3371 rc = VINF_IOM_R3_IOPORT_WRITE; … … 3353 3387 { 3354 3388 ichac97MixerSet(pThis, AC97_PCM_Front_DAC_Rate, 0xbb80); /* Set default (48000 Hz). */ 3355 ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */); 3389 ichac97R3StreamReOpen(pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], 3390 &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */); 3356 3391 3357 3392 ichac97MixerSet(pThis, AC97_PCM_LR_ADC_Rate, 0xbb80); /* Set default (48000 Hz). */ 3358 ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */); 3393 ichac97R3StreamReOpen(pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], 3394 &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */); 3359 3395 } 3360 3396 else … … 3367 3403 { 3368 3404 ichac97MixerSet(pThis, AC97_MIC_ADC_Rate, 0xbb80); /* Set default (48000 Hz). */ 3369 ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */); 3405 ichac97R3StreamReOpen(pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], 3406 &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */); 3370 3407 } 3371 3408 else … … 3384 3421 LogRel2(("AC97: Setting front DAC rate to 0x%x\n", u32)); 3385 3422 ichac97MixerSet(pThis, offPort, u32); 3386 ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */); 3423 ichac97R3StreamReOpen(pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], 3424 &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */); 3387 3425 } 3388 3426 else … … 3398 3436 LogRel2(("AC97: Setting microphone ADC rate to 0x%x\n", u32)); 3399 3437 ichac97MixerSet(pThis, offPort, u32); 3400 ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */); 3438 ichac97R3StreamReOpen(pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], 3439 &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */); 3401 3440 } 3402 3441 else … … 3412 3451 LogRel2(("AC97: Setting line-in ADC rate to 0x%x\n", u32)); 3413 3452 ichac97MixerSet(pThis, offPort, u32); 3414 ichac97R3StreamReOpen(pThis, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */); 3453 ichac97R3StreamReOpen(pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], 3454 &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */); 3415 3455 } 3416 3456 else … … 3478 3518 static DECLCALLBACK(int) ichac97R3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 3479 3519 { 3480 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3481 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3520 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3521 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3522 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3482 3523 3483 3524 LogFlowFuncEnter(); … … 3499 3540 uint8_t active[AC97SOUNDSOURCE_END_INDEX]; 3500 3541 3501 active[AC97SOUNDSOURCE_PI_INDEX] = ichac97R3StreamIsEnabled(pThis , &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX]) ? 1 : 0;3502 active[AC97SOUNDSOURCE_PO_INDEX] = ichac97R3StreamIsEnabled(pThis , &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX]) ? 1 : 0;3503 active[AC97SOUNDSOURCE_MC_INDEX] = ichac97R3StreamIsEnabled(pThis , &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX]) ? 1 : 0;3542 active[AC97SOUNDSOURCE_PI_INDEX] = ichac97R3StreamIsEnabled(pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX]) ? 1 : 0; 3543 active[AC97SOUNDSOURCE_PO_INDEX] = ichac97R3StreamIsEnabled(pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX]) ? 1 : 0; 3544 active[AC97SOUNDSOURCE_MC_INDEX] = ichac97R3StreamIsEnabled(pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX]) ? 1 : 0; 3504 3545 3505 3546 pHlp->pfnSSMPutMem(pSSM, active, sizeof(active)); … … 3539 3580 static DECLCALLBACK(int) ichac97R3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 3540 3581 { 3541 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3542 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3582 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3583 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3584 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3543 3585 3544 3586 LogRel2(("ichac97LoadExec: uVersion=%RU32, uPass=0x%x\n", uVersion, uPass)); … … 3567 3609 3568 3610 ichac97R3MixerRecordSelect(pThis, ichac97MixerGet(pThis, AC97_Record_Select)); 3569 ichac97R3MixerSetVolume(pThis, AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER, ichac97MixerGet(pThis, AC97_Master_Volume_Mute)); 3570 ichac97R3MixerSetVolume(pThis, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT, ichac97MixerGet(pThis, AC97_PCM_Out_Volume_Mute)); 3571 ichac97R3MixerSetVolume(pThis, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, ichac97MixerGet(pThis, AC97_Line_In_Volume_Mute)); 3572 ichac97R3MixerSetVolume(pThis, AC97_Mic_Volume_Mute, PDMAUDIOMIXERCTL_MIC_IN, ichac97MixerGet(pThis, AC97_Mic_Volume_Mute)); 3573 ichac97R3MixerSetGain(pThis, AC97_Record_Gain_Mic_Mute, PDMAUDIOMIXERCTL_MIC_IN, ichac97MixerGet(pThis, AC97_Record_Gain_Mic_Mute)); 3574 ichac97R3MixerSetGain(pThis, AC97_Record_Gain_Mute, PDMAUDIOMIXERCTL_LINE_IN, ichac97MixerGet(pThis, AC97_Record_Gain_Mute)); 3611 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER, 3612 ichac97MixerGet(pThis, AC97_Master_Volume_Mute)); 3613 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_FRONT, 3614 ichac97MixerGet(pThis, AC97_PCM_Out_Volume_Mute)); 3615 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, 3616 ichac97MixerGet(pThis, AC97_Line_In_Volume_Mute)); 3617 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_Mic_Volume_Mute, PDMAUDIOMIXERCTL_MIC_IN, 3618 ichac97MixerGet(pThis, AC97_Mic_Volume_Mute)); 3619 ichac97R3MixerSetGain(pThis, pThisCC, AC97_Record_Gain_Mic_Mute, PDMAUDIOMIXERCTL_MIC_IN, 3620 ichac97MixerGet(pThis, AC97_Record_Gain_Mic_Mute)); 3621 ichac97R3MixerSetGain(pThis, pThisCC, AC97_Record_Gain_Mute, PDMAUDIOMIXERCTL_LINE_IN, 3622 ichac97MixerGet(pThis, AC97_Record_Gain_Mute)); 3575 3623 if (pThis->uCodecModel == AC97_CODEC_AD1980) 3576 3624 if (ichac97MixerGet(pThis, AC97_AD_Misc) & AC97_AD_MISC_HPSEL) 3577 ichac97R3MixerSetVolume(pThis, AC97_Headphone_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER,3625 ichac97R3MixerSetVolume(pThis, pThisCC, AC97_Headphone_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME_MASTER, 3578 3626 ichac97MixerGet(pThis, AC97_Headphone_Volume_Mute)); 3579 3627 … … 3581 3629 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++) 3582 3630 { 3583 const bool fEnable = RT_BOOL(uaStrmsActive[i]); 3584 const PAC97STREAM pStream = &pThis->aStreams[i]; 3585 3586 rc2 = ichac97R3StreamEnable(pThis, pStream, fEnable); 3631 const bool fEnable = RT_BOOL(uaStrmsActive[i]); 3632 const PAC97STREAM pStream = &pThis->aStreams[i]; 3633 const PAC97STREAMR3 pStreamCC = &pThisCC->aStreams[i]; 3634 3635 rc2 = ichac97R3StreamEnable(pThis, pThisCC, pStream, pStreamCC, fEnable); 3587 3636 AssertRC(rc2); 3588 3637 if ( fEnable … … 3590 3639 { 3591 3640 /* Re-arm the timer for this stream. */ 3592 ichac97R3TimerSet(pDevIns, pStream, pStream ->State.cTransferTicks);3641 ichac97R3TimerSet(pDevIns, pStream, pStreamCC->State.cTransferTicks); 3593 3642 } 3594 3643 … … 3608 3657 static DECLCALLBACK(void *) ichac97R3QueryInterface(struct PDMIBASE *pInterface, const char *pszIID) 3609 3658 { 3610 PAC97STATE pThis = RT_FROM_MEMBER(pInterface, AC97STATE, IBase); 3611 Assert(&pThis->IBase == pInterface); 3612 3613 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase); 3659 PAC97STATER3 pThisCC = RT_FROM_MEMBER(pInterface, AC97STATER3, IBase); 3660 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase); 3614 3661 return NULL; 3615 3662 } … … 3623 3670 static DECLCALLBACK(void) ichac97R3PowerOff(PPDMDEVINS pDevIns) 3624 3671 { 3625 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3672 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3673 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3626 3674 3627 3675 LogRel2(("AC97: Powering off ...\n")); … … 3629 3677 /* Note: Involves mixer stream / sink destruction, so also do this here 3630 3678 * instead of in ichac97R3Destruct(). */ 3631 ichac97R3StreamsDestroy(pThis );3632 3633 /* *3679 ichac97R3StreamsDestroy(pThis, pThisCC); 3680 3681 /* 3634 3682 * Note: Destroy the mixer while powering off and *not* in ichac97R3Destruct, 3635 3683 * giving the mixer the chance to release any references held to 3636 3684 * PDM audio streams it maintains. 3637 3685 */ 3638 if (pThis ->pMixer)3639 { 3640 AudioMixerDestroy(pThis ->pMixer);3641 pThis ->pMixer = NULL;3686 if (pThisCC->pMixer) 3687 { 3688 AudioMixerDestroy(pThisCC->pMixer); 3689 pThisCC->pMixer = NULL; 3642 3690 } 3643 3691 } … … 3652 3700 static DECLCALLBACK(void) ichac97R3Reset(PPDMDEVINS pDevIns) 3653 3701 { 3654 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3702 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3703 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3655 3704 3656 3705 LogRel(("AC97: Reset\n")); … … 3661 3710 * the codec manually. 3662 3711 */ 3663 ichac97R3MixerReset(pThis );3712 ichac97R3MixerReset(pThis, pThisCC); 3664 3713 3665 3714 /* … … 3668 3717 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++) 3669 3718 { 3670 ichac97R3StreamEnable(pThis, &pThis->aStreams[i], false /* fEnable */);3671 ichac97R3StreamReset(pThis, &pThis->aStreams[i] );3719 ichac97R3StreamEnable(pThis, pThisCC, &pThis->aStreams[i], &pThisCC->aStreams[i], false /* fEnable */); 3720 ichac97R3StreamReset(pThis, &pThis->aStreams[i], &pThisCC->aStreams[i]); 3672 3721 } 3673 3722 … … 3678 3727 * the mixer sink(s) might still have data to be processed when an audio stream gets reset. 3679 3728 */ 3680 AudioMixerSinkReset(pThis ->pSinkLineIn);3681 AudioMixerSinkReset(pThis ->pSinkMicIn);3682 AudioMixerSinkReset(pThis ->pSinkOut);3729 AudioMixerSinkReset(pThisCC->pSinkLineIn); 3730 AudioMixerSinkReset(pThisCC->pSinkMicIn); 3731 AudioMixerSinkReset(pThisCC->pSinkOut); 3683 3732 } 3684 3733 … … 3692 3741 * 3693 3742 * @returns VBox status code. 3694 * @param pThis AC'97 state. 3743 * @param pDevIns The device instance. 3744 * @param pThisCC The ring-3 AC'97 device state. 3695 3745 * @param iLun The logical unit which is being attached. 3696 3746 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 3697 3747 * @param ppDrv Attached driver instance on success. Optional. 3698 3748 */ 3699 static int ichac97R3AttachInternal(P AC97STATE pThis, unsigned iLun, uint32_t fFlags, PAC97DRIVER *ppDrv)3749 static int ichac97R3AttachInternal(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, unsigned iLun, uint32_t fFlags, PAC97DRIVER *ppDrv) 3700 3750 { 3701 3751 RT_NOREF(fFlags); … … 3709 3759 3710 3760 PPDMIBASE pDrvBase; 3711 int rc = PDMDevHlpDriverAttach(p This->pDevInsR3, iLun, &pThis->IBase, &pDrvBase, pszDesc);3761 int rc = PDMDevHlpDriverAttach(pDevIns, iLun, &pThisCC->IBase, &pDrvBase, pszDesc); 3712 3762 if (RT_SUCCESS(rc)) 3713 3763 { … … 3718 3768 pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pDrvBase, PDMIAUDIOCONNECTOR); 3719 3769 AssertMsg(pDrv->pConnector != NULL, ("Configuration error: LUN #%u has no host audio interface, rc=%Rrc\n", iLun, rc)); 3720 pDrv->pAC97State = pThis;3721 3770 pDrv->uLUN = iLun; 3722 3771 pDrv->pszDesc = pszDesc; … … 3734 3783 if (!pDrv->fAttached) 3735 3784 { 3736 RTListAppend(&pThis ->lstDrv, &pDrv->Node);3785 RTListAppend(&pThisCC->lstDrv, &pDrv->Node); 3737 3786 pDrv->fAttached = true; 3738 3787 } … … 3765 3814 * 3766 3815 * @returns VBox status code. 3767 * @param pThis AC'97state.3816 * @param pThisCC The ring-3 AC'97 device state. 3768 3817 * @param pDrv Driver to detach from device. 3769 3818 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 3770 3819 */ 3771 static int ichac97R3DetachInternal(PAC97STATE pThis, PAC97DRIVER pDrv, uint32_t fFlags)3820 static int ichac97R3DetachInternal(PAC97STATER3 pThisCC, PAC97DRIVER pDrv, uint32_t fFlags) 3772 3821 { 3773 3822 RT_NOREF(fFlags); … … 3775 3824 /* First, remove the driver from our list and destory it's associated streams. 3776 3825 * This also will un-set the driver as a recording source (if associated). */ 3777 ichac97R3MixerRemoveDrv(pThis , pDrv);3826 ichac97R3MixerRemoveDrv(pThisCC, pDrv); 3778 3827 3779 3828 /* Next, search backwards for a capable (attached) driver which now will be the … … 3781 3830 PDMAUDIODSTSRCUNION dstSrc; 3782 3831 PAC97DRIVER pDrvCur; 3783 RTListForEachReverse(&pThis ->lstDrv, pDrvCur, AC97DRIVER, Node)3832 RTListForEachReverse(&pThisCC->lstDrv, pDrvCur, AC97DRIVER, Node) 3784 3833 { 3785 3834 if (!pDrvCur->pConnector) … … 3792 3841 3793 3842 dstSrc.enmSrc = PDMAUDIORECSRC_MIC; 3794 PAC97DRIVERSTREAM pDrvStrm = ichac97R3MixerGetDrvStream(p This, pDrvCur, PDMAUDIODIR_IN, dstSrc);3843 PAC97DRIVERSTREAM pDrvStrm = ichac97R3MixerGetDrvStream(pDrvCur, PDMAUDIODIR_IN, dstSrc); 3795 3844 if ( pDrvStrm 3796 3845 && pDrvStrm->pMixStrm) 3797 3846 { 3798 rc2 = AudioMixerSinkSetRecordingSource(pThis ->pSinkMicIn, pDrvStrm->pMixStrm);3847 rc2 = AudioMixerSinkSetRecordingSource(pThisCC->pSinkMicIn, pDrvStrm->pMixStrm); 3799 3848 if (RT_SUCCESS(rc2)) 3800 3849 LogRel2(("AC97: Set new recording source for 'Mic In' to '%s'\n", Cfg.szName)); … … 3802 3851 3803 3852 dstSrc.enmSrc = PDMAUDIORECSRC_LINE; 3804 pDrvStrm = ichac97R3MixerGetDrvStream(p This, pDrvCur, PDMAUDIODIR_IN, dstSrc);3853 pDrvStrm = ichac97R3MixerGetDrvStream(pDrvCur, PDMAUDIODIR_IN, dstSrc); 3805 3854 if ( pDrvStrm 3806 3855 && pDrvStrm->pMixStrm) 3807 3856 { 3808 rc2 = AudioMixerSinkSetRecordingSource(pThis ->pSinkLineIn, pDrvStrm->pMixStrm);3857 rc2 = AudioMixerSinkSetRecordingSource(pThisCC->pSinkLineIn, pDrvStrm->pMixStrm); 3809 3858 if (RT_SUCCESS(rc2)) 3810 3859 LogRel2(("AC97: Set new recording source for 'Line In' to '%s'\n", Cfg.szName)); … … 3821 3870 static DECLCALLBACK(int) ichac97R3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 3822 3871 { 3823 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3872 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3873 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3824 3874 3825 3875 LogFunc(("iLUN=%u, fFlags=0x%x\n", iLUN, fFlags)); … … 3828 3878 3829 3879 PAC97DRIVER pDrv; 3830 int rc2 = ichac97R3AttachInternal(p This, iLUN, fFlags, &pDrv);3880 int rc2 = ichac97R3AttachInternal(pDevIns, pThisCC, iLUN, fFlags, &pDrv); 3831 3881 if (RT_SUCCESS(rc2)) 3832 rc2 = ichac97R3MixerAddDrv(pThis , pDrv);3882 rc2 = ichac97R3MixerAddDrv(pThisCC, pDrv); 3833 3883 3834 3884 if (RT_FAILURE(rc2)) … … 3845 3895 static DECLCALLBACK(void) ichac97R3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 3846 3896 { 3847 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3897 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3898 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3848 3899 3849 3900 LogFunc(("iLUN=%u, fFlags=0x%x\n", iLUN, fFlags)); … … 3852 3903 3853 3904 PAC97DRIVER pDrv, pDrvNext; 3854 RTListForEachSafe(&pThis ->lstDrv, pDrv, pDrvNext, AC97DRIVER, Node)3905 RTListForEachSafe(&pThisCC->lstDrv, pDrv, pDrvNext, AC97DRIVER, Node) 3855 3906 { 3856 3907 if (pDrv->uLUN == iLUN) 3857 3908 { 3858 int rc2 = ichac97R3DetachInternal(pThis , pDrv, fFlags);3909 int rc2 = ichac97R3DetachInternal(pThisCC, pDrv, fFlags); 3859 3910 if (RT_SUCCESS(rc2)) 3860 3911 { … … 3875 3926 * 3876 3927 * @returns VBox status code. 3877 * @param pThis Device instance. 3928 * @param pDevIns The device instance. 3929 * @param pThis The ring-3 AC'97 device state. 3878 3930 * @param iLun The logical unit which is being replaced. 3879 3931 */ 3880 static int ichac97R3ReconfigLunWithNullAudio(P AC97STATE pThis, unsigned iLun)3881 { 3882 int rc = PDMDevHlpDriverReconfigure2(p This->pDevInsR3, iLun, "AUDIO", "NullAudio");3932 static int ichac97R3ReconfigLunWithNullAudio(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, unsigned iLun) 3933 { 3934 int rc = PDMDevHlpDriverReconfigure2(pDevIns, iLun, "AUDIO", "NullAudio"); 3883 3935 if (RT_SUCCESS(rc)) 3884 rc = ichac97R3AttachInternal(p This, iLun, 0 /* fFlags */, NULL /* ppDrv */);3885 LogFunc(("pThis =%p, iLun=%u, rc=%Rrc\n", pThis, iLun, rc));3936 rc = ichac97R3AttachInternal(pDevIns, pThisCC, iLun, 0 /* fFlags */, NULL /* ppDrv */); 3937 LogFunc(("pThisCC=%p, iLun=%u, rc=%Rrc\n", pThisCC, iLun, rc)); 3886 3938 return rc; 3887 3939 } … … 3893 3945 { 3894 3946 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); /* this shall come first */ 3895 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE);3947 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3896 3948 3897 3949 LogFlowFuncEnter(); 3898 3950 3899 3951 PAC97DRIVER pDrv, pDrvNext; 3900 RTListForEachSafe(&pThis ->lstDrv, pDrv, pDrvNext, AC97DRIVER, Node)3952 RTListForEachSafe(&pThisCC->lstDrv, pDrv, pDrvNext, AC97DRIVER, Node) 3901 3953 { 3902 3954 RTListNodeRemove(&pDrv->Node); … … 3906 3958 3907 3959 /* Sanity. */ 3908 Assert(RTListIsEmpty(&pThis ->lstDrv));3960 Assert(RTListIsEmpty(&pThisCC->lstDrv)); 3909 3961 3910 3962 return VINF_SUCCESS; … … 3918 3970 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); /* this shall come first */ 3919 3971 PAC97STATE pThis = PDMDEVINS_2_DATA(pDevIns, PAC97STATE); 3972 PAC97STATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAC97STATER3); 3920 3973 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3921 3974 Assert(iInstance == 0); RT_NOREF(iInstance); … … 3924 3977 * Initialize data so we can run the destructor without scewing up. 3925 3978 */ 3926 pThis ->pDevInsR3= pDevIns;3927 pThis ->IBase.pfnQueryInterface = ichac97R3QueryInterface;3928 RTListInit(&pThis ->lstDrv);3979 pThisCC->pDevIns = pDevIns; 3980 pThisCC->IBase.pfnQueryInterface = ichac97R3QueryInterface; 3981 RTListInit(&pThisCC->lstDrv); 3929 3982 3930 3983 /* … … 3947 4000 LogRel(("AC97: Using custom device timer rate (%RU16Hz)\n", pThis->uTimerHz)); 3948 4001 3949 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "DebugEnabled", &pThis ->Dbg.fEnabled, false);4002 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "DebugEnabled", &pThisCC->Dbg.fEnabled, false); 3950 4003 if (RT_FAILURE(rc)) 3951 4004 return PDMDEV_SET_ERROR(pDevIns, rc, 3952 4005 N_("AC97 configuration error: failed to read debugging enabled flag as boolean")); 3953 4006 3954 rc = pHlp->pfnCFGMQueryStringDef(pCfg, "DebugPathOut", pThis ->Dbg.szOutPath, sizeof(pThis->Dbg.szOutPath),4007 rc = pHlp->pfnCFGMQueryStringDef(pCfg, "DebugPathOut", pThisCC->Dbg.szOutPath, sizeof(pThisCC->Dbg.szOutPath), 3955 4008 VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH); 3956 4009 if (RT_FAILURE(rc)) … … 3958 4011 N_("AC97 configuration error: failed to read debugging output path flag as string")); 3959 4012 3960 if (pThis ->Dbg.fEnabled)3961 LogRel2(("AC97: Debug output will be saved to '%s'\n", pThis ->Dbg.szOutPath));4013 if (pThisCC->Dbg.fEnabled) 4014 LogRel2(("AC97: Debug output will be saved to '%s'\n", pThisCC->Dbg.szOutPath)); 3962 4015 3963 4016 /* … … 4062 4115 AssertBreak(iLun < UINT8_MAX); 4063 4116 LogFunc(("Trying to attach driver for LUN#%u ...\n", iLun)); 4064 rc = ichac97R3AttachInternal(p This, iLun, 0 /* fFlags */, NULL /* ppDrv */);4117 rc = ichac97R3AttachInternal(pDevIns, pThisCC, iLun, 0 /* fFlags */, NULL /* ppDrv */); 4065 4118 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 4066 4119 { … … 4070 4123 if (rc == VERR_AUDIO_BACKEND_INIT_FAILED) 4071 4124 { 4072 ichac97R3ReconfigLunWithNullAudio(p This, iLun); /* Pretend attaching to the NULL audio backend will never fail. */4125 ichac97R3ReconfigLunWithNullAudio(pDevIns, pThisCC, iLun); /* Pretend attaching to the NULL audio backend will never fail. */ 4073 4126 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 4074 4127 N_("Host audio backend initialization has failed. " … … 4079 4132 } 4080 4133 4081 rc = AudioMixerCreate("AC'97 Mixer", 0 /* uFlags */, &pThis ->pMixer);4134 rc = AudioMixerCreate("AC'97 Mixer", 0 /* uFlags */, &pThisCC->pMixer); 4082 4135 AssertRCReturn(rc, rc); 4083 rc = AudioMixerCreateSink(pThis ->pMixer, "[Recording] Line In", AUDMIXSINKDIR_INPUT, &pThis->pSinkLineIn);4136 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Recording] Line In", AUDMIXSINKDIR_INPUT, &pThisCC->pSinkLineIn); 4084 4137 AssertRCReturn(rc, rc); 4085 rc = AudioMixerCreateSink(pThis ->pMixer, "[Recording] Microphone In", AUDMIXSINKDIR_INPUT, &pThis->pSinkMicIn);4138 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Recording] Microphone In", AUDMIXSINKDIR_INPUT, &pThisCC->pSinkMicIn); 4086 4139 AssertRCReturn(rc, rc); 4087 rc = AudioMixerCreateSink(pThis ->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOut);4140 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThisCC->pSinkOut); 4088 4141 AssertRCReturn(rc, rc); 4089 4142 … … 4094 4147 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++) 4095 4148 { 4096 rc = ichac97R3StreamCreate(pThis , &pThis->aStreams[i], i /* SD# */);4149 rc = ichac97R3StreamCreate(pThisCC, &pThis->aStreams[i], &pThisCC->aStreams[i], i /* SD# */); 4097 4150 AssertRCReturn(rc, rc); 4098 4151 } … … 4123 4176 # ifdef VBOX_WITH_AUDIO_AC97_ONETIME_INIT 4124 4177 PAC97DRIVER pDrv; 4125 RTListForEach(&pThis ->lstDrv, pDrv, AC97DRIVER, Node)4178 RTListForEach(&pThisCC->lstDrv, pDrv, AC97DRIVER, Node) 4126 4179 { 4127 4180 /* … … 4145 4198 LogRel(("AC97: Falling back to NULL backend (no sound audible)\n")); 4146 4199 ichac97R3Reset(pDevIns); 4147 ichac97R3ReconfigLunWithNullAudio(p This, iLun);4200 ichac97R3ReconfigLunWithNullAudio(pdEvIns, pThsiCC, iLun); 4148 4201 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 4149 4202 N_("No audio devices could be opened. " … … 4269 4322 /* .uSharedVersion = */ 42, 4270 4323 /* .cbInstanceShared = */ sizeof(AC97STATE), 4271 /* .cbInstanceCC = */ 0,4324 /* .cbInstanceCC = */ CTX_EXPR(sizeof(AC97STATER3), 0, 0), 4272 4325 /* .cbInstanceRC = */ 0, 4273 4326 /* .cMaxPciDevices = */ 1,
Note:
See TracChangeset
for help on using the changeset viewer.