Skip to content

Commit

Permalink
[ALSA] Try to fallback on get_buffer_size.
Browse files Browse the repository at this point in the history
Apparently some driver returns error here.
  • Loading branch information
Themaister committed Feb 22, 2014
1 parent c429a9e commit 190db26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions audio/alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency)

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);
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);
alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size);
alsa->can_pause = snd_pcm_hw_params_can_pause(params);
Expand Down
8 changes: 6 additions & 2 deletions audio/alsathread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

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);
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);

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);

Expand Down

0 comments on commit 190db26

Please sign in to comment.