summaryrefslogtreecommitdiff
path: root/multimedia/gst-plugins0.10-good/patches/patch-ac
blob: da906a97658000cc0dd0a20792a942e61e483f60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
$NetBSD: patch-ac,v 1.3 2007/01/13 09:18:21 wiz Exp $

--- ext/flac/gstflacdec.c.orig	2006-10-16 18:22:46.000000000 +0000
+++ ext/flac/gstflacdec.c
@@ -56,6 +56,12 @@
 
 #include <gst/tag/tag.h>
 
+#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
+#define LEGACY_FLAC
+#else
+#undef LEGACY_FLAC
+#endif
+
 GST_DEBUG_CATEGORY_STATIC (flacdec_debug);
 #define GST_CAT_DEFAULT flacdec_debug
 
@@ -93,9 +99,13 @@ static void gst_flac_dec_reset_decoders 
 static void gst_flac_dec_setup_seekable_decoder (GstFlacDec * flacdec);
 static void gst_flac_dec_setup_stream_decoder (GstFlacDec * flacdec);
 
+#ifdef LEGACY_FLAC
 static FLAC__SeekableStreamDecoderReadStatus
 gst_flac_dec_read_seekable (const FLAC__SeekableStreamDecoder * decoder,
     FLAC__byte buffer[], unsigned *bytes, void *client_data);
+static FLAC__StreamDecoderReadStatus
+gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
+    FLAC__byte buffer[], unsigned *bytes, void *client_data);
 static FLAC__SeekableStreamDecoderSeekStatus
 gst_flac_dec_seek (const FLAC__SeekableStreamDecoder * decoder,
     FLAC__uint64 position, void *client_data);
@@ -107,9 +117,6 @@ gst_flac_dec_length (const FLAC__Seekabl
     FLAC__uint64 * length, void *client_data);
 static FLAC__bool gst_flac_dec_eof (const FLAC__SeekableStreamDecoder * decoder,
     void *client_data);
-static FLAC__StreamDecoderReadStatus
-gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
-    FLAC__byte buffer[], unsigned *bytes, void *client_data);
 static FLAC__StreamDecoderWriteStatus
 gst_flac_dec_write_seekable (const FLAC__SeekableStreamDecoder * decoder,
     const FLAC__Frame * frame,
@@ -123,13 +130,38 @@ static void gst_flac_dec_metadata_callba
     const FLAC__StreamMetadata * metadata, void *client_data);
 static void gst_flac_dec_metadata_callback_stream (const FLAC__StreamDecoder *
     decoder, const FLAC__StreamMetadata * metadata, void *client_data);
-static void gst_flac_dec_metadata_callback (GstFlacDec * flacdec,
-    const FLAC__StreamMetadata * metadata);
 static void gst_flac_dec_error_callback_seekable (const
     FLAC__SeekableStreamDecoder * decoder,
     FLAC__StreamDecoderErrorStatus status, void *client_data);
 static void gst_flac_dec_error_callback_stream (const FLAC__StreamDecoder *
     decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
+#else
+static FLAC__StreamDecoderReadStatus
+gst_flac_dec_read_seekable (const FLAC__StreamDecoder * decoder,
+    FLAC__byte buffer[], size_t *bytes, void *client_data);
+static FLAC__StreamDecoderReadStatus
+gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
+    FLAC__byte buffer[], size_t *bytes, void *client_data);
+static FLAC__StreamDecoderSeekStatus
+gst_flac_dec_seek (const FLAC__StreamDecoder * decoder,
+    FLAC__uint64 position, void *client_data);
+static FLAC__StreamDecoderTellStatus
+gst_flac_dec_tell (const FLAC__StreamDecoder * decoder,
+    FLAC__uint64 * position, void *client_data);
+static FLAC__StreamDecoderLengthStatus
+gst_flac_dec_length (const FLAC__StreamDecoder * decoder,
+    FLAC__uint64 * length, void *client_data);
+static FLAC__bool gst_flac_dec_eof (const FLAC__StreamDecoder * decoder,
+    void *client_data);
+static FLAC__StreamDecoderWriteStatus
+gst_flac_dec_write_stream (const FLAC__StreamDecoder * decoder,
+    const FLAC__Frame * frame,
+    const FLAC__int32 * const buffer[], void *client_data);
+static void gst_flac_dec_metadata_callback_stream (const FLAC__StreamDecoder *
+    decoder, const FLAC__StreamMetadata * metadata, void *client_data);
+static void gst_flac_dec_error_callback_stream (const FLAC__StreamDecoder *
+    decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
+#endif
 
 GST_BOILERPLATE (GstFlacDec, gst_flac_dec, GstElement, GST_TYPE_ELEMENT);
 #define GST_FLAC_DEC_SRC_CAPS                             \
@@ -212,7 +244,11 @@ static void
 gst_flac_dec_reset_decoders (GstFlacDec * flacdec)
 {
   if (flacdec->seekable_decoder) {
+#ifdef LEGACY_FLAC
     FLAC__seekable_stream_decoder_delete (flacdec->seekable_decoder);
+#else
+    FLAC__stream_decoder_delete (flacdec->seekable_decoder);
+#endif
     flacdec->seekable_decoder = NULL;
   }
 
@@ -238,6 +274,7 @@ gst_flac_dec_setup_seekable_decoder (Gst
 {
   gst_flac_dec_reset_decoders (dec);
 
+#ifdef LEGACY_FLAC
   dec->seekable_decoder = FLAC__seekable_stream_decoder_new ();
 
   FLAC__seekable_stream_decoder_set_read_callback (dec->seekable_decoder,
@@ -259,6 +296,12 @@ gst_flac_dec_setup_seekable_decoder (Gst
   FLAC__seekable_stream_decoder_set_error_callback (dec->seekable_decoder,
       gst_flac_dec_error_callback_seekable);
   FLAC__seekable_stream_decoder_set_client_data (dec->seekable_decoder, dec);
+#else
+  dec->seekable_decoder = FLAC__stream_decoder_new ();
+
+  FLAC__stream_decoder_set_metadata_respond (dec->seekable_decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
+  FLAC__stream_decoder_set_md5_checking (dec->seekable_decoder, false); /* no point calculating since it's never checked here */
+#endif
 }
 
 static void
@@ -270,17 +313,21 @@ gst_flac_dec_setup_stream_decoder (GstFl
 
   dec->stream_decoder = FLAC__stream_decoder_new ();
 
+#ifdef LEGACY_FLAC
   FLAC__stream_decoder_set_read_callback (dec->stream_decoder,
       gst_flac_dec_read_stream);
   FLAC__stream_decoder_set_write_callback (dec->stream_decoder,
       gst_flac_dec_write_stream);
-  FLAC__stream_decoder_set_metadata_respond (dec->stream_decoder,
-      FLAC__METADATA_TYPE_VORBIS_COMMENT);
   FLAC__stream_decoder_set_metadata_callback (dec->stream_decoder,
       gst_flac_dec_metadata_callback_stream);
   FLAC__stream_decoder_set_error_callback (dec->stream_decoder,
       gst_flac_dec_error_callback_stream);
   FLAC__stream_decoder_set_client_data (dec->stream_decoder, dec);
+#else
+  FLAC__stream_decoder_set_md5_checking (dec->stream_decoder, false); /* no point calculating since it's never checked here */
+#endif
+  FLAC__stream_decoder_set_metadata_respond (dec->stream_decoder,
+      FLAC__METADATA_TYPE_VORBIS_COMMENT);
 }
 
 static void
@@ -544,6 +591,7 @@ gst_flac_dec_metadata_callback (GstFlacD
   }
 }
 
+#ifdef LEGACY_FLAC
 static void
 gst_flac_dec_metadata_callback_seekable (const FLAC__SeekableStreamDecoder * d,
     const FLAC__StreamMetadata * metadata, void *client_data)
@@ -552,6 +600,7 @@ gst_flac_dec_metadata_callback_seekable 
 
   gst_flac_dec_metadata_callback (dec, metadata);
 }
+#endif
 
 static void
 gst_flac_dec_metadata_callback_stream (const FLAC__StreamDecoder * decoder,
@@ -587,12 +636,14 @@ gst_flac_dec_error_callback (GstFlacDec 
   dec->last_flow = GST_FLOW_ERROR;
 }
 
+#ifdef LEGACY_FLAC
 static void
 gst_flac_dec_error_callback_seekable (const FLAC__SeekableStreamDecoder * d,
     FLAC__StreamDecoderErrorStatus status, void *client_data)
 {
   gst_flac_dec_error_callback (GST_FLAC_DEC (client_data), status);
 }
+#endif
 
 static void
 gst_flac_dec_error_callback_stream (const FLAC__StreamDecoder * d,
@@ -601,9 +652,15 @@ gst_flac_dec_error_callback_stream (cons
   gst_flac_dec_error_callback (GST_FLAC_DEC (client_data), status);
 }
 
+#ifdef LEGACY_FLAC
 static FLAC__SeekableStreamDecoderSeekStatus
 gst_flac_dec_seek (const FLAC__SeekableStreamDecoder * decoder,
     FLAC__uint64 position, void *client_data)
+#else
+static FLAC__StreamDecoderSeekStatus
+gst_flac_dec_seek (const FLAC__StreamDecoder * decoder,
+    FLAC__uint64 position, void *client_data)
+#endif
 {
   GstFlacDec *flacdec;
 
@@ -612,12 +669,22 @@ gst_flac_dec_seek (const FLAC__SeekableS
   GST_DEBUG ("seek %" G_GINT64_FORMAT, position);
   flacdec->offset = position;
 
+#ifdef LEGACY_FLAC
   return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
+#else
+  return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
+#endif
 }
 
+#ifdef LEGACY_FLAC
 static FLAC__SeekableStreamDecoderTellStatus
 gst_flac_dec_tell (const FLAC__SeekableStreamDecoder * decoder,
     FLAC__uint64 * position, void *client_data)
+#else
+static FLAC__StreamDecoderTellStatus
+gst_flac_dec_tell (const FLAC__StreamDecoder * decoder,
+    FLAC__uint64 * position, void *client_data)
+#endif
 {
   GstFlacDec *flacdec;
 
@@ -627,12 +694,22 @@ gst_flac_dec_tell (const FLAC__SeekableS
 
   GST_DEBUG ("tell %" G_GINT64_FORMAT, *position);
 
+#ifdef LEGACY_FLAC
   return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
+#else
+  return FLAC__STREAM_DECODER_TELL_STATUS_OK;
+#endif
 }
 
+#ifdef LEGACY_FLAC
 static FLAC__SeekableStreamDecoderLengthStatus
 gst_flac_dec_length (const FLAC__SeekableStreamDecoder * decoder,
     FLAC__uint64 * length, void *client_data)
+#else
+static FLAC__StreamDecoderLengthStatus
+gst_flac_dec_length (const FLAC__StreamDecoder * decoder,
+    FLAC__uint64 * length, void *client_data)
+#endif
 {
   GstFlacDec *flacdec;
   GstFormat fmt = GST_FORMAT_BYTES;
@@ -642,22 +719,40 @@ gst_flac_dec_length (const FLAC__Seekabl
   flacdec = GST_FLAC_DEC (client_data);
 
   if (!(peer = gst_pad_get_peer (flacdec->sinkpad)))
+#ifdef LEGACY_FLAC
     return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR;
+#else
+    return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
+#endif
   gst_pad_query_duration (peer, &fmt, &len);
   gst_object_unref (peer);
   if (fmt != GST_FORMAT_BYTES || len == -1)
+#ifdef LEGACY_FLAC
     return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR;
+#else
+    return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
+#endif
 
   *length = len;
 
   GST_DEBUG ("length %" G_GINT64_FORMAT, *length);
 
+#ifdef LEGACY_FLAC
   return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
+#else
+  return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
+#endif
 }
 
+#ifdef LEGACY_FLAC
 static FLAC__bool
 gst_flac_dec_eof (const FLAC__SeekableStreamDecoder * decoder,
     void *client_data)
+#else
+static FLAC__bool
+gst_flac_dec_eof (const FLAC__StreamDecoder * decoder,
+    void *client_data)
+#endif
 {
   GstFlacDec *flacdec;
   GstFormat fmt;
@@ -685,9 +780,15 @@ gst_flac_dec_eof (const FLAC__SeekableSt
   return ret;
 }
 
+#ifdef LEGACY_FLAC
 static FLAC__SeekableStreamDecoderReadStatus
 gst_flac_dec_read_seekable (const FLAC__SeekableStreamDecoder * decoder,
     FLAC__byte buffer[], unsigned *bytes, void *client_data)
+#else
+static FLAC__StreamDecoderReadStatus
+gst_flac_dec_read_seekable (const FLAC__StreamDecoder * decoder,
+    FLAC__byte buffer[], size_t *bytes, void *client_data)
+#endif
 {
   GstFlacDec *flacdec;
   GstBuffer *buf;
@@ -696,7 +797,11 @@ gst_flac_dec_read_seekable (const FLAC__
 
   if (gst_pad_pull_range (flacdec->sinkpad, flacdec->offset, *bytes,
           &buf) != GST_FLOW_OK)
+#ifdef LEGACY_FLAC
     return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
+#else
+    return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
+#endif
 
   GST_DEBUG ("Read %d bytes at %" G_GUINT64_FORMAT,
       GST_BUFFER_SIZE (buf), flacdec->offset);
@@ -705,12 +810,22 @@ gst_flac_dec_read_seekable (const FLAC__
   gst_buffer_unref (buf);
   flacdec->offset += *bytes;
 
+#ifdef LEGACY_FLAC
   return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
+#else
+  return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+#endif
 }
 
+#ifdef LEGACY_FLAC
 static FLAC__StreamDecoderReadStatus
 gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
     FLAC__byte buffer[], unsigned *bytes, void *client_data)
+#else
+static FLAC__StreamDecoderReadStatus
+gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
+    FLAC__byte buffer[], size_t *bytes, void *client_data)
+#endif
 {
   GstFlacDec *dec = GST_FLAC_DEC (client_data);
   guint len;
@@ -880,6 +995,7 @@ done:
   return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
 }
 
+#ifdef LEGACY_FLAC
 static FLAC__StreamDecoderWriteStatus
 gst_flac_dec_write_seekable (const FLAC__SeekableStreamDecoder * decoder,
     const FLAC__Frame * frame,
@@ -887,6 +1003,7 @@ gst_flac_dec_write_seekable (const FLAC_
 {
   return gst_flac_dec_write (GST_FLAC_DEC (client_data), frame, buffer);
 }
+#endif
 
 static FLAC__StreamDecoderWriteStatus
 gst_flac_dec_write_stream (const FLAC__StreamDecoder * decoder,
@@ -900,7 +1017,12 @@ static void
 gst_flac_dec_loop (GstPad * sinkpad)
 {
   GstFlacDec *flacdec;
+#ifdef LEGACY_FLAC
   FLAC__SeekableStreamDecoderState s;
+#else
+  FLAC__StreamDecoderState s;
+  FLAC__StreamDecoderInitStatus is;
+#endif
 
   flacdec = GST_FLAC_DEC (GST_OBJECT_PARENT (sinkpad));
 
@@ -908,9 +1030,15 @@ gst_flac_dec_loop (GstPad * sinkpad)
 
   if (flacdec->init) {
     GST_DEBUG_OBJECT (flacdec, "initializing decoder");
+#ifdef LEGACY_FLAC
     s = FLAC__seekable_stream_decoder_init (flacdec->seekable_decoder);
     if (s != FLAC__SEEKABLE_STREAM_DECODER_OK)
       goto analyze_state;
+#else
+    is = FLAC__stream_decoder_init_stream (flacdec->seekable_decoder, gst_flac_dec_read_seekable, gst_flac_dec_seek, gst_flac_dec_tell, gst_flac_dec_length, gst_flac_dec_eof, gst_flac_dec_write_stream, gst_flac_dec_metadata_callback_stream, gst_flac_dec_error_callback_stream, flacdec);
+    if (is != FLAC__STREAM_DECODER_INIT_STATUS_OK)
+      goto analyze_state;
+#endif
     /*    FLAC__seekable_stream_decoder_process_metadata (flacdec->seekable_decoder); */
     flacdec->init = FALSE;
   }
@@ -920,15 +1048,31 @@ gst_flac_dec_loop (GstPad * sinkpad)
   flacdec->last_flow = GST_FLOW_OK;
 
   GST_LOG_OBJECT (flacdec, "processing single");
+#ifdef LEGACY_FLAC
   FLAC__seekable_stream_decoder_process_single (flacdec->seekable_decoder);
+#else
+  FLAC__stream_decoder_process_single (flacdec->seekable_decoder);
+#endif
 
 analyze_state:
 
   GST_LOG_OBJECT (flacdec, "done processing, checking encoder state");
+#ifdef LEGACY_FLAC
   s = FLAC__seekable_stream_decoder_get_state (flacdec->seekable_decoder);
+#else
+  s = FLAC__stream_decoder_get_state (flacdec->seekable_decoder);
+#endif
   switch (s) {
+#ifdef LEGACY_FLAC
     case FLAC__SEEKABLE_STREAM_DECODER_OK:
-    case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:{
+    case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:
+#else
+    case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
+    case FLAC__STREAM_DECODER_READ_METADATA:
+    case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
+    case FLAC__STREAM_DECODER_READ_FRAME:
+#endif
+    {
       GST_DEBUG_OBJECT (flacdec, "everything ok");
 
       if (flacdec->last_flow != GST_FLOW_OK &&
@@ -956,9 +1100,18 @@ analyze_state:
       return;
     }
 
-    case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM:{
+#ifdef LEGACY_FLAC
+    case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM:
+#else
+    case FLAC__STREAM_DECODER_END_OF_STREAM:
+#endif
+    {
       GST_DEBUG_OBJECT (flacdec, "EOS");
+#ifdef LEGACY_FLAC
       FLAC__seekable_stream_decoder_reset (flacdec->seekable_decoder);
+#else
+      FLAC__stream_decoder_reset (flacdec->seekable_decoder);
+#endif
 
       if ((flacdec->segment.flags & GST_SEEK_FLAG_SEGMENT) != 0) {
         if (flacdec->segment.duration > 0) {
@@ -972,6 +1125,7 @@ analyze_state:
       goto eos_and_pause;
     }
 
+#ifdef LEGACY_FLAC
     case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
     case FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR:
     case FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR:
@@ -979,11 +1133,23 @@ analyze_state:
     case FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED:
     case FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK:
     case FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED:
+#else
+    case FLAC__STREAM_DECODER_OGG_ERROR:
+    case FLAC__STREAM_DECODER_SEEK_ERROR:
+    case FLAC__STREAM_DECODER_ABORTED:
+    case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
+    case FLAC__STREAM_DECODER_UNINITIALIZED:
+#endif
     default:{
       /* fixme: this error sucks -- should try to figure out when/if an more
          specific error was already sent via the callback */
+#ifdef LEGACY_FLAC
       GST_ELEMENT_ERROR (flacdec, STREAM, DECODE, (NULL),
           ("%s", FLAC__SeekableStreamDecoderStateString[s]));
+#else
+      GST_ELEMENT_ERROR (flacdec, STREAM, DECODE, (NULL),
+          ("%s", FLAC__StreamDecoderStateString[s]));
+#endif
       goto eos_and_pause;
     }
   }
@@ -1113,11 +1279,19 @@ gst_flac_dec_chain (GstPad * pad, GstBuf
 
   if (dec->init) {
     GST_DEBUG_OBJECT (dec, "initializing decoder");
+#ifdef LEGACY_FLAC
     s = FLAC__stream_decoder_init (dec->stream_decoder);
     if (s != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA) {
       GST_ELEMENT_ERROR (GST_ELEMENT (dec), LIBRARY, INIT, (NULL), (NULL));
       return GST_FLOW_ERROR;
     }
+#else
+    s = FLAC__stream_decoder_init_stream (dec->stream_decoder, gst_flac_dec_read_stream, NULL, NULL, NULL, NULL, gst_flac_dec_write_stream, gst_flac_dec_metadata_callback_stream, gst_flac_dec_error_callback_stream, dec);
+    if (s != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
+      GST_ELEMENT_ERROR (GST_ELEMENT (dec), LIBRARY, INIT, (NULL), (NULL));
+      return GST_FLOW_ERROR;
+    }
+#endif
     GST_DEBUG_OBJECT (dec, "initialized (framed=%d)", dec->framed);
     dec->init = FALSE;
   }
@@ -1598,8 +1772,13 @@ gst_flac_dec_handle_seek_event (GstFlacD
   flacdec->seeking = TRUE;
 
   seek_ok =
+#ifdef LEGACY_FLAC
       FLAC__seekable_stream_decoder_seek_absolute (flacdec->seekable_decoder,
       segment.start);
+#else
+      FLAC__stream_decoder_seek_absolute (flacdec->seekable_decoder,
+      segment.start);
+#endif
 
   flacdec->seeking = FALSE;