[MPlayer-dev-eng] Changing channel parameter in radio_set_channel from string to int

Vladimir Voroshilov voroshil at gmail.com
Tue Aug 29 21:18:59 CEST 2006


Hi, All.

Channel parameter in radio_set_channel function always contains only channel number, 
so string type is not neccesery.


-- 
Vladimir Voroshilov mailto:voroshli at univer.omsk.su
Omsk State University
JID: voroshil at jabber.ru
ICQ: 95587719
-------------- next part --------------
Index: stream/stream_radio.c
===================================================================
--- stream/stream_radio.c	(revision 19592)
+++ stream/stream_radio.c	(working copy)
@@ -861,27 +857,28 @@
 
 /*****************************************************************
  * \brief change channel to one with given index
- * \parameter channel string, containing channel number
+ * \parameter channel int, containing channel number
  * \return 1 if success,0 - otherwise
  *
  *  if radio_param_channel is NULL function prints error message and does nothing, otherwise
  *  changes channel to given
  */
-int radio_set_channel(struct stream_st *stream, char *channel) {
+int radio_set_channel(struct stream_st *stream, int channel) {
     radio_priv_t* priv=(radio_priv_t*)stream->priv;
-    int i, channel_int;
+    int i;
     radio_channels_t* tmp;
 
+    if (channel<=0)
+	mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongChannelNumberInt,channel);
     if (priv->radio_channel_list) {
-        channel_int = atoi(channel);
         tmp = priv->radio_channel_list;
-        for (i = 1; i < channel_int; i++)
+        for (i = 1; i < channel; i++)
             if (tmp->next)
                 tmp = tmp->next;
             else
                 break;
-        if (tmp->index!=channel_int){
-            mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongChannelNumberInt,channel_int);
+        if (tmp->index!=channel){
+            mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongChannelNumberInt,channel);
             return 0;
         }
         priv->radio_channel_current=tmp;
Index: stream/stream_radio.h
===================================================================
--- stream/stream_radio.h	(revision 19592)
+++ stream/stream_radio.h	(working copy)
@@ -15,7 +15,7 @@
 
 int radio_set_freq(struct stream_st *stream, float freq);
 char* radio_get_channel_name(struct stream_st *stream);
-int radio_set_channel(struct stream_st *stream, char *channel);
+int radio_set_channel(struct stream_st *stream, int channel);
 int radio_step_channel(struct stream_st *stream, int direction);
 
 #endif
Index: input/input.c
===================================================================
--- input/input.c	(revision 19592)
+++ input/input.c	(working copy)
@@ -49,7 +49,7 @@
 static mp_cmd_t mp_cmds[] = {
 #ifdef USE_RADIO
   { MP_CMD_RADIO_STEP_CHANNEL, "radio_step_channel", 1,  { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }},
-  { MP_CMD_RADIO_SET_CHANNEL, "radio_set_channel", 1, { { MP_CMD_ARG_STRING, {0}}, {-1,{0}}  }},
+  { MP_CMD_RADIO_SET_CHANNEL, "radio_set_channel", 1, { { MP_CMD_ARG_INT, {0}}, {-1,{0}} }},
   { MP_CMD_RADIO_SET_FREQ, "radio_set_freq", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } },
 #endif
   { MP_CMD_SEEK, "seek", 1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 19592)
+++ mplayer.c	(working copy)
@@ -4780,7 +4780,7 @@
     } break;
     case MP_CMD_RADIO_SET_CHANNEL :  {
         if (demuxer->stream->type== STREAMTYPE_RADIO) {
-            radio_set_channel(demuxer->stream, cmd->args[0].v.s);
+            radio_set_channel(demuxer->stream, cmd->args[0].v.i);
             if (radio_get_channel_name(demuxer->stream)) {
                 set_osd_msg(OSD_MSG_RADIO_CHANNEL,1,osd_duration,
                       MSGTR_OSDChannel, radio_get_channel_name(demuxer->stream));


More information about the MPlayer-dev-eng mailing list