ao: fix crash after ao init failure (from recent 3a5fd15fa2)
[mplayer/greg.git] / stream / audio_in.h
blob31688e71926cf0d6cf544a89d9f592023313df5c
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_AUDIO_IN_H
20 #define MPLAYER_AUDIO_IN_H
22 #define AUDIO_IN_ALSA 1
23 #define AUDIO_IN_OSS 2
25 #include "config.h"
27 #ifdef CONFIG_ALSA
28 #include <alsa/asoundlib.h>
30 typedef struct {
31 char *device;
33 snd_pcm_t *handle;
34 snd_output_t *log;
35 int buffer_time, period_time, chunk_size;
36 size_t bits_per_sample, bits_per_frame;
37 } ai_alsa_t;
38 #endif
40 #ifdef CONFIG_OSS_AUDIO
41 typedef struct {
42 char *device;
44 int audio_fd;
45 } ai_oss_t;
46 #endif
48 typedef struct
50 int type;
51 int setup;
53 /* requested values */
54 int req_channels;
55 int req_samplerate;
57 /* real values read-only */
58 int channels;
59 int samplerate;
60 int blocksize;
61 int bytes_per_sample;
62 int samplesize;
64 #ifdef CONFIG_ALSA
65 ai_alsa_t alsa;
66 #endif
67 #ifdef CONFIG_OSS_AUDIO
68 ai_oss_t oss;
69 #endif
70 } audio_in_t;
72 int audio_in_init(audio_in_t *ai, int type);
73 int audio_in_setup(audio_in_t *ai);
74 int audio_in_set_device(audio_in_t *ai, char *device);
75 int audio_in_set_samplerate(audio_in_t *ai, int rate);
76 int audio_in_set_channels(audio_in_t *ai, int channels);
77 int audio_in_uninit(audio_in_t *ai);
78 int audio_in_start_capture(audio_in_t *ai);
79 int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer);
81 #ifdef CONFIG_ALSA
82 int ai_alsa_setup(audio_in_t *ai);
83 int ai_alsa_init(audio_in_t *ai);
84 int ai_alsa_xrun(audio_in_t *ai);
85 #endif
87 #ifdef CONFIG_OSS_AUDIO
88 int ai_oss_set_samplerate(audio_in_t *ai);
89 int ai_oss_set_channels(audio_in_t *ai);
90 int ai_oss_init(audio_in_t *ai);
91 #endif
93 #endif /* MPLAYER_AUDIO_IN_H */