2010-01-30 23:26:47 +01:00
|
|
|
/*
|
2015-04-13 09:36:54 +02:00
|
|
|
* This file is part of mpv.
|
2010-01-30 23:26:47 +01:00
|
|
|
*
|
2015-04-13 09:36:54 +02:00
|
|
|
* mpv is free software; you can redistribute it and/or modify
|
2010-01-30 23:26:47 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2015-04-13 09:36:54 +02:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-30 23:26:47 +01:00
|
|
|
* 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
|
2015-04-13 09:36:54 +02:00
|
|
|
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-30 23:26:47 +01:00
|
|
|
*/
|
|
|
|
|
2008-02-22 10:09:46 +01:00
|
|
|
#ifndef MPLAYER_AUDIO_IN_H
|
|
|
|
#define MPLAYER_AUDIO_IN_H
|
2002-08-22 00:50:40 +02:00
|
|
|
|
|
|
|
#define AUDIO_IN_ALSA 1
|
|
|
|
#define AUDIO_IN_OSS 2
|
2013-09-28 18:01:12 +02:00
|
|
|
#define AUDIO_IN_SNDIO 3
|
2002-08-22 00:50:40 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-12-21 20:24:20 +01:00
|
|
|
struct mp_log;
|
|
|
|
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_ALSA
|
2002-08-22 00:50:40 +02:00
|
|
|
#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
|
|
|
|
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_OSS_AUDIO
|
2002-08-22 00:50:40 +02:00
|
|
|
typedef struct {
|
|
|
|
char *device;
|
|
|
|
|
|
|
|
int audio_fd;
|
|
|
|
} ai_oss_t;
|
2002-12-28 14:39:51 +01:00
|
|
|
#endif
|
2002-08-22 00:50:40 +02:00
|
|
|
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_SNDIO
|
2013-09-28 18:01:12 +02:00
|
|
|
#include <sndio.h>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *device;
|
|
|
|
|
|
|
|
struct sio_hdl *hdl;
|
|
|
|
} ai_sndio_t;
|
|
|
|
#endif
|
|
|
|
|
2009-05-13 04:58:57 +02:00
|
|
|
typedef struct
|
2002-08-22 00:50:40 +02:00
|
|
|
{
|
2013-12-21 20:24:20 +01:00
|
|
|
struct mp_log *log;
|
2002-08-22 00:50:40 +02:00
|
|
|
int type;
|
|
|
|
int setup;
|
2009-05-13 04:58:57 +02:00
|
|
|
|
2002-08-22 00:50:40 +02:00
|
|
|
/* requested values */
|
|
|
|
int req_channels;
|
|
|
|
int req_samplerate;
|
|
|
|
|
|
|
|
/* real values read-only */
|
|
|
|
int channels;
|
|
|
|
int samplerate;
|
|
|
|
int blocksize;
|
|
|
|
int bytes_per_sample;
|
|
|
|
int samplesize;
|
2009-05-13 04:58:57 +02:00
|
|
|
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_ALSA
|
2002-08-22 00:50:40 +02:00
|
|
|
ai_alsa_t alsa;
|
|
|
|
#endif
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_OSS_AUDIO
|
2002-08-22 00:50:40 +02:00
|
|
|
ai_oss_t oss;
|
2002-12-28 14:39:51 +01:00
|
|
|
#endif
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_SNDIO
|
2013-09-28 18:01:12 +02:00
|
|
|
ai_sndio_t sndio;
|
|
|
|
#endif
|
2002-08-22 00:50:40 +02:00
|
|
|
} audio_in_t;
|
|
|
|
|
2013-12-21 20:24:20 +01:00
|
|
|
int audio_in_init(audio_in_t *ai, struct mp_log *log, int type);
|
2002-08-22 00:50:40 +02:00
|
|
|
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);
|
|
|
|
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_ALSA
|
2002-08-22 00:50:40 +02:00
|
|
|
int ai_alsa_setup(audio_in_t *ai);
|
|
|
|
int ai_alsa_init(audio_in_t *ai);
|
2002-10-02 18:46:55 +02:00
|
|
|
int ai_alsa_xrun(audio_in_t *ai);
|
2002-08-22 00:50:40 +02:00
|
|
|
#endif
|
|
|
|
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_OSS_AUDIO
|
2002-08-22 00:50:40 +02:00
|
|
|
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);
|
2002-12-28 14:39:51 +01:00
|
|
|
#endif
|
2002-08-22 00:50:40 +02:00
|
|
|
|
2013-07-16 13:28:28 +02:00
|
|
|
#if HAVE_SNDIO
|
2013-09-28 18:01:12 +02:00
|
|
|
int ai_sndio_setup(audio_in_t *ai);
|
|
|
|
int ai_sndio_init(audio_in_t *ai);
|
|
|
|
#endif
|
|
|
|
|
2008-02-22 10:09:46 +01:00
|
|
|
#endif /* MPLAYER_AUDIO_IN_H */
|