Skip to content

Commit

Permalink
Fix alsa latency calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
quiniouben committed May 11, 2018
1 parent ddb1c70 commit 923c74c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/common/backend/alsa_backend.c
Expand Up @@ -75,6 +75,7 @@ int alsa_open(audio_backend_handle_t handle, char const* output_name, enum audio
{
int ret;
struct alsa_backend_t* const alsa_backend = (struct alsa_backend_t*)handle;
size_t frame_nb = 0;

if (handle == 0)
{
Expand All @@ -83,6 +84,7 @@ int alsa_open(audio_backend_handle_t handle, char const* output_name, enum audio
}

alsa_backend->frame_size = VBanBitResolutionSize[config->bit_fmt] * config->nb_channels;
frame_nb = buffer_size / alsa_backend->frame_size;

ret = snd_pcm_open(&alsa_backend->alsa_handle, (output_name[0] == '\0') ? ALSA_DEVICE_NAME_DEFAULT : output_name,
(direction == AUDIO_OUT) ? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE, 0);
Expand All @@ -101,8 +103,7 @@ int alsa_open(audio_backend_handle_t handle, char const* output_name, enum audio
config->nb_channels,
config->sample_rate,
1,
//XXX this is wrong !
((unsigned int)buffer_size * 1000000) / config->sample_rate);
((unsigned int)frame_nb* 1000000) / config->sample_rate);

if (ret < 0)
{
Expand Down

0 comments on commit 923c74c

Please sign in to comment.