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

voroshil at gmail.com voroshil at gmail.com
Wed Nov 15 19:44:15 CET 2006


Reimar D?ffinger wrote: 
> Hello,
> On Wed, Nov 15, 2006 at 11:17:48PM +0600, voroshil at gmail.com wrote:
> > Attached patch adds ability to tune radio frequency using new slave command:
> > radio_step_freq. Step interval can be changed with step_value parameter.
> 
> Make the slave command argument a float instead.
Done.
> 
> > 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?
> 
> Start by using double instead of float.
> Ideally all this could use and reuse the property code and slave
> commands I guess...
I'm not sure that it is float issue, because i dodn't store frequency value in variables.
Procedure gets current frequency from tuner and adds step_interval to given
value. Float error can be accumulated only when tuner returns frequency  which
differs from the setted one for a bit. In any case, i can use double only in
get_frequency, because all options and slave commands' arguments are float.

> 
> Greetings,
> Reimar D?ffinger
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng

-- 
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)
@@ -825,6 +825,27 @@
 }
 
 /*****************************************************************
+ * \brief tune current frequency by step_interval value
+ * \parameter step_interval increment value
+ * \return 1 if success,0 - otherwise
+ *
+ */
+int radio_step_freq(struct stream_st *stream, float step_interval){
+    float frequency;
+    radio_priv_t* priv=(radio_priv_t*)stream->priv;
+    
+    if (get_frequency(priv,&frequency)!=STREAM_OK)
+        return 0;
+    
+    frequency+=step_interval;
+    if (frequency>priv->rangehigh)
+        frequency=priv->rangehigh;
+    if (frequency<priv->rangelow)
+        frequency=priv->rangelow;
+
+    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)
@@ -17,6 +17,7 @@
 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, float step_interval);
 
 #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_FLOAT,{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,9 @@
     Step forwards (1) or backwards (-1) in channel list. Works only when the
     'channels' radio parameter was set.
 
+radio_step_freq <value>
+    Tune frequency by <value> (positive - up, negative - down). 
+
 seek <value> [type]
     Seek to some place in the movie.
         0 is a relative seek of +/- <value> seconds (default).
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 20942)
+++ mplayer.c	(working copy)
@@ -4894,6 +4894,11 @@
       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){
+        radio_step_freq(demuxer->stream, cmd->args[0].v.f);
+      }
+    } break;
 #endif
 #ifdef USE_TV
     case MP_CMD_TV_SET_FREQ :  {


More information about the MPlayer-dev-eng mailing list