1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-30 11:02:10 +00:00
mpv/stream/audio_in.h
Stefano Pigozzi 37388ebb0e 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
2013-11-03 21:59:54 +01:00

113 lines
2.5 KiB
C

/*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPLAYER_AUDIO_IN_H
#define MPLAYER_AUDIO_IN_H
#define AUDIO_IN_ALSA 1
#define AUDIO_IN_OSS 2
#define AUDIO_IN_SNDIO 3
#include "config.h"
#if HAVE_ALSA
#include <alsa/asoundlib.h>
typedef struct {
char *device;
snd_pcm_t *handle;
snd_output_t *log;
int buffer_time, period_time, chunk_size;
size_t bits_per_sample, bits_per_frame;
} ai_alsa_t;
#endif
#if HAVE_OSS_AUDIO
typedef struct {
char *device;
int audio_fd;
} ai_oss_t;
#endif
#if HAVE_SNDIO
#include <sndio.h>
typedef struct {
char *device;
struct sio_hdl *hdl;
} ai_sndio_t;
#endif
typedef struct
{
int type;
int setup;
/* requested values */
int req_channels;
int req_samplerate;
/* real values read-only */
int channels;
int samplerate;
int blocksize;
int bytes_per_sample;
int samplesize;
#if HAVE_ALSA
ai_alsa_t alsa;
#endif
#if HAVE_OSS_AUDIO
ai_oss_t oss;
#endif
#if HAVE_SNDIO
ai_sndio_t sndio;
#endif
} audio_in_t;
int audio_in_init(audio_in_t *ai, int type);
int audio_in_setup(audio_in_t *ai);
int audio_in_set_device(audio_in_t *ai, char *device);
int audio_in_set_samplerate(audio_in_t *ai, int rate);
int audio_in_set_channels(audio_in_t *ai, int channels);
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);
#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
#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
#if HAVE_SNDIO
int ai_sndio_setup(audio_in_t *ai);
int ai_sndio_init(audio_in_t *ai);
#endif
#endif /* MPLAYER_AUDIO_IN_H */