summaryrefslogtreecommitdiff
path: root/libraries/audiere/patches/audiere-1.9.4-flac.patch
blob: 96fb19989780f74d7b522569ecd0e8578f4d6a9e (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
diff -Naur audiere/configure.in audiere.tpg/configure.in
--- audiere/configure.in	2004-11-07 23:41:37.000000000 +0000
+++ audiere.tpg/configure.in	2008-06-03 18:13:32.000000000 +0000
@@ -66,7 +66,7 @@
     AC_MSG_ERROR(could not find pthread library))
 
 dnl Look for FLAC
-AC_CHECK_LIB(FLAC, FLAC__seekable_stream_decoder_process_single,
+AC_CHECK_LIB(FLAC, FLAC__stream_decoder_process_single,
     LIBS="-lFLAC -lm $LIBS"
     EXTRA_LIBS="-lFLAC -lm $EXTRA_LIBS"
     HAVE_FLAC=true
diff -Naur audiere/src/debug.h audiere.tpg/src/debug.h
--- audiere/src/debug.h	2004-04-09 09:33:50.000000000 +0000
+++ audiere.tpg/src/debug.h	2008-06-03 18:38:53.000000000 +0000
@@ -60,7 +60,8 @@
   #define ADR_IF_DEBUG     if (true)
 
   #ifdef _MSC_VER
-    #define ADR_ASSERT(condition, label) if (!(condition)) { __asm int 3 }
+    #include <intrin.h>
+    #define ADR_ASSERT(condition, label) if (!(condition)) { __debugbreak(); }
   #else  // assume x86 gcc
     #define ADR_ASSERT(condition, label) assert(condition && label);
   #endif
diff -Naur audiere/src/input_flac.cpp audiere.tpg/src/input_flac.cpp
--- audiere/src/input_flac.cpp	2003-10-23 03:41:17.000000000 +0000
+++ audiere.tpg/src/input_flac.cpp	2008-06-03 18:39:53.000000000 +0000
@@ -19,8 +19,8 @@
 
   FLACInputStream::~FLACInputStream() {
     if (m_decoder) {
-      FLAC__seekable_stream_decoder_finish(m_decoder);
-      FLAC__seekable_stream_decoder_delete(m_decoder);
+      FLAC__stream_decoder_finish(m_decoder);
+      FLAC__stream_decoder_delete(m_decoder);
       m_decoder = 0;
     }
   }
@@ -31,19 +31,19 @@
     m_file = file;
 
     // initialize the decoder
-    m_decoder = FLAC__seekable_stream_decoder_new();
+    m_decoder = FLAC__stream_decoder_new();
     if (!m_decoder) {
       m_file = 0;
       return false;
     }
-
+/*
 #define SET_CALLBACK(name)                                   \
-  FLAC__seekable_stream_decoder_set_##name##_callback(       \
+  FLAC__stream_decoder_set_##name##_callback(       \
     m_decoder,                                               \
     name##_callback)
 
     // set callbacks
-    FLAC__seekable_stream_decoder_set_client_data      (m_decoder, this);
+    FLAC__stream_decoder_set_client_data      (m_decoder, this);
     SET_CALLBACK(read);
     SET_CALLBACK(seek);
     SET_CALLBACK(tell);
@@ -52,39 +52,50 @@
     SET_CALLBACK(write);
     SET_CALLBACK(metadata);
     SET_CALLBACK(error);
-
-    FLAC__SeekableStreamDecoderState state =
-      FLAC__seekable_stream_decoder_init(m_decoder);
-    if (state != FLAC__SEEKABLE_STREAM_DECODER_OK) {
-      FLAC__seekable_stream_decoder_finish(m_decoder);
-      FLAC__seekable_stream_decoder_delete(m_decoder);
+*/
+    FLAC__StreamDecoderInitStatus state = FLAC__stream_decoder_init_stream(
+      m_decoder,
+      read_callback,
+      seek_callback,
+      tell_callback,
+      length_callback,
+      eof_callback,
+      write_callback,
+      metadata_callback,
+      error_callback,
+      this
+    );
+
+    if (state != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
+      FLAC__stream_decoder_finish(m_decoder);
+      FLAC__stream_decoder_delete(m_decoder);
       m_decoder = 0;
       m_file = 0;
       return false;
     }
 
     // make sure we have metadata before we return!
-    if (!FLAC__seekable_stream_decoder_process_until_end_of_metadata(m_decoder)) {
-      FLAC__seekable_stream_decoder_finish(m_decoder);
-      FLAC__seekable_stream_decoder_delete(m_decoder);
+    if (!FLAC__stream_decoder_process_until_end_of_metadata(m_decoder)) {
+      FLAC__stream_decoder_finish(m_decoder);
+      FLAC__stream_decoder_delete(m_decoder);
       m_decoder = 0;
       m_file = 0;
       return false;
     }
 
     // process one frame so we can do something!
-    if (!FLAC__seekable_stream_decoder_process_single(m_decoder)) {
-      FLAC__seekable_stream_decoder_finish(m_decoder);
-      FLAC__seekable_stream_decoder_delete(m_decoder);
+    if (!FLAC__stream_decoder_process_single(m_decoder)) {
+      FLAC__stream_decoder_finish(m_decoder);
+      FLAC__stream_decoder_delete(m_decoder);
       m_decoder = 0;
       m_file = 0;
       return false;
     }
 
     // get info about the flac file
-    m_channel_count = FLAC__seekable_stream_decoder_get_channels(m_decoder);
-    m_sample_rate   = FLAC__seekable_stream_decoder_get_sample_rate(m_decoder);
-    int bps         = FLAC__seekable_stream_decoder_get_bits_per_sample(m_decoder);
+    m_channel_count = FLAC__stream_decoder_get_channels(m_decoder);
+    m_sample_rate   = FLAC__stream_decoder_get_sample_rate(m_decoder);
+    int bps         = FLAC__stream_decoder_get_bits_per_sample(m_decoder);
     if (bps == 16) {
       m_sample_format = SF_S16;
     } else if (bps == 8) {
@@ -120,7 +131,7 @@
       
       // if the buffer is empty, ask FLAC to fill it p
       if (m_buffer.getSize() < frame_size) {
-        if (!FLAC__seekable_stream_decoder_process_single(m_decoder)) {
+        if (!FLAC__stream_decoder_process_single(m_decoder)) {
           return frames_read;
         }
 
@@ -147,7 +158,7 @@
   void
   FLACInputStream::reset() {
     m_file->seek(0, File::BEGIN);
-    FLAC__seekable_stream_decoder_seek_absolute(m_decoder, 0);
+    FLAC__stream_decoder_seek_absolute(m_decoder, 0);
     m_position = 0;
     m_buffer.clear();
   }
@@ -167,7 +178,7 @@
 
   void
   FLACInputStream::setPosition(int position) {
-    if (FLAC__seekable_stream_decoder_seek_absolute(m_decoder, position)) {
+    if (FLAC__stream_decoder_seek_absolute(m_decoder, position)) {
       m_position = position;
     }
   }
@@ -218,56 +229,58 @@
   }
 
 
-  FLAC__SeekableStreamDecoderReadStatus FLACInputStream::read_callback(
-    const FLAC__SeekableStreamDecoder* decoder,
+  FLAC__StreamDecoderReadStatus FLACInputStream::read_callback(
+    const FLAC__StreamDecoder* decoder,
     FLAC__byte buffer[],
-    unsigned *bytes,
+    size_t *bytes,
     void* client_data)
   {
     *bytes = getFile(client_data)->read(buffer, *bytes);
     if (*bytes == 0) {
-      return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
+      // was: FLAC__STREAM_DECODER_READ_STATUS_ERROR
+      return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
     } else {
-      return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
+      // was: FLAC__STREAM_DECODER_READ_STATUS_OK
+      return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
     }
   }
 
 
-  FLAC__SeekableStreamDecoderSeekStatus FLACInputStream::seek_callback(
-    const FLAC__SeekableStreamDecoder* decoder,
+  FLAC__StreamDecoderSeekStatus FLACInputStream::seek_callback(
+    const FLAC__StreamDecoder* decoder,
     FLAC__uint64 absolute_byte_offset,
     void* client_data)
   {
     if (getFile(client_data)->seek(static_cast<int>(absolute_byte_offset), File::BEGIN)) {
-      return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
+      return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
     } else {
-      return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
+      return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
     }
   }
 
 
-  FLAC__SeekableStreamDecoderTellStatus FLACInputStream::tell_callback(
-    const FLAC__SeekableStreamDecoder* decoder,
+  FLAC__StreamDecoderTellStatus FLACInputStream::tell_callback(
+    const FLAC__StreamDecoder* decoder,
     FLAC__uint64* absolute_byte_offset,
     void* client_data)
   {
     *absolute_byte_offset = getFile(client_data)->tell();
-    return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
+    return FLAC__STREAM_DECODER_TELL_STATUS_OK;
   }
 
 
-  FLAC__SeekableStreamDecoderLengthStatus FLACInputStream::length_callback(
-    const FLAC__SeekableStreamDecoder* decoder,
+  FLAC__StreamDecoderLengthStatus FLACInputStream::length_callback(
+    const FLAC__StreamDecoder* decoder,
     FLAC__uint64* stream_length,
     void* client_data)
   {
     *stream_length = GetFileLength(getFile(client_data));
-    return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
+    return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
   }
 
 
   FLAC__bool FLACInputStream::eof_callback(
-    const FLAC__SeekableStreamDecoder* decoder,
+    const FLAC__StreamDecoder* decoder,
     void* client_data)
   {
     File* file = getFile(client_data);
@@ -276,7 +289,7 @@
 
 
   FLAC__StreamDecoderWriteStatus FLACInputStream::write_callback(
-    const FLAC__SeekableStreamDecoder* decoder,
+    const FLAC__StreamDecoder* decoder,
     const FLAC__Frame* frame,
     const FLAC__int32* const buffer[],
     void* client_data)
@@ -286,7 +299,7 @@
 
 
   void FLACInputStream::metadata_callback(
-    const FLAC__SeekableStreamDecoder* decoder,
+    const FLAC__StreamDecoder* decoder,
     const FLAC__StreamMetadata *metadata,
     void* client_data)
   {
@@ -298,7 +311,7 @@
 
 
   void FLACInputStream::error_callback(
-    const FLAC__SeekableStreamDecoder* decoder,
+    const FLAC__StreamDecoder* decoder,
     FLAC__StreamDecoderErrorStatus status,
     void* client_data)
   {
diff -Naur audiere/src/input_flac.h audiere.tpg/src/input_flac.h
--- audiere/src/input_flac.h	2003-07-01 18:45:44.000000000 +0000
+++ audiere.tpg/src/input_flac.h	2008-06-03 18:42:04.000000000 +0000
@@ -2,7 +2,7 @@
 #define INPUT_FLAC_H
 
 
-#include <FLAC/seekable_stream_decoder.h>
+#include <FLAC/stream_decoder.h>
 #include "audiere.h"
 #include "basic_source.h"
 #include "utility.h"
@@ -34,37 +34,37 @@
       const FLAC__Frame* frame,
       const FLAC__int32* const buffer[]);
 
-    static FLAC__SeekableStreamDecoderReadStatus read_callback(
-      const FLAC__SeekableStreamDecoder* decoder,
+    static FLAC__StreamDecoderReadStatus read_callback(
+      const FLAC__StreamDecoder* decoder,
       FLAC__byte buffer[],
-      unsigned* bytes,
+      size_t* bytes,
       void* client_data);
-    static FLAC__SeekableStreamDecoderSeekStatus seek_callback(
-      const FLAC__SeekableStreamDecoder* decoder,
+    static FLAC__StreamDecoderSeekStatus seek_callback(
+      const FLAC__StreamDecoder* decoder,
       FLAC__uint64 absolute_byte_offset,
       void* client_data);
-    static FLAC__SeekableStreamDecoderTellStatus tell_callback(
-      const FLAC__SeekableStreamDecoder* decoder,
+    static FLAC__StreamDecoderTellStatus tell_callback(
+      const FLAC__StreamDecoder* decoder,
       FLAC__uint64* absolute_byte_offset,
       void* client_data);
-    static FLAC__SeekableStreamDecoderLengthStatus length_callback(
-      const FLAC__SeekableStreamDecoder* decoder,
+    static FLAC__StreamDecoderLengthStatus length_callback(
+      const FLAC__StreamDecoder* decoder,
       FLAC__uint64* stream_length,
       void* client_data);
     static FLAC__bool eof_callback(
-      const FLAC__SeekableStreamDecoder* decoder,
+      const FLAC__StreamDecoder* decoder,
       void* client_data);
     static FLAC__StreamDecoderWriteStatus write_callback(
-      const FLAC__SeekableStreamDecoder* decoder,
+      const FLAC__StreamDecoder* decoder,
       const FLAC__Frame* frame,
       const FLAC__int32* const buffer[],
       void* client_data);
     static void metadata_callback(
-      const FLAC__SeekableStreamDecoder* decoder,
+      const FLAC__StreamDecoder* decoder,
       const FLAC__StreamMetadata* metadata,
       void* client_data);
     static void error_callback(
-      const FLAC__SeekableStreamDecoder* decoder,
+      const FLAC__StreamDecoder* decoder,
       FLAC__StreamDecoderErrorStatus status,
       void* client_data);
 
@@ -74,7 +74,7 @@
 
     FilePtr m_file;
 
-    FLAC__SeekableStreamDecoder* m_decoder;
+    FLAC__StreamDecoder* m_decoder;
 
     /**
      * This is the buffer used to combine the different channels from FLAC
diff -Naur audiere/src/mci_device.h audiere.tpg/src/mci_device.h
--- audiere/src/mci_device.h	2004-07-30 02:30:47.000000000 +0000
+++ audiere.tpg/src/mci_device.h	2008-06-03 18:43:02.000000000 +0000
@@ -41,7 +41,11 @@
         0, 0, 0, 0,
         NULL, NULL, GetModuleHandle(NULL), NULL);
       if (m_window) {
+        #if defined(_M_X64)
+        SetWindowLongPtr(m_window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
+        #else
         SetWindowLong(m_window, GWL_USERDATA, reinterpret_cast<LONG>(this));
+        #endif
       } else {
         ADR_LOG("MCI notification window creation failed");
       }
@@ -96,7 +100,13 @@
     static LRESULT CALLBACK notifyWindowProc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam) {
       switch (msg) {
         case MM_MCINOTIFY: {
+          #if defined(_M_X64)
+          MCIDevice* This = reinterpret_cast<MCIDevice*>(
+            GetWindowLongPtr(window, GWLP_USERDATA)
+          );
+          #else
           MCIDevice* This = reinterpret_cast<MCIDevice*>(GetWindowLong(window, GWL_USERDATA));
+          #endif
           if (This) {
             This->notify(wparam);
           }