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
|
--- k3b-1.0pre2/plugins/decoder/flac/configure.in.in 2006-08-23 00:32:30.000000000 -0700
+++ k3b-1.0pre2-b2/plugins/decoder/flac/configure.in.in 2006-10-17 19:23:48.000000000 -0700
@@ -248,7 +248,7 @@
have_flac=no
if test "$ac_cv_use_flac" = "yes"; then
KDE_CHECK_HEADERS(FLAC++/decoder.h, [
- AC_CHECK_LIB(FLAC,FLAC__seekable_stream_decoder_process_single,
+ AC_CHECK_LIB(FLAC,FLAC__stream_decoder_process_single,
have_flac=yes,[],$all_libraries)])
# Hack to get the flac version since I was not able to handle the code from
--- k3b-1.0pre2/plugins/decoder/flac/k3bflacdecoder.cpp 2006-08-23 00:31:46.000000000 -0700
+++ k3b-1.0pre2-b2/plugins/decoder/flac/k3bflacdecoder.cpp 2006-10-18 14:32:24.000000000 -0700
@@ -36,11 +36,21 @@
#include <taglib/flacfile.h>
#endif
+#if !defined FLACPP_API_VERSION_CURRENT || FLACPP_API_VERSION_CURRENT < 6
+#define LEGACY_FLAC
+#else
+#undef LEGACY_FLAC
+#endif
+
K_EXPORT_COMPONENT_FACTORY( libk3bflacdecoder, K3bPluginFactory<K3bFLACDecoderFactory>( "libk3bflacdecoder" ) )
class K3bFLACDecoder::Private
+#ifdef LEGACY_FLAC
: public FLAC::Decoder::SeekableStream
+#else
+ : public FLAC::Decoder::Stream
+#endif
{
public:
void open(QFile* f) {
@@ -64,7 +74,11 @@
}
Private(QFile* f)
+#ifdef LEGACY_FLAC
: FLAC::Decoder::SeekableStream(),
+#else
+ : FLAC::Decoder::Stream(),
+#endif
comments(0) {
internalBuffer = new QBuffer();
internalBuffer->open(IO_ReadWrite);
@@ -93,10 +107,17 @@
FLAC__uint64 samples;
protected:
+#ifdef LEGACY_FLAC
virtual FLAC__SeekableStreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes);
virtual FLAC__SeekableStreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
virtual FLAC__SeekableStreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
virtual FLAC__SeekableStreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length);
+#else
+ virtual FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
+ virtual FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
+ virtual FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
+ virtual FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length);
+#endif
virtual bool eof_callback();
virtual void error_callback(FLAC__StreamDecoderErrorStatus){};
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
@@ -112,6 +133,7 @@
return file->atEnd();
}
+#ifdef LEGACY_FLAC
FLAC__SeekableStreamDecoderReadStatus K3bFLACDecoder::Private::read_callback(FLAC__byte buffer[], unsigned *bytes) {
long retval = file->readBlock((char *)buffer, (*bytes));
if(-1 == retval) {
@@ -121,7 +143,19 @@
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
}
}
+#else
+FLAC__StreamDecoderReadStatus K3bFLACDecoder::Private::read_callback(FLAC__byte buffer[], size_t *bytes) {
+ long retval = file->readBlock((char *)buffer, (*bytes));
+ if(-1 == retval) {
+ return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
+ } else {
+ (*bytes) = retval;
+ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+ }
+}
+#endif
+#ifdef LEGACY_FLAC
FLAC__SeekableStreamDecoderSeekStatus
K3bFLACDecoder::Private::seek_callback(FLAC__uint64 absolute_byte_offset) {
if(file->at(absolute_byte_offset) == FALSE)
@@ -129,18 +163,43 @@
else
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
}
+#else
+FLAC__StreamDecoderSeekStatus
+K3bFLACDecoder::Private::seek_callback(FLAC__uint64 absolute_byte_offset) {
+ if(file->at(absolute_byte_offset) == FALSE)
+ return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
+ else
+ return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
+}
+#endif
+#ifdef LEGACY_FLAC
FLAC__SeekableStreamDecoderTellStatus
K3bFLACDecoder::Private::tell_callback(FLAC__uint64 *absolute_byte_offset) {
(*absolute_byte_offset) = file->at();
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
}
+#else
+FLAC__StreamDecoderTellStatus
+K3bFLACDecoder::Private::tell_callback(FLAC__uint64 *absolute_byte_offset) {
+ (*absolute_byte_offset) = file->at();
+ return FLAC__STREAM_DECODER_TELL_STATUS_OK;
+}
+#endif
+#ifdef LEGACY_FLAC
FLAC__SeekableStreamDecoderLengthStatus
K3bFLACDecoder::Private::length_callback(FLAC__uint64 *stream_length) {
(*stream_length) = file->size();
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
}
+#else
+FLAC__StreamDecoderLengthStatus
+K3bFLACDecoder::Private::length_callback(FLAC__uint64 *stream_length) {
+ (*stream_length) = file->size();
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
+}
+#endif
void K3bFLACDecoder::Private::metadata_callback(const FLAC__StreamMetadata *metadata) {
@@ -260,6 +319,7 @@
int bytesCopied;
int bytesAvailable;
+#ifdef LEGACY_FLAC
if(d->internalBuffer->size() == 0) {
// want more data
switch(d->get_state()) {
@@ -274,6 +334,19 @@
return -1;
}
}
+#else
+ if(d->internalBuffer->size() == 0) {
+ // want more data
+ if(d->get_state() == FLAC__STREAM_DECODER_END_OF_STREAM)
+ d->finish();
+ else if(d->get_state() < FLAC__STREAM_DECODER_END_OF_STREAM) {
+ if(! d->process_single())
+ return -1;
+ }
+ else
+ return -1;
+ }
+#endif
bytesAvailable = d->internalBuffer->size() - d->internalBuffer->at();
bytesToCopy = QMIN(maxLen, bytesAvailable);
|