mirror of https://github.com/mpv-player/mpv
Adding ability to check allowed frequency range.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20774 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
7e5c903723
commit
09621fb285
|
@ -1603,6 +1603,7 @@ These options set various parameters of the radio capture module.
|
||||||
For listening to radio with MPlayer use 'radio://<frequency>'
|
For listening to radio with MPlayer use 'radio://<frequency>'
|
||||||
(if channels option is not given) or 'radio://<channel_number>'
|
(if channels option is not given) or 'radio://<channel_number>'
|
||||||
(if channels option is given) as a movie URL.
|
(if channels option is given) as a movie URL.
|
||||||
|
You can see allowed frequency range by running MPlayer with '\-v'.
|
||||||
To start the grabbing subsystem, use 'radio://<frequency or channel>/capture'.
|
To start the grabbing subsystem, use 'radio://<frequency or channel>/capture'.
|
||||||
If the capture keyword is not given you can listen to radio
|
If the capture keyword is not given you can listen to radio
|
||||||
using the line-in cable only.
|
using the line-in cable only.
|
||||||
|
|
|
@ -1846,6 +1846,7 @@ static char help_text[]=
|
||||||
// stream/stream_radio.c
|
// stream/stream_radio.c
|
||||||
|
|
||||||
#define MSGTR_RADIO_ChannelNamesDetected "[radio] Radio channel names detected.\n"
|
#define MSGTR_RADIO_ChannelNamesDetected "[radio] Radio channel names detected.\n"
|
||||||
|
#define MSGTR_RADIO_FreqRange "[radio] Allowable frequency range is %.2f-%.2f MHz\n"
|
||||||
#define MSGTR_RADIO_WrongFreqForChannel "[radio] Wrong frequency for channel %s\n"
|
#define MSGTR_RADIO_WrongFreqForChannel "[radio] Wrong frequency for channel %s\n"
|
||||||
#define MSGTR_RADIO_WrongChannelNumberFloat "[radio] Wrong channel number: %.2f\n"
|
#define MSGTR_RADIO_WrongChannelNumberFloat "[radio] Wrong channel number: %.2f\n"
|
||||||
#define MSGTR_RADIO_WrongChannelNumberInt "[radio] Wrong channel number: %d\n"
|
#define MSGTR_RADIO_WrongChannelNumberInt "[radio] Wrong channel number: %d\n"
|
||||||
|
|
|
@ -112,6 +112,8 @@ typedef struct radio_priv_s {
|
||||||
int frac; ///< fraction value (see comment to init_frac)
|
int frac; ///< fraction value (see comment to init_frac)
|
||||||
radio_channels_t* radio_channel_list;
|
radio_channels_t* radio_channel_list;
|
||||||
radio_channels_t* radio_channel_current;
|
radio_channels_t* radio_channel_current;
|
||||||
|
float rangelow; ///< lowest tunable frequency in MHz
|
||||||
|
float rangehigh; ///< highest tunable frequency in MHz
|
||||||
int driver;
|
int driver;
|
||||||
int old_snd_volume;
|
int old_snd_volume;
|
||||||
#ifdef USE_RADIO_CAPTURE
|
#ifdef USE_RADIO_CAPTURE
|
||||||
|
@ -186,7 +188,7 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){
|
||||||
|
|
||||||
priv->radio_channel_current->freq=atof(tmp);
|
priv->radio_channel_current->freq=atof(tmp);
|
||||||
|
|
||||||
if (priv->radio_channel_current->freq == 0)
|
if ((priv->radio_channel_current->freq>priv->rangehigh)||(priv->radio_channel_current->freq<priv->rangelow))
|
||||||
mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_WrongFreqForChannel,
|
mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_WrongFreqForChannel,
|
||||||
priv->radio_channel_current->name);
|
priv->radio_channel_current->name);
|
||||||
|
|
||||||
|
@ -272,6 +274,10 @@ static int init_frac_v4l2(radio_priv_t* priv){
|
||||||
priv->frac=16;
|
priv->frac=16;
|
||||||
mp_msg(MSGT_RADIO,MSGL_DBG2,MSGTR_RADIO_TunerCapLowNo,priv->frac);
|
mp_msg(MSGT_RADIO,MSGL_DBG2,MSGTR_RADIO_TunerCapLowNo,priv->frac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->rangelow=((float)tuner.rangelow)/priv->frac;
|
||||||
|
priv->rangehigh=((float)tuner.rangehigh)/priv->frac;
|
||||||
|
mp_msg(MSGT_RADIO,MSGL_V,MSGTR_RADIO_FreqRange,priv->rangelow,priv->rangehigh);
|
||||||
return STREAM_OK;
|
return STREAM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,6 +421,11 @@ static int init_frac_v4l(radio_priv_t* priv){
|
||||||
priv->frac=16;
|
priv->frac=16;
|
||||||
mp_msg(MSGT_RADIO,MSGL_DBG2,MSGTR_RADIO_TunerCapLowNo,priv->frac);
|
mp_msg(MSGT_RADIO,MSGL_DBG2,MSGTR_RADIO_TunerCapLowNo,priv->frac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->rangelow=((float)tuner.rangelow)/priv->frac;
|
||||||
|
priv->rangehigh=((float)tuner.rangehigh)/priv->frac;
|
||||||
|
mp_msg(MSGT_RADIO,MSGL_V,MSGTR_RADIO_FreqRange,priv->rangelow,priv->rangehigh);
|
||||||
|
|
||||||
return STREAM_OK;
|
return STREAM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,6 +535,10 @@ static inline int init_frac(radio_priv_t* priv){
|
||||||
return STREAM_ERROR;
|
return STREAM_ERROR;
|
||||||
}
|
}
|
||||||
static inline int set_frequency(radio_priv_t* priv,float frequency){
|
static inline int set_frequency(radio_priv_t* priv,float frequency){
|
||||||
|
if ((frequency<priv->rangelow)||(frequency>priv->rangehigh)){
|
||||||
|
mp_msg(MSGT_RADIO,MSGL_ERR,MSGTR_RADIO_WrongFreq,frequency);
|
||||||
|
return STREAM_ERROR;
|
||||||
|
}
|
||||||
switch(priv->driver){
|
switch(priv->driver){
|
||||||
#ifdef HAVE_RADIO_V4L
|
#ifdef HAVE_RADIO_V4L
|
||||||
case RADIO_DRIVER_V4L:
|
case RADIO_DRIVER_V4L:
|
||||||
|
@ -1034,7 +1049,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
|
||||||
return STREAM_ERROR;
|
return STREAM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frequency==0){
|
if ((frequency<priv->rangelow)||(frequency>priv->rangehigh)){
|
||||||
mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_WrongFreq,frequency);
|
mp_msg(MSGT_RADIO, MSGL_ERR, MSGTR_RADIO_WrongFreq,frequency);
|
||||||
close_s(stream);
|
close_s(stream);
|
||||||
return STREAM_ERROR;
|
return STREAM_ERROR;
|
||||||
|
|
Loading…
Reference in New Issue