summaryrefslogtreecommitdiffstats
path: root/stream/stream_radio.c
diff options
context:
space:
mode:
authorvoroshil <voroshil@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-11 18:41:14 +0000
committervoroshil <voroshil@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-11 18:41:14 +0000
commite409a93e36359f5634a129cb299415022f829c49 (patch)
tree8d2bd2325b48512f9f6f9c759d0c86c06bd430ec /stream/stream_radio.c
parent9eea286729fb8c80bececeeca85c537390807902 (diff)
downloadmpv-e409a93e36359f5634a129cb299415022f829c49.tar.bz2
mpv-e409a93e36359f5634a129cb299415022f829c49.tar.xz
ability to pass channel name (not only number) to radio_set_channel
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19799 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream/stream_radio.c')
-rw-r--r--stream/stream_radio.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/stream/stream_radio.c b/stream/stream_radio.c
index 85a4d9ce15..7daed44cd8 100644
--- a/stream/stream_radio.c
+++ b/stream/stream_radio.c
@@ -862,10 +862,24 @@ int radio_set_channel(struct stream_st *stream, char *channel) {
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 @@ int radio_set_channel(struct stream_st *stream, char *channel) {
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);