updated on Wed Jan 25 08:34:36 UTC 2012
[aur-mirror.git] / rezound / flacpatch
blob30bf37675e2cf4bc6aa5819b1585a820b42bd76e
1 This patch adds ifdefs to make rezound compile and work with flac 1.1.2 and >=1.1.3
2 See : http://flac.sourceforge.net/api/group__porting.html for more details
4 Index: rezound-0.12.3beta/src/backend/CFLACSoundTranslator.cpp
5 ===================================================================
6 --- rezound-0.12.3beta.orig/src/backend/CFLACSoundTranslator.cpp
7 +++ rezound-0.12.3beta/src/backend/CFLACSoundTranslator.cpp
8 @@ -42,6 +42,12 @@
9  #include "CSound.h"
10  #include "AStatusComm.h"
12 +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
13 +#define LEGACY_FLAC
14 +#else
15 +#undef LEGACY_FLAC
16 +#endif
18  CFLACSoundTranslator::CFLACSoundTranslator()
19  {
20  }
21 @@ -75,15 +81,23 @@ public:
22                 for(unsigned t=0;t<MAX_CHANNELS;t++)
23                         accessers[t]=NULL;
25 +#ifdef LEGACY_FLAC
26                 set_filename(filename.c_str());
27 +#endif
29                 set_metadata_ignore_all();
30                 //set_metadata_respond(FLAC__METADATA_TYPE_VORBIS_COMMENT);
31                 //set_metadata_respond(FLAC__METADATA_TYPE_CUESHEET);
33 +#ifdef LEGACY_FLAC
34                 State s=init();
35                 if(s!=FLAC__FILE_DECODER_OK)
36                         throw runtime_error(string(__func__)+" -- "+s.as_cstring());
37 +#else
38 +               FLAC__StreamDecoderInitStatus s=init(filename.c_str());
39 +               if(s!=FLAC__STREAM_DECODER_INIT_STATUS_OK)
40 +                       throw runtime_error(string(__func__)+" -- FLAC__STREAM_DECODER_INIT_STATUS not OK");
41 +#endif
42         }
44         virtual ~MyFLACDecoderFile()
45 @@ -170,7 +184,11 @@ protected:
47                 // update status bar and detect user cancel
48                 FLAC__uint64 filePosition;
49 +#ifdef LEGACY_FLAC
50                 FLAC__file_decoder_get_decode_position(decoder_, &filePosition);
51 +#else
52 +               FLAC__stream_decoder_get_decode_position(decoder_, &filePosition);
53 +#endif
54                 return statusBar.update(filePosition) ? FLAC__STREAM_DECODER_WRITE_STATUS_ABORT : FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
55         }
57 @@ -215,7 +233,11 @@ private:
58  bool CFLACSoundTranslator::onLoadSound(const string filename,CSound *sound) const
59  {
60         MyFLACDecoderFile f(filename,sound);
61 +#ifdef LEGACY_FLAC
62         return f.process_until_end_of_file();
63 +#else
64 +       return f.process_until_end_of_stream();
65 +#endif 
66  }
69 @@ -258,7 +280,9 @@ bool CFLACSoundTranslator::onSaveSound(c
71         MyFLACEncoderFile f(saveLength);
73 +#ifdef LEGACY_FLAC
74         f.set_filename(filename.c_str());
75 +#endif
77         f.set_channels(sound->getChannelCount());
79 @@ -274,8 +298,13 @@ bool CFLACSoundTranslator::onSaveSound(c
80         //f.set_metadata(...) // ??? to do to set cues and user notes, etc
83 +#ifdef LEGACY_FLAC
84         MyFLACEncoderFile::State s=f.init();
85         if(s==FLAC__STREAM_ENCODER_OK)
86 +#else
87 +       FLAC__StreamEncoderInitStatus s=f.init(filename.c_str());
88 +       if(s==FLAC__STREAM_ENCODER_INIT_STATUS_OK)
89 +#endif
90         {
91                 #define BUFFER_SIZE 65536
92                 TAutoBuffer<FLAC__int32> buffers[MAX_CHANNELS];
93 @@ -328,7 +357,11 @@ bool CFLACSoundTranslator::onSaveSound(c
94                 return true;
95         }
96         else
97 +#ifdef LEGACY_FLAC
98                 throw runtime_error(string(__func__)+" -- error creating FLAC encoder -- "+s.as_cstring());
99 +#else
100 +               throw runtime_error(string(__func__)+" -- error creating FLAC encoder -- ");
101 +#endif