summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-07-16 13:28:28 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-11-03 21:59:54 +0100
commit37388ebb0ef9085c841d7f94e665a5a77cfe0e92 (patch)
treeb47d18bee4e7f661d9e6d794dac0ec1cebcd3a37 /stream
parent891a2a1f474add323145e6b2cd2d29181830e4a4 (diff)
downloadmpv-37388ebb0ef9085c841d7f94e665a5a77cfe0e92.tar.bz2
mpv-37388ebb0ef9085c841d7f94e665a5a77cfe0e92.tar.xz
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
Diffstat (limited to 'stream')
-rw-r--r--stream/ai_oss.c4
-rw-r--r--stream/audio_in.c50
-rw-r--r--stream/audio_in.h18
-rw-r--r--stream/stream.c20
-rw-r--r--stream/stream_radio.c40
-rw-r--r--stream/tv.c4
-rw-r--r--stream/tvi_v4l2.c8
7 files changed, 72 insertions, 72 deletions
diff --git a/stream/ai_oss.c b/stream/ai_oss.c
index 52cdb71b8d..46e232b264 100644
--- a/stream/ai_oss.c
+++ b/stream/ai_oss.c
@@ -26,10 +26,10 @@
#include <errno.h>
#include <sys/ioctl.h>
-#ifdef HAVE_SYS_SOUNDCARD_H
+#if HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
#else
-#ifdef HAVE_SOUNDCARD_H
+#if HAVE_SOUNDCARD_H
#include <soundcard.h>
#else
#include <linux/soundcard.h>
diff --git a/stream/audio_in.c b/stream/audio_in.c
index 420311e848..6cfbcda129 100644
--- a/stream/audio_in.c
+++ b/stream/audio_in.c
@@ -40,20 +40,20 @@ int audio_in_init(audio_in_t *ai, int type)
ai->samplesize = -1;
switch (ai->type) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
case AUDIO_IN_ALSA:
ai->alsa.handle = NULL;
ai->alsa.log = NULL;
ai->alsa.device = strdup("default");
return 0;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
case AUDIO_IN_OSS:
ai->oss.audio_fd = -1;
ai->oss.device = strdup("/dev/dsp");
return 0;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
case AUDIO_IN_SNDIO:
ai->sndio.hdl = NULL;
ai->sndio.device = strdup("default");
@@ -68,19 +68,19 @@ int audio_in_setup(audio_in_t *ai)
{
switch (ai->type) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
case AUDIO_IN_ALSA:
if (ai_alsa_init(ai) < 0) return -1;
ai->setup = 1;
return 0;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
case AUDIO_IN_OSS:
if (ai_oss_init(ai) < 0) return -1;
ai->setup = 1;
return 0;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
case AUDIO_IN_SNDIO:
if (ai_sndio_init(ai) < 0) return -1;
ai->setup = 1;
@@ -94,21 +94,21 @@ int audio_in_setup(audio_in_t *ai)
int audio_in_set_samplerate(audio_in_t *ai, int rate)
{
switch (ai->type) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
case AUDIO_IN_ALSA:
ai->req_samplerate = rate;
if (!ai->setup) return 0;
if (ai_alsa_setup(ai) < 0) return -1;
return ai->samplerate;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
case AUDIO_IN_OSS:
ai->req_samplerate = rate;
if (!ai->setup) return 0;
if (ai_oss_set_samplerate(ai) < 0) return -1;
return ai->samplerate;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
case AUDIO_IN_SNDIO:
ai->req_samplerate = rate;
if (!ai->setup) return 0;
@@ -123,21 +123,21 @@ int audio_in_set_samplerate(audio_in_t *ai, int rate)
int audio_in_set_channels(audio_in_t *ai, int channels)
{
switch (ai->type) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
case AUDIO_IN_ALSA:
ai->req_channels = channels;
if (!ai->setup) return 0;
if (ai_alsa_setup(ai) < 0) return -1;
return ai->channels;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
case AUDIO_IN_OSS:
ai->req_channels = channels;
if (!ai->setup) return 0;
if (ai_oss_set_channels(ai) < 0) return -1;
return ai->channels;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
case AUDIO_IN_SNDIO:
ai->req_channels = channels;
if (!ai->setup) return 0;
@@ -151,12 +151,12 @@ int audio_in_set_channels(audio_in_t *ai, int channels)
int audio_in_set_device(audio_in_t *ai, char *device)
{
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
int i;
#endif
if (ai->setup) return -1;
switch (ai->type) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
case AUDIO_IN_ALSA:
free(ai->alsa.device);
ai->alsa.device = strdup(device);
@@ -166,13 +166,13 @@ int audio_in_set_device(audio_in_t *ai, char *device)
}
return 0;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
case AUDIO_IN_OSS:
free(ai->oss.device);
ai->oss.device = strdup(device);
return 0;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
case AUDIO_IN_SNDIO:
if (ai->sndio.device) free(ai->sndio.device);
ai->sndio.device = strdup(device);
@@ -187,7 +187,7 @@ int audio_in_uninit(audio_in_t *ai)
{
if (ai->setup) {
switch (ai->type) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
case AUDIO_IN_ALSA:
if (ai->alsa.log)
snd_output_close(ai->alsa.log);
@@ -197,13 +197,13 @@ int audio_in_uninit(audio_in_t *ai)
ai->setup = 0;
return 0;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
case AUDIO_IN_OSS:
close(ai->oss.audio_fd);
ai->setup = 0;
return 0;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
case AUDIO_IN_SNDIO:
if (ai->sndio.hdl)
sio_close(ai->sndio.hdl);
@@ -218,15 +218,15 @@ int audio_in_uninit(audio_in_t *ai)
int audio_in_start_capture(audio_in_t *ai)
{
switch (ai->type) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
case AUDIO_IN_ALSA:
return snd_pcm_start(ai->alsa.handle);
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
case AUDIO_IN_OSS:
return 0;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
case AUDIO_IN_SNDIO:
if (!sio_start(ai->sndio.hdl))
return -1;
@@ -242,7 +242,7 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
int ret;
switch (ai->type) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
case AUDIO_IN_ALSA:
ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size);
if (ret != ai->alsa.chunk_size) {
@@ -262,7 +262,7 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
}
return ret;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
case AUDIO_IN_OSS:
ret = read(ai->oss.audio_fd, buffer, ai->blocksize);
if (ret != ai->blocksize) {
@@ -276,7 +276,7 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
}
return ret;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
case AUDIO_IN_SNDIO:
ret = sio_read(ai->sndio.hdl, buffer, ai->blocksize);
if (ret != ai->blocksize) {
diff --git a/stream/audio_in.h b/stream/audio_in.h
index 2f42685c7c..af2cecd28d 100644
--- a/stream/audio_in.h
+++ b/stream/audio_in.h
@@ -25,7 +25,7 @@
#include "config.h"
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
#include <alsa/asoundlib.h>
typedef struct {
@@ -38,7 +38,7 @@ typedef struct {
} ai_alsa_t;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
typedef struct {
char *device;
@@ -46,7 +46,7 @@ typedef struct {
} ai_oss_t;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
#include <sndio.h>
typedef struct {
@@ -72,13 +72,13 @@ typedef struct
int bytes_per_sample;
int samplesize;
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
ai_alsa_t alsa;
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
ai_oss_t oss;
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
ai_sndio_t sndio;
#endif
} audio_in_t;
@@ -92,19 +92,19 @@ int audio_in_uninit(audio_in_t *ai);
int audio_in_start_capture(audio_in_t *ai);
int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer);
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
int ai_alsa_setup(audio_in_t *ai);
int ai_alsa_init(audio_in_t *ai);
int ai_alsa_xrun(audio_in_t *ai);
#endif
-#ifdef CONFIG_OSS_AUDIO
+#if HAVE_OSS_AUDIO
int ai_oss_set_samplerate(audio_in_t *ai);
int ai_oss_set_channels(audio_in_t *ai);
int ai_oss_init(audio_in_t *ai);
#endif
-#ifdef CONFIG_SNDIO
+#if HAVE_SNDIO
int ai_sndio_setup(audio_in_t *ai);
int ai_sndio_init(audio_in_t *ai);
#endif
diff --git a/stream/stream.c b/stream/stream.c
index 186fc7c79d..fbc324563a 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -80,34 +80,34 @@ extern const stream_info_t stream_info_rar_filter;
extern const stream_info_t stream_info_rar_entry;
static const stream_info_t *const stream_list[] = {
-#ifdef CONFIG_VCD
+#if HAVE_VCD
&stream_info_vcd,
#endif
-#ifdef CONFIG_CDDA
+#if HAVE_CDDA
&stream_info_cdda,
#endif
&stream_info_ffmpeg,
&stream_info_avdevice,
-#ifdef CONFIG_DVBIN
+#if HAVE_DVBIN
&stream_info_dvb,
#endif
-#ifdef CONFIG_TV
+#if HAVE_TV
&stream_info_tv,
#endif
-#ifdef CONFIG_RADIO
+#if HAVE_RADIO
&stream_info_radio,
#endif
-#ifdef CONFIG_PVR
+#if HAVE_PVR
&stream_info_pvr,
#endif
-#ifdef CONFIG_LIBSMBCLIENT
+#if HAVE_LIBSMBCLIENT
&stream_info_smb,
#endif
-#ifdef CONFIG_DVDREAD
+#if HAVE_DVDREAD
&stream_info_ifo,
&stream_info_dvd,
#endif
-#ifdef CONFIG_LIBBLURAY
+#if HAVE_LIBBLURAY
&stream_info_bluray,
#endif
@@ -804,7 +804,7 @@ static int stream_enable_cache(stream_t **stream, int64_t size, int64_t min,
int res = -1;
-#ifdef CONFIG_STREAM_CACHE
+#if HAVE_STREAM_CACHE
res = stream_cache_init(cache, orig, size, min, seek_limit);
#endif
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 <linux/types.h>
-#ifdef CONFIG_RADIO_V4L2
+#if HAVE_RADIO_V4L2
#include <linux/videodev2.h>
#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 <sys/soundcard.h>
#else
-#ifdef HAVE_SOUNDCARD_H
+#if HAVE_SOUNDCARD_H
#include <soundcard.h>
#else
#include <linux/soundcard.h>
@@ -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;
diff --git a/stream/tv.c b/stream/tv.c
index 43a516e202..dd76230a2e 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -60,7 +60,7 @@ extern const tvi_info_t tvi_info_v4l2;
/** List of drivers in autodetection order */
static const tvi_info_t* tvi_driver_list[]={
-#ifdef CONFIG_TV_V4L2
+#if HAVE_TV_V4L2
&tvi_info_v4l2,
#endif
&tvi_info_dummy,
@@ -474,7 +474,7 @@ static int open_tv(tvi_handle_t *tvh)
funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tvh->tv_param->input);
if ((!strcmp(tvh->tv_param->driver, "v4l2") && tvh->tv_param->normid >= 0))
- tv_set_norm_i(tvh, tvh->tv_param->normid);
+ tv_set_norm_i(tvh, tvh->tv_param->normid);
else
tv_set_norm(tvh,tvh->tv_param->norm);
diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c
index 135fcbf8ff..5891ac4556 100644
--- a/stream/tvi_v4l2.c
+++ b/stream/tvi_v4l2.c
@@ -46,10 +46,10 @@ known issues:
#include <sys/types.h>
#include <unistd.h>
#include <math.h>
-#ifdef HAVE_SYS_SYSINFO_H
+#if HAVE_SYS_SYSINFO_H
#include <sys/sysinfo.h>
#endif
-#ifdef HAVE_SYS_VIDEOIO_H
+#if HAVE_SYS_VIDEOIO_H
#include <sys/videoio.h>
#else
#include <linux/types.h>
@@ -400,7 +400,7 @@ static void init_audio(priv_t *priv)
if (priv->audio_initialized) return;
if (!priv->tv_param->noaudio) {
-#ifdef CONFIG_ALSA
+#if HAVE_ALSA
if (priv->tv_param->alsa)
audio_in_init(&priv->audio_in, AUDIO_IN_ALSA);
else
@@ -1321,7 +1321,7 @@ static int get_capture_buffer_size(priv_t *priv)
if (priv->tv_param->buffer_size >= 0) {
bufsize = priv->tv_param->buffer_size*1024*1024;
} else {
-#ifdef HAVE_SYS_SYSINFO_H
+#if HAVE_SYS_SYSINFO_H
struct sysinfo si;
sysinfo(&si);