[MPlayer-dev-eng] [RFC] defines for demux seek flags

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Jan 27 09:13:13 CET 2008


Hello,
> @@ -79,14 +79,14 @@ static void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,float aud
>  
>    if(priv->ad != priv->vd) {
>      sh_audio_t* sh = (sh_audio_t*)demuxer->audio->sh;
> -    demux_seek(priv->ad,pos,audio_delay,1);
> +    demux_seek(priv->ad,pos,audio_delay,(struct seekflags){.absolute=1});

I find this really, really ugly.

> diff --git a/libmpdemux/demux_nut.c b/libmpdemux/demux_nut.c
> index 4cf4e6c..91dc6a3 100644
> --- a/libmpdemux/demux_nut.c
> +++ b/libmpdemux/demux_nut.c
> @@ -239,7 +239,7 @@ static int demux_nut_fill_buffer(demuxer_t * demuxer, demux_stream_t * dsds) {
>  	return 1;
>  }
>  
> -static void demux_seek_nut(demuxer_t * demuxer, float time_pos, float audio_delay, int flags) {
> +static void demux_seek_nut(demuxer_t * demuxer, float time_pos, float audio_delay, struct seekflags flags) {
>  	nut_context_t * nut = ((nut_priv_t*)demuxer->priv)->nut;
>  	nut_priv_t * priv = demuxer->priv;
>  	sh_audio_t * sh_audio = demuxer->audio->sh;
> @@ -247,12 +247,12 @@ static void demux_seek_nut(demuxer_t * demuxer, float time_pos, float audio_dela
>  	int ret;
>  	const int tmp[] = { 0, -1 };
>  
> -	if (!(flags & 1)) {
> +	if (!flags.absolute) {
>  		nutflags |= 1; // relative
>  		if (time_pos > 0) nutflags |= 2; // forwards
>  	}
>  
> -	if (flags & 2) // percent
> +	if (flags.percent & 2)

Not quite :-P

> diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h
> index 9e6eaf6..283a3cf 100644
> --- a/libmpdemux/demuxer.h
> +++ b/libmpdemux/demuxer.h
> @@ -141,6 +141,11 @@ struct demuxer_st;
>  
>  extern int correct_pts;
>  
> +struct seekflags {
> +    unsigned absolute : 1;
> +    unsigned percent : 1;
> +};

Typedef to seekflags_t might be nicer, though this name still risks
collisions either way.

> diff --git a/mplayer.c b/mplayer.c
> index 8d779d6..efcba69 100644
> --- a/mplayer.c
> +++ b/mplayer.c
> @@ -2487,7 +2487,8 @@ static void edl_update(MPContext *mpctx)
>  static int seek(MPContext *mpctx, double amount, int style)
>  {
>      current_module = "seek";
> -    if (demux_seek(mpctx->demuxer, amount, audio_delay, style) == 0)
> +    struct seekflags flags = {.absolute = style & 1, .percent = style >> 1};
> +    if (demux_seek(mpctx->demuxer, amount, audio_delay, flags) == 0)
>  	return -1;

Quite a cheat to avoid a even larger patch :-).
This way does not really look much better to me, also considering the
amount of change it needs.

Greetings,
Reimar Döffinger
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080127/cf6cc73a/attachment.pgp>


More information about the MPlayer-dev-eng mailing list