VirtualBox

Changeset 73476 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 3, 2018 12:19:22 PM (6 years ago)
Author:
vboxsync
Message:

DrvAudio/ALSA: Removed more disabled code (not / never used).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp

    r73473 r73476  
    317317    return rc;
    318318}
    319 
    320 
    321 #if 0 /* After Beta. */
    322 static int alsaSetHWParams(snd_pcm_t *phPCM, PALSAAUDIOSTREAMCFG pCfg)
    323 {
    324     int rc;
    325     snd_pcm_hw_params_t *pParams = NULL;
    326 
    327     do
    328     {
    329         snd_pcm_hw_params_alloca(&pParams);
    330         if (!pParams)
    331         {
    332             rc = VERR_NO_MEMORY;
    333             break;
    334         }
    335 
    336         unsigned int rrate;
    337         snd_pcm_uframes_t size;
    338         int dir;
    339 
    340         /* choose all parameters */
    341         int err = snd_pcm_hw_params_any(phPCM, pParams);
    342         if (err < 0)
    343         {
    344             LogRel(("ALSA: Broken configuration for playback: no configurations available: %s\n", snd_strerror(err)));
    345             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    346             break;
    347         }
    348         /* set hardware resampling */
    349         err = snd_pcm_hw_params_set_rate_resample(phPCM, pParams, pCfg->resample);
    350         if (err < 0)
    351         {
    352             LogRel(("ALSA: Resampling setup failed for playback: %s\n", snd_strerror(err)));
    353             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    354             break;
    355         }
    356         /* set the interleaved read/write format */
    357         err = snd_pcm_hw_params_set_access(phPCM, pParams, pCfg->access);
    358         if (err < 0)
    359         {
    360             LogRel(("ALSA: Access type not available for playback: %s\n", snd_strerror(err)));
    361             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    362             break;
    363         }
    364         /* set the sample format */
    365         err = snd_pcm_hw_params_set_format(phPCM, pParams, pCfg->fmt);
    366         if (err < 0)
    367         {
    368             LogRel(("ALSA: Sample format not available for playback: %s\n", snd_strerror(err)));
    369             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    370             break;
    371         }
    372         /* set the count of channels */
    373         err = snd_pcm_hw_params_set_channels(phPCM, pParams, pCfg->nchannels);
    374         if (err < 0)
    375         {
    376             LogRel(("ALSA: Channels count (%d) not available for playbacks: %s\n", pCfg->nchannels, snd_strerror(err)));
    377             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    378             break;
    379         }
    380         /* set the stream rate */
    381         rrate = pCfg->freq;
    382         err = snd_pcm_hw_params_set_rate_near(phPCM, pParams, &rrate, 0);
    383         if (err < 0)
    384         {
    385             LogRel(("ALSA: Rate %uHz not available for playback: %s\n", pCfg->freq, snd_strerror(err)));
    386             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    387             break;
    388         }
    389         if (rrate != pCfg->freq)
    390         {
    391             LogRel(("ALSA: Rate doesn't match (requested %iHz, get %uHz)\n", pCfg->freq, err));
    392             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    393             break;
    394         }
    395         /* set the buffer time */
    396         err = snd_pcm_hw_params_set_buffer_time_near(phPCM, pParams, &pCfg->buffer_time, &dir);
    397         if (err < 0)
    398         {
    399             LogRel(("ALSA: Unable to set buffer time %i for playback: %s\n", buffer_time, snd_strerror(err)));
    400             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    401             break;
    402         }
    403         err = snd_pcm_hw_params_get_buffer_size(pParams, &size);
    404         if (err < 0)
    405         {
    406             LogRel(("ALSA: Unable to get buffer size for playback: %s\n", snd_strerror(err)));
    407             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    408             break;
    409         }
    410         buffer_size = size;
    411         /* set the period time */
    412         err = snd_pcm_hw_params_set_period_time_near(phPCM, pParams, &period_time, &dir);
    413         if (err < 0)
    414         {
    415             LogRel(("ALSA: Unable to set period time %i for playback: %s\n", period_time, snd_strerror(err)));
    416             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    417             break;
    418         }
    419         err = snd_pcm_hw_params_get_period_size(pParams, &size, &dir);
    420         if (err < 0)
    421         {
    422             LogRel(("ALSA: Unable to get period size for playback: %s\n", snd_strerror(err)));
    423             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    424             break;
    425         }
    426         period_size = size;
    427         /* write the parameters to device */
    428         err = snd_pcm_hw_params(phPCM, pParams);
    429         if (err < 0)
    430         {
    431             LogRel(("ALSA: Unable to set hw params for playback: %s\n", snd_strerror(err)));
    432             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    433             break;
    434         }
    435 
    436         rc = VINF_SUCCESS;
    437 
    438     } while (0);
    439 
    440     if (pParams)
    441     {
    442         snd_pcm_hw_params_free(pParams);
    443         pParams = NULL;
    444     }
    445 
    446     LogFlowFuncLeaveRC(rc);
    447     return rc;
    448 }
    449 
    450 
    451 static int alsaSetSWParams(snd_pcm_t *phPCM, PALSAAUDIOCFG pCfg)
    452 {
    453     int rc;
    454     snd_pcm_sw_params_t *pParams = NULL;
    455 
    456     do
    457     {
    458         snd_pcm_sw_params_alloca(&pParams);
    459         if (!pParams)
    460         {
    461             rc = VERR_NO_MEMORY;
    462             break;
    463         }
    464         /* get the current swparams */
    465         int err = snd_pcm_sw_params_current(phPCM, pParams);
    466         if (err < 0)
    467         {
    468             LogRel(("ALSA: Unable to determine current swparams for playback: %s\n", snd_strerror(err)));
    469             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    470             break;
    471         }
    472         /* start the transfer when the buffer is almost full: */
    473         /* (buffer_size / avail_min) * avail_min */
    474         err = snd_pcm_sw_params_set_start_threshold(phPCM, pParams, (buffer_size / period_size) * period_size);
    475         if (err < 0)
    476         {
    477             LogRel(("ALSA: Unable to set start threshold mode for playback: %s\n", snd_strerror(err)));
    478             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    479             break;
    480         }
    481         /* allow the transfer when at least period_size samples can be processed */
    482         /* or disable this mechanism when period event is enabled (aka interrupt like style processing) */
    483         err = snd_pcm_sw_params_set_avail_min(phPCM, pParams, period_size);
    484         if (err < 0)
    485         {
    486             LogRel(("ALSA: Unable to set avail min for playback: %s\n", snd_strerror(err)));
    487             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    488             break;
    489         }
    490         /* write the parameters to the playback device */
    491         err = snd_pcm_sw_params(phPCM, pParams);
    492         if (err < 0)
    493         {
    494             LogRel(("ALSA: Unable to set sw params for playback: %s\n", snd_strerror(err)));
    495             rc = VERR_AUDIO_BACKEND_INIT_FAILED;
    496             break;
    497         }
    498 
    499         rc = VINF_SUCCESS;
    500 
    501     } while (0);
    502 
    503     if (pParams)
    504     {
    505         snd_pcm_sw_params_free(pParams);
    506         pParams = NULL;
    507     }
    508 
    509     LogFlowFuncLeaveRC(rc);
    510     return rc;
    511 }
    512 #endif
    513319
    514320
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette