- Timestamp:
- Feb 8, 2018 10:30:58 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120733
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r70894 r70905 272 272 */ 273 273 #ifdef IN_RING3 274 static int hdaAddStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg); 275 static int hdaRemoveStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg); 274 276 # ifdef HDA_USE_DMA_ACCESS_HANDLER 275 277 static DECLCALLBACK(VBOXSTRICTRC) hdaDMAAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser); … … 1400 1402 hdaStreamLock(pStream); 1401 1403 1404 int rc2; 1405 1402 1406 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 1407 if (fRun) 1408 rc2 = hdaStreamAsyncIOCreate(pStream); 1409 1403 1410 hdaStreamAsyncIOLock(pStream); 1404 hdaStreamAsyncIOEnable(pStream, fRun /* fEnable */);1405 1411 # endif 1406 /* (Re-)initialize the stream with current values. */ 1407 int rc2 = hdaStreamInit(pStream, pStream->u8SD); 1408 AssertRC(rc2); 1412 if (fRun) 1413 { 1414 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 1415 hdaStreamAsyncIOEnable(pStream, fRun /* fEnable */); 1416 # endif 1417 /* (Re-)initialize the stream with current values. */ 1418 rc2 = hdaStreamInit(pStream, pStream->u8SD); 1419 AssertRC(rc2); 1420 1421 /* Remove the old stream from the device setup. */ 1422 hdaRemoveStream(pThis, &pStream->State.Cfg); 1423 1424 /* Add the stream to the device setup. */ 1425 rc2 = hdaAddStream(pThis, &pStream->State.Cfg); 1426 AssertRC(rc2); 1427 } 1409 1428 1410 1429 /* Enable/disable the stream. */ … … 1857 1876 pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); 1858 1877 1859 rc = hdaCodecRemoveStream(pThis->pCodec, PDMAUDIOMIXERCTL_FRONT); 1860 if (RT_SUCCESS(rc)) 1861 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_FRONT, pCfg); 1878 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_FRONT, pCfg); 1862 1879 } 1863 1880 … … 1874 1891 pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); 1875 1892 1876 rc = hdaCodecRemoveStream(pThis->pCodec, PDMAUDIOMIXERCTL_CENTER_LFE); 1877 if (RT_SUCCESS(rc)) 1878 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_CENTER_LFE, pCfg); 1893 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_CENTER_LFE, pCfg); 1879 1894 } 1880 1895 … … 1890 1905 pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); 1891 1906 1892 rc = hdaCodecRemoveStream(pThis->pCodec, PDMAUDIOMIXERCTL_REAR); 1893 if (RT_SUCCESS(rc)) 1894 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_REAR, pCfg); 1907 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_REAR, pCfg); 1895 1908 } 1896 1909 #endif /* VBOX_WITH_AUDIO_HDA_51_SURROUND */ … … 1924 1937 case PDMAUDIORECSOURCE_LINE: 1925 1938 { 1926 rc = hdaCodecRemoveStream(pThis->pCodec, PDMAUDIOMIXERCTL_LINE_IN); 1927 if (RT_SUCCESS(rc)) 1928 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_LINE_IN, pCfg); 1939 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_LINE_IN, pCfg); 1929 1940 break; 1930 1941 } … … 1932 1943 case PDMAUDIORECSOURCE_MIC: 1933 1944 { 1934 rc = hdaCodecRemoveStream(pThis->pCodec, PDMAUDIOMIXERCTL_MIC_IN); 1935 if (RT_SUCCESS(rc)) 1936 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_MIC_IN, pCfg); 1945 rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_MIC_IN, pCfg); 1937 1946 break; 1938 1947 } … … 1981 1990 LogFlowFunc(("Returning %Rrc\n", rc)); 1982 1991 1992 return rc; 1993 } 1994 1995 /** 1996 * Removes an audio stream from the device setup using the given configuration. 1997 * 1998 * @returns IPRT status code. 1999 * @param pThis Device state. 2000 * @param pCfg Stream configuration to use for removing a stream. 2001 */ 2002 static int hdaRemoveStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) 2003 { 2004 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 2005 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 2006 2007 int rc = VINF_SUCCESS; 2008 2009 PDMAUDIOMIXERCTL enmMixerCtl = PDMAUDIOMIXERCTL_UNKNOWN; 2010 switch (pCfg->enmDir) 2011 { 2012 case PDMAUDIODIR_IN: 2013 { 2014 LogFlowFunc(("Stream=%s, Source=%ld\n", pCfg->szName, pCfg->DestSource.Source)); 2015 2016 switch (pCfg->DestSource.Source) 2017 { 2018 case PDMAUDIORECSOURCE_LINE: enmMixerCtl = PDMAUDIOMIXERCTL_LINE_IN; break; 2019 #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 2020 case PDMAUDIORECSOURCE_MIC: enmMixerCtl = PDMAUDIOMIXERCTL_MIC_IN; break; 2021 #endif 2022 default: 2023 rc = VERR_NOT_SUPPORTED; 2024 break; 2025 } 2026 2027 break; 2028 } 2029 2030 case PDMAUDIODIR_OUT: 2031 { 2032 LogFlowFunc(("Stream=%s, Source=%ld\n", pCfg->szName, pCfg->DestSource.Dest)); 2033 2034 switch (pCfg->DestSource.Dest) 2035 { 2036 case PDMAUDIOPLAYBACKDEST_FRONT: enmMixerCtl = PDMAUDIOMIXERCTL_FRONT; break; 2037 #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 2038 case PDMAUDIOPLAYBACKDEST_CENTER_LFE: enmMixerCtl = PDMAUDIOMIXERCTL_CENTER_LFE; break; 2039 case PDMAUDIOPLAYBACKDEST_REAR: enmMixerCtl = PDMAUDIOMIXERCTL_REAR; break; 2040 #endif 2041 default: 2042 rc = VERR_NOT_SUPPORTED; 2043 break; 2044 } 2045 break; 2046 } 2047 2048 default: 2049 rc = VERR_NOT_SUPPORTED; 2050 break; 2051 } 2052 2053 if (RT_SUCCESS(rc)) 2054 rc = hdaCodecRemoveStream(pThis->pCodec, enmMixerCtl); 2055 2056 LogFlowFuncLeaveRC(rc); 1983 2057 return rc; 1984 2058 } … … 2007 2081 int rc = hdaRegWriteU16(pThis, iReg, u32Value); 2008 2082 AssertRC(rc); 2009 2010 rc = hdaStreamInit(pStream, pStream->u8SD);2011 if (RT_SUCCESS(rc))2012 {2013 /* Add the stream to the device setup. */2014 rc = hdaAddStream(pThis, &pStream->State.Cfg);2015 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2016 if (RT_SUCCESS(rc))2017 rc = hdaStreamAsyncIOCreate(pStream);2018 # endif2019 }2020 2083 2021 2084 DEVHDA_UNLOCK(pThis); -
trunk/src/VBox/Devices/Audio/HDACodec.cpp
r70249 r70905 3284 3284 pThis->paNodes[STAC9220_NID_AFG].afg.u32F20_param = CODEC_MAKE_F20(pThis->u16VendorId, pThis->u8BSKU, pThis->u8AssemblyId); 3285 3285 3286 do3287 {3288 /* Initialize the streams to some default values (44.1 kHz, 16-bit signed, 2 channels).3289 * The codec's (fixed) delivery rate is 48kHz, so a frame will be delivered every 20.83us. */3290 PDMAUDIOSTREAMCFG strmCfg;3291 RT_ZERO(strmCfg);3292 3293 /* Note: Adding the default input/output streams is *not* critical for the overall3294 * codec construction result. */3295 3296 /*3297 * Output streams.3298 */3299 strmCfg.enmDir = PDMAUDIODIR_OUT;3300 strmCfg.enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;3301 3302 strmCfg.Props.cBits = 16;3303 strmCfg.Props.fSigned = true;3304 strmCfg.Props.cChannels = 2;3305 strmCfg.Props.uHz = 44100;3306 strmCfg.Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(strmCfg.Props.cBits, strmCfg.Props.cChannels);3307 3308 /* Front. */3309 RTStrPrintf(strmCfg.szName, RT_ELEMENTS(strmCfg.szName), "Front");3310 strmCfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;3311 int rc2 = hdaCodecAddStream(pThis, PDMAUDIOMIXERCTL_FRONT, &strmCfg);3312 if (RT_FAILURE(rc2))3313 LogRel2(("HDA: Failed to add front output stream: %Rrc\n", rc2));3314 3315 #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND3316 /* Center / LFE. */3317 RTStrPrintf(strmCfg.szName, RT_ELEMENTS(strmCfg.szName), "Center / LFE");3318 strmCfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_CENTER_LFE;3319 /** @todo Handle mono channel if only center *or* LFE is available? */3320 rc2 = hdaCodecAddStream(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, &strmCfg);3321 if (RT_FAILURE(rc2))3322 LogRel2(("HDA: Failed to add center/LFE output stream: %Rrc\n", rc2));3323 3324 /* Rear. */3325 RTStrPrintf(strmCfg.szName, RT_ELEMENTS(strmCfg.szName), "Rear");3326 strmCfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_REAR;3327 rc2 = hdaCodecAddStream(pThis, PDMAUDIOMIXERCTL_REAR, &strmCfg);3328 if (RT_FAILURE(rc2))3329 LogRel2(("HDA: Failed to add rear output stream: %Rrc\n", rc2));3330 #endif3331 3332 /*3333 * Input streams.3334 */3335 RT_ZERO(strmCfg);3336 3337 strmCfg.enmDir = PDMAUDIODIR_IN;3338 strmCfg.enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;3339 3340 strmCfg.Props.cBits = 16;3341 strmCfg.Props.fSigned = true;3342 strmCfg.Props.cChannels = 2;3343 strmCfg.Props.uHz = 44100;3344 strmCfg.Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(strmCfg.Props.cBits, strmCfg.Props.cChannels);3345 3346 #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN3347 RTStrPrintf(strmCfg.szName, RT_ELEMENTS(strmCfg.szName), "Microphone In");3348 strmCfg.DestSource.Source = PDMAUDIORECSOURCE_MIC;3349 rc2 = hdaCodecAddStream(pThis, PDMAUDIOMIXERCTL_MIC_IN, &strmCfg);3350 if (RT_FAILURE(rc2))3351 LogRel2(("HDA: Failed to add microphone input stream: %Rrc\n", rc2));3352 #endif3353 RTStrPrintf(strmCfg.szName, RT_ELEMENTS(strmCfg.szName), "Line In");3354 strmCfg.DestSource.Source = PDMAUDIORECSOURCE_LINE;3355 rc2 = hdaCodecAddStream(pThis, PDMAUDIOMIXERCTL_LINE_IN, &strmCfg);3356 if (RT_FAILURE(rc2))3357 LogRel2(("HDA: Failed to add line input stream: %Rrc\n", rc2));3358 3359 } while (0);3360 3361 3286 /* 3362 3287 * Set initial volume.
Note:
See TracChangeset
for help on using the changeset viewer.