[PATCH v2] alsa-util: Set ALSA report_delay flag in pa_alsa_safe_delay()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11.05.2018 10:09, Tanu Kaskinen wrote:
> On Fri, 2018-05-04 at 21:10 +0200, Georg Chini wrote:
>> The current code does not call snd_pcm_status_set_audio_htstamp_config()
>> to configure the way timestamps are updated in ALSA. In kernel 4.14 and
>> above a bug in ALSA has been fixed which changes timmestamp behavior.
>> This leads to inconsistencies in the delay reporting because the time
>> stamp no longer reflects the time when the delay was updated if the
>> ALSA report_delay flag is not set. Therefore latencies are not calculated
>> correctly.
>>
>> This patch uses snd_pcm_status_set_audio_htstamp_config() to set the
>> ALSA report_delay flag to 1 before the call to snd_pcm_status(). With
>> this, time stamps are updated as expected.
>> ---
>>
>> Changes in v2:
>>   - updated commit message
>>
>>   src/modules/alsa/alsa-util.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
>> index 61fb4903..b91a0e98 100644
>> --- a/src/modules/alsa/alsa-util.c
>> +++ b/src/modules/alsa/alsa-util.c
>> @@ -1187,6 +1187,7 @@ int pa_alsa_safe_delay(snd_pcm_t *pcm, snd_pcm_status_t *status, snd_pcm_sframes
>>       size_t abs_k;
>>       int err;
>>       snd_pcm_sframes_t avail = 0;
>> +    snd_pcm_audio_tstamp_config_t tstamp_config;
>>   
>>       pa_assert(pcm);
>>       pa_assert(delay);
>> @@ -1200,6 +1201,12 @@ int pa_alsa_safe_delay(snd_pcm_t *pcm, snd_pcm_status_t *status, snd_pcm_sframes
>>        * avail, delay and timestamp values in a single kernel call to improve
>>        * timer-based scheduling */
>>   
>> +    /* The time stamp configuration needs to be set so that the
>> +     * ALSA code will use the internal delay reported by the driver */
>> +    tstamp_config.type_requested = 1; /* ALSA default time stamp type */
>> +    tstamp_config.report_delay = 1;
>> +    snd_pcm_status_set_audio_htstamp_config(status, &tstamp_config);
>> +
>>       if ((err = snd_pcm_status(pcm, status)) < 0)
>>           return err;
>>   
> Looks good to me.
>
This patch breaks the build on older ALSA versions. Should we change the 
dependency
to 1.1.0 which introduces snd_pcm_status_set_audio_htstamp_config() or 
make the
usage of the function dependent on ALSA version?



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux