1 /*
2 * sndio play and grab interface
3 * Copyright (c) 2010 Jacob Meuser
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <stdint.h>
24
26
28
30 {
32
33 s->hwpos +=
delta *
s->channels *
s->bps;
34 }
35
37 const char *audio_device)
38 {
40 struct sio_hdl *hdl;
41 struct sio_par par;
42
43 hdl = sio_open(audio_device, is_output ? SIO_PLAY : SIO_REC, 0);
44 if (!hdl) {
47 }
48
49 sio_initpar(&par);
50
51 par.bits = 16;
52 par.sig = 1;
53 par.le = SIO_LE_NATIVE;
54
55 if (is_output)
56 par.pchan =
s->channels;
57 else
58 par.rchan =
s->channels;
59 par.rate =
s->sample_rate;
60
61 if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par)) {
63 "channels: %d sample rate: %d\n",
s->channels,
s->sample_rate);
65 }
66
67 if (par.bits != 16 || par.sig != 1 ||
68 (is_output && (par.pchan !=
s->channels)) ||
69 (!is_output && (par.rchan !=
s->channels)) ||
70 (par.rate !=
s->sample_rate)) {
72 "channels: %d sample rate: %d\n",
s->channels,
s->sample_rate);
74 }
75
76 s->buffer_size = par.round * par.bps *
77 (is_output ? par.pchan : par.rchan);
78
79 if (is_output) {
84 }
85 }
86
88 s->channels = is_output ? par.pchan : par.rchan;
89 s->sample_rate = par.rate;
91
93
94 if (!sio_start(hdl)) {
97 }
98
100
101 return 0;
102
105
106 if (hdl)
107 sio_close(hdl);
108
110 }
111
113 {
115
118
119 return 0;
120 }