From 37388ebb0ef9085c841d7f94e665a5a77cfe0e92 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Jul 2013 13:28:28 +0200 Subject: configure: uniform the defines to #define HAVE_xxx (0|1) The configure followed 5 different convetions of defines because the next guy always wanted to introduce a new better way to uniform it[1]. For an hypothetic feature 'hurr' you could have had: * #define HAVE_HURR 1 / #undef HAVE_DURR * #define HAVE_HURR / #undef HAVE_DURR * #define CONFIG_HURR 1 / #undef CONFIG_DURR * #define HAVE_HURR 1 / #define HAVE_DURR 0 * #define CONFIG_HURR 1 / #define CONFIG_DURR 0 All is now uniform and uses: * #define HAVE_HURR 1 * #define HAVE_DURR 0 We like definining to 0 as opposed to `undef` bcause it can help spot typos and is very helpful when doing big reorganizations in the code. [1]: http://xkcd.com/927/ related --- stream/stream_radio.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'stream/stream_radio.c') diff --git a/stream/stream_radio.c b/stream/stream_radio.c index de2f474bc9..9bbfcbecb1 100644 --- a/stream/stream_radio.c +++ b/stream/stream_radio.c @@ -37,7 +37,7 @@ #include -#ifdef CONFIG_RADIO_V4L2 +#if HAVE_RADIO_V4L2 #include #endif @@ -48,13 +48,13 @@ #include "stream_radio.h" #include "libavutil/avstring.h" -#ifdef CONFIG_RADIO_CAPTURE +#if HAVE_RADIO_CAPTURE #include "audio_in.h" -#ifdef HAVE_SYS_SOUNDCARD_H +#if HAVE_SYS_SOUNDCARD_H #include #else -#ifdef HAVE_SOUNDCARD_H +#if HAVE_SOUNDCARD_H #include #else #include @@ -93,7 +93,7 @@ typedef struct radio_priv_s { float rangehigh; ///< highest tunable frequency in MHz const struct radio_driver_s* driver; int old_snd_volume; -#ifdef CONFIG_RADIO_CAPTURE +#if HAVE_RADIO_CAPTURE volatile int do_capture; ///< is capture enabled audio_in_t audio_in; unsigned char* audio_ringbuffer; @@ -125,7 +125,7 @@ static const m_option_t stream_opts_fields[] = { }; static void close_s(struct stream *stream); -#ifdef CONFIG_RADIO_CAPTURE +#if HAVE_RADIO_CAPTURE static int clear_buffer(radio_priv_t* priv); #endif @@ -221,7 +221,7 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){ return STREAM_OK; } -#ifdef CONFIG_RADIO_V4L2 +#if HAVE_RADIO_V4L2 /***************************************************************** * \brief get fraction value for using in set_frequency and get_frequency * \return STREAM_OK if success, STREAM_ERROR otherwise @@ -378,7 +378,7 @@ static const radio_driver_t radio_driver_v4l2={ set_frequency_v4l2, get_frequency_v4l2 }; -#endif /* CONFIG_RADIO_V4L2 */ +#endif /* HAVE_RADIO_V4L2 */ static inline int init_frac(radio_priv_t* priv){ return priv->driver->init_frac(priv); @@ -391,7 +391,7 @@ static inline int set_frequency(radio_priv_t* priv,float frequency){ if(priv->driver->set_frequency(priv,frequency)!=STREAM_OK) return STREAM_ERROR; -#ifdef CONFIG_RADIO_CAPTURE +#if HAVE_RADIO_CAPTURE if(clear_buffer(priv)!=STREAM_OK){ mp_tmsg(MSGT_RADIO,MSGL_ERR,"[radio] Clearing buffer failed: %s\n",strerror(errno)); return STREAM_ERROR; @@ -410,7 +410,7 @@ static inline int get_volume(radio_priv_t* priv,int* volume){ } -#ifndef CONFIG_RADIO_CAPTURE +#if !HAVE_RADIO_CAPTURE /***************************************************************** * \brief stub, if capture disabled at compile-time * \return STREAM_OK @@ -441,7 +441,7 @@ static int read_chunk(audio_in_t *ai, unsigned char *buffer) int ret; switch (ai->type) { -#ifdef CONFIG_ALSA +#if HAVE_ALSA case AUDIO_IN_ALSA: //device opened in non-blocking mode ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size); @@ -463,7 +463,7 @@ static int read_chunk(audio_in_t *ai, unsigned char *buffer) } return ret; #endif -#ifdef CONFIG_OSS_AUDIO +#if HAVE_OSS_AUDIO case AUDIO_IN_OSS: { int bt=0; @@ -562,7 +562,7 @@ static int init_audio(radio_priv_t *priv) priv->do_capture=1; mp_tmsg(MSGT_RADIO,MSGL_V,"[radio] Starting capture stuff.\n"); -#ifdef CONFIG_ALSA +#if HAVE_ALSA while ((tmp = strrchr(priv->radio_param->adevice, '='))){ tmp[0] = ':'; //adevice option looks like ALSA device name. Switching to ALSA @@ -584,11 +584,11 @@ static int init_audio(radio_priv_t *priv) mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] audio_in_setup call failed: %s\n", strerror(errno)); return STREAM_ERROR; } -#ifdef CONFIG_OSS_AUDIO +#if HAVE_OSS_AUDIO if(is_oss) ioctl(priv->audio_in.oss.audio_fd, SNDCTL_DSP_NONBLOCK, 0); #endif -#ifdef CONFIG_ALSA +#if HAVE_ALSA if(!is_oss) snd_pcm_nonblock(priv->audio_in.alsa.handle,1); #endif @@ -616,7 +616,7 @@ static int init_audio(radio_priv_t *priv) return STREAM_OK; } -#endif /* CONFIG_RADIO_CAPTURE */ +#endif /* HAVE_RADIO_CAPTURE */ /*------------------------------------------------------------------------- for call from mplayer.c @@ -788,7 +788,7 @@ char* radio_get_channel_name(struct stream *stream){ static int fill_buffer_s(struct stream *s, char *buffer, int max_len){ int len=max_len; -#ifdef CONFIG_RADIO_CAPTURE +#if HAVE_RADIO_CAPTURE radio_priv_t* priv=(radio_priv_t*)s->priv; if (priv->do_capture){ @@ -806,7 +806,7 @@ static int fill_buffer_s(struct stream *s, char *buffer, int max_len){ when no driver explicitly specified first available will be used */ static const radio_driver_t* radio_drivers[]={ -#ifdef CONFIG_RADIO_V4L2 +#if HAVE_RADIO_V4L2 &radio_driver_v4l2, #endif 0 @@ -837,7 +837,7 @@ static int open_s(stream_t *stream,int mode) priv->radio_param=stream->priv; stream->priv=NULL; -#ifdef CONFIG_RADIO_CAPTURE +#if HAVE_RADIO_CAPTURE if (priv->radio_param->capture && strncmp("capture",priv->radio_param->capture,7)==0) priv->do_capture=1; else @@ -934,7 +934,7 @@ static void close_s(struct stream *stream){ radio_channels_t * tmp; if (!priv) return; -#ifdef CONFIG_RADIO_CAPTURE +#if HAVE_RADIO_CAPTURE free(priv->audio_ringbuffer); priv->audio_ringbuffer = NULL; -- cgit v1.2.3