Changeset 74059 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Sep 4, 2018 9:22:25 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r74038 r74059 396 396 typedef struct AC97DRIVERSTREAM 397 397 { 398 union399 {400 /** Desired playback destination (for an output stream). */401 PDMAUDIOPLAYBACKDEST Dest;402 /** Desired recording source (for an input stream). */403 PDMAUDIORECSOURCE Source;404 } DestSource;405 uint8_t Padding1[4];406 398 /** Associated mixer stream handle. */ 407 399 R3PTRTYPE(PAUDMIXSTREAM) pMixStrm; … … 654 646 static void ichac97R3DoTransfers(PAC97STATE pThis); 655 647 648 static int ichac97R3MixerAddDrv(PAC97STATE pThis, PAC97DRIVER pDrv); 656 649 static int ichac97R3MixerAddDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv); 657 650 static int ichac97R3MixerAddDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg); 651 static void ichac97R3MixerRemoveDrv(PAC97STATE pThis, PAC97DRIVER pDrv); 658 652 static void ichac97R3MixerRemoveDrvStream(PAC97STATE pThis, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc, PAC97DRIVER pDrv); 659 653 static void ichac97R3MixerRemoveDrvStreams(PAC97STATE pThis, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODESTSOURCE dstSrc); … … 1781 1775 LogFlowFuncLeaveRC(rc); 1782 1776 return rc; 1777 } 1778 1779 /** 1780 * Adds a specific AC'97 driver to the driver chain. 1781 * 1782 * @return IPRT status code. 1783 * @param pThis AC'97 state. 1784 * @param pDrv AC'97 driver to add. 1785 */ 1786 static int ichac97R3MixerAddDrv(PAC97STATE pThis, PAC97DRIVER pDrv) 1787 { 1788 int rc = VINF_SUCCESS; 1789 1790 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamLineIn.State.Cfg)) 1791 { 1792 int rc2 = ichac97R3MixerAddDrvStream(pThis, pThis->pSinkLineIn, &pThis->StreamLineIn.State.Cfg, pDrv); 1793 if (RT_SUCCESS(rc)) 1794 rc = rc2; 1795 } 1796 1797 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamMicIn.State.Cfg)) 1798 { 1799 int rc2 = ichac97R3MixerAddDrvStream(pThis, pThis->pSinkMicIn, &pThis->StreamMicIn.State.Cfg, pDrv); 1800 if (RT_SUCCESS(rc)) 1801 rc = rc2; 1802 } 1803 1804 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamOut.State.Cfg)) 1805 { 1806 int rc2 = ichac97R3MixerAddDrvStream(pThis, pThis->pSinkOut, &pThis->StreamOut.State.Cfg, pDrv); 1807 if (RT_SUCCESS(rc)) 1808 rc = rc2; 1809 } 1810 1811 return rc; 1812 } 1813 1814 /** 1815 * Removes a specific AC'97 driver from the driver chain and destroys its 1816 * associated streams. 1817 * 1818 * @param pThis AC'97 state. 1819 * @param pDrv AC'97 driver to remove. 1820 */ 1821 static void ichac97R3MixerRemoveDrv(PAC97STATE pThis, PAC97DRIVER pDrv) 1822 { 1823 AssertPtrReturnVoid(pThis); 1824 AssertPtrReturnVoid(pDrv); 1825 1826 if (pDrv->MicIn.pMixStrm) 1827 { 1828 if (AudioMixerSinkGetRecordingSource(pThis->pSinkMicIn) == pDrv->MicIn.pMixStrm) 1829 AudioMixerSinkSetRecordingSource(pThis->pSinkMicIn, NULL); 1830 1831 AudioMixerSinkRemoveStream(pThis->pSinkMicIn, pDrv->MicIn.pMixStrm); 1832 AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm); 1833 pDrv->MicIn.pMixStrm = NULL; 1834 } 1835 1836 if (pDrv->LineIn.pMixStrm) 1837 { 1838 if (AudioMixerSinkGetRecordingSource(pThis->pSinkLineIn) == pDrv->LineIn.pMixStrm) 1839 AudioMixerSinkSetRecordingSource(pThis->pSinkLineIn, NULL); 1840 1841 AudioMixerSinkRemoveStream(pThis->pSinkLineIn, pDrv->LineIn.pMixStrm); 1842 AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm); 1843 pDrv->LineIn.pMixStrm = NULL; 1844 } 1845 1846 if (pDrv->Out.pMixStrm) 1847 { 1848 AudioMixerSinkRemoveStream(pThis->pSinkOut, pDrv->Out.pMixStrm); 1849 AudioMixerStreamDestroy(pDrv->Out.pMixStrm); 1850 pDrv->Out.pMixStrm = NULL; 1851 } 1852 1853 RTListNodeRemove(&pDrv->Node); 1783 1854 } 1784 1855 … … 3693 3764 * @returns VBox status code. 3694 3765 * @param pThis AC'97 state. 3695 * @param uLUN The logical unit which is being detached.3766 * @param uLUN The logical unit which is being attached. 3696 3767 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 3697 3768 * @param ppDrv Attached driver instance on success. Optional. … … 3766 3837 * @returns VBox status code. 3767 3838 * @param pThis AC'97 state. 3768 * @param pDrv Driver to detach device from.3839 * @param pDrv Driver to detach from device. 3769 3840 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 3770 3841 */ … … 3773 3844 RT_NOREF(fFlags); 3774 3845 3775 AudioMixerSinkRemoveStream(pThis->pSinkMicIn, pDrv->MicIn.pMixStrm); 3776 AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm); 3777 pDrv->MicIn.pMixStrm = NULL; 3778 3779 AudioMixerSinkRemoveStream(pThis->pSinkLineIn, pDrv->LineIn.pMixStrm); 3780 AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm); 3781 pDrv->LineIn.pMixStrm = NULL; 3782 3783 AudioMixerSinkRemoveStream(pThis->pSinkOut, pDrv->Out.pMixStrm); 3784 AudioMixerStreamDestroy(pDrv->Out.pMixStrm); 3785 pDrv->Out.pMixStrm = NULL; 3786 3787 RTListNodeRemove(&pDrv->Node); 3846 /* First, remove the driver from our list and destory it's associated streams. 3847 * This also will un-set the driver as a recording source (if associated). */ 3848 ichac97R3MixerRemoveDrv(pThis, pDrv); 3849 3850 /* Next, search backwards for a capable (attached) driver which now will be the 3851 * new recording source. */ 3852 PDMAUDIODESTSOURCE dstSrc; 3853 PAC97DRIVER pDrvCur; 3854 RTListForEachReverse(&pThis->lstDrv, pDrvCur, AC97DRIVER, Node) 3855 { 3856 if (!pDrvCur->pConnector) 3857 continue; 3858 3859 PDMAUDIOBACKENDCFG Cfg; 3860 int rc2 = pDrvCur->pConnector->pfnGetConfig(pDrvCur->pConnector, &Cfg); 3861 if (RT_FAILURE(rc2)) 3862 continue; 3863 3864 dstSrc.Source = PDMAUDIORECSOURCE_MIC; 3865 PAC97DRIVERSTREAM pDrvStrm = ichac97R3MixerGetDrvStream(pThis, pDrvCur, PDMAUDIODIR_IN, dstSrc); 3866 if ( pDrvStrm 3867 && pDrvStrm->pMixStrm) 3868 { 3869 rc2 = AudioMixerSinkSetRecordingSource(pThis->pSinkMicIn, pDrvStrm->pMixStrm); 3870 if (RT_SUCCESS(rc2)) 3871 LogRel2(("AC97: Set recording source for 'Mic In' to '%s'\n", Cfg.szName)); 3872 } 3873 3874 dstSrc.Source = PDMAUDIORECSOURCE_LINE; 3875 pDrvStrm = ichac97R3MixerGetDrvStream(pThis, pDrvCur, PDMAUDIODIR_IN, dstSrc); 3876 if ( pDrvStrm 3877 && pDrvStrm->pMixStrm) 3878 { 3879 rc2 = AudioMixerSinkSetRecordingSource(pThis->pSinkLineIn, pDrvStrm->pMixStrm); 3880 if (RT_SUCCESS(rc2)) 3881 LogRel2(("AC97: Set recording source for 'Line In' to '%s'\n", Cfg.szName)); 3882 } 3883 } 3788 3884 3789 3885 LogFunc(("uLUN=%u, fFlags=0x%x\n", pDrv->uLUN, fFlags)); … … 3805 3901 int rc2 = ichac97R3AttachInternal(pThis, uLUN, fFlags, &pDrv); 3806 3902 if (RT_SUCCESS(rc2)) 3807 { 3808 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamLineIn.State.Cfg)) 3809 ichac97R3MixerAddDrvStream(pThis, pThis->pSinkLineIn, &pThis->StreamLineIn.State.Cfg, pDrv); 3810 3811 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamMicIn.State.Cfg)) 3812 ichac97R3MixerAddDrvStream(pThis, pThis->pSinkMicIn, &pThis->StreamMicIn.State.Cfg, pDrv); 3813 3814 if (DrvAudioHlpStreamCfgIsValid(&pThis->StreamOut.State.Cfg)) 3815 ichac97R3MixerAddDrvStream(pThis, pThis->pSinkOut, &pThis->StreamOut.State.Cfg, pDrv); 3816 } 3903 rc2 = ichac97R3MixerAddDrv(pThis, pDrv); 3904 3905 if (RT_FAILURE(rc2)) 3906 LogFunc(("Failed with %Rrc\n", rc2)); 3817 3907 3818 3908 DEVAC97_UNLOCK(pThis);
Note:
See TracChangeset
for help on using the changeset viewer.