[ALSA] Try to fallback on get_buffer_size.

Apparently some driver returns error here.
This commit is contained in:
Themaister 2014-02-22 15:30:52 +01:00
parent c429a9e424
commit 190db263b0
2 changed files with 11 additions and 4 deletions

View File

@ -87,9 +87,12 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency)
TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params)); TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params));
snd_pcm_hw_params_get_period_size(params, &buffer_size, NULL); // Shouldn't have to bother with this, but some drivers are apparently broken.
if (snd_pcm_hw_params_get_period_size(params, &buffer_size, NULL))
snd_pcm_hw_params_get_period_size_min(params, &buffer_size, NULL);
RARCH_LOG("ALSA: Period size: %d frames\n", (int)buffer_size); RARCH_LOG("ALSA: Period size: %d frames\n", (int)buffer_size);
snd_pcm_hw_params_get_buffer_size(params, &buffer_size); if (snd_pcm_hw_params_get_buffer_size(params, &buffer_size))
snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size);
RARCH_LOG("ALSA: Buffer size: %d frames\n", (int)buffer_size); RARCH_LOG("ALSA: Buffer size: %d frames\n", (int)buffer_size);
alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size); alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size);
alsa->can_pause = snd_pcm_hw_params_can_pause(params); alsa->can_pause = snd_pcm_hw_params_can_pause(params);

View File

@ -177,10 +177,14 @@ static void *alsa_thread_init(const char *device, unsigned rate, unsigned latenc
TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params)); TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params));
snd_pcm_hw_params_get_period_size(params, &alsa->period_frames, NULL); // Shouldn't have to bother with this, but some drivers are apparently broken.
if (snd_pcm_hw_params_get_period_size(params, &alsa->period_frames, NULL))
snd_pcm_hw_params_get_period_size_min(params, &alsa->period_frames, NULL);
RARCH_LOG("ALSA: Period size: %d frames\n", (int)alsa->period_frames); RARCH_LOG("ALSA: Period size: %d frames\n", (int)alsa->period_frames);
snd_pcm_hw_params_get_buffer_size(params, &buffer_size); if (snd_pcm_hw_params_get_buffer_size(params, &buffer_size))
snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size);
RARCH_LOG("ALSA: Buffer size: %d frames\n", (int)buffer_size); RARCH_LOG("ALSA: Buffer size: %d frames\n", (int)buffer_size);
alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size); alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size);
alsa->period_size = snd_pcm_frames_to_bytes(alsa->pcm, alsa->period_frames); alsa->period_size = snd_pcm_frames_to_bytes(alsa->pcm, alsa->period_frames);