Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 157587
Collapse All | Expand All

(-)Cynthiune-0.9.5/Bundles/FLAC/FLAC.h (+4 lines)
Lines 31-37 Link Here
31
31
32
@interface FLAC : NSObject <CynthiuneBundle, Format>
32
@interface FLAC : NSObject <CynthiuneBundle, Format>
33
{
33
{
34
#ifdef LEGACY_FLAC
34
  FLAC__FileDecoder *fileDecoder;
35
  FLAC__FileDecoder *fileDecoder;
36
#else
37
  FLAC__StreamDecoder *fileDecoder;
38
#endif
35
39
36
  unsigned int bitsPerSample;
40
  unsigned int bitsPerSample;
37
  unsigned int duration;
41
  unsigned int duration;
(-)Cynthiune-0.9.5/Bundles/FLAC/FLAC.m (+71 lines)
Lines 34-46 Link Here
34
#import <Cynthiune/Format.h>
34
#import <Cynthiune/Format.h>
35
#import <Cynthiune/utils.h>
35
#import <Cynthiune/utils.h>
36
36
37
/* FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 */
38
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
39
#define LEGACY_FLAC
40
#else
41
#undef LEGACY_FLAC
42
#endif
43
37
#import "FLAC.h"
44
#import "FLAC.h"
38
45
39
#define LOCALIZED(X) _b ([FLAC class], X)
46
#define LOCALIZED(X) _b ([FLAC class], X)
40
47
41
static FLAC__StreamDecoderWriteStatus
48
static FLAC__StreamDecoderWriteStatus
49
#ifdef LEGACY_FLAC
42
writeCallback (const FLAC__FileDecoder *fileDecoder, const FLAC__Frame *frame,
50
writeCallback (const FLAC__FileDecoder *fileDecoder, const FLAC__Frame *frame,
43
               const FLAC__int32 * const buffer[], void *clientData)
51
               const FLAC__int32 * const buffer[], void *clientData)
52
#else
53
writeCallback (const FLAC__StreamDecoder *fileDecoder, const FLAC__Frame *frame,
54
               const FLAC__int32 * const buffer[], void *clientData)
55
#endif
44
{
56
{
45
  CFLAC *cStream;
57
  CFLAC *cStream;
46
  unsigned int sample, channel;
58
  unsigned int sample, channel;
Lines 70-78 Link Here
70
}
82
}
71
83
72
static void
84
static void
85
#ifdef LEGACY_FLAC
73
metadataCallback (const FLAC__FileDecoder *fileDecoder,
86
metadataCallback (const FLAC__FileDecoder *fileDecoder,
74
                  const FLAC__StreamMetadata *metadata,
87
                  const FLAC__StreamMetadata *metadata,
75
                  void *clientData)
88
                  void *clientData)
89
#else
90
metadataCallback (const FLAC__StreamDecoder *fileDecoder,
91
                  const FLAC__StreamMetadata *metadata,
92
                  void *clientData)
93
#endif
76
{
94
{
77
  CFLAC *cStream;
95
  CFLAC *cStream;
78
96
Lines 88-96 Link Here
88
}
106
}
89
107
90
static void
108
static void
109
#ifdef LEGACY_FLAC
91
errorCallback (const FLAC__FileDecoder *fileDecoder,
110
errorCallback (const FLAC__FileDecoder *fileDecoder,
92
               FLAC__StreamDecoderErrorStatus status,
111
               FLAC__StreamDecoderErrorStatus status,
93
               void *clientData)
112
               void *clientData)
113
#else
114
errorCallback (const FLAC__StreamDecoder *fileDecoder,
115
               FLAC__StreamDecoderErrorStatus status,
116
               void *clientData)
117
#endif
94
{
118
{
95
  NSLog (@"FLAC: received error with status %d", status);
119
  NSLog (@"FLAC: received error with status %d", status);
96
}
120
}
Lines 161-166 Link Here
161
185
162
- (BOOL) _initializeFileDecoderWithFilename: (NSString *) fileName
186
- (BOOL) _initializeFileDecoderWithFilename: (NSString *) fileName
163
{
187
{
188
#ifdef LEGACY_FLAC
164
  FLAC__file_decoder_set_metadata_ignore_all (fileDecoder);
189
  FLAC__file_decoder_set_metadata_ignore_all (fileDecoder);
165
  FLAC__file_decoder_set_metadata_respond (fileDecoder,
190
  FLAC__file_decoder_set_metadata_respond (fileDecoder,
166
                                           FLAC__METADATA_TYPE_STREAMINFO);
191
                                           FLAC__METADATA_TYPE_STREAMINFO);
Lines 173-185 Link Here
173
  return (FLAC__file_decoder_set_filename (fileDecoder, [fileName cString])
198
  return (FLAC__file_decoder_set_filename (fileDecoder, [fileName cString])
174
          && (FLAC__file_decoder_init (fileDecoder) == FLAC__FILE_DECODER_OK)
199
          && (FLAC__file_decoder_init (fileDecoder) == FLAC__FILE_DECODER_OK)
175
          && FLAC__file_decoder_process_until_end_of_metadata (fileDecoder));
200
          && FLAC__file_decoder_process_until_end_of_metadata (fileDecoder));
201
#else
202
  FLAC__stream_decoder_set_metadata_ignore_all (fileDecoder);
203
  FLAC__stream_decoder_set_metadata_respond (fileDecoder,
204
                                           FLAC__METADATA_TYPE_STREAMINFO);
205
  return ((FLAC__stream_decoder_init_file (fileDecoder, [fileName cString],
206
          writeCallback, metadataCallback, errorCallback, self) == FLAC__STREAM_DECODER_INIT_STATUS_OK)
207
          && FLAC__stream_decoder_process_until_end_of_metadata (fileDecoder));
208
#endif
176
}
209
}
177
210
178
- (BOOL) streamOpen: (NSString *) fileName
211
- (BOOL) streamOpen: (NSString *) fileName
179
{
212
{
180
  BOOL result;
213
  BOOL result;
181
214
215
#ifdef LEGACY_FLAC
182
  fileDecoder = FLAC__file_decoder_new();
216
  fileDecoder = FLAC__file_decoder_new();
217
#else
218
  fileDecoder = FLAC__stream_decoder_new();
219
#endif
183
220
184
  if (fileDecoder)
221
  if (fileDecoder)
185
    {
222
    {
Lines 187-193 Link Here
187
        result = YES;
224
        result = YES;
188
      else
225
      else
189
        {
226
        {
227
#ifdef LEGACY_FLAC
190
          FLAC__file_decoder_delete (fileDecoder);
228
          FLAC__file_decoder_delete (fileDecoder);
229
#else
230
          FLAC__stream_decoder_delete (fileDecoder);
231
#endif
191
          fileDecoder = NULL;
232
          fileDecoder = NULL;
192
          result = NO;
233
          result = NO;
193
        }
234
        }
Lines 200-206 Link Here
200
241
201
- (void) streamClose
242
- (void) streamClose
202
{
243
{
244
#ifdef LEGACY_FLAC
203
  FLAC__file_decoder_delete (fileDecoder);
245
  FLAC__file_decoder_delete (fileDecoder);
246
#else
247
  FLAC__stream_decoder_delete (fileDecoder);
248
#endif
204
  fileDecoder = NULL;
249
  fileDecoder = NULL;
205
}
250
}
206
251
Lines 215-221 Link Here
215
  if (position >= readBufferSize)
260
  if (position >= readBufferSize)
216
    {
261
    {
217
      position = 0;
262
      position = 0;
263
#ifdef LEGACY_FLAC
218
      success = FLAC__file_decoder_process_single (fileDecoder);
264
      success = FLAC__file_decoder_process_single (fileDecoder);
265
#else
266
      success = FLAC__stream_decoder_process_single (fileDecoder);
267
#endif
219
    }
268
    }
220
269
221
  if (success)
270
  if (success)
Lines 251-263 Link Here
251
             withSize: (unsigned int) bufferSize
300
             withSize: (unsigned int) bufferSize
252
{
301
{
253
  int readBytes;
302
  int readBytes;
303
#ifdef LEGACY_FLAC
254
  FLAC__FileDecoderState state;
304
  FLAC__FileDecoderState state;
255
305
256
  state = FLAC__file_decoder_get_state (fileDecoder);
306
  state = FLAC__file_decoder_get_state (fileDecoder);
307
#else
308
  FLAC__StreamDecoderState state;
309
310
  state = FLAC__stream_decoder_get_state (fileDecoder);
311
#endif
257
312
313
#ifdef LEGACY_FLAC
258
  if (state == FLAC__FILE_DECODER_OK)
314
  if (state == FLAC__FILE_DECODER_OK)
315
#else
316
  if (state < FLAC__STREAM_DECODER_END_OF_STREAM)
317
#endif
259
    readBytes = [self _processNextChunk: buffer withSize: bufferSize];
318
    readBytes = [self _processNextChunk: buffer withSize: bufferSize];
319
#ifdef LEGACY_FLAC
260
  else if (state == FLAC__FILE_DECODER_END_OF_FILE)
320
  else if (state == FLAC__FILE_DECODER_END_OF_FILE)
321
#else
322
  else if (state == FLAC__STREAM_DECODER_END_OF_STREAM)
323
#endif
261
    readBytes = 0;
324
    readBytes = 0;
262
  else
325
  else
263
    readBytes = -1;
326
    readBytes = -1;
Lines 272-278 Link Here
272
335
273
- (void) seek: (unsigned int) aPos
336
- (void) seek: (unsigned int) aPos
274
{
337
{
338
#ifdef LEGACY_FLAC
275
  FLAC__file_decoder_seek_absolute (fileDecoder, aPos * rate);
339
  FLAC__file_decoder_seek_absolute (fileDecoder, aPos * rate);
340
#else
341
  FLAC__stream_decoder_seek_absolute (fileDecoder, aPos * rate);
342
#endif
276
}
343
}
277
344
278
- (unsigned int) readChannels
345
- (unsigned int) readChannels
Lines 295-301 Link Here
295
  if (readBuffer)
362
  if (readBuffer)
296
    free (readBuffer);
363
    free (readBuffer);
297
  if (fileDecoder)
364
  if (fileDecoder)
365
#ifdef LEGACY_FLAC
298
    FLAC__file_decoder_delete (fileDecoder);
366
    FLAC__file_decoder_delete (fileDecoder);
367
#else
368
    FLAC__stream_decoder_delete (fileDecoder);
369
#endif
299
  [super dealloc];
370
  [super dealloc];
300
}
371
}
301
372
(-)Cynthiune-0.9.5/Bundles/FLACTags/FLACTags.m (+44 lines)
Lines 33-38 Link Here
33
33
34
#import "FLACTags.h"
34
#import "FLACTags.h"
35
35
36
/* FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 */
37
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
38
#define LEGACY_FLAC
39
#else
40
#undef LEGACY_FLAC
41
#endif
42
36
#define LOCALIZED(X) _b ([FLACTags class], X)
43
#define LOCALIZED(X) _b ([FLACTags class], X)
37
44
38
static inline int
45
static inline int
Lines 78-93 Link Here
78
}
85
}
79
86
80
static FLAC__StreamDecoderWriteStatus
87
static FLAC__StreamDecoderWriteStatus
88
#ifdef LEGACY_FLAC
81
writeCallback (const FLAC__FileDecoder *fileDecoder, const FLAC__Frame *frame,
89
writeCallback (const FLAC__FileDecoder *fileDecoder, const FLAC__Frame *frame,
82
               const FLAC__int32 * const buffer[], void *clientData)
90
               const FLAC__int32 * const buffer[], void *clientData)
91
#else
92
writeCallback (const FLAC__StreamDecoder *fileDecoder, const FLAC__Frame *frame,
93
               const FLAC__int32 * const buffer[], void *clientData)
94
#endif
83
{
95
{
84
  return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
96
  return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
85
}
97
}
86
98
87
static void
99
static void
100
#ifdef LEGACY_FLAC
88
metadataCallback (const FLAC__FileDecoder *fileDecoder,
101
metadataCallback (const FLAC__FileDecoder *fileDecoder,
89
                  const FLAC__StreamMetadata *metadata,
102
                  const FLAC__StreamMetadata *metadata,
90
                  void *clientData)
103
                  void *clientData)
104
#else
105
metadataCallback (const FLAC__StreamDecoder *fileDecoder,
106
                  const FLAC__StreamMetadata *metadata,
107
                  void *clientData)
108
#endif
91
{
109
{
92
  unsigned int count;
110
  unsigned int count;
93
111
Lines 104-112 Link Here
104
}
122
}
105
123
106
static void
124
static void
125
#ifdef LEGACY_FLAC
107
errorCallback (const FLAC__FileDecoder *fileDecoder,
126
errorCallback (const FLAC__FileDecoder *fileDecoder,
108
               FLAC__StreamDecoderErrorStatus status,
127
               FLAC__StreamDecoderErrorStatus status,
109
               void *clientData)
128
               void *clientData)
129
#else
130
errorCallback (const FLAC__StreamDecoder *fileDecoder,
131
               FLAC__StreamDecoderErrorStatus status,
132
               void *clientData)
133
#endif
110
{
134
{
111
  NSLog (@"FLACTags: received error with status %d", status);
135
  NSLog (@"FLACTags: received error with status %d", status);
112
}
136
}
Lines 132-145 Link Here
132
              year: (NSString **) year
156
              year: (NSString **) year
133
        ofFilename: (NSString *) filename
157
        ofFilename: (NSString *) filename
134
{
158
{
159
#ifdef LEGACY_FLAC
135
  FLAC__FileDecoder *fileDecoder;
160
  FLAC__FileDecoder *fileDecoder;
161
#else
162
  FLAC__StreamDecoder *fileDecoder;
163
#endif
136
  BOOL result;
164
  BOOL result;
137
  NSString **arrayOfValues[] = { title, artist, album, trackNumber,
165
  NSString **arrayOfValues[] = { title, artist, album, trackNumber,
138
                                 genre, year };
166
                                 genre, year };
139
167
168
#ifdef LEGACY_FLAC
140
  fileDecoder = FLAC__file_decoder_new();
169
  fileDecoder = FLAC__file_decoder_new();
170
#else
171
  fileDecoder = FLAC__stream_decoder_new();
172
#endif
141
  if (fileDecoder)
173
  if (fileDecoder)
142
    {
174
    {
175
#ifdef LEGACY_FLAC
143
      FLAC__file_decoder_set_metadata_ignore_all (fileDecoder);
176
      FLAC__file_decoder_set_metadata_ignore_all (fileDecoder);
144
      FLAC__file_decoder_set_metadata_respond (fileDecoder,
177
      FLAC__file_decoder_set_metadata_respond (fileDecoder,
145
                                               FLAC__METADATA_TYPE_VORBIS_COMMENT);
178
                                               FLAC__METADATA_TYPE_VORBIS_COMMENT);
Lines 156-161 Link Here
156
                && FLAC__file_decoder_process_until_end_of_metadata
189
                && FLAC__file_decoder_process_until_end_of_metadata
157
                (fileDecoder));
190
                (fileDecoder));
158
      FLAC__file_decoder_delete (fileDecoder);
191
      FLAC__file_decoder_delete (fileDecoder);
192
#else
193
      FLAC__stream_decoder_set_metadata_ignore_all (fileDecoder);
194
      FLAC__stream_decoder_set_metadata_respond (fileDecoder,
195
                                               FLAC__METADATA_TYPE_VORBIS_COMMENT);
196
      result = ((FLAC__stream_decoder_init_file (fileDecoder, [filename cString],
197
                    writeCallback, metadataCallback, errorCallback, arrayOfValues)
198
                    == FLAC__STREAM_DECODER_INIT_STATUS_OK)
199
                && FLAC__stream_decoder_process_until_end_of_metadata
200
                (fileDecoder));
201
      FLAC__stream_decoder_delete (fileDecoder);
202
#endif
159
    }
203
    }
160
  else
204
  else
161
    result = NO;
205
    result = NO;

Return to bug 157587