# HG changeset patch # User reimar # Date 1351621014 0 # Node ID 63274beacefbe1126068421e794e6c2c641faa43 # Parent 8b8e20725b249843b4724451ef691a37ea4112c9 Make checks for STREAMTYPE simpler and more consistent. diff -r 8b8e20725b24 -r 63274beacefb command.c --- a/command.c Tue Oct 30 18:03:30 2012 +0000 +++ b/command.c Tue Oct 30 18:16:54 2012 +0000 @@ -73,6 +73,8 @@ #include "libavutil/avstring.h" #include "edl.h" +#define IS_STREAMTYPE(t) (mpctx->stream && mpctx->stream->type == STREAMTYPE_##t) + static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy) { //remove the borders, if any, and rescale to the range [0,1],[0,1] @@ -1592,8 +1594,8 @@ } #ifdef CONFIG_DVDREAD if (vo_spudec - && (mpctx->stream->type == STREAMTYPE_DVD - || mpctx->stream->type == STREAMTYPE_DVDNAV) + && (IS_STREAMTYPE(DVD) + || IS_STREAMTYPE(DVDNAV)) && dvdsub_id < 0 && reset_spu) { d_sub->id = -2; d_sub->sh = NULL; @@ -2948,7 +2950,7 @@ #ifdef CONFIG_RADIO case MP_CMD_RADIO_STEP_CHANNEL: - if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) { + if (IS_STREAMTYPE(RADIO)) { int v = cmd->args[0].v.i; if (v > 0) radio_step_channel(mpctx->demuxer->stream, @@ -2965,7 +2967,7 @@ break; case MP_CMD_RADIO_SET_CHANNEL: - if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) { + if (IS_STREAMTYPE(RADIO)) { radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s); if (radio_get_channel_name(mpctx->demuxer->stream)) { set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration, @@ -2976,12 +2978,12 @@ break; case MP_CMD_RADIO_SET_FREQ: - if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) + if (IS_STREAMTYPE(RADIO)) radio_set_freq(mpctx->demuxer->stream, cmd->args[0].v.f); break; case MP_CMD_RADIO_STEP_FREQ: - if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) + if (IS_STREAMTYPE(RADIO)) radio_step_freq(mpctx->demuxer->stream, cmd->args[0].v.f); break; #endif @@ -2996,7 +2998,7 @@ tv_set_freq((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.f * 16.0); #ifdef CONFIG_PVR - else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { + else if (IS_STREAMTYPE(PVR)) { pvr_set_freq (mpctx->stream, ROUND (cmd->args[0].v.f)); set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", pvr_get_current_channelname (mpctx->stream), @@ -3010,7 +3012,7 @@ tv_step_freq((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.f * 16.0); #ifdef CONFIG_PVR - else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { + else if (IS_STREAMTYPE(PVR)) { pvr_force_freq_step (mpctx->stream, ROUND (cmd->args[0].v.f)); set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: f %d", pvr_get_current_channelname (mpctx->stream), @@ -3044,8 +3046,7 @@ } } #ifdef CONFIG_PVR - else if (mpctx->stream && - mpctx->stream->type == STREAMTYPE_PVR) { + else if (IS_STREAMTYPE(PVR)) { pvr_set_channel_step (mpctx->stream, cmd->args[0].v.i); set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", pvr_get_current_channelname (mpctx->stream), @@ -3054,7 +3055,7 @@ #endif /* CONFIG_PVR */ } #ifdef CONFIG_DVBIN - if (mpctx->stream->type == STREAMTYPE_DVB) { + if (IS_STREAMTYPE(DVB)) { int dir; int v = cmd->args[0].v.i; @@ -3082,7 +3083,7 @@ } } #ifdef CONFIG_PVR - else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { + else if (IS_STREAMTYPE(PVR)) { pvr_set_channel (mpctx->stream, cmd->args[0].v.s); set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", pvr_get_current_channelname (mpctx->stream), @@ -3093,7 +3094,7 @@ #ifdef CONFIG_DVBIN case MP_CMD_DVB_SET_CHANNEL: - if (mpctx->stream->type == STREAMTYPE_DVB) { + if (IS_STREAMTYPE(DVB)) { mpctx->last_dvb_step = 1; if (dvb_set_channel @@ -3113,7 +3114,7 @@ } } #ifdef CONFIG_PVR - else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { + else if (IS_STREAMTYPE(PVR)) { pvr_set_lastchannel (mpctx->stream); set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", pvr_get_current_channelname (mpctx->stream), @@ -3373,7 +3374,7 @@ pointer_y = cmd->args[1].v.i; rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy); #ifdef CONFIG_DVDNAV - if (mpctx->stream->type == STREAMTYPE_DVDNAV + if (IS_STREAMTYPE(DVDNAV) && dx > 0.0 && dy > 0.0) { int button = -1; pointer_x = (int) (dx * (double) sh_video->disp_w); @@ -3397,7 +3398,7 @@ int button = -1; int i; mp_command_type command = 0; - if (mpctx->stream->type != STREAMTYPE_DVDNAV) + if (!IS_STREAMTYPE(DVDNAV)) break; for (i = 0; mp_dvdnav_bindings[i].name; i++) @@ -3414,7 +3415,7 @@ break; case MP_CMD_SWITCH_TITLE: - if (mpctx->stream->type == STREAMTYPE_DVDNAV) + if (IS_STREAMTYPE(DVDNAV)) mp_dvdnav_switch_title(mpctx->stream, cmd->args[0].v.i); break;