Mercurial > mplayer.hg
changeset 25377:31e0937ebe38
dvb cleanup: call dvb_(set|step)_channel() without dereferencing stream->priv (1000l to me)
author | nicodvb |
---|---|
date | Sat, 15 Dec 2007 13:05:06 +0000 |
parents | 382aeacc771f |
children | f0f03ec41cd3 |
files | command.c mplayer.c stream/dvbin.h stream/stream_dvb.c |
diffstat | 4 files changed, 14 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/command.c Sat Dec 15 12:17:51 2007 +0000 +++ b/command.c Sat Dec 15 13:05:06 2007 +0000 @@ -2628,10 +2628,7 @@ #endif /* HAVE_PVR */ } #ifdef HAS_DVBIN_SUPPORT - if ((mpctx->stream->type == STREAMTYPE_DVB) - && mpctx->stream->priv) { - dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv; - if (priv->is_on) { + if (mpctx->stream->type == STREAMTYPE_DVB) { int dir; int v = cmd->args[0].v.i; @@ -2642,9 +2639,8 @@ dir = DVB_CHANNEL_LOWER; - if (dvb_step_channel(priv, dir)) + if (dvb_step_channel(mpctx->stream, dir)) mpctx->eof = mpctx->dvbin_reopen = 1; - } } #endif /* HAS_DVBIN_SUPPORT */ break; @@ -2671,19 +2667,12 @@ #ifdef HAS_DVBIN_SUPPORT case MP_CMD_DVB_SET_CHANNEL: - if ((mpctx->stream->type == STREAMTYPE_DVB) - && mpctx->stream->priv) { - dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv; - if (priv->is_on) { - if (priv->list->current <= cmd->args[0].v.i) + if (mpctx->stream->type == STREAMTYPE_DVB) { mpctx->last_dvb_step = 1; - else - mpctx->last_dvb_step = -1; if (dvb_set_channel - (priv, cmd->args[1].v.i, cmd->args[0].v.i)) + (mpctx->stream, cmd->args[1].v.i, cmd->args[0].v.i)) mpctx->eof = mpctx->dvbin_reopen = 1; - } } break; #endif /* HAS_DVBIN_SUPPORT */
--- a/mplayer.c Sat Dec 15 12:17:51 2007 +0000 +++ b/mplayer.c Sat Dec 15 13:05:06 2007 +0000 @@ -3115,11 +3115,8 @@ if(!mpctx->sh_video && !mpctx->sh_audio){ mp_msg(MSGT_CPLAYER,MSGL_FATAL, MSGTR_NoStreamFound); #ifdef HAS_DVBIN_SUPPORT - if((mpctx->stream->type == STREAMTYPE_DVB) && mpctx->stream->priv) + if(mpctx->stream->type == STREAMTYPE_DVB) { - dvb_priv_t *priv = (dvb_priv_t*) mpctx->stream->priv; - if(priv->is_on) - { int dir; int v = mpctx->last_dvb_step; if(v > 0) @@ -3127,9 +3124,8 @@ else dir = DVB_CHANNEL_LOWER; - if(dvb_step_channel(priv, dir)) + if(dvb_step_channel(mpctx->stream, dir)) mpctx->eof = mpctx->dvbin_reopen = 1; - } } #endif goto goto_next_file; // exit_player(MSGTR_Exit_error);
--- a/stream/dvbin.h Sat Dec 15 12:17:51 2007 +0000 +++ b/stream/dvbin.h Sat Dec 15 13:05:06 2007 +0000 @@ -109,8 +109,8 @@ #define TUNER_CBL 3 #define TUNER_ATSC 4 -extern int dvb_step_channel(dvb_priv_t *, int); -extern int dvb_set_channel(dvb_priv_t *, int, int); +extern int dvb_step_channel(stream_t *, int); +extern int dvb_set_channel(stream_t *, int, int); extern dvb_config_t *dvb_get_config(void); #endif
--- a/stream/stream_dvb.c Sat Dec 15 12:17:51 2007 +0000 +++ b/stream/stream_dvb.c Sat Dec 15 13:05:06 2007 +0000 @@ -469,11 +469,11 @@ static void dvbin_close(stream_t *stream); -int dvb_set_channel(dvb_priv_t *priv, int card, int n) +int dvb_set_channel(stream_t *stream, int card, int n) { dvb_channels_list *new_list; dvb_channel_t *channel; - stream_t *stream = (stream_t*) priv->stream; + dvb_priv_t *priv = stream->priv; char buf[4096]; dvb_config_t *conf = (dvb_config_t *) priv->config; int devno; @@ -557,10 +557,11 @@ -int dvb_step_channel(dvb_priv_t *priv, int dir) +int dvb_step_channel(stream_t *stream, int dir) { int new_current; dvb_channels_list *list; + dvb_priv_t *priv = stream->priv; mp_msg(MSGT_DEMUX, MSGL_V, "DVB_STEP_CHANNEL dir %d\n", dir); @@ -579,7 +580,7 @@ new_current = (list->NUM_CHANNELS + list->current + (dir == DVB_CHANNEL_HIGHER ? 1 : -1)) % list->NUM_CHANNELS; - return dvb_set_channel(priv, priv->card, new_current); + return dvb_set_channel(stream, priv->card, new_current); } @@ -640,7 +641,7 @@ } - if(!dvb_set_channel(priv, priv->card, priv->list->current)) + if(!dvb_set_channel(stream, priv->card, priv->list->current)) { mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR, COULDN'T SET CHANNEL %i: ", priv->list->current); dvbin_close(stream);