[MPlayer-dev-eng] [PATCH] New slave command radio_step_freq

voroshil at gmail.com voroshil at gmail.com
Wed Nov 15 18:17:48 CET 2006


Hi, All
Attached patch adds ability to tune radio frequency using new slave command:
radio_step_freq. Step interval can be changed with step_value parameter.

Issue: 
if user repeats tuning frequency very fast (i.e. holding binded to
radio_step_freq key), frequency losts aligment to step_interval.
For example: user start mplayer with frequency 100.00, step_interval=0.05.
When user holds binded key, frequency can take values not aligned to 0.05,
i.e. 100.3). 
Should i check and always align frequency value to step_interval?

Opinions? Objections?

-- 
Regards,
Vladimir Voroshilov mailto:voroshil at gmail.com
Omsk State University
JID: voroshil at jabber.ru
ICQ: 95587719
-------------- next part --------------
Index: stream/stream_radio.c
===================================================================
--- stream/stream_radio.c	(revision 20942)
+++ stream/stream_radio.c	(working copy)
@@ -85,6 +85,8 @@
 char*   radio_param_device="/dev/radio0";
 /** (driver,string, "v4l2") radio driver (v4l,v4l2) */
 char*   radio_param_driver="default";
+/** radio_param_step_interval (step_interval,float,0.05) tune step interval */
+float  radio_param_step_interval=0.05;
 /** radio_param_channels (channels,string,NULL) channels list (see man page) */
 char**  radio_param_channels;
 /** radio_param_volume (volume,number,100) initial volume for radio device */
@@ -825,6 +827,30 @@
 }
 
 /*****************************************************************
+ * \brief tune current frequency up or down by radio_param_step_interval value
+ * \parameter direction RADIO_CHANNEL_LOWER - tune down,RADIO_CHANNEL_HIGHER - tune up
+ * \return 1 if success,0 - otherwise
+ *
+ */
+int radio_step_freq(struct stream_st *stream, int direction){
+    float frequency;
+    radio_priv_t* priv=(radio_priv_t*)stream->priv;
+    
+    if (get_frequency(priv,&frequency)!=STREAM_OK)
+        return 0;
+    
+    switch(direction){
+        case RADIO_CHANNEL_HIGHER:
+            frequency=frequency+radio_param_step_interval>priv->rangehigh?priv->rangehigh:frequency+radio_param_step_interval;
+            break;
+        case RADIO_CHANNEL_LOWER:
+            frequency=frequency-radio_param_step_interval<priv->rangelow?priv->rangelow:frequency-radio_param_step_interval;
+            break;
+    }
+
+    return radio_set_freq(stream,frequency);
+}
+/*****************************************************************
  * \brief step channel up or down
  * \parameter direction RADIO_CHANNEL_LOWER - go to prev channel,RADIO_CHANNEL_HIGHER - to next
  * \return 1 if success,0 - otherwise
Index: stream/stream_radio.h
===================================================================
--- stream/stream_radio.h	(revision 20942)
+++ stream/stream_radio.h	(working copy)
@@ -12,11 +12,13 @@
 extern char* radio_param_adevice;
 extern int radio_param_arate;
 extern int radio_param_achannels;
+extern float radio_param_step_interval;
 
 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_step_channel(struct stream_st *stream, int direction);
+int radio_step_freq(struct stream_st *stream, int direction);
 
 #endif
 
Index: input/input.c
===================================================================
--- input/input.c	(revision 20942)
+++ input/input.c	(working copy)
@@ -51,6 +51,7 @@
   { 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_FREQ, "radio_set_freq", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } },
+  { MP_CMD_RADIO_STEP_FREQ, "radio_step_freq", 1, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
 #endif
   { MP_CMD_SEEK, "seek", 1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
   { MP_CMD_EDL_MARK, "edl_mark", 0, { {-1,{0}} } },
Index: input/input.h
===================================================================
--- input/input.h	(revision 20942)
+++ input/input.h	(working copy)
@@ -91,6 +91,7 @@
 #define MP_CMD_RADIO_SET_FREQ 89
 #define MP_CMD_SET_MOUSE_POS 90
 #define MP_CMD_STEP_PROPERTY 91
+#define MP_CMD_RADIO_STEP_FREQ 92
 
 #define MP_CMD_GUI_EVENTS       5000
 #define MP_CMD_GUI_LOADFILE     5001
Index: DOCS/tech/slave.txt
===================================================================
--- DOCS/tech/slave.txt	(revision 20942)
+++ DOCS/tech/slave.txt	(working copy)
@@ -222,6 +222,10 @@
     Step forwards (1) or backwards (-1) in channel list. Works only when the
     'channels' radio parameter was set.
 
+radio_step_freq <-1|1>
+    Tune frequency up (1) or down (-1). Step interval can be set by step_interval
+    parameter of -radio option. 
+
 seek <value> [type]
     Seek to some place in the movie.
         0 is a relative seek of +/- <value> seconds (default).
Index: DOCS/man/en/mplayer.1
===================================================================
--- DOCS/man/en/mplayer.1	(revision 20942)
+++ DOCS/man/en/mplayer.1	(working copy)
@@ -1620,6 +1620,8 @@
 Currently, v4l and v4l2 drivers are supported.
 .IPs volume=<0..100>
 sound volume for radio device (default 100)
+.IPs step_interval=<0.01..1.00>
+step interval for radio_step_freq slave command (default: 0.05).
 .IPs channels=<frequency>\-<name>,<frequency>\-<name>,...
 Set channel list.
 Use _ for spaces in names (or play with quoting ;-).
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 20942)
+++ mplayer.c	(working copy)
@@ -4894,6 +4894,15 @@
       if (demuxer->stream->type==  STREAMTYPE_RADIO)
         radio_set_freq(demuxer->stream, cmd->args[0].v.f);
     } break;
+    case MP_CMD_RADIO_STEP_FREQ :  {
+      if (demuxer->stream->type==  STREAMTYPE_RADIO){
+          int v = cmd->args[0].v.i;
+          if(v > 0)
+              radio_step_freq(demuxer->stream, RADIO_CHANNEL_HIGHER);
+          else
+              radio_step_freq(demuxer->stream, RADIO_CHANNEL_LOWER);
+      }
+    } break;
 #endif
 #ifdef USE_TV
     case MP_CMD_TV_SET_FREQ :  {
Index: cfg-common.h
===================================================================
--- cfg-common.h	(revision 20942)
+++ cfg-common.h	(working copy)
@@ -395,6 +395,7 @@
     {"device", &radio_param_device, CONF_TYPE_STRING, 0, 0 ,0, NULL},
     {"driver", &radio_param_driver, CONF_TYPE_STRING, 0, 0 ,0, NULL},
     {"channels", &radio_param_channels, CONF_TYPE_STRING_LIST, 0, 0 ,0, NULL},
+    {"step_interval", &radio_param_step_interval, CONF_TYPE_FLOAT, CONF_RANGE, 0.01 ,1.0, NULL},
     {"volume", &radio_param_volume, CONF_TYPE_INT, CONF_RANGE, 0 ,100, NULL},
     {"adevice", &radio_param_adevice, CONF_TYPE_STRING, 0, 0 ,0, NULL},
     {"arate", &radio_param_arate, CONF_TYPE_INT, CONF_MIN, 0 ,0, NULL},


More information about the MPlayer-dev-eng mailing list