summaryrefslogtreecommitdiff
path: root/multimedia/kdemultimedia3/patches/patch-aq
blob: fea0da6cd25a1e66ee336d7153e5ba22b5d26d30 (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
$NetBSD: patch-aq,v 1.1 2007/01/13 18:33:44 wiz Exp $

--- kioslave/audiocd/plugins/flac/encoderflac.cpp.orig	2006-01-19 16:40:33.000000000 +0000
+++ kioslave/audiocd/plugins/flac/encoderflac.cpp
@@ -29,6 +29,11 @@
 #include <kconfig.h>
 #include <kdebug.h>
 
+#if !defined FLAC_API_VERSION_CURRENT || FLAC_API_VERSION_CURRENT < 8
+#define LEGACY_FLAC
+#else
+#undef LEGACY_FLAC
+#endif
 
 extern "C"
 {
@@ -47,7 +52,11 @@ public:
     unsigned long data;
 };
 
+#ifdef LEGACY_FLAC
 static FLAC__StreamEncoderWriteStatus WriteCallback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)
+#else
+static FLAC__StreamEncoderWriteStatus WriteCallback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data)
+#endif
 {
     EncoderFLAC::Private *d = (EncoderFLAC::Private*)client_data;
 
@@ -109,9 +118,11 @@ unsigned long EncoderFLAC::size(long tim
 long EncoderFLAC::readInit(long size) {
     kdDebug(7117) << "EncoderFLAC::readInit() called"<< endl;
     d->data = 0;
+#ifdef LEGACY_FLAC
     FLAC__stream_encoder_set_write_callback(d->encoder, WriteCallback);
     FLAC__stream_encoder_set_metadata_callback(d->encoder, MetadataCallback);
     FLAC__stream_encoder_set_client_data(d->encoder, d);
+#endif
 
     // The options match approximely those of flac compression-level-3
     FLAC__stream_encoder_set_do_mid_side_stereo(d->encoder, true);
@@ -124,7 +135,13 @@ long EncoderFLAC::readInit(long size) {
     if (size > 0)
         FLAC__stream_encoder_set_total_samples_estimate(d->encoder, size/4);
 
-    FLAC__stream_encoder_init(d->encoder);
+#ifdef LEGACY_FLAC
+    if(FLAC__stream_encoder_init(d->encoder) != FLAC__STREAM_ENCODER_OK)
+		; // really should handle an init failure
+#else
+    if(FLAC__stream_encoder_init_stream(d->encoder, WriteCallback, NULL, NULL, MetadataCallback, d) != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
+		; // really should handle an init failure
+#endif
     return d->data;
 }