changeset 19793:6c98f3566af1

ability to pass channel name (not only number) to radio_set_channel
author voroshil
date Mon, 11 Sep 2006 18:41:14 +0000
parents 8e3d8735e21b
children 0951c3e8864b
files help/help_mp-en.h help/help_mp-ru.h stream/stream_radio.c
diffstat 3 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/help/help_mp-en.h	Mon Sep 11 16:56:31 2006 +0000
+++ b/help/help_mp-en.h	Mon Sep 11 18:41:14 2006 +0000
@@ -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"
--- a/help/help_mp-ru.h	Mon Sep 11 16:56:31 2006 +0000
+++ b/help/help_mp-ru.h	Mon Sep 11 18:41:14 2006 +0000
@@ -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"
--- a/stream/stream_radio.c	Mon Sep 11 16:56:31 2006 +0000
+++ b/stream/stream_radio.c	Mon Sep 11 18:41:14 2006 +0000
@@ -862,10 +862,24 @@
     radio_priv_t* priv=(radio_priv_t*)stream->priv;
     int i, channel_int;
     radio_channels_t* tmp;
+    char* endptr;
 
+    if (*channel=='\0')
+        mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongChannelName,channel);
+    
     if (priv->radio_channel_list) {
-        channel_int = atoi(channel);
+        channel_int = strtol(channel,&endptr,10);
         tmp = priv->radio_channel_list;
+        if (*endptr!='\0'){
+            //channel is not a number, so it contains channel name
+            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;
@@ -875,6 +889,7 @@
             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);