Fix a couple of Windows 2Gig file size issues.
[platform/upstream/flac.git] / src / test_libFLAC++ / decoders.cpp
index 25925a8..f5b1d0b 100644 (file)
@@ -1,5 +1,5 @@
 /* test_libFLAC++ - Unit tester for libFLAC++
- * Copyright (C) 2002,2003,2004,2005,2006  Josh Coalson
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -11,9 +11,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #if HAVE_CONFIG_H
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#if defined _MSC_VER || defined __MINGW32__
-#if _MSC_VER <= 1200 /* @@@ [2G limit] */
-#define fseeko fseek
-#define ftello ftell
-#endif
-#endif
 #include "decoders.h"
 #include "FLAC/assert.h"
 #include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal()
 #include "FLAC++/decoder.h"
 #include "share/grabbag.h"
+#include "share/compat.h"
 extern "C" {
 #include "test_libs_common/file_utils_flac.h"
 #include "test_libs_common/metadata_utils.h"
@@ -62,11 +57,11 @@ static const char * const LayerString[] = {
 static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_;
 static ::FLAC__StreamMetadata *expected_metadata_sequence_[9];
 static unsigned num_expected_;
-static off_t flacfilesize_;
+static FLAC__off_t flacfilesize_;
 
 static const char *flacfilename(bool is_ogg)
 {
-       return is_ogg? "metadata.ogg" : "metadata.flac";
+       return is_ogg? "metadata.oga" : "metadata.flac";
 }
 
 static bool die_(const char *msg)
@@ -234,7 +229,7 @@ public:
        if(error_occurred_)
                return ::FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
 
-       if(fseeko(file_, (off_t)absolute_byte_offset, SEEK_SET) < 0) {
+       if(fseeko(file_, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) {
                error_occurred_ = true;
                return ::FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
        }
@@ -250,7 +245,7 @@ public:
        if(error_occurred_)
                return ::FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
 
-       off_t offset = ftello(file_);
+       FLAC__off_t offset = ftello(file_);
        *absolute_byte_offset = (FLAC__uint64)offset;
 
        if(offset < 0) {
@@ -332,7 +327,11 @@ bool StreamDecoder::test_respond(bool is_ogg)
        printf("OK\n");
 
        printf("testing finish()... ");
-       finish();
+       if(!finish()) {
+               State state = get_state();
+               printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
+               return false;
+       }
        printf("OK\n");
 
        return true;
@@ -414,7 +413,11 @@ bool FileDecoder::test_respond(bool is_ogg)
        printf("OK\n");
 
        printf("testing finish()... ");
-       finish();
+       if(!finish()) {
+               State state = get_state();
+               printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
+               return false;
+       }
        printf("OK\n");
 
        return true;
@@ -714,7 +717,11 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
        }
 
        printf("testing finish()... ");
-       decoder->finish();
+       if(!decoder->finish()) {
+               state = decoder->get_state();
+               printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
+               return false;
+       }
        printf("OK\n");
 
        /*