Modify
Warning Please read the Ticket HowTo before creating or commenting on a ticket. Failure to do so may cause your ticket to be rejected or result in a slower response.

Opened 2 years ago

Closed 2 years ago

#10484 closed Patch - Bug Fix (Fixed)

Proposed pulseaudio latency calculation fixes (fixes warning for unsigned int value)

Reported by: Gary Buhrmaster <gary.buhrmaster@…> Owned by: jyavenard
Priority: minor Milestone: 0.25
Component: MythTV - Audio Output Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

In audiooutputpulse.cpp, clang reports a warning (comparison of unsigned expression < 0 is always false) for the following code fragment:

if (latency < 0)

latency is defined as:

pa_usec_t latency = (pa_usec_t) -1;

which, since pa_usec_t is an unsigned variable, actually sets latency to be the max value, and as the warning indicates, as an unsigned variable the comparison will always be false.

I am not at all familiar with the PulseAudio? API, but it seems that one should check for the value being returned from get_latency being negative via the negative return int, and act accordingly if one wants to change a negative value to zero.

I think that it is possible with the current code for a latency value which should be interpreted as negative to be interpreted as positive, resulting in some confusion elsewhere.

I have provided a proposed patch, but the SME for this code needs to review it carefully to insure the patch would be an improvement. Since I do not currently use PulseAudio?, I am not sure when I could test these changes.

Thanks.

Gary

Attachments (1)

audiooutputpulse_cpp.diff (1.1 KB) - added by Gary Buhrmaster <gary.buhrmaster@…> 2 years ago.

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by Gary Buhrmaster <gary.buhrmaster@…>

comment:1 Changed 2 years ago by stuartm

  • Component changed from MythTV - General to MythTV - Audio Output
  • Milestone changed from unknown to 0.25
  • Owner set to jyavenard
  • Version changed from Unspecified to Master Head

comment:2 Changed 2 years ago by jyavenard

The stream isn't a capture stream. As such, latency_negative will never be set to 1.

That whole test serves no purpose, it's just legacy code that wasn't properly adapted to pulse API..
Will simplify

comment:3 Changed 2 years ago by jyavenard

  • Resolution set to Fixed
  • Status changed from new to closed

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'new'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.