[MPlayer-dev-eng] [PATCH] GUI: Implement a true rotary potmeter

Hans-Dieter Kosch hdkosch at kabelbw.de
Mon Apr 7 03:27:22 CEST 2014


Ingo Brückl wrote:

> I've finished the (hopefully) completely elaborated more universal version
> which is very much based on your patch (though comments and variable names
> may vary). It supports arbitrary start and stop points which must be defined
> in the skin configuration file:
> 
>   (plastic)  rpotmeter = NULL, 0, 0, volume, 51, 0'49'52'60'26, 189, 126, 61, 57, evSetVolume
>   (standard) rpotmeter = NULL, 0, 0, volume, 51, 0'10'36'28'37, 311, 17, 40, 40, evSetVolume
> 
> I'd very much appreciate you looking over, commenting and checking it

Here my first findings:

Your comments in the code are great, they really help understanding! Wish that 
MPlayer (and other code) had more of such! :-)

gui/app/gui.h:

I wouldn't bother this header with math, defining M_2PI. Just use '(2*M_PI)' in 
place, the compiler folds it into a single constant anyway.

gui/skin/skin.c:

The syntax using "'" appears somewhat strange to me. I see that you have chosen 
it for consistent parsing. Another solution could be to count the number of "," 
ahead. As the parsing checks for rpotmeter at that point anyway, we could check 
if there are 4 more ",".

The special case 'x0 == x1 && y0 == y1' to determine if 'zeropoint' and 'stop' 
are the same seems not needed. There are more cases where this happens: x0 == 0 
and x1 == 0 and y0 and y1 are in the same quadrant or vice versa. So, simply 
calculate 'stop' and apply it.

gui/ui/main.c and gui/ui/playbar.c:

'wsRLMouseButton' must regard the stop gap like 'wsMoveMouse' does, otherwise 
the potmeter's position may jump away after dragging and releasing (see my 
original patch). That's a code redundancy I mentioned earlier. Your new file 
'gui/util/misc.c' could eventually be a place to outsource and in turn include 
such common code.

The stop gap doesn't work reliably for me. Seems to be dependent on speed of 
mouse movement, i.e. dependent on the actually captured positions.

I'll come back with further details.

Hans-Dieter


More information about the MPlayer-dev-eng mailing list