[MPlayer-dev-eng] [PATCH] Ability to pass channel name in radio_set_channel command
Vladimir Voroshilov
voroshil at gmail.com
Fri Sep 1 23:52:31 CEST 2006
Reimar D?ffinger wrote:
> strtol would provide a more reliable way by checking if the result in
> endptr parameter points to the terminating 0.
Fixed. Now parameter treated as channel number only if it equals to any integer.
>
>
> You have a few stray tabs here...
Fixed.
> Changing the indentation of this part is cosmetics and (if desired)
> should be done in a separate patch.
Sorry. Forget for this. I'll make separate cosmetics patch later.
>
> Greetings,
> Reimar D?ffinger
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
--
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 19630)
+++ stream/stream_radio.c (working copy)
@@ -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);
Index: help/help_mp-ru.h
===================================================================
--- help/help_mp-ru.h (revision 19630)
+++ 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 19630)
+++ 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