--- /dev/null
+# FLAC - Free Lossless Audio Codec
+# Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
+#
+# This file is part the FLAC project. FLAC is comprised of several
+# components distributed under difference licenses. The codec libraries
+# are distributed under Xiph.Org's BSD-like license (see the file
+# COPYING.Xiph in this distribution). All other programs, libraries, and
+# plugins are distributed under the GPL (see COPYING.GPL). The documentation
+# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
+# FLAC distribution contains at the top the terms under which it may be
+# distributed.
+#
+# Since this particular file is relevant to all components of FLAC,
+# it may be distributed under the Xiph.Org license, which is the least
+# restrictive of those mentioned above. See the file COPYING.Xiph in this
+# distribution.
+
+SUBDIRS = decode
--- /dev/null
+# FLAC - Free Lossless Audio Codec
+# Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
+#
+# This file is part the FLAC project. FLAC is comprised of several
+# components distributed under difference licenses. The codec libraries
+# are distributed under Xiph.Org's BSD-like license (see the file
+# COPYING.Xiph in this distribution). All other programs, libraries, and
+# plugins are distributed under the GPL (see COPYING.GPL). The documentation
+# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
+# FLAC distribution contains at the top the terms under which it may be
+# distributed.
+#
+# Since this particular file is relevant to all components of FLAC,
+# it may be distributed under the Xiph.Org license, which is the least
+# restrictive of those mentioned above. See the file COPYING.Xiph in this
+# distribution.
+
+SUBDIRS = file
--- /dev/null
+# example_cpp_decode_file - Simple FLAC file decoder using libFLAC
+# Copyright (C) 2007 Josh Coalson
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# 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.
+
+EXTRA_DIST = \
+ Makefile.lite \
+ example_cpp_decode_file.dsp \
+ example_cpp_decode_file.vcproj \
+
+noinst_PROGRAMS = example_cpp_decode_file
+example_cpp_decode_file_LDADD = \
+ @OGG_LIBS@ \
+ @MINGW_WINSOCK_LIBS@ \
+ -lm
+example_cpp_decode_file_SOURCES = main.c
--- /dev/null
+# example_cpp_decode_file - Simple FLAC file decoder using libFLAC
+# Copyright (C) 2007 Josh Coalson
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# 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.
+
+#
+# GNU makefile
+#
+
+topdir = ../../../..
+libdir = $(topdir)/obj/$(BUILD)/lib
+
+PROGRAM_NAME = example_cpp_decode_file
+
+INCLUDES = -I$(topdir)/include
+
+ifeq ($(DARWIN_BUILD),yes)
+EXPLICIT_LIBS = $(libdir)/libFLAC++.a $(libdir)/libFLAC.a $(OGG_LIB_DIR)/libogg.a -lm
+else
+LIBS = -lFLAC++ -lFLAC -L$(OGG_LIB_DIR) -logg -lm
+endif
+
+SRCS_CPP = main.cpp
+
+include $(topdir)/build/exe.mk
+
+LINK = $(CCC) $(LINKAGE)
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
--- /dev/null
+# Microsoft Developer Studio Project File - Name="example_cpp_decode_file" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=example_cpp_decode_file - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "example_cpp_decode_file.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "example_cpp_decode_file.mak" CFG="example_cpp_decode_file - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "example_cpp_decode_file - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "example_cpp_decode_file - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""\r
+# PROP Scc_LocalPath ""\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF "$(CFG)" == "example_cpp_decode_file - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "..\..\..\..\obj\release\bin"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c\r
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\..\include" /D "NDEBUG" /D "FLAC__NO_DLL" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c\r
+# SUBTRACT CPP /YX /Yc /Yu\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 ..\..\..\..\obj\release\lib\libFLAC++_static.lib ..\..\..\..\obj\release\lib\libFLAC_static.lib ..\..\..\..\obj\release\lib\ogg_static.lib /nologo /subsystem:console /machine:I386\r
+\r
+!ELSEIF "$(CFG)" == "example_cpp_decode_file - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "..\..\..\..\obj\debug\bin"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c\r
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\include" /D "_DEBUG" /D "DEBUG" /D "FLAC__NO_DLL" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c\r
+# SUBTRACT CPP /YX /Yc /Yu\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 ..\..\..\..\obj\release\lib\libFLAC++_static.lib ..\..\..\..\obj\debug\lib\libFLAC_static.lib ..\..\..\..\obj\release\lib\ogg_static.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "example_cpp_decode_file - Win32 Release"\r
+# Name "example_cpp_decode_file - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=.\main.cpp\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# End Group\r
+# End Target\r
+# End Project\r
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+ ProjectType="Visual C++"\r
+ Version="8.00"\r
+ Name="example_cpp_decode_file"\r
+ ProjectGUID="{4cefbe00-c215-11db-8314-0800200c9a66}"\r
+ RootNamespace="example_cpp_decode_file"\r
+ Keyword="Win32Proj"\r
+ >\r
+ <Platforms>\r
+ <Platform\r
+ Name="Win32"\r
+ />\r
+ </Platforms>\r
+ <ToolFiles>\r
+ </ToolFiles>\r
+ <Configurations>\r
+ <Configuration\r
+ Name="Debug|Win32"\r
+ OutputDirectory="..\..\..\..\obj\debug\bin"\r
+ IntermediateDirectory="Debug"\r
+ ConfigurationType="1"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ AdditionalIncludeDirectories="..\..\..\..\include"\r
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;FLAC__NO_DLL;DEBUG"\r
+ MinimalRebuild="true"\r
+ BasicRuntimeChecks="3"\r
+ RuntimeLibrary="1"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="3"\r
+ Detect64BitPortabilityProblems="true"\r
+ DebugInformationFormat="4"\r
+ CompileAs="0"\r
+ DisableSpecificWarnings="4267;4996"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="..\..\..\..\obj\release\lib\ogg_static.lib"\r
+ LinkIncremental="2"\r
+ IgnoreDefaultLibraryNames="uuid.lib"\r
+ GenerateDebugInformation="true"\r
+ SubSystem="1"\r
+ TargetMachine="1"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebDeploymentTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ <Configuration\r
+ Name="Release|Win32"\r
+ OutputDirectory="..\..\..\..\obj\release\bin"\r
+ IntermediateDirectory="Release"\r
+ ConfigurationType="1"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ EnableIntrinsicFunctions="true"\r
+ FavorSizeOrSpeed="1"\r
+ OmitFramePointers="true"\r
+ WholeProgramOptimization="true"\r
+ AdditionalIncludeDirectories="..\..\..\..\include"\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;FLAC__NO_DLL"\r
+ RuntimeLibrary="0"\r
+ BufferSecurityCheck="false"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="3"\r
+ Detect64BitPortabilityProblems="true"\r
+ DebugInformationFormat="3"\r
+ CompileAs="0"\r
+ DisableSpecificWarnings="4267;4996"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="..\..\..\..\obj\release\lib\ogg_static.lib"\r
+ LinkIncremental="1"\r
+ IgnoreDefaultLibraryNames="uuid.lib"\r
+ GenerateDebugInformation="true"\r
+ SubSystem="1"\r
+ OptimizeReferences="2"\r
+ EnableCOMDATFolding="2"\r
+ LinkTimeCodeGeneration="1"\r
+ TargetMachine="1"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebDeploymentTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ </Configurations>\r
+ <References>\r
+ </References>\r
+ <Files>\r
+ <Filter\r
+ Name="Header Files"\r
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+ UniqueIdentifier="{93292580-829B-b441-E8B8-65A95828BEB0}"\r
+ >\r
+ </Filter>\r
+ <Filter\r
+ Name="Source Files"\r
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+ UniqueIdentifier="{9C7247F1-CA27-1761-A016-0F27452AD2F0}"\r
+ >\r
+ <File\r
+ RelativePath=".\main.cpp"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ </Files>\r
+ <Globals>\r
+ </Globals>\r
+</VisualStudioProject>\r
--- /dev/null
+/* example_cpp_decode_file - Simple FLAC file decoder using libFLAC
+ * Copyright (C) 2007 Josh Coalson
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * 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.
+ */
+
+/*
+ * This example shows how to use libFLAC to decode a FLAC file to a WAVE
+ * file. It only supports 16-bit stereo files.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "FLAC++/decoder.h"
+
+FLAC__uint64 total_samples = 0;
+unsigned sample_rate = 0;
+unsigned channels = 0;
+unsigned bps = 0;
+
+static bool write_little_endian_uint16(FILE *f, FLAC__uint16 x)
+{
+ return
+ fputc(x, f) != EOF &&
+ fputc(x >> 8, f) != EOF
+ ;
+}
+
+static bool write_little_endian_int16(FILE *f, FLAC__int16 x)
+{
+ return write_little_endian_uint16(f, (FLAC__uint16)x);
+}
+
+static bool write_little_endian_uint32(FILE *f, FLAC__uint32 x)
+{
+ return
+ fputc(x, f) != EOF &&
+ fputc(x >> 8, f) != EOF &&
+ fputc(x >> 16, f) != EOF &&
+ fputc(x >> 24, f) != EOF
+ ;
+}
+
+class OurDecoder: public FLAC::Decoder::File {
+public:
+ OurDecoder(FILE *f_): FLAC::Decoder::File(), f(f_) { }
+protected:
+ FILE *f;
+
+ 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);
+};
+
+int main(int argc, char *argv[])
+{
+ bool ok = true;
+ FILE *fout;
+
+ if(argc != 3) {
+ fprintf(stderr, "usage: %s infile.flac outfile.wav\n", argv[0]);
+ return 1;
+ }
+
+ if((fout = fopen(argv[2], "wb")) == NULL) {
+ fprintf(stderr, "ERROR: opening %s for output\n", argv[2]);
+ return 1;
+ }
+
+ OurDecoder decoder(fout);
+
+ if(!decoder) {
+ fprintf(stderr, "ERROR: allocating decoder\n");
+ return 1;
+ }
+
+ (void)decoder.set_md5_checking(true);
+
+ FLAC__StreamDecoderInitStatus init_status = decoder.init(argv[1]);
+ if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
+ fprintf(stderr, "ERROR: initializing decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]);
+ ok = false;
+ }
+
+ if(ok) {
+ ok = decoder.process_until_end_of_stream();
+ fprintf(stderr, "decoding: %s\n", ok? "succeeded" : "FAILED");
+ fprintf(stderr, " state: %s\n", decoder.get_state().resolved_as_cstring(decoder));
+ }
+
+ fclose(fout);
+
+ return 0;
+}
+
+::FLAC__StreamDecoderWriteStatus OurDecoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[])
+{
+ const FLAC__uint32 total_size = (FLAC__uint32)(total_samples * channels * (bps/8));
+ size_t i;
+
+ 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;
+ }
+ if(channels != 2 || bps != 16) {
+ fprintf(stderr, "ERROR: this example only supports 16bit stereo streams\n");
+ return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
+ }
+
+ /* write WAVE header before we write the first frame */
+ if(frame->header.number.sample_number == 0) {
+ if(
+ fwrite("RIFF", 1, 4, f) < 4 ||
+ !write_little_endian_uint32(f, total_size + 36) ||
+ fwrite("WAVEfmt ", 1, 8, f) < 8 ||
+ !write_little_endian_uint32(f, 16) ||
+ !write_little_endian_uint16(f, 1) ||
+ !write_little_endian_uint16(f, (FLAC__uint16)channels) ||
+ !write_little_endian_uint32(f, sample_rate) ||
+ !write_little_endian_uint32(f, sample_rate * channels * (bps/8)) ||
+ !write_little_endian_uint16(f, (FLAC__uint16)(channels * (bps/8))) || /* block align */
+ !write_little_endian_uint16(f, (FLAC__uint16)bps) ||
+ fwrite("data", 1, 4, f) < 4 ||
+ !write_little_endian_uint32(f, total_size)
+ ) {
+ fprintf(stderr, "ERROR: write error\n");
+ return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
+ }
+ }
+
+ /* write decoded PCM samples */
+ for(i = 0; i < frame->header.blocksize; i++) {
+ if(
+ !write_little_endian_int16(f, (FLAC__int16)buffer[0][i]) || /* left channel */
+ !write_little_endian_int16(f, (FLAC__int16)buffer[1][i]) /* right channel */
+ ) {
+ fprintf(stderr, "ERROR: write error\n");
+ return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
+ }
+ }
+
+ return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+}
+
+void OurDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata)
+{
+ /* print some stats */
+ if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
+ /* save for later */
+ total_samples = metadata->data.stream_info.total_samples;
+ sample_rate = metadata->data.stream_info.sample_rate;
+ channels = metadata->data.stream_info.channels;
+ bps = metadata->data.stream_info.bits_per_sample;
+
+ 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
+ }
+}
+
+void OurDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status)
+{
+ fprintf(stderr, "Got error callback: %s\n", FLAC__StreamDecoderErrorStatusString[status]);
+}