1 /*
2    Copyright (C) 2004-2006 Jean-Marc Valin
3    Copyright (C) 2006 Commonwealth Scientific and Industrial Research
4                       Organisation (CSIRO) Australia
5 
6    Redistribution and use in source and binary forms, with or without
7    modification, are permitted provided that the following conditions are
8    met:
9 
10    1. Redistributions of source code must retain the above copyright notice,
11    this list of conditions and the following disclaimer.
12 
13    2. Redistributions in binary form must reproduce the above copyright
14    notice, this list of conditions and the following disclaimer in the
15    documentation and/or other materials provided with the distribution.
16 
17    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20    DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
21    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27    POSSIBILITY OF SUCH DAMAGE.
28 
29 */
30 
31 #ifndef ALSA_DEVICE_H
32 #define ALSA_DEVICE_H
33 
34 #include <sys/poll.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 struct AlsaDevice_;
41 
42 typedef struct AlsaDevice_ AlsaDevice;
43 
44 AlsaDevice *alsa_device_open(char *device_name, unsigned int rate, int channels, int period);
45 
46 void alsa_device_close(AlsaDevice *dev);
47 
48 int alsa_device_read(AlsaDevice *dev, short *pcm, int len);
49 
50 int alsa_device_write(AlsaDevice *dev, const short *pcm, int len);
51 
52 int alsa_device_capture_ready(AlsaDevice *dev, struct pollfd *pfds, unsigned int nfds);
53 
54 int alsa_device_playback_ready(AlsaDevice *dev, struct pollfd *pfds, unsigned int nfds);
55 
56 void alsa_device_start(AlsaDevice *dev);
57 
58 int alsa_device_nfds(AlsaDevice *dev);
59 
60 void alsa_device_getfds(AlsaDevice *dev, struct pollfd *pfds, unsigned int nfds);
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif
67