summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/libflac/examples/cpp/decode/file/main.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-12-06 17:05:32 +1100
committer Vas Crabb <vas@vastheman.com>2023-12-06 17:12:45 +1100
commitfaf991a563a9bf8adc7aeee80001606d58857b99 (patch)
tree5eb75ca6182e9816f4ac501c124712cd8e5ee353 /3rdparty/libflac/examples/cpp/decode/file/main.cpp
parent2cf244ef3b53129d711aa5b663fb38e9133726c0 (diff)
3rdparty/libflac: Updated to version 1.4.3.
Also removed FLAC documentation - it's a lot of bloat.
Diffstat (limited to '3rdparty/libflac/examples/cpp/decode/file/main.cpp')
-rw-r--r--3rdparty/libflac/examples/cpp/decode/file/main.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/3rdparty/libflac/examples/cpp/decode/file/main.cpp b/3rdparty/libflac/examples/cpp/decode/file/main.cpp
index 56140503fcf..d1c29958d69 100644
--- a/3rdparty/libflac/examples/cpp/decode/file/main.cpp
+++ b/3rdparty/libflac/examples/cpp/decode/file/main.cpp
@@ -1,5 +1,6 @@
/* example_cpp_decode_file - Simple FLAC file decoder using libFLAC
- * Copyright (C) 2007 Josh Coalson
+ * Copyright (C) 2007-2009 Josh Coalson
+ * Copyright (C) 2011-2023 Xiph.Org Foundation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -11,9 +12,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.
*/
/*
@@ -21,21 +22,23 @@
* file. It only supports 16-bit stereo files.
*
* Complete API documentation can be found at:
- * http://flac.sourceforge.net/api/
+ * http://xiph.org/flac/api/
*/
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
+
#include "FLAC++/decoder.h"
+#include "share/compat.h"
static FLAC__uint64 total_samples = 0;
-static unsigned sample_rate = 0;
-static unsigned channels = 0;
-static unsigned bps = 0;
+static uint32_t sample_rate = 0;
+static uint32_t channels = 0;
+static uint32_t bps = 0;
static bool write_little_endian_uint16(FILE *f, FLAC__uint16 x)
{
@@ -69,6 +72,9 @@ protected:
virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
virtual void error_callback(::FLAC__StreamDecoderErrorStatus status);
+private:
+ OurDecoder(const OurDecoder&);
+ OurDecoder&operator=(const OurDecoder&);
};
int main(int argc, char *argv[])
@@ -118,6 +124,10 @@ int main(int argc, char *argv[])
const FLAC__uint32 total_size = (FLAC__uint32)(total_samples * channels * (bps/8));
size_t i;
+ // Update data
+ channels = OurDecoder::get_channels();
+ bps = OurDecoder::get_bits_per_sample();
+
if(total_samples == 0) {
fprintf(stderr, "ERROR: this example only works for FLAC files that have a total_samples count in STREAMINFO\n");
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
@@ -175,11 +185,7 @@ void OurDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata)
fprintf(stderr, "sample rate : %u Hz\n", sample_rate);
fprintf(stderr, "channels : %u\n", channels);
fprintf(stderr, "bits per sample: %u\n", bps);
-#ifdef _MSC_VER
- fprintf(stderr, "total samples : %I64u\n", total_samples);
-#else
- fprintf(stderr, "total samples : %llu\n", total_samples);
-#endif
+ fprintf(stderr, "total samples : %" PRIu64 "\n", total_samples);
}
}