|
0 |
#! /bin/sh /usr/share/dpatch/dpatch-run
|
|
1 |
## flac-1.1.4.dpatch by Samuel Mimram <smimram@debian.org>
|
|
2 |
##
|
|
3 |
## All lines beginning with `## DP:' are a description of the patch.
|
|
4 |
## DP: Adapt to FLAC 1.1.4 API.
|
|
5 |
## DP: Patch stolen from http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/lib/libsndfile/flac-1.1.4.patch.
|
|
6 |
|
|
7 |
@DPATCH@
|
|
8 |
diff -urNad libsndfile-1.0.17~/configure.ac libsndfile-1.0.17/configure.ac
|
|
9 |
--- libsndfile-1.0.17~/configure.ac 2006-08-31 11:39:37.000000000 +0200
|
|
10 |
+++ libsndfile-1.0.17/configure.ac 2007-06-15 12:38:53.000000000 +0200
|
|
11 |
@@ -339,7 +339,8 @@
|
|
12 |
if test "x$HAVE_FLAC_1_1_1" = xyes ; then
|
|
13 |
AC_DEFINE(HAVE_FLAC_1_1_1, [1], [Define to 1 if you have libflac 1.1.1])
|
|
14 |
fi
|
|
15 |
- FLAC_LIBS="-lFLAC"
|
|
16 |
+ # in FLAC 1.1.3 libOggFLAC was merged into libFLAC, hence we need -logg
|
|
17 |
+ FLAC_LIBS="-lFLAC -logg"
|
|
18 |
fi
|
|
19 |
fi
|
|
20 |
|
|
21 |
diff -urNad libsndfile-1.0.17~/src/flac.c libsndfile-1.0.17/src/flac.c
|
|
22 |
--- libsndfile-1.0.17~/src/flac.c 2006-08-31 11:22:19.000000000 +0200
|
|
23 |
+++ libsndfile-1.0.17/src/flac.c 2007-06-15 12:38:53.000000000 +0200
|
|
24 |
@@ -46,6 +46,13 @@
|
|
25 |
#include "sfendian.h"
|
|
26 |
#include "float_cast.h"
|
|
27 |
|
|
28 |
+/* FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 */
|
|
29 |
+#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
|
|
30 |
+#define LEGACY_FLAC
|
|
31 |
+#else
|
|
32 |
+#undef LEGACY_FLAC
|
|
33 |
+#endif
|
|
34 |
+
|
|
35 |
/*------------------------------------------------------------------------------
|
|
36 |
** Private static functions.
|
|
37 |
*/
|
|
38 |
@@ -60,8 +67,14 @@
|
|
39 |
} PFLAC_PCM ;
|
|
40 |
|
|
41 |
typedef struct
|
|
42 |
-{ FLAC__SeekableStreamDecoder *fsd ;
|
|
43 |
+{
|
|
44 |
+#ifdef LEGACY_FLAC
|
|
45 |
+ FLAC__SeekableStreamDecoder *fsd ;
|
|
46 |
FLAC__SeekableStreamEncoder *fse ;
|
|
47 |
+#else
|
|
48 |
+ FLAC__StreamDecoder *fsd ;
|
|
49 |
+ FLAC__StreamEncoder *fse ;
|
|
50 |
+#endif
|
|
51 |
PFLAC_PCM pcmtype ;
|
|
52 |
void* ptr ;
|
|
53 |
unsigned pos, len, remain ;
|
|
54 |
@@ -108,6 +121,7 @@
|
|
55 |
static int flac_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
|
|
56 |
|
|
57 |
/* Decoder Callbacks */
|
|
58 |
+#ifdef LEGACY_FLAC
|
|
59 |
static FLAC__SeekableStreamDecoderReadStatus sf_flac_read_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer [], unsigned *bytes, void *client_data) ;
|
|
60 |
static FLAC__SeekableStreamDecoderSeekStatus sf_flac_seek_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
|
|
61 |
static FLAC__SeekableStreamDecoderTellStatus sf_flac_tell_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
|
|
62 |
@@ -116,13 +130,29 @@
|
|
63 |
static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ;
|
|
64 |
static void sf_flac_meta_callback (const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) ;
|
|
65 |
static void sf_flac_error_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) ;
|
|
66 |
+#else
|
|
67 |
+static FLAC__StreamDecoderReadStatus sf_flac_read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte buffer [], size_t *bytes, void *client_data) ;
|
|
68 |
+static FLAC__StreamDecoderSeekStatus sf_flac_seek_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
|
|
69 |
+static FLAC__StreamDecoderTellStatus sf_flac_tell_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
|
|
70 |
+static FLAC__StreamDecoderLengthStatus sf_flac_length_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) ;
|
|
71 |
+static FLAC__bool sf_flac_eof_callback (const FLAC__StreamDecoder *decoder, void *client_data) ;
|
|
72 |
+static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ;
|
|
73 |
+static void sf_flac_meta_callback (const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) ;
|
|
74 |
+static void sf_flac_error_callback (const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) ;
|
|
75 |
+#endif
|
|
76 |
|
|
77 |
/* Encoder Callbacks */
|
|
78 |
+#ifdef LEGACY_FLAC
|
|
79 |
static FLAC__SeekableStreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
|
|
80 |
#ifdef HAVE_FLAC_1_1_1
|
|
81 |
static FLAC__SeekableStreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
|
|
82 |
#endif
|
|
83 |
static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer [], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data) ;
|
|
84 |
+#else
|
|
85 |
+static FLAC__StreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) ;
|
|
86 |
+static FLAC__StreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ;
|
|
87 |
+static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer [], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) ;
|
|
88 |
+#endif
|
|
89 |
|
|
90 |
static const int legal_sample_rates [] =
|
|
91 |
{ 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000
|
|
92 |
@@ -283,51 +313,99 @@
|
|
93 |
} /* flac_buffer_copy */
|
|
94 |
|
|
95 |
|
|
96 |
+#ifdef LEGACY_FLAC
|
|
97 |
static FLAC__SeekableStreamDecoderReadStatus
|
|
98 |
sf_flac_read_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__byte buffer [], unsigned *bytes, void *client_data)
|
|
99 |
+#else
|
|
100 |
+static FLAC__StreamDecoderReadStatus
|
|
101 |
+sf_flac_read_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__byte buffer [], size_t *bytes, void *client_data)
|
|
102 |
+#endif
|
|
103 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
104 |
|
|
105 |
*bytes = psf_fread (buffer, 1, *bytes, psf) ;
|
|
106 |
if (*bytes > 0 && psf->error == 0)
|
|
107 |
+#ifdef LEGACY_FLAC
|
|
108 |
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK ;
|
|
109 |
|
|
110 |
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR ;
|
|
111 |
+#else
|
|
112 |
+ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE ;
|
|
113 |
+
|
|
114 |
+ return FLAC__STREAM_DECODER_READ_STATUS_ABORT ;
|
|
115 |
+#endif
|
|
116 |
} /* sf_flac_read_callback */
|
|
117 |
|
|
118 |
+#ifdef LEGACY_FLAC
|
|
119 |
static FLAC__SeekableStreamDecoderSeekStatus
|
|
120 |
sf_flac_seek_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 absolute_byte_offset, void *client_data)
|
|
121 |
+#else
|
|
122 |
+static FLAC__StreamDecoderSeekStatus
|
|
123 |
+sf_flac_seek_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 absolute_byte_offset, void *client_data)
|
|
124 |
+#endif
|
|
125 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
126 |
|
|
127 |
psf_fseek (psf, absolute_byte_offset, SEEK_SET) ;
|
|
128 |
if (psf->error)
|
|
129 |
+#ifdef LEGACY_FLAC
|
|
130 |
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR ;
|
|
131 |
|
|
132 |
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK ;
|
|
133 |
+#else
|
|
134 |
+ return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR ;
|
|
135 |
+
|
|
136 |
+ return FLAC__STREAM_DECODER_SEEK_STATUS_OK ;
|
|
137 |
+#endif
|
|
138 |
} /* sf_flac_seek_callback */
|
|
139 |
|
|
140 |
+#ifdef LEGACY_FLAC
|
|
141 |
static FLAC__SeekableStreamDecoderTellStatus
|
|
142 |
sf_flac_tell_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 *absolute_byte_offset, void *client_data)
|
|
143 |
+#else
|
|
144 |
+static FLAC__StreamDecoderTellStatus
|
|
145 |
+sf_flac_tell_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 *absolute_byte_offset, void *client_data)
|
|
146 |
+#endif
|
|
147 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
148 |
|
|
149 |
*absolute_byte_offset = psf_ftell (psf) ;
|
|
150 |
if (psf->error)
|
|
151 |
+#ifdef LEGACY_FLAC
|
|
152 |
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR ;
|
|
153 |
|
|
154 |
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK ;
|
|
155 |
+#else
|
|
156 |
+ return FLAC__STREAM_DECODER_TELL_STATUS_ERROR ;
|
|
157 |
+
|
|
158 |
+ return FLAC__STREAM_DECODER_TELL_STATUS_OK ;
|
|
159 |
+#endif
|
|
160 |
} /* sf_flac_tell_callback */
|
|
161 |
|
|
162 |
+#ifdef LEGACY_FLAC
|
|
163 |
static FLAC__SeekableStreamDecoderLengthStatus
|
|
164 |
sf_flac_length_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__uint64 *stream_length, void *client_data)
|
|
165 |
+#else
|
|
166 |
+static FLAC__StreamDecoderLengthStatus
|
|
167 |
+sf_flac_length_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 *stream_length, void *client_data)
|
|
168 |
+#endif
|
|
169 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
170 |
|
|
171 |
if ((*stream_length = psf->filelength) == 0)
|
|
172 |
+#ifdef LEGACY_FLAC
|
|
173 |
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR ;
|
|
174 |
|
|
175 |
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK ;
|
|
176 |
+#else
|
|
177 |
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR ;
|
|
178 |
+
|
|
179 |
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_OK ;
|
|
180 |
+#endif
|
|
181 |
} /* sf_flac_length_callback */
|
|
182 |
|
|
183 |
static FLAC__bool
|
|
184 |
+#ifdef LEGACY_FLAC
|
|
185 |
sf_flac_eof_callback (const FLAC__SeekableStreamDecoder *UNUSED (decoder), void *client_data)
|
|
186 |
+#else
|
|
187 |
+sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_data)
|
|
188 |
+#endif
|
|
189 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
190 |
|
|
191 |
if (psf_ftell (psf) == psf->filelength)
|
|
192 |
@@ -337,7 +415,11 @@
|
|
193 |
} /* sf_flac_eof_callback */
|
|
194 |
|
|
195 |
static FLAC__StreamDecoderWriteStatus
|
|
196 |
+#ifdef LEGACY_FLAC
|
|
197 |
sf_flac_write_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data)
|
|
198 |
+#else
|
|
199 |
+sf_flac_write_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data)
|
|
200 |
+#endif
|
|
201 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
202 |
FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;
|
|
203 |
|
|
204 |
@@ -353,7 +435,11 @@
|
|
205 |
} /* sf_flac_write_callback */
|
|
206 |
|
|
207 |
static void
|
|
208 |
+#ifdef LEGACY_FLAC
|
|
209 |
sf_flac_meta_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data)
|
|
210 |
+#else
|
|
211 |
+sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data)
|
|
212 |
+#endif
|
|
213 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
214 |
|
|
215 |
switch (metadata->type)
|
|
216 |
@@ -387,7 +473,11 @@
|
|
217 |
} /* sf_flac_meta_callback */
|
|
218 |
|
|
219 |
static void
|
|
220 |
+#ifdef LEGACY_FLAC
|
|
221 |
sf_flac_error_callback (const FLAC__SeekableStreamDecoder * UNUSED (decoder), FLAC__StreamDecoderErrorStatus status, void *client_data)
|
|
222 |
+#else
|
|
223 |
+sf_flac_error_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__StreamDecoderErrorStatus status, void *client_data)
|
|
224 |
+#endif
|
|
225 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
226 |
|
|
227 |
psf_log_printf (psf, "ERROR : %s\n", FLAC__StreamDecoderErrorStatusString [status]) ;
|
|
228 |
@@ -407,17 +497,29 @@
|
|
229 |
return ;
|
|
230 |
} /* sf_flac_error_callback */
|
|
231 |
|
|
232 |
+#ifdef LEGACY_FLAC
|
|
233 |
static FLAC__SeekableStreamEncoderSeekStatus
|
|
234 |
sf_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder * UNUSED (encoder), FLAC__uint64 absolute_byte_offset, void *client_data)
|
|
235 |
+#else
|
|
236 |
+static FLAC__StreamEncoderSeekStatus
|
|
237 |
+sf_flac_enc_seek_callback (const FLAC__StreamEncoder * UNUSED (encoder), FLAC__uint64 absolute_byte_offset, void *client_data)
|
|
238 |
+#endif
|
|
239 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
240 |
|
|
241 |
psf_fseek (psf, absolute_byte_offset, SEEK_SET) ;
|
|
242 |
if (psf->error)
|
|
243 |
+#ifdef LEGACY_FLAC
|
|
244 |
return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR ;
|
|
245 |
|
|
246 |
return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK ;
|
|
247 |
+#else
|
|
248 |
+ return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR ;
|
|
249 |
+
|
|
250 |
+ return FLAC__STREAM_ENCODER_SEEK_STATUS_OK ;
|
|
251 |
+#endif
|
|
252 |
} /* sf_flac_enc_seek_callback */
|
|
253 |
|
|
254 |
+#ifdef LEGACY_FLAC
|
|
255 |
#ifdef HAVE_FLAC_1_1_1
|
|
256 |
static FLAC__SeekableStreamEncoderTellStatus
|
|
257 |
sf_flac_enc_tell_callback (const FLAC__SeekableStreamEncoder *UNUSED (encoder), FLAC__uint64 *absolute_byte_offset, void *client_data)
|
|
258 |
@@ -430,9 +532,25 @@
|
|
259 |
return FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_OK ;
|
|
260 |
} /* sf_flac_enc_tell_callback */
|
|
261 |
#endif
|
|
262 |
+#else
|
|
263 |
+static FLAC__StreamEncoderTellStatus
|
|
264 |
+sf_flac_enc_tell_callback (const FLAC__StreamEncoder *UNUSED (encoder), FLAC__uint64 *absolute_byte_offset, void *client_data)
|
|
265 |
+{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
266 |
+
|
|
267 |
+ *absolute_byte_offset = psf_ftell (psf) ;
|
|
268 |
+ if (psf->error)
|
|
269 |
+ return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR ;
|
|
270 |
+
|
|
271 |
+ return FLAC__STREAM_ENCODER_TELL_STATUS_OK ;
|
|
272 |
+} /* sf_flac_enc_tell_callback */
|
|
273 |
+#endif
|
|
274 |
|
|
275 |
static FLAC__StreamEncoderWriteStatus
|
|
276 |
+#ifdef LEGACY_FLAC
|
|
277 |
sf_flac_enc_write_callback (const FLAC__SeekableStreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], unsigned bytes, unsigned UNUSED (samples), unsigned UNUSED (current_frame), void *client_data)
|
|
278 |
+#else
|
|
279 |
+sf_flac_enc_write_callback (const FLAC__StreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], size_t bytes, unsigned UNUSED (samples), unsigned UNUSED (current_frame), void *client_data)
|
|
280 |
+#endif
|
|
281 |
{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
|
|
282 |
|
|
283 |
if (psf_fwrite (buffer, 1, bytes, psf) == bytes && psf->error == 0)
|
|
284 |
@@ -509,15 +627,27 @@
|
|
285 |
return 0 ;
|
|
286 |
|
|
287 |
if (psf->mode == SFM_WRITE)
|
|
288 |
- { FLAC__seekable_stream_encoder_finish (pflac->fse) ;
|
|
289 |
+ {
|
|
290 |
+#ifdef LEGACY_FLAC
|
|
291 |
+ FLAC__seekable_stream_encoder_finish (pflac->fse) ;
|
|
292 |
FLAC__seekable_stream_encoder_delete (pflac->fse) ;
|
|
293 |
+#else
|
|
294 |
+ FLAC__stream_encoder_finish (pflac->fse) ;
|
|
295 |
+ FLAC__stream_encoder_delete (pflac->fse) ;
|
|
296 |
+#endif
|
|
297 |
if (pflac->encbuffer)
|
|
298 |
free (pflac->encbuffer) ;
|
|
299 |
} ;
|
|
300 |
|
|
301 |
if (psf->mode == SFM_READ)
|
|
302 |
- { FLAC__seekable_stream_decoder_finish (pflac->fsd) ;
|
|
303 |
+ {
|
|
304 |
+#ifdef LEGACY_FLAC
|
|
305 |
+ FLAC__seekable_stream_decoder_finish (pflac->fsd) ;
|
|
306 |
FLAC__seekable_stream_decoder_delete (pflac->fsd) ;
|
|
307 |
+#else
|
|
308 |
+ FLAC__stream_decoder_finish (pflac->fsd) ;
|
|
309 |
+ FLAC__stream_decoder_delete (pflac->fsd) ;
|
|
310 |
+#endif
|
|
311 |
} ;
|
|
312 |
|
|
313 |
for (k = 0 ; k < ARRAY_LEN (pflac->rbuffer) ; k++)
|
|
314 |
@@ -546,17 +676,6 @@
|
|
315 |
return SFE_FLAC_BAD_SAMPLE_RATE ;
|
|
316 |
|
|
317 |
psf_fseek (psf, 0, SEEK_SET) ;
|
|
318 |
- if ((pflac->fse = FLAC__seekable_stream_encoder_new ()) == NULL)
|
|
319 |
- return SFE_FLAC_NEW_DECODER ;
|
|
320 |
- FLAC__seekable_stream_encoder_set_write_callback (pflac->fse, sf_flac_enc_write_callback) ;
|
|
321 |
- FLAC__seekable_stream_encoder_set_seek_callback (pflac->fse, sf_flac_enc_seek_callback) ;
|
|
322 |
-
|
|
323 |
-#ifdef HAVE_FLAC_1_1_1
|
|
324 |
- FLAC__seekable_stream_encoder_set_tell_callback (pflac->fse, sf_flac_enc_tell_callback) ;
|
|
325 |
-#endif
|
|
326 |
- FLAC__seekable_stream_encoder_set_client_data (pflac->fse, psf) ;
|
|
327 |
- FLAC__seekable_stream_encoder_set_channels (pflac->fse, psf->sf.channels) ;
|
|
328 |
- FLAC__seekable_stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate) ;
|
|
329 |
|
|
330 |
switch (psf->sf.format & SF_FORMAT_SUBMASK)
|
|
331 |
{ case SF_FORMAT_PCM_S8 :
|
|
332 |
@@ -574,12 +693,36 @@
|
|
333 |
break ;
|
|
334 |
} ;
|
|
335 |
|
|
336 |
+#ifdef LEGACY_FLAC
|
|
337 |
+ if ((pflac->fse = FLAC__seekable_stream_encoder_new ()) == NULL)
|
|
338 |
+ return SFE_FLAC_NEW_DECODER ;
|
|
339 |
+ FLAC__seekable_stream_encoder_set_write_callback (pflac->fse, sf_flac_enc_write_callback) ;
|
|
340 |
+ FLAC__seekable_stream_encoder_set_seek_callback (pflac->fse, sf_flac_enc_seek_callback) ;
|
|
341 |
+
|
|
342 |
+#ifdef HAVE_FLAC_1_1_1
|
|
343 |
+ FLAC__seekable_stream_encoder_set_tell_callback (pflac->fse, sf_flac_enc_tell_callback) ;
|
|
344 |
+#endif
|
|
345 |
+ FLAC__seekable_stream_encoder_set_client_data (pflac->fse, psf) ;
|
|
346 |
+ FLAC__seekable_stream_encoder_set_channels (pflac->fse, psf->sf.channels) ;
|
|
347 |
+ FLAC__seekable_stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate) ;
|
|
348 |
FLAC__seekable_stream_encoder_set_bits_per_sample (pflac->fse, bps) ;
|
|
349 |
|
|
350 |
if ((bps = FLAC__seekable_stream_encoder_init (pflac->fse)) != FLAC__SEEKABLE_STREAM_DECODER_OK)
|
|
351 |
{ psf_log_printf (psf, "Error : FLAC encoder init returned error : %s\n", FLAC__seekable_stream_encoder_get_resolved_state_string (pflac->fse)) ;
|
|
352 |
return SFE_FLAC_INIT_DECODER ;
|
|
353 |
} ;
|
|
354 |
+#else
|
|
355 |
+ if ((pflac->fse = FLAC__stream_encoder_new ()) == NULL)
|
|
356 |
+ return SFE_FLAC_NEW_DECODER ;
|
|
357 |
+ FLAC__stream_encoder_set_channels (pflac->fse, psf->sf.channels) ;
|
|
358 |
+ FLAC__stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate) ;
|
|
359 |
+ FLAC__stream_encoder_set_bits_per_sample (pflac->fse, bps) ;
|
|
360 |
+
|
|
361 |
+ if ((bps = FLAC__stream_encoder_init_stream (pflac->fse, sf_flac_enc_write_callback, sf_flac_enc_seek_callback, sf_flac_enc_tell_callback, NULL, psf)) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
|
362 |
+ { psf_log_printf (psf, "Error : FLAC encoder init returned error : %s\n", FLAC__StreamEncoderInitStatusString[bps]) ;
|
|
363 |
+ return SFE_FLAC_INIT_DECODER ;
|
|
364 |
+ } ;
|
|
365 |
+#endif
|
|
366 |
|
|
367 |
if (psf->error == 0)
|
|
368 |
psf->dataoffset = psf_ftell (psf) ;
|
|
369 |
@@ -593,6 +736,7 @@
|
|
370 |
{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;
|
|
371 |
|
|
372 |
psf_fseek (psf, 0, SEEK_SET) ;
|
|
373 |
+#ifdef LEGACY_FLAC
|
|
374 |
if ((pflac->fsd = FLAC__seekable_stream_decoder_new ()) == NULL)
|
|
375 |
return SFE_FLAC_NEW_DECODER ;
|
|
376 |
|
|
377 |
@@ -610,9 +754,22 @@
|
|
378 |
return SFE_FLAC_INIT_DECODER ;
|
|
379 |
|
|
380 |
FLAC__seekable_stream_decoder_process_until_end_of_metadata (pflac->fsd) ;
|
|
381 |
+#else
|
|
382 |
+ if ((pflac->fsd = FLAC__stream_decoder_new ()) == NULL)
|
|
383 |
+ return SFE_FLAC_NEW_DECODER ;
|
|
384 |
+
|
|
385 |
+ if (FLAC__stream_decoder_init_stream (pflac->fsd, sf_flac_read_callback, sf_flac_seek_callback, sf_flac_tell_callback, sf_flac_length_callback, sf_flac_eof_callback, sf_flac_write_callback, sf_flac_meta_callback, sf_flac_error_callback, psf) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
|
386 |
+ return SFE_FLAC_INIT_DECODER ;
|
|
387 |
+
|
|
388 |
+ FLAC__stream_decoder_process_until_end_of_metadata (pflac->fsd) ;
|
|
389 |
+#endif
|
|
390 |
if (psf->error == 0)
|
|
391 |
{ FLAC__uint64 position ;
|
|
392 |
+#ifdef LEGACY_FLAC
|
|
393 |
FLAC__seekable_stream_decoder_get_decode_position (pflac->fsd, &position) ;
|
|
394 |
+#else
|
|
395 |
+ FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ;
|
|
396 |
+#endif
|
|
397 |
psf->dataoffset = position ;
|
|
398 |
} ;
|
|
399 |
|
|
400 |
@@ -676,10 +833,18 @@
|
|
401 |
flac_buffer_copy (psf) ;
|
|
402 |
|
|
403 |
while (pflac->pos < pflac->len)
|
|
404 |
- { if (FLAC__seekable_stream_decoder_process_single (pflac->fsd) == 0)
|
|
405 |
+ {
|
|
406 |
+#ifdef LEGACY_FLAC
|
|
407 |
+ if (FLAC__seekable_stream_decoder_process_single (pflac->fsd) == 0)
|
|
408 |
break ;
|
|
409 |
if (FLAC__seekable_stream_decoder_get_state (pflac->fsd) != FLAC__SEEKABLE_STREAM_DECODER_OK)
|
|
410 |
break ;
|
|
411 |
+#else
|
|
412 |
+ if (FLAC__stream_decoder_process_single (pflac->fsd) == 0)
|
|
413 |
+ break ;
|
|
414 |
+ if (FLAC__stream_decoder_get_state (pflac->fsd) >= FLAC__STREAM_DECODER_END_OF_STREAM)
|
|
415 |
+ break ;
|
|
416 |
+#endif
|
|
417 |
} ;
|
|
418 |
|
|
419 |
pflac->ptr = NULL ;
|
|
420 |
@@ -795,7 +960,11 @@
|
|
421 |
while (len > 0)
|
|
422 |
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
|
423 |
convert (ptr + total, buffer, writecount) ;
|
|
424 |
+#ifdef LEGACY_FLAC
|
|
425 |
if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
|
426 |
+#else
|
|
427 |
+ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
|
428 |
+#endif
|
|
429 |
thiswrite = writecount ;
|
|
430 |
else
|
|
431 |
break ;
|
|
432 |
@@ -837,7 +1006,11 @@
|
|
433 |
while (len > 0)
|
|
434 |
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
|
435 |
convert (ptr + total, buffer, writecount) ;
|
|
436 |
+#ifdef LEGACY_FLAC
|
|
437 |
if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
|
438 |
+#else
|
|
439 |
+ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
|
440 |
+#endif
|
|
441 |
thiswrite = writecount ;
|
|
442 |
else
|
|
443 |
break ;
|
|
444 |
@@ -879,7 +1052,11 @@
|
|
445 |
while (len > 0)
|
|
446 |
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
|
447 |
convert (ptr + total, buffer, writecount, psf->norm_float) ;
|
|
448 |
+#ifdef LEGACY_FLAC
|
|
449 |
if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
|
450 |
+#else
|
|
451 |
+ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
|
452 |
+#endif
|
|
453 |
thiswrite = writecount ;
|
|
454 |
else
|
|
455 |
break ;
|
|
456 |
@@ -1011,7 +1188,11 @@
|
|
457 |
while (len > 0)
|
|
458 |
{ writecount = (len >= bufferlen) ? bufferlen : (int) len ;
|
|
459 |
convert (ptr + total, buffer, writecount, psf->norm_double) ;
|
|
460 |
+#ifdef LEGACY_FLAC
|
|
461 |
if (FLAC__seekable_stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
|
462 |
+#else
|
|
463 |
+ if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount/psf->sf.channels))
|
|
464 |
+#endif
|
|
465 |
thiswrite = writecount ;
|
|
466 |
else
|
|
467 |
break ;
|
|
468 |
@@ -1131,10 +1312,17 @@
|
|
469 |
|
|
470 |
if (psf->mode == SFM_READ)
|
|
471 |
{ FLAC__uint64 position ;
|
|
472 |
+#ifdef LEGACY_FLAC
|
|
473 |
if (FLAC__seekable_stream_decoder_seek_absolute (pflac->fsd, offset))
|
|
474 |
{ FLAC__seekable_stream_decoder_get_decode_position (pflac->fsd, &position) ;
|
|
475 |
return offset ;
|
|
476 |
} ;
|
|
477 |
+#else
|
|
478 |
+ if (FLAC__stream_decoder_seek_absolute (pflac->fsd, offset))
|
|
479 |
+ { FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ;
|
|
480 |
+ return offset ;
|
|
481 |
+ } ;
|
|
482 |
+#endif
|
|
483 |
|
|
484 |
return ((sf_count_t) -1) ;
|
|
485 |
} ;
|