Import upstream version 1.9+git20221121.dbe69eb
Debian Janitor
5 months ago
281 | 281 | |
282 | 282 | static bool load_flac() { |
283 | 283 | #if !LINKALL |
284 | void *handle = dlopen(LIBFLAC, RTLD_NOW); | |
284 | void *handle = NULL; | |
285 | char name[30]; | |
285 | 286 | char *err; |
287 | ||
288 | sprintf(name, LIBFLAC, FLAC_API_VERSION_CURRENT < 12 ? 8 : 12); | |
289 | ||
290 | handle = dlopen(name, RTLD_NOW); | |
286 | 291 | |
287 | 292 | if (!handle) { |
288 | 293 | LOG_INFO("dlerror: %s", dlerror()); |
304 | 309 | return false; |
305 | 310 | } |
306 | 311 | |
307 | LOG_INFO("loaded "LIBFLAC); | |
312 | LOG_INFO("loaded %s", name); | |
308 | 313 | #endif |
309 | 314 | |
310 | 315 | return true; |
44 | 44 | |
45 | 45 | struct opus { |
46 | 46 | struct OggOpusFile *of; |
47 | bool end; | |
47 | 48 | #if FRAME_BUF |
48 | 49 | u8_t *write_buf; |
49 | 50 | #endif |
118 | 119 | |
119 | 120 | LOCK_S; |
120 | 121 | |
121 | if (stream.state <= DISCONNECT && !_buf_used(streambuf)) { | |
122 | if (stream.state <= DISCONNECT && u->end) { | |
122 | 123 | UNLOCK_S; |
123 | 124 | return DECODE_COMPLETE; |
124 | 125 | } |
170 | 171 | frames = process.max_in_frames; |
171 | 172 | write_buf = process.inbuf; |
172 | 173 | ); |
174 | ||
175 | u->end = frames == 0; | |
173 | 176 | |
174 | 177 | // write the decoded frames into outputbuf then unpack them (they are 16 bits) |
175 | 178 | n = OP(u, read, u->of, (opus_int16*) write_buf, frames * channels, NULL); |
272 | 275 | free(u->write_buf); |
273 | 276 | u->write_buf = NULL; |
274 | 277 | #endif |
278 | u->end = false; | |
275 | 279 | } |
276 | 280 | |
277 | 281 | static bool load_opus(void) { |
25 | 25 | |
26 | 26 | #define MAJOR_VERSION "1.9" |
27 | 27 | #define MINOR_VERSION "9" |
28 | #define MICRO_VERSION "1411" | |
28 | #define MICRO_VERSION "1414" | |
29 | 29 | |
30 | 30 | #if defined(CUSTOM_VERSION) |
31 | 31 | #define VERSION "v" MAJOR_VERSION "." MINOR_VERSION "-" MICRO_VERSION STR(CUSTOM_VERSION) |
189 | 189 | // dynamically loaded libraries at run time |
190 | 190 | |
191 | 191 | #if LINUX |
192 | #define LIBFLAC "libFLAC.so.8" | |
192 | #define LIBFLAC "libFLAC.so.%d" | |
193 | 193 | #define LIBMAD "libmad.so.0" |
194 | 194 | #define LIBMPG "libmpg123.so.0" |
195 | 195 | #define LIBVORBIS "libvorbisfile.so.3" |
204 | 204 | #endif |
205 | 205 | |
206 | 206 | #if OSX |
207 | #define LIBFLAC "libFLAC.8.dylib" | |
207 | #define LIBFLAC "libFLAC.%d.dylib" | |
208 | 208 | #define LIBMAD "libmad.0.dylib" |
209 | 209 | #define LIBMPG "libmpg123.0.dylib" |
210 | 210 | #define LIBVORBIS "libvorbisfile.3.dylib" |
232 | 232 | #endif |
233 | 233 | |
234 | 234 | #if FREEBSD |
235 | #define LIBFLAC "libFLAC.so.8" | |
235 | #define LIBFLAC "libFLAC.so.%d" | |
236 | 236 | #define LIBMAD "libmad.so.0" |
237 | 237 | #define LIBMPG "libmpg123.so.0" |
238 | 238 | #define LIBVORBIS "libvorbisfile.so.3" |
53 | 53 | |
54 | 54 | struct vorbis { |
55 | 55 | OggVorbis_File *vf; |
56 | bool opened; | |
56 | bool opened, end; | |
57 | 57 | #if FRAME_BUF |
58 | 58 | u8_t *write_buf; |
59 | 59 | #endif |
139 | 139 | |
140 | 140 | LOCK_S; |
141 | 141 | |
142 | if (stream.state <= DISCONNECT && !_buf_used(streambuf)) { | |
142 | if (stream.state <= DISCONNECT && v->end) { | |
143 | 143 | UNLOCK_S; |
144 | 144 | return DECODE_COMPLETE; |
145 | 145 | } |
203 | 203 | ); |
204 | 204 | |
205 | 205 | bytes = frames * 2 * channels; // samples returned are 16 bits |
206 | v->end = frames == 0; | |
206 | 207 | |
207 | 208 | // write the decoded frames into outputbuf even though they are 16 bits per sample, then unpack them |
208 | 209 | #ifdef TREMOR_ONLY |
310 | 311 | v->opened = false; |
311 | 312 | } |
312 | 313 | } |
314 | v->end = false; | |
313 | 315 | } |
314 | 316 | |
315 | 317 | static void vorbis_close(void) { |