[MPlayer-dev-eng] [PATCH] Ability to pass channel name in radio_set_channel command

Vladimir Voroshilov voroshil at gmail.com
Fri Sep 1 20:00:41 CEST 2006


Hi, All
New ability for radio_set_channel command.

If channel parameter for radio_set_channel command converts to nonzero by atoi
function it will be treated as channel number, otherwise - as channel name.
In this case channel list will be searched for desired channel by name (case sensitive).


-- 
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 19623)
+++ stream/stream_radio.c	(working copy)
@@ -870,16 +865,27 @@
 
     if (priv->radio_channel_list) {
         channel_int = atoi(channel);
-        tmp = priv->radio_channel_list;
-        for (i = 1; i < channel_int; 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);
-            return 0;
-        }
+	tmp=priv->radio_channel_list;
+	if (channel_int==0){
+	    //channel is not a number, so it contains channel name or '0'
+            for ( ; tmp; tmp=tmp->next)
+		if (!strncmp(channel,tmp->name,sizeof(tmp->name)-1))
+		    break;		    
+    	    if (!tmp){
+                mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongChannelName,channel);
+                return 0;
+            }
+	}else
+            for (i = 1; i < channel_int; 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);
+                return 0;
+            }
+	}
         priv->radio_channel_current=tmp;
         mp_msg(MSGT_RADIO, MSGL_V, MSGTR_RADIO_SelectedChannel, priv->radio_channel_current->index,
             priv->radio_channel_current->name, priv->radio_channel_current->freq);
Index: help/help_mp-ru.h
===================================================================
--- help/help_mp-ru.h	(revision 19623)
+++ help/help_mp-ru.h	(working copy)
@@ -1180,6 +1180,7 @@
 #define MSGTR_RADIO_WrongFreqForChannel "[radio] ???????? ??????? ??? ??????? %s\n"
 #define MSGTR_RADIO_WrongChannelNumberFloat "[radio] ???????? ????? ???????: %.2f\n"
 #define MSGTR_RADIO_WrongChannelNumberInt "[radio] ???????? ????? ???????: %d\n"
+#define MSGTR_RADIO_WrongChannelName "[radio] ???????? ???????? ???????: %s\n"
 #define MSGTR_RADIO_FreqParameterDetected "[radio] ? ?????????? ?????????? ???????.\n"
 #define MSGTR_RADIO_DoneParsingChannels "[radio] ?????? ???? ???????????? ????????\n"
 #define MSGTR_RADIO_GetTunerFailed "[radio] ??????????????:???? ?????? ioctl get tuner : %s. frac ?????????? ? %d\n"
Index: help/help_mp-en.h
===================================================================
--- help/help_mp-en.h	(revision 19623)
+++ help/help_mp-en.h	(working copy)
@@ -1821,6 +1821,7 @@
 #define MSGTR_RADIO_WrongFreqForChannel "[radio] Wrong frequency for channel %s\n"
 #define MSGTR_RADIO_WrongChannelNumberFloat "[radio] Wrong channel number: %.2f\n"
 #define MSGTR_RADIO_WrongChannelNumberInt "[radio] Wrong channel number: %d\n"
+#define MSGTR_RADIO_WrongChannelName "[radio] Wrong channel name: %s\n"
 #define MSGTR_RADIO_FreqParameterDetected "[radio] Radio frequency parameter detected.\n"
 #define MSGTR_RADIO_DoneParsingChannels "[radio] Done parsing channels\n"
 #define MSGTR_RADIO_GetTunerFailed "[radio] Warning:ioctl get tuner failed: %s. Setting frac to %d\n"


More information about the MPlayer-dev-eng mailing list