Changeset 73643 in vbox
- Timestamp:
- Aug 14, 2018 8:52:49 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
r73529 r73643 84 84 struct 85 85 { 86 87 86 } In; 88 87 struct 89 88 { 90 /** Minimum samples required for ALSA to play data. */91 uint32_t cSamplesMin;92 89 } Out; 93 90 }; … … 241 238 242 239 243 static int alsaStreamSetThreshold(snd_pcm_t *phPCM, snd_pcm_uframes_t threshold) 244 { 240 static int alsaStreamSetSWParams(snd_pcm_t *phPCM, bool fIn, PALSAAUDIOSTREAMCFG pCfgReq, PALSAAUDIOSTREAMCFG pCfgObt) 241 { 242 if (fIn) /* For input streams there's nothing to do in here right now. */ 243 return VINF_SUCCESS; 244 245 245 snd_pcm_sw_params_t *pSWParms = NULL; 246 246 snd_pcm_sw_params_alloca(&pSWParms); … … 254 254 if (err < 0) 255 255 { 256 LogRel(("ALSA: Failed to get current software parameters for threshold: %s\n", 257 snd_strerror(err))); 256 LogRel(("ALSA: Failed to get current software parameters: %s\n", snd_strerror(err))); 258 257 rc = VERR_ACCESS_DENIED; 259 258 break; 260 259 } 261 260 262 err = snd_pcm_sw_params_set_start_threshold(phPCM, pSWParms, threshold); 263 if (err < 0) 264 { 265 LogRel(("ALSA: Failed to set software threshold to %ld: %s\n", 266 threshold, snd_strerror(err))); 261 err = snd_pcm_sw_params_set_start_threshold(phPCM, pSWParms, pCfgReq->threshold); 262 if (err < 0) 263 { 264 LogRel(("ALSA: Failed to set software threshold to %ld: %s\n", pCfgReq->threshold, snd_strerror(err))); 267 265 rc = VERR_ACCESS_DENIED; 268 266 break; 269 267 } 270 268 271 err = snd_pcm_sw_params_set_avail_min(phPCM, pSWParms, 512); 272 if (err < 0) 273 { 274 LogRel(("ALSA: Failed to set available minimum to %ld: %s\n", 275 threshold, snd_strerror(err))); 269 err = snd_pcm_sw_params_set_avail_min(phPCM, pSWParms, pCfgReq->period_size); 270 if (err < 0) 271 { 272 LogRel(("ALSA: Failed to set available minimum to %ld: %s\n", pCfgReq->threshold, snd_strerror(err))); 276 273 rc = VERR_ACCESS_DENIED; 277 274 break; … … 281 278 if (err < 0) 282 279 { 283 LogRel(("ALSA: Failed to set new software parameters for threshold: %s\n", 284 snd_strerror(err))); 280 LogRel(("ALSA: Failed to set new software parameters: %s\n", snd_strerror(err))); 285 281 rc = VERR_ACCESS_DENIED; 286 282 break; 287 283 } 288 284 289 LogFlowFunc(("Setting threshold to %RU32\n", threshold)); 285 err = snd_pcm_sw_params_get_start_threshold(pSWParms, &pCfgObt->threshold); 286 if (err < 0) 287 { 288 LogRel(("ALSA: Failed to get start threshold\n")); 289 rc = VERR_ACCESS_DENIED; 290 break; 291 } 292 293 LogFunc(("Setting threshold to %RU32 frames\n", pCfgObt->threshold)); 290 294 rc = VINF_SUCCESS; 291 295 } … … 482 486 } 483 487 484 LogRel2(("ALSA: Frequency is %dHz, period size is %RU32 frames, buffer size is %RU32 f ames\n",488 LogRel2(("ALSA: Frequency is %dHz, period size is %RU32 frames, buffer size is %RU32 frames\n", 485 489 pCfgReq->freq, obt_period_size, obt_buffer_size)); 486 490 … … 493 497 } 494 498 495 if ( !fIn 496 && pCfgReq->threshold) 497 { 498 rc = alsaStreamSetThreshold(phPCM, pCfgReq->threshold); 499 if (RT_FAILURE(rc)) 500 break; 501 502 LogRel2(("ALSA: Threshold for playback set to %RU32 frames\n", pCfgReq->threshold)); 503 } 499 rc = alsaStreamSetSWParams(phPCM, fIn, pCfgReq, pCfgObt); 500 if (RT_FAILURE(rc)) 501 break; 504 502 505 503 pCfgObt->fmt = pCfgReq->fmt; … … 508 506 pCfgObt->period_size = obt_period_size; 509 507 pCfgObt->buffer_size = obt_buffer_size; 510 pCfgObt->threshold = pCfgReq->threshold;511 512 rc = VINF_SUCCESS;513 508 } 514 509 while (0); … … 1383 1378 snd_pcm_sframes_t cFramesAvail; 1384 1379 int rc = alsaStreamGetAvail(pStreamALSA->phPCM, &cFramesAvail); 1385 if ( RT_SUCCESS(rc) 1386 && (uint32_t)cFramesAvail >= pStreamALSA->Out.cSamplesMin) 1387 { 1380 if (RT_SUCCESS(rc)) 1388 1381 cbAvail = PDMAUDIOSTREAMCFG_F2B(pStreamALSA->pCfg, cFramesAvail); 1389 }1390 1382 1391 1383 return cbAvail;
Note:
See TracChangeset
for help on using the changeset viewer.