Changeset 76157 in vbox for trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
- Timestamp:
- Dec 11, 2018 10:27:25 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r75975 r76157 1908 1908 int rc = VINF_SUCCESS; 1909 1909 1910 LogFunc(("[SD%RU8]\n", pStream->u8SD)); 1911 1912 RT_ZERO(pStream->State.Cfg); 1913 1914 PPDMAUDIOSTREAMCFG pCfg = &pStream->State.Cfg; 1915 PAUDMIXSINK pMixSink = NULL; 1916 AssertCompile(sizeof(pCfg->szName) >= 8); 1910 PDMAUDIOSTREAMCFG Cfg; 1911 RT_ZERO(Cfg); 1912 1913 PAUDMIXSINK pMixSink = NULL; 1917 1914 1918 1915 /* Set scheduling hint (if available). */ 1919 1916 if (pThis->uTimerHz) 1920 pCfg->Device.uSchedulingHintMs = 1000 /* ms */ / pThis->uTimerHz; 1917 Cfg.Device.uSchedulingHintMs = 1000 /* ms */ / pThis->uTimerHz; 1918 1919 Cfg.Props.cChannels = 2; 1920 Cfg.Props.cBytes = 2 /* 16-bit */; 1921 Cfg.Props.fSigned = true; 1922 Cfg.Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(Cfg.Props.cBytes, Cfg.Props.cChannels); 1921 1923 1922 1924 switch (pStream->u8SD) … … 1924 1926 case AC97SOUNDSOURCE_PI_INDEX: 1925 1927 { 1926 pCfg->Props.uHz = ichac97MixerGet(pThis, AC97_PCM_LR_ADC_Rate);1927 pCfg->enmDir = PDMAUDIODIR_IN;1928 pCfg->DestSource.Source = PDMAUDIORECSOURCE_LINE;1929 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;1930 strcpy(pCfg->szName, "Line-In");1931 1932 pMixSink 1928 Cfg.Props.uHz = ichac97MixerGet(pThis, AC97_PCM_LR_ADC_Rate); 1929 Cfg.enmDir = PDMAUDIODIR_IN; 1930 Cfg.DestSource.Source = PDMAUDIORECSOURCE_LINE; 1931 Cfg.enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 1932 RTStrCopy(Cfg.szName, sizeof(Cfg.szName), "Line-In"); 1933 1934 pMixSink = pThis->pSinkLineIn; 1933 1935 break; 1934 1936 } … … 1936 1938 case AC97SOUNDSOURCE_MC_INDEX: 1937 1939 { 1938 pCfg->Props.uHz = ichac97MixerGet(pThis, AC97_MIC_ADC_Rate);1939 pCfg->enmDir = PDMAUDIODIR_IN;1940 pCfg->DestSource.Source = PDMAUDIORECSOURCE_MIC;1941 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;1942 strcpy(pCfg->szName, "Mic-In");1943 1944 pMixSink 1940 Cfg.Props.uHz = ichac97MixerGet(pThis, AC97_MIC_ADC_Rate); 1941 Cfg.enmDir = PDMAUDIODIR_IN; 1942 Cfg.DestSource.Source = PDMAUDIORECSOURCE_MIC; 1943 Cfg.enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 1944 RTStrCopy(Cfg.szName, sizeof(Cfg.szName), "Mic-In"); 1945 1946 pMixSink = pThis->pSinkMicIn; 1945 1947 break; 1946 1948 } … … 1948 1950 case AC97SOUNDSOURCE_PO_INDEX: 1949 1951 { 1950 pCfg->Props.uHz = ichac97MixerGet(pThis, AC97_PCM_Front_DAC_Rate);1951 pCfg->enmDir = PDMAUDIODIR_OUT;1952 pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;1953 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;1954 strcpy(pCfg->szName, "Output");1955 1956 pMixSink 1952 Cfg.Props.uHz = ichac97MixerGet(pThis, AC97_PCM_Front_DAC_Rate); 1953 Cfg.enmDir = PDMAUDIODIR_OUT; 1954 Cfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT; 1955 Cfg.enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 1956 RTStrCopy(Cfg.szName, sizeof(Cfg.szName), "Output"); 1957 1958 pMixSink = pThis->pSinkOut; 1957 1959 break; 1958 1960 } … … 1965 1967 if (RT_SUCCESS(rc)) 1966 1968 { 1967 ichac97R3MixerRemoveDrvStreams(pThis, pMixSink, pCfg->enmDir, pCfg->DestSource); 1968 1969 if (pCfg->Props.uHz) 1970 { 1971 Assert(pCfg->enmDir != PDMAUDIODIR_UNKNOWN); 1972 1973 pCfg->Props.cChannels = 2; 1974 pCfg->Props.cBytes = 2 /* 16-bit */; 1975 pCfg->Props.fSigned = true; 1976 pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBytes, pCfg->Props.cChannels); 1977 1978 if (pStream->State.pCircBuf) 1969 /* Only (re-)create the stream (and driver chain) if we really have to. 1970 * Otherwise avoid this and just reuse it, as this costs performance. */ 1971 if (!DrvAudioHlpPCMPropsAreEqual(&Cfg.Props, &pStream->State.Cfg.Props)) 1972 { 1973 LogFlowFunc(("[SD%RU8] uHz=%RU32\n", pStream->u8SD, Cfg.Props.uHz)); 1974 1975 if (Cfg.Props.uHz) 1979 1976 { 1980 RTCircBufDestroy(pStream->State.pCircBuf); 1981 pStream->State.pCircBuf = NULL; 1977 Assert(Cfg.enmDir != PDMAUDIODIR_UNKNOWN); 1978 1979 if (pStream->State.pCircBuf) 1980 { 1981 RTCircBufDestroy(pStream->State.pCircBuf); 1982 pStream->State.pCircBuf = NULL; 1983 } 1984 1985 rc = RTCircBufCreate(&pStream->State.pCircBuf, DrvAudioHlpMilliToBytes(500 /* ms */, &Cfg.Props)); /** @todo Make this configurable. */ 1986 if (RT_SUCCESS(rc)) 1987 { 1988 ichac97R3MixerRemoveDrvStreams(pThis, pMixSink, Cfg.enmDir, Cfg.DestSource); 1989 1990 rc = ichac97R3MixerAddDrvStreams(pThis, pMixSink, &Cfg); 1991 if (RT_SUCCESS(rc)) 1992 rc = DrvAudioHlpStreamCfgCopy(&pStream->State.Cfg, &Cfg); 1993 } 1982 1994 } 1983 1984 rc = RTCircBufCreate(&pStream->State.pCircBuf, DrvAudioHlpMilliToBytes(500 /* ms */, &pCfg->Props)); /** @todo Make this configurable. */ 1985 if (RT_SUCCESS(rc)) 1986 rc = ichac97R3MixerAddDrvStreams(pThis, pMixSink, pCfg); 1987 } 1995 } 1996 else 1997 LogFlowFunc(("[SD%RU8] Skipping (re-)creation\n", pStream->u8SD)); 1988 1998 } 1989 1999
Note:
See TracChangeset
for help on using the changeset viewer.