Debian Codegraph @

src/audio/au_palmos.c

raw
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 2004 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author: Alan W Black ([email protected]) */
34 /* Date: July 2004 */
35 /*************************************************************************/
36 /* */
37 /* Audio support for PalmOS */
38 /* */
39 /*************************************************************************/
40
41 #include "cst_file.h"
42 #include <stdlib.h>
43 #include <sys/types.h>
44 #include "cst_string.h"
45 #include "cst_wave.h"
46 #include "cst_audio.h"
47
48 #include <System/SoundMgr.h>
49
50 cst_audiodev *audio_open_palmos(int sps, int channels, cst_audiofmt fmt)
51 {
52 cst_audiodev *ad;
53 int afmt;
54 int sfmts;
55 int afd;
56 int frag;
57
58 ad = cst_alloc(cst_audiodev, 1);
59 ad->sps = sps;
60 ad->channels = channels;
61 ad->fmt = fmt;
62 ad->platform_data = NULL;
63
64 if (ad->channels == 0)
65 ad->channels = 1;
66
67 ad->real_sps = ad->sps;
68
69 ad->real_channels = ad->channels;
70
71 #if 0
72 if (fmt == CST_AUDIO_LINEAR8 && (sfmts & AFMT_U8))
73 {
74 ad->real_fmt = CST_AUDIO_LINEAR8;
75 afmt = AFMT_U8;
76 }
77 else if (fmt == CST_AUDIO_MULAW && (sfmts & AFMT_MU_LAW))
78 {
79 ad->real_fmt = CST_AUDIO_MULAW;
80 afmt = AFMT_MU_LAW;
81 }
82 else if (CST_LITTLE_ENDIAN)
83 {
84 if (sfmts & AFMT_S16_LE)
85 {
86 ad->real_fmt = CST_AUDIO_LINEAR16;
87 afmt = AFMT_S16_LE;
88 }
89 else if (sfmts & AFMT_S16_BE) /* not likely */
90 {
91 ad->byteswap = 1;
92 ad->real_fmt = CST_AUDIO_LINEAR16;
93 afmt = AFMT_S16_BE;
94 }
95 else if (sfmts & AFMT_U8)
96 {
97 afmt = AFMT_U8;
98 ad->real_fmt = CST_AUDIO_LINEAR8;
99 }
100 else
101 {
102 cst_free(ad);
103 close(afd);
104 return NULL;
105 }
106 }
107 else
108 {
109 if (sfmts & AFMT_S16_BE)
110 {
111 ad->real_fmt = CST_AUDIO_LINEAR16;
112 afmt = AFMT_S16_BE;
113 }
114 else if (sfmts & AFMT_S16_LE) /* likely */
115 {
116 ad->real_fmt = CST_AUDIO_LINEAR16;
117 ad->byteswap = 1;
118 afmt = AFMT_S16_LE;
119 }
120 else if (sfmts & AFMT_U8)
121 {
122 ad->real_fmt = CST_AUDIO_LINEAR8;
123 afmt = AFMT_U8;
124 }
125 else
126 {
127 cst_free(ad);
128 close(afd);
129 return NULL;
130 }
131 }
132 #endif
133
134 return ad;
135 }
136
137 int audio_close_palmos(cst_audiodev *ad)
138 {
139 int rv=0;
140
141 if (ad == NULL)
142 return 0;
143
144 cst_free(ad);
145 return rv;
146 }
147
148 int audio_write_palmos(cst_audiodev *ad, void *samples, int num_bytes)
149 {
150 /* return write((int)ad->platform_data,samples,num_bytes); */
151 return 0;
152 }
153
154 int audio_flush_palmos(cst_audiodev *ad)
155 {
156 /* return ioctl((int)ad->platform_data, SNDCTL_DSP_SYNC, NULL); */
157 return 0;
158 }
159
160 int audio_drain_palmos(cst_audiodev *ad)
161 {
162 /* return ioctl((int)ad->platform_data, SNDCTL_DSP_RESET, NULL); */
163 return 0;
164 }