Debian Codegraph @

swig/audio.swg

raw
1 /* -*- c -*-
2 Copyright (C) 2006, 2008, 2011, 2017 Rocky Bernstein <[email protected]>
3
4 This program 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 3 of the License, or
7 (at your option) any later version.
8
9 This program 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.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /** NOTE: This is most of the easily-converted subset of libcdio's <cdio/audio.h>.
19 For more, feel free to dig in and add.
20 **/
21
22 /* See <cdio/audio.h> for more extensive documentation. */
23
24 %rename cdio_audio_pause audio_pause;
25 %feature("autodoc",
26 "audio_pause(cdio)->status
27
28 Pause playing CD through analog output.");
29 driver_return_code_t cdio_audio_pause (CdIo_t *p_cdio);
30
31
32 %feature("autodoc",
33 "audio_play_track_index(cdio, start_track, start_index, end_track, end_index)->status
34
35 Playing CD through analog output at the desired start track and index,
36 to the end track and index. Tracks should be in the valid CD track range 0..99.
37
38 Just as a track number is burned into the CD, so is a an index for a track.
39 It gives a position within the track. Use 0 for the beginning.
40 ");
41 driver_return_code_t audio_play_track_index (CdIo_t *p_cdio,
42 int start_track, int start_index,
43 int end_track, int end_index);
44 %inline %{
45
46 #ifndef CLAMP
47 # define CLAMP(val, min_value, max_value) \
48 ( (val < min_value ? min_value : \
49 ((val > max_value) ? max_value : val)) )
50 #endif
51
52 driver_return_code_t audio_play_track_index(CdIo_t *p_cdio,
53 int start_track, int start_index,
54 int end_track, int end_index)
55 {
56 cdio_track_index_t track_index;
57
58 track_index.i_start_track = (uint8_t) (CLAMP(start_track, 0, 99));
59 track_index.i_start_index = (uint8_t) (CLAMP(start_index, 0, 255));
60 track_index.i_start_track = (uint8_t) (CLAMP(end_track, 0, 99));
61 track_index.i_end_track = (uint8_t) (CLAMP(end_index, 0, 99));
62 return cdio_audio_play_track_index(p_cdio, &track_index);
63 }
64 %}
65
66
67 %feature("autodoc",
68 "auto_play_lsn(cdio, start_lsn, end_lsn)->status
69
70 Playing CD through analog output at the given lsn to the ending lsn");
71 driver_return_code_t audio_play_lsn (CdIo_t *p_cdio, lsn_t start_lsn,
72 lsn_t end_lsn);
73 %inline %{
74 driver_return_code_t audio_play_lsn (CdIo_t *p_cdio, lsn_t start_lsn,
75 lsn_t end_lsn)
76 {
77 msf_t start_msf;
78 msf_t end_msf;
79 cdio_lsn_to_msf (start_lsn, &start_msf);
80 cdio_lsn_to_msf (end_lsn, &end_msf);
81 return cdio_audio_play_msf(p_cdio, &start_msf, &end_msf);
82 }
83 %}
84
85 %rename cdio_audio_resume audio_resume;
86 %feature("autodoc",
87 "audio_resume(cdio)->status
88 Resume playing an audio CD.");
89 driver_return_code_t cdio_audio_resume (CdIo_t *p_cdio);
90
91
92 %rename cdio_audio_stop audio_stop;
93 %feature("autodoc",
94 "audio_stop(cdio)->status
95 Stop playing an audio CD.");
96 driver_return_code_t cdio_audio_stop (CdIo_t *p_cdio);
97
98 %feature("autodoc",
99 "return audio volume levels array");
100
101
102 %typemap(out) uint8_t,int {
103 $result = sv_newmortal();
104 sv_setiv($result,(IV) $1);
105 argvi++;
106 }
107 %typemap(out) uint8_t*,int* {
108 AV *myav;
109 SV **svs;
110 if ($1) {
111 svs = (SV **) malloc(4*sizeof(SV *));
112 svs[0] = sv_newmortal();
113 sv_setiv((SV*) svs[0],$1[0]);
114 svs[1] = sv_newmortal();
115 sv_setiv((SV*) svs[1],$1[1]);
116 svs[2] = sv_newmortal();
117 sv_setiv((SV*) svs[2],$1[2]);
118 svs[3] = sv_newmortal();
119 sv_setiv((SV*) svs[3],$1[3]);
120 myav = av_make(4,svs);
121 free(svs);
122 $result = newRV_noinc((SV*)myav);
123 sv_2mortal($result);
124 argvi++;
125 }
126
127 }
128
129 %apply int *OUTPUT { int *rc };
130 uint8_t *audio_get_volume_levels (CdIo_t *p_cdio, int *rc);
131
132 %inline %{
133 uint8_t *audio_get_volume_levels (CdIo_t *p_cdio, int *rc)
134 {
135 static uint8_t _volume[4];
136
137 driver_return_code_t drc;
138 drc = cdio_audio_get_volume (p_cdio, (cdio_audio_volume_t*)&_volume);
139 *rc = drc;
140 return _volume;
141 }
142 %}
143
144 %feature("autodoc",
145 "audio_set_volume_levels(cdio, channel0, channel1, channel2, channel3)->status
146
147 Set volume levels for playing CD through analog output. For strereo
148 CDROM devices's (which is most of them) only channel0 and channel1 are
149 used. 0 is the smallest volume and 255 is the largest valume. Values
150 above 255 will be pegged at 255 and values below 0 will be pegged at
151 0.
152 ");
153 int audio_set_volume_levels(CdIo_t *p_cdio,
154 int channel_vol1, int channel_vol2,
155 int channel_vol3, int channel_vol4);
156
157 %inline %{
158
159 #ifndef CLAMP
160 # define CLAMP(val, min_value, max_value) \
161 ( (val < min_value ? min_value : \
162 ((val > max_value) ? max_value : val)) )
163 #endif
164
165 int audio_set_volume_levels(CdIo_t *p_cdio,
166 int channel_vol1, int channel_vol2,
167 int channel_vol3, int channel_vol4)
168 {
169 static cdio_audio_volume_t audio_volume;
170
171 audio_volume.level[0] = CLAMP(channel_vol1, 0, 255);
172 audio_volume.level[1] = CLAMP(channel_vol2, 0, 255);
173 audio_volume.level[2] = CLAMP(channel_vol3, 0, 255);
174 audio_volume.level[3] = CLAMP(channel_vol4, 0, 255);
175 return cdio_audio_set_volume(p_cdio, &audio_volume);
176 }
177 %}
178
179
180 %apply int *OUTPUT { int *drc };
181 SV * audio_get_status ( CdIo_t *p_cdio, int *drc);
182 %inline %{
183 extern uint8_t cdio_from_bcd8(uint8_t p);
184 //static cdio_subchannel_t cdio_subchannel;
185 SV * audio_get_status ( CdIo_t *p_cdio, int *drc)
186 {
187 static cdio_subchannel_t sub;
188 driver_return_code_t rc;
189 HV * audio_st;
190 char *a_s_t;
191 rc = cdio_audio_read_subchannel(p_cdio, &sub);
192 *drc = rc;
193 audio_st = newHV();
194 /* unsigned int msf_seconds(msf_t *msf) or
195 *
196 */
197 switch(sub.audio_status) {
198 case 0x00:
199 a_s_t = "INVALID";
200 break;
201 case 0x11:
202 a_s_t = "playing";
203 break;
204 case 0x12:
205 a_s_t = "paused";
206 break;
207 case 0x13:
208 a_s_t = "completed";
209 break;
210 case 0x14:
211 a_s_t = "ERROR";
212 break;
213 case 0x15:
214 a_s_t = "NO_STATUS";
215 break;
216 default:
217 a_s_t = "UNKNOWN";
218 }
219 hv_store(audio_st, "format", 6,
220 newSVuv(sub.format), 0);
221 hv_store(audio_st, "audio_status", 12,
222 newSVuv(sub.audio_status), 0);
223 hv_store(audio_st, "status_text", 11,
224 newSVpv(a_s_t, 0), 0);
225 hv_store(audio_st, "address", 7,
226 newSVuv(sub.address), 0);
227 hv_store(audio_st, "control", 7,
228 newSVuv(sub.control), 0);
229 hv_store(audio_st, "track", 5,
230 newSVuv(sub.track), 0);
231 hv_store(audio_st, "index", 5,
232 newSVuv(sub.index), 0);
233 hv_store(audio_st, "abs_m", 5,
234 newSVuv(cdio_from_bcd8(sub.abs_addr.m)), 0);
235 hv_store(audio_st, "abs_s", 5,
236 newSVuv(cdio_from_bcd8(sub.abs_addr.s)), 0);
237 hv_store(audio_st, "abs_f", 5,
238 newSVuv(cdio_from_bcd8(sub.abs_addr.f)), 0);
239 hv_store(audio_st, "disk_s", 6,
240 newSVuv(cdio_audio_get_msf_seconds(&sub.abs_addr)),0);
241 hv_store(audio_st, "rel_m", 5,
242 newSVuv(cdio_from_bcd8(sub.rel_addr.m)), 0);
243 hv_store(audio_st, "rel_s", 5,
244 newSVuv(cdio_from_bcd8(sub.rel_addr.s)), 0);
245 hv_store(audio_st, "rel_f", 5,
246 newSVuv(cdio_from_bcd8(sub.rel_addr.f)), 0);
247 hv_store(audio_st, "track_s", 7,
248 newSVuv(cdio_audio_get_msf_seconds(&sub.rel_addr)),0);
249
250 return newRV_noinc(sv_2mortal((SV*)audio_st));
251 }
252 %}