changeset 21042:c549c2de24ce

new slave command: radio_step_freq
author voroshil
date Sun, 19 Nov 2006 16:15:05 +0000
parents 456aef02280d
children 80581271f64d
files DOCS/tech/slave.txt input/input.c input/input.h mplayer.c stream/stream_radio.c stream/stream_radio.h
diffstat 6 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/tech/slave.txt	Sun Nov 19 15:27:20 2006 +0000
+++ b/DOCS/tech/slave.txt	Sun Nov 19 16:15:05 2006 +0000
@@ -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 the <value> (positive - up, negative - down). 
+
 seek <value> [type]
     Seek to some place in the movie.
         0 is a relative seek of +/- <value> seconds (default).
--- a/input/input.c	Sun Nov 19 15:27:20 2006 +0000
+++ b/input/input.c	Sun Nov 19 16:15:05 2006 +0000
@@ -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}} } },
--- a/input/input.h	Sun Nov 19 15:27:20 2006 +0000
+++ b/input/input.h	Sun Nov 19 16:15:05 2006 +0000
@@ -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
--- a/mplayer.c	Sun Nov 19 15:27:20 2006 +0000
+++ b/mplayer.c	Sun Nov 19 16:15:05 2006 +0000
@@ -5025,6 +5025,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 :  {
--- a/stream/stream_radio.c	Sun Nov 19 15:27:20 2006 +0000
+++ b/stream/stream_radio.c	Sun Nov 19 16:15:05 2006 +0000
@@ -981,6 +981,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
--- a/stream/stream_radio.h	Sun Nov 19 15:27:20 2006 +0000
+++ b/stream/stream_radio.h	Sun Nov 19 16:15:05 2006 +0000
@@ -22,6 +22,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