3 Copyright (C) 1998-2000, Michael Pruett <michael@68k.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307 USA.
24 This file contains an implementation of SGI's Audio Library parameter
32 #include "aupvinternal.h"
35 AUpvlist
AUpvnew (int maxitems
)
41 return AU_NULL_PVLIST
;
43 aupvlist
= (AUpvlist
) malloc(sizeof (struct _AUpvlist
));
46 return AU_NULL_PVLIST
;
48 aupvlist
->items
= calloc(maxitems
, sizeof (struct _AUpvitem
));
50 assert(aupvlist
->items
);
51 if (aupvlist
->items
== NULL
)
54 return AU_NULL_PVLIST
;
57 /* Initialize the items in the list. */
58 for (i
=0; i
<maxitems
; i
++)
60 aupvlist
->items
[i
].valid
= _AU_VALID_PVITEM
;
61 aupvlist
->items
[i
].type
= AU_PVTYPE_LONG
;
62 aupvlist
->items
[i
].parameter
= 0;
63 memset(&aupvlist
->items
[i
].value
, 0, sizeof (aupvlist
->items
[i
].value
));
66 aupvlist
->valid
= _AU_VALID_PVLIST
;
67 aupvlist
->count
= maxitems
;
72 int AUpvgetmaxitems (AUpvlist list
)
76 if (list
== AU_NULL_PVLIST
)
78 if (list
->valid
!= _AU_VALID_PVLIST
)
84 int AUpvfree (AUpvlist list
)
89 if (list
== AU_NULL_PVLIST
)
91 if (list
->valid
!= _AU_VALID_PVLIST
)
94 if ((list
->items
!= _AU_NULL_PVITEM
) &&
95 (list
->items
[0].valid
== _AU_VALID_PVITEM
))
105 int AUpvsetparam (AUpvlist list
, int item
, int param
)
110 assert(item
< list
->count
);
112 if (list
== AU_NULL_PVLIST
)
113 return AU_BAD_PVLIST
;
114 if (list
->valid
!= _AU_VALID_PVLIST
)
115 return AU_BAD_PVLIST
;
116 if ((item
< 0) || (item
> list
->count
- 1))
117 return AU_BAD_PVITEM
;
118 if (list
->items
[item
].valid
!= _AU_VALID_PVITEM
)
119 return AU_BAD_PVLIST
;
121 list
->items
[item
].parameter
= param
;
125 int AUpvsetvaltype (AUpvlist list
, int item
, int type
)
130 assert(item
< list
->count
);
132 if (list
== AU_NULL_PVLIST
)
133 return AU_BAD_PVLIST
;
134 if (list
->valid
!= _AU_VALID_PVLIST
)
135 return AU_BAD_PVLIST
;
136 if ((item
< 0) || (item
> list
->count
- 1))
137 return AU_BAD_PVITEM
;
138 if (list
->items
[item
].valid
!= _AU_VALID_PVITEM
)
139 return AU_BAD_PVLIST
;
141 list
->items
[item
].type
= type
;
145 int AUpvsetval (AUpvlist list
, int item
, void *val
)
150 assert(item
< list
->count
);
152 if (list
== AU_NULL_PVLIST
)
153 return AU_BAD_PVLIST
;
154 if (list
->valid
!= _AU_VALID_PVLIST
)
155 return AU_BAD_PVLIST
;
156 if ((item
< 0) || (item
> list
->count
- 1))
157 return AU_BAD_PVITEM
;
158 if (list
->items
[item
].valid
!= _AU_VALID_PVITEM
)
159 return AU_BAD_PVLIST
;
161 switch (list
->items
[item
].type
)
164 list
->items
[item
].value
.l
= *((long *) val
);
166 case AU_PVTYPE_DOUBLE
:
167 list
->items
[item
].value
.d
= *((double *) val
);
170 list
->items
[item
].value
.v
= *((void **) val
);
174 return AU_BAD_PVLIST
;
180 int AUpvgetparam (AUpvlist list
, int item
, int *param
)
185 assert(item
< list
->count
);
187 if (list
== AU_NULL_PVLIST
)
188 return AU_BAD_PVLIST
;
189 if (list
->valid
!= _AU_VALID_PVLIST
)
190 return AU_BAD_PVLIST
;
191 if ((item
< 0) || (item
> list
->count
- 1))
192 return AU_BAD_PVITEM
;
193 if (list
->items
[item
].valid
!= _AU_VALID_PVITEM
)
194 return AU_BAD_PVLIST
;
196 *param
= list
->items
[item
].parameter
;
200 int AUpvgetvaltype (AUpvlist list
, int item
, int *type
)
205 assert(item
< list
->count
);
207 if (list
== AU_NULL_PVLIST
)
208 return AU_BAD_PVLIST
;
209 if (list
->valid
!= _AU_VALID_PVLIST
)
210 return AU_BAD_PVLIST
;
211 if ((item
< 0) || (item
> list
->count
- 1))
212 return AU_BAD_PVITEM
;
213 if (list
->items
[item
].valid
!= _AU_VALID_PVITEM
)
214 return AU_BAD_PVLIST
;
216 *type
= list
->items
[item
].type
;
220 int AUpvgetval (AUpvlist list
, int item
, void *val
)
225 assert(item
< list
->count
);
227 if (list
== AU_NULL_PVLIST
)
228 return AU_BAD_PVLIST
;
229 if (list
->valid
!= _AU_VALID_PVLIST
)
230 return AU_BAD_PVLIST
;
231 if ((item
< 0) || (item
> list
->count
- 1))
232 return AU_BAD_PVITEM
;
233 if (list
->items
[item
].valid
!= _AU_VALID_PVITEM
)
234 return AU_BAD_PVLIST
;
236 switch (list
->items
[item
].type
)
239 *((long *) val
) = list
->items
[item
].value
.l
;
241 case AU_PVTYPE_DOUBLE
:
242 *((double *) val
) = list
->items
[item
].value
.d
;
245 *((void **) val
) = list
->items
[item
].value
.v
;