Index: plugins/codec_flac/FlacEncoder.cpp =================================================================== --- plugins/codec_flac/FlacEncoder.cpp (Revision 1972) +++ plugins/codec_flac/FlacEncoder.cpp (Arbeitskopie) @@ -208,15 +208,27 @@ } // initialize the FLAC stream, this already writes some meta info - FLAC::Encoder::Stream::State state = init(); - if (state != FLAC__STREAM_ENCODER_OK) { - qWarning("state = %s", state.as_cstring()); - KMessageBox::error(widget, - i18n("Unable to open the FLAC encoder!")); - m_info = 0; - result = false; - break; - } +#if defined(FLAC_API_VERSION_1_1_3) + FLAC__StreamEncoderInitStatus init_state = init(); + if (init_state != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { + qWarning("state = %d", (int)init_state); + KMessageBox::error(widget, + i18n("Unable to open the FLAC encoder!")); + m_info = 0; + result = false; + break; + } +#else + FLAC::Encoder::Stream::State init_state = init(); + if (init_state != FLAC__STREAM_ENCODER_OK) { + qWarning("state = %s", init_state.as_cstring()); + KMessageBox::error(widget, + i18n("Unable to open the FLAC encoder!")); + m_info = 0; + result = false; + break; + } +#endif // allocate output buffers, with FLAC 32 bit format unsigned int len = 8192; // samples Index: plugins/codec_flac/FlacDecoder.cpp =================================================================== --- plugins/codec_flac/FlacDecoder.cpp (Revision 1972) +++ plugins/codec_flac/FlacDecoder.cpp (Arbeitskopie) @@ -158,7 +158,7 @@ const FLAC::Metadata::VorbisComment &vorbis_comments) { // first of all: the vendor string, specifying the software -#ifdef FLAC_API_VERSION_1_1_1_OR_OLDER +#if defined(FLAC_API_VERSION_1_1_1_OR_OLDER) if (vorbis_comments.get_vendor_string().is_valid()) { const FLAC::Metadata::VorbisComment::Entry &entry = vorbis_comments.get_vendor_string(); @@ -169,13 +169,15 @@ m_info.set(INF_SOFTWARE, s); qDebug("Encoded by: '%s'\n\n", s.local8Bit().data()); } -#else +#elif defined(FLAC_API_VERSION_1_1_2) || defined(FLAC_API_VERSION_1_1_3) QString vendor = QString::fromUtf8(reinterpret_cast( vorbis_comments.get_vendor_string())); if (vendor.length()) { m_info.set(INF_SOFTWARE, vendor); qDebug("Encoded by: '%s'\n\n", vendor.local8Bit().data()); } +#else + #error "no usable FLAC API found" #endif // parse all vorbis comments into Kwave file properties @@ -275,17 +277,26 @@ set_metadata_respond_all(); // initialize the stream - FLAC::Decoder::Stream::State state = init(); - if (state >= FLAC__STREAM_DECODER_END_OF_STREAM) { - KMessageBox::error(widget, i18n( - "opening the FLAC bitstream failed.")); - return false; +#if defined(FLAC_API_VERSION_1_1_3) + FLAC__StreamDecoderInitStatus init_state = init(); + if (init_state > FLAC__STREAM_DECODER_INIT_STATUS_OK) { + KMessageBox::error(widget, i18n( + "opening the FLAC bitstream failed.")); + return false; } +#else /* API v1.1.2 and older */ + FLAC::Decoder::Stream::State init_state = init(); + if (init_state >= FLAC__STREAM_DECODER_END_OF_STREAM) { + KMessageBox::error(widget, i18n( + "opening the FLAC bitstream failed.")); + return false; + } +#endif // read in all metadata process_until_end_of_metadata(); - state = get_state(); + FLAC::Decoder::Stream::State state = get_state(); if (state >= FLAC__STREAM_DECODER_END_OF_STREAM) { KMessageBox::error(widget, i18n( "error while parsing FLAC metadata. (%s)"), Index: configure.in =================================================================== --- configure.in (Revision 1972) +++ configure.in (Arbeitskopie) @@ -449,6 +449,7 @@ AC_LINK_IFELSE([ #include #include + #include #include int main(int, char **) @@ -456,16 +457,54 @@ const FLAC::Metadata::VorbisComment vorbis_comments; const FLAC__byte *vendor = vorbis_comments.get_vendor_string(); if (!vendor) return -1; + + FLAC::Decoder::Stream *decoder = 0; + FLAC::Encoder::Stream *encoder = 0; + FLAC::Decoder::Stream::State init_state_d = decoder->init(); + FLAC::Encoder::Stream::State init_state_e = encoder->init(); + return 0; } ], AC_MSG_RESULT([ok. use v1.1.2 API]) - AC_DEFINE(FLAC_API_VERSION_1_1_2_OR_NEWER, 1, [new API from v1.1.2 and newer]) + AC_DEFINE(FLAC_API_VERSION_1_1_2, 1, [API from v1.1.2]) , [ - AC_MSG_ERROR([unable to figure out a valid API]) - ] - ) + AC_LINK_IFELSE([ + #include + #include + #include + #include + #include + + /* FLAC-1.1.3 has cur=8, rev=0 */ + /* FLAC-1.1.4 has cur=8, rev=1 */ + #if !defined(FLAC_API_VERSION_CURRENT) || \ + !defined(FLAC_API_VERSION_REVISION) + #error "FLAC API is much too old" + #endif + + #if (FLAC_API_VERSION_CURRENT < 8) + #error "FLAC API is too old" + #endif + + int main(int, char **) + { + FLAC__StreamEncoderInitStatus init_state_d = + FLAC__STREAM_ENCODER_INIT_STATUS_OK; + FLAC__StreamDecoderInitStatus init_state_e = + FLAC__STREAM_DECODER_INIT_STATUS_OK; + return 0; + } + ], + AC_MSG_RESULT([ok. use v1.1.3 API]) + AC_DEFINE(FLAC_API_VERSION_1_1_3, 1, [new API from v1.1.3]) + , + [ + AC_MSG_ERROR([unable to figure out a valid API]) + ] + ) + ]) ] ) AC_LANG_POP(C++)