- Timestamp:
- Mar 19, 2021 5:47:14 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143375
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
r88028 r88210 103 103 { 104 104 /** Pointer to the driver instance structure. */ 105 PPDMDRVINS pDrvIns;105 PPDMDRVINS pDrvIns; 106 106 /** Pointer to host audio interface. */ 107 PDMIHOSTAUDIO IHostAudio;107 PDMIHOSTAUDIO IHostAudio; 108 108 /** Error count for not flooding the release log. 109 109 * UINT32_MAX for unlimited logging. */ 110 uint32_t cLogErrors; 110 uint32_t cLogErrors; 111 /** Default input device name. */ 112 char szDefaultIn[256]; 113 /** Default output device name. */ 114 char szDefaultOut[256]; 111 115 } DRVHOSTALSAAUDIO, *PDRVHOSTALSAAUDIO; 112 116 … … 362 366 * 363 367 * @returns VBox status code. 364 * @param fIn Whether this is an input stream to create or not. 365 * @param pCfgReq Requested configuration to create stream with. 366 * @param pCfgObt Obtained configuration the stream got created on success. 367 * @param pphPCM Where to store the ALSA stream handle on success. 368 */ 369 static int alsaStreamOpen(bool fIn, PALSAAUDIOSTREAMCFG pCfgReq, PALSAAUDIOSTREAMCFG pCfgObt, snd_pcm_t **pphPCM) 368 * @param pszDev The name of the device to open. 369 * @param fIn Whether this is an input stream to create or not. 370 * @param pCfgReq Requested configuration to create stream with. 371 * @param pCfgObt Obtained configuration the stream got created on success. 372 * @param pphPCM Where to store the ALSA stream handle on success. 373 */ 374 static int alsaStreamOpen(const char *pszDev, bool fIn, PALSAAUDIOSTREAMCFG pCfgReq, 375 PALSAAUDIOSTREAMCFG pCfgObt, snd_pcm_t **pphPCM) 370 376 { 371 377 snd_pcm_t *phPCM = NULL; … … 379 385 do 380 386 { 381 const char *pszDev = "default"; /** @todo Make this configurable through PALSAAUDIOSTREAMCFG. */ 382 if (!pszDev) 383 { 384 LogRel(("ALSA: Invalid or no %s device name set\n", fIn ? "input" : "output")); 385 rc = VERR_INVALID_PARAMETER; 386 break; 387 } 387 AssertLogRelMsgReturn(pszDev && *pszDev, 388 ("ALSA: Invalid or no %s device name set\n", fIn ? "input" : "output"), 389 VERR_INVALID_NAME); 388 390 389 391 LogRel(("ALSA: Using %s device \"%s\"\n", fIn ? "input" : "output", pszDev)); … … 964 966 * 965 967 * @returns VBox status code. 966 * @param pStreamALSA ALSA output stream to create. 967 * @param pCfgReq Requested configuration to create stream with. 968 * @param pCfgAcq Obtained configuration the stream got created with on success. 969 */ 970 static int alsaCreateStreamOut(PALSAAUDIOSTREAM pStreamALSA, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 968 * @param pThis The ALSA driver instance data. 969 * @param pStreamALSA ALSA output stream to create. 970 * @param pCfgReq Requested configuration to create stream with. 971 * @param pCfgAcq Obtained configuration the stream got created 972 * with on success. 973 */ 974 static int alsaCreateStreamOut(PDRVHOSTALSAAUDIO pThis, PALSAAUDIOSTREAM pStreamALSA, 975 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 971 976 { 972 977 snd_pcm_t *phPCM = NULL; … … 985 990 986 991 ALSAAUDIOSTREAMCFG obt; 987 rc = alsaStreamOpen( false /* fIn */, &req, &obt, &phPCM);992 rc = alsaStreamOpen(pThis->szDefaultOut, false /* fIn */, &req, &obt, &phPCM); 988 993 if (RT_FAILURE(rc)) 989 994 break; … … 1024 1029 * 1025 1030 * @returns VBox status code. 1026 * @param pStreamALSA ALSA input stream to create. 1027 * @param pCfgReq Requested configuration to create stream with. 1028 * @param pCfgAcq Obtained configuration the stream got created with on success. 1029 */ 1030 static int alsaCreateStreamIn(PALSAAUDIOSTREAM pStreamALSA, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1031 * @param pThis The ALSA driver instance data. 1032 * @param pStreamALSA ALSA input stream to create. 1033 * @param pCfgReq Requested configuration to create stream with. 1034 * @param pCfgAcq Obtained configuration the stream got created 1035 * with on success. 1036 */ 1037 static int alsaCreateStreamIn(PDRVHOSTALSAAUDIO pThis, PALSAAUDIOSTREAM pStreamALSA, 1038 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1031 1039 { 1032 1040 int rc; … … 1045 1053 1046 1054 ALSAAUDIOSTREAMCFG obt; 1047 rc = alsaStreamOpen( true /* fIn */, &req, &obt, &phPCM);1055 rc = alsaStreamOpen(pThis->szDefaultIn, true /* fIn */, &req, &obt, &phPCM); 1048 1056 if (RT_FAILURE(rc)) 1049 1057 break; … … 1351 1359 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1352 1360 { 1361 PDRVHOSTALSAAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTALSAAUDIO, IHostAudio); 1353 1362 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1354 1363 AssertPtrReturn(pStream, VERR_INVALID_POINTER); … … 1360 1369 int rc; 1361 1370 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 1362 rc = alsaCreateStreamIn( p StreamALSA, pCfgReq, pCfgAcq);1371 rc = alsaCreateStreamIn( pThis, pStreamALSA, pCfgReq, pCfgAcq); 1363 1372 else 1364 rc = alsaCreateStreamOut(p StreamALSA, pCfgReq, pCfgAcq);1373 rc = alsaCreateStreamOut(pThis, pStreamALSA, pCfgReq, pCfgAcq); 1365 1374 1366 1375 if (RT_SUCCESS(rc)) … … 1586 1595 pThis->IHostAudio.pfnStreamCaptureEnd = NULL; 1587 1596 1597 /* 1598 * Read configuration. 1599 */ 1600 int rc = CFGMR3QueryStringDef(pCfg, "DefaultInput", pThis->szDefaultIn, sizeof(pThis->szDefaultIn), "default"); 1601 AssertRCReturn(rc, rc); 1602 rc = CFGMR3QueryStringDef(pCfg, "DefaultOutput", pThis->szDefaultOut, sizeof(pThis->szDefaultOut), "default"); 1603 AssertRCReturn(rc, rc); 1588 1604 1589 1605 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.