inputPlugins/flac_plugin: switch to the new (1.1.3) API
We will restore compatibility with the old API in the next few commits; along with OggFLAC support. git-svn-id: https://svn.musicpd.org/mpd/trunk@5110 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
5048388251
commit
ccf971a320
|
@ -2,7 +2,7 @@
|
||||||
# "Inspired" by ogg.m4
|
# "Inspired" by ogg.m4
|
||||||
|
|
||||||
dnl AM_PATH_LIBFLAC([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
dnl AM_PATH_LIBFLAC([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||||
dnl Test for libFLAC, and define LIBFLAC_CFLAGS and LIBFLAC_LIBS
|
dnl Test for libFLAC, and define LIBFLAC_CFLAGS, LIBFLAC_LIBS, LIBFLAC_LIBDIR
|
||||||
dnl
|
dnl
|
||||||
AC_DEFUN([AM_PATH_LIBFLAC],
|
AC_DEFUN([AM_PATH_LIBFLAC],
|
||||||
[dnl
|
[dnl
|
||||||
|
@ -14,21 +14,21 @@ AC_ARG_WITH(libFLAC-includes,[ --with-libFLAC-includes=DIR Directory where li
|
||||||
AC_ARG_ENABLE(libFLACtest, [ --disable-libFLACtest Do not try to compile and run a test libFLAC program],, enable_libFLACtest=yes)
|
AC_ARG_ENABLE(libFLACtest, [ --disable-libFLACtest Do not try to compile and run a test libFLAC program],, enable_libFLACtest=yes)
|
||||||
|
|
||||||
if test "x$libFLAC_libraries" != "x" ; then
|
if test "x$libFLAC_libraries" != "x" ; then
|
||||||
LIBFLAC_LIBS="-L$libFLAC_libraries"
|
LIBFLAC_LIBDIR="$libFLAC_libraries"
|
||||||
elif test "x$libFLAC_prefix" != "x" ; then
|
elif test "x$libFLAC_prefix" != "x" ; then
|
||||||
LIBFLAC_LIBS="-L$libFLAC_prefix/lib"
|
LIBFLAC_LIBDIR="$libFLAC_prefix/lib"
|
||||||
elif test "x$prefix" != "xNONE" ; then
|
elif test "x$prefix" != "xNONE" ; then
|
||||||
LIBFLAC_LIBS="-L$prefix/lib"
|
LIBFLAC_LIBDIR="$libdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LIBFLAC_LIBS="$LIBFLAC_LIBS -lFLAC -lm"
|
LIBFLAC_LIBS="-L$LIBFLAC_LIBDIR -lFLAC $OGG_LIBS -lm"
|
||||||
|
|
||||||
if test "x$libFLAC_includes" != "x" ; then
|
if test "x$libFLAC_includes" != "x" ; then
|
||||||
LIBFLAC_CFLAGS="-I$libFLAC_includes"
|
LIBFLAC_CFLAGS="-I$libFLAC_includes"
|
||||||
elif test "x$libFLAC_prefix" != "x" ; then
|
elif test "x$libFLAC_prefix" != "x" ; then
|
||||||
LIBFLAC_CFLAGS="-I$libFLAC_prefix/include"
|
LIBFLAC_CFLAGS="-I$libFLAC_prefix/include"
|
||||||
elif test "x$prefix" != "xNONE"; then
|
elif test "x$prefix" != "xNONE"; then
|
||||||
LIBFLAC_CFLAGS="-I$prefix/include"
|
LIBFLAC_CFLAGS=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_MSG_CHECKING(for libFLAC)
|
AC_MSG_CHECKING(for libFLAC)
|
||||||
|
@ -39,9 +39,11 @@ AC_ARG_ENABLE(libFLACtest, [ --disable-libFLACtest Do not try to compile
|
||||||
ac_save_CFLAGS="$CFLAGS"
|
ac_save_CFLAGS="$CFLAGS"
|
||||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||||
ac_save_LIBS="$LIBS"
|
ac_save_LIBS="$LIBS"
|
||||||
|
ac_save_LDPATH="$LD_LIBRARY_PATH"
|
||||||
CFLAGS="$CFLAGS $LIBFLAC_CFLAGS"
|
CFLAGS="$CFLAGS $LIBFLAC_CFLAGS"
|
||||||
CXXFLAGS="$CXXFLAGS $LIBFLAC_CFLAGS"
|
CXXFLAGS="$CXXFLAGS $LIBFLAC_CFLAGS"
|
||||||
LIBS="$LIBS $LIBFLAC_LIBS"
|
LIBS="$LIBS $LIBFLAC_LIBS"
|
||||||
|
LD_LIBRARY_PATH="$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH"
|
||||||
dnl
|
dnl
|
||||||
dnl Now check if the installed libFLAC is sufficiently new.
|
dnl Now check if the installed libFLAC is sufficiently new.
|
||||||
dnl
|
dnl
|
||||||
|
@ -60,7 +62,9 @@ int main ()
|
||||||
|
|
||||||
],, no_libFLAC=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
],, no_libFLAC=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||||
CFLAGS="$ac_save_CFLAGS"
|
CFLAGS="$ac_save_CFLAGS"
|
||||||
|
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||||
LIBS="$ac_save_LIBS"
|
LIBS="$ac_save_LIBS"
|
||||||
|
LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$no_libFLAC" = "x" ; then
|
if test "x$no_libFLAC" = "x" ; then
|
||||||
|
@ -73,7 +77,9 @@ int main ()
|
||||||
else
|
else
|
||||||
echo "*** Could not run libFLAC test program, checking why..."
|
echo "*** Could not run libFLAC test program, checking why..."
|
||||||
CFLAGS="$CFLAGS $LIBFLAC_CFLAGS"
|
CFLAGS="$CFLAGS $LIBFLAC_CFLAGS"
|
||||||
|
CXXFLAGS="$CXXFLAGS $LIBFLAC_CFLAGS"
|
||||||
LIBS="$LIBS $LIBFLAC_LIBS"
|
LIBS="$LIBS $LIBFLAC_LIBS"
|
||||||
|
LD_LIBRARY_PATH="$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH"
|
||||||
AC_TRY_LINK([
|
AC_TRY_LINK([
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <FLAC/format.h>
|
#include <FLAC/format.h>
|
||||||
|
@ -92,13 +98,17 @@ int main ()
|
||||||
echo "*** or that you have moved libFLAC since it was installed. In the latter case, you"
|
echo "*** or that you have moved libFLAC since it was installed. In the latter case, you"
|
||||||
echo "*** may want to edit the libFLAC-config script: $LIBFLAC_CONFIG" ])
|
echo "*** may want to edit the libFLAC-config script: $LIBFLAC_CONFIG" ])
|
||||||
CFLAGS="$ac_save_CFLAGS"
|
CFLAGS="$ac_save_CFLAGS"
|
||||||
|
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||||
LIBS="$ac_save_LIBS"
|
LIBS="$ac_save_LIBS"
|
||||||
|
LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH"
|
||||||
fi
|
fi
|
||||||
LIBFLAC_CFLAGS=""
|
LIBFLAC_CFLAGS=""
|
||||||
|
LIBFLAC_LIBDIR=""
|
||||||
LIBFLAC_LIBS=""
|
LIBFLAC_LIBS=""
|
||||||
ifelse([$2], , :, [$2])
|
ifelse([$2], , :, [$2])
|
||||||
fi
|
fi
|
||||||
AC_SUBST(LIBFLAC_CFLAGS)
|
AC_SUBST(LIBFLAC_CFLAGS)
|
||||||
|
AC_SUBST(LIBFLAC_LIBDIR)
|
||||||
AC_SUBST(LIBFLAC_LIBS)
|
AC_SUBST(LIBFLAC_LIBS)
|
||||||
rm -f conf.libFLACtest
|
rm -f conf.libFLACtest
|
||||||
])
|
])
|
||||||
|
|
|
@ -33,13 +33,12 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <FLAC/seekable_stream_decoder.h>
|
#include <FLAC/stream_decoder.h>
|
||||||
#include <FLAC/metadata.h>
|
#include <FLAC/metadata.h>
|
||||||
|
|
||||||
/* this code is based on flac123, from flac-tools */
|
/* this code is based on flac123, from flac-tools */
|
||||||
|
|
||||||
static FLAC__SeekableStreamDecoderReadStatus flacRead(const
|
static FLAC__StreamDecoderReadStatus flacRead(const FLAC__StreamDecoder
|
||||||
FLAC__SeekableStreamDecoder
|
|
||||||
* flacDec,
|
* flacDec,
|
||||||
FLAC__byte buf[],
|
FLAC__byte buf[],
|
||||||
unsigned *bytes,
|
unsigned *bytes,
|
||||||
|
@ -58,14 +57,16 @@ static FLAC__SeekableStreamDecoderReadStatus flacRead(const
|
||||||
}
|
}
|
||||||
*bytes = r;
|
*bytes = r;
|
||||||
|
|
||||||
if (*bytes == 0 && !inputStreamAtEOF(data->inStream) && !data->dc->stop)
|
if (r == 0 && !data->dc->stop) {
|
||||||
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
|
if (inputStreamAtEOF(data->inStream))
|
||||||
|
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||||
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
|
else
|
||||||
|
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||||
|
}
|
||||||
|
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__SeekableStreamDecoderSeekStatus flacSeek(const
|
static FLAC__StreamDecoderSeekStatus flacSeek(const FLAC__StreamDecoder
|
||||||
FLAC__SeekableStreamDecoder
|
|
||||||
* flacDec,
|
* flacDec,
|
||||||
FLAC__uint64 offset,
|
FLAC__uint64 offset,
|
||||||
void *fdata)
|
void *fdata)
|
||||||
|
@ -73,14 +74,13 @@ static FLAC__SeekableStreamDecoderSeekStatus flacSeek(const
|
||||||
FlacData *data = (FlacData *) fdata;
|
FlacData *data = (FlacData *) fdata;
|
||||||
|
|
||||||
if (seekInputStream(data->inStream, offset, SEEK_SET) < 0) {
|
if (seekInputStream(data->inStream, offset, SEEK_SET) < 0) {
|
||||||
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
|
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
|
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__SeekableStreamDecoderTellStatus flacTell(const
|
static FLAC__StreamDecoderTellStatus flacTell(const FLAC__StreamDecoder
|
||||||
FLAC__SeekableStreamDecoder
|
|
||||||
* flacDec,
|
* flacDec,
|
||||||
FLAC__uint64 * offset,
|
FLAC__uint64 * offset,
|
||||||
void *fdata)
|
void *fdata)
|
||||||
|
@ -89,11 +89,10 @@ static FLAC__SeekableStreamDecoderTellStatus flacTell(const
|
||||||
|
|
||||||
*offset = (long)(data->inStream->offset);
|
*offset = (long)(data->inStream->offset);
|
||||||
|
|
||||||
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
|
return FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__SeekableStreamDecoderLengthStatus flacLength(const
|
static FLAC__StreamDecoderLengthStatus flacLength(const FLAC__StreamDecoder
|
||||||
FLAC__SeekableStreamDecoder
|
|
||||||
* flacDec,
|
* flacDec,
|
||||||
FLAC__uint64 * length,
|
FLAC__uint64 * length,
|
||||||
void *fdata)
|
void *fdata)
|
||||||
|
@ -102,11 +101,10 @@ static FLAC__SeekableStreamDecoderLengthStatus flacLength(const
|
||||||
|
|
||||||
*length = (size_t) (data->inStream->size);
|
*length = (size_t) (data->inStream->size);
|
||||||
|
|
||||||
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
|
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder * flacDec,
|
static FLAC__bool flacEOF(const FLAC__StreamDecoder * flacDec, void *fdata)
|
||||||
void *fdata)
|
|
||||||
{
|
{
|
||||||
FlacData *data = (FlacData *) fdata;
|
FlacData *data = (FlacData *) fdata;
|
||||||
|
|
||||||
|
@ -115,51 +113,48 @@ static FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder * flacDec,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flacError(const FLAC__SeekableStreamDecoder * dec,
|
static void flacError(const FLAC__StreamDecoder * dec,
|
||||||
FLAC__StreamDecoderErrorStatus status, void *fdata)
|
FLAC__StreamDecoderErrorStatus status, void *fdata)
|
||||||
{
|
{
|
||||||
flac_error_common_cb("flac", status, (FlacData *) fdata);
|
flac_error_common_cb("flac", status, (FlacData *) fdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state)
|
static void flacPrintErroredState(FLAC__StreamDecoderState state)
|
||||||
{
|
{
|
||||||
|
const char *str = ""; /* "" to silence compiler warning */
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
|
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
||||||
ERROR("flac allocation error\n");
|
case FLAC__STREAM_DECODER_READ_METADATA:
|
||||||
|
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
|
||||||
|
case FLAC__STREAM_DECODER_READ_FRAME:
|
||||||
|
case FLAC__STREAM_DECODER_END_OF_STREAM:
|
||||||
|
return;
|
||||||
|
case FLAC__STREAM_DECODER_OGG_ERROR:
|
||||||
|
str = "error in the Ogg layer";
|
||||||
break;
|
break;
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR:
|
case FLAC__STREAM_DECODER_SEEK_ERROR:
|
||||||
ERROR("flac read error\n");
|
str = "seek error";
|
||||||
break;
|
break;
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR:
|
case FLAC__STREAM_DECODER_ABORTED:
|
||||||
ERROR("flac seek error\n");
|
str = "decoder aborted by read";
|
||||||
break;
|
break;
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR:
|
case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
|
||||||
ERROR("flac seekable stream error\n");
|
str = "allocation error";
|
||||||
break;
|
break;
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED:
|
case FLAC__STREAM_DECODER_UNINITIALIZED:
|
||||||
ERROR("flac decoder already initialized\n");
|
str = "decoder uninitialized";
|
||||||
break;
|
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK:
|
|
||||||
ERROR("invalid flac callback\n");
|
|
||||||
break;
|
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED:
|
|
||||||
ERROR("flac decoder uninitialized\n");
|
|
||||||
break;
|
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_OK:
|
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:
|
|
||||||
case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ERROR("flac %s\n", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flacMetadata(const FLAC__SeekableStreamDecoder * dec,
|
static void flacMetadata(const FLAC__StreamDecoder * dec,
|
||||||
const FLAC__StreamMetadata * block, void *vdata)
|
const FLAC__StreamMetadata * block, void *vdata)
|
||||||
{
|
{
|
||||||
flac_metadata_common_cb(block, (FlacData *) vdata);
|
flac_metadata_common_cb(block, (FlacData *) vdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLAC__StreamDecoderWriteStatus flacWrite(const
|
static FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__StreamDecoder *
|
||||||
FLAC__SeekableStreamDecoder *
|
|
||||||
dec, const FLAC__Frame * frame,
|
dec, const FLAC__Frame * frame,
|
||||||
const FLAC__int32 * const buf[],
|
const FLAC__int32 * const buf[],
|
||||||
void *vdata)
|
void *vdata)
|
||||||
|
@ -176,7 +171,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const
|
||||||
timeChange = ((float)samples) / frame->header.sample_rate;
|
timeChange = ((float)samples) / frame->header.sample_rate;
|
||||||
data->time += timeChange;
|
data->time += timeChange;
|
||||||
|
|
||||||
FLAC__seekable_stream_decoder_get_decode_position(dec, &newPosition);
|
FLAC__stream_decoder_get_decode_position(dec, &newPosition);
|
||||||
if (data->position) {
|
if (data->position) {
|
||||||
data->bitRate =
|
data->bitRate =
|
||||||
((newPosition - data->position) * 8.0 / timeChange)
|
((newPosition - data->position) * 8.0 / timeChange)
|
||||||
|
@ -292,65 +287,27 @@ static MpdTag *flacTagDup(char *file)
|
||||||
static int flac_decode(OutputBuffer * cb, DecoderControl * dc,
|
static int flac_decode(OutputBuffer * cb, DecoderControl * dc,
|
||||||
InputStream * inStream)
|
InputStream * inStream)
|
||||||
{
|
{
|
||||||
FLAC__SeekableStreamDecoder *flacDec = NULL;
|
FLAC__StreamDecoder *flacDec;
|
||||||
FlacData data;
|
FlacData data;
|
||||||
int status = 1;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!(flacDec = FLAC__stream_decoder_new()))
|
||||||
|
return -1;
|
||||||
init_FlacData(&data, cb, dc, inStream);
|
init_FlacData(&data, cb, dc, inStream);
|
||||||
|
if (FLAC__stream_decoder_init_stream(flacDec, flacRead, flacSeek,
|
||||||
if (!(flacDec = FLAC__seekable_stream_decoder_new())) {
|
flacTell, flacLength, flacEOF,
|
||||||
ret = -1;
|
flacWrite, flacMetadata,
|
||||||
goto fail;
|
flacError, (void *)&data)
|
||||||
}
|
!= FLAC__STREAM_DECODER_INIT_STATUS_OK) {
|
||||||
/*status&=FLAC__file_decoder_set_md5_checking(flacDec,1); */
|
|
||||||
status &= FLAC__seekable_stream_decoder_set_read_callback(flacDec,
|
|
||||||
flacRead);
|
|
||||||
status &= FLAC__seekable_stream_decoder_set_seek_callback(flacDec,
|
|
||||||
flacSeek);
|
|
||||||
status &= FLAC__seekable_stream_decoder_set_tell_callback(flacDec,
|
|
||||||
flacTell);
|
|
||||||
status &= FLAC__seekable_stream_decoder_set_length_callback(flacDec,
|
|
||||||
flacLength);
|
|
||||||
status &=
|
|
||||||
FLAC__seekable_stream_decoder_set_eof_callback(flacDec, flacEOF);
|
|
||||||
status &=
|
|
||||||
FLAC__seekable_stream_decoder_set_write_callback(flacDec,
|
|
||||||
flacWrite);
|
|
||||||
status &=
|
|
||||||
FLAC__seekable_stream_decoder_set_metadata_callback(flacDec,
|
|
||||||
flacMetadata);
|
|
||||||
status &=
|
|
||||||
FLAC__seekable_stream_decoder_set_metadata_respond(flacDec,
|
|
||||||
FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
|
||||||
status &=
|
|
||||||
FLAC__seekable_stream_decoder_set_error_callback(flacDec,
|
|
||||||
flacError);
|
|
||||||
status &=
|
|
||||||
FLAC__seekable_stream_decoder_set_client_data(flacDec,
|
|
||||||
(void *)&data);
|
|
||||||
if (!status) {
|
|
||||||
ERROR("flac problem before init()\n");
|
|
||||||
flacPrintErroredState(FLAC__seekable_stream_decoder_get_state
|
|
||||||
(flacDec));
|
|
||||||
ret = -1;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FLAC__seekable_stream_decoder_init(flacDec) !=
|
|
||||||
FLAC__SEEKABLE_STREAM_DECODER_OK) {
|
|
||||||
ERROR("flac problem doing init()\n");
|
ERROR("flac problem doing init()\n");
|
||||||
flacPrintErroredState(FLAC__seekable_stream_decoder_get_state
|
flacPrintErroredState(FLAC__stream_decoder_get_state(flacDec));
|
||||||
(flacDec));
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FLAC__seekable_stream_decoder_process_until_end_of_metadata
|
if (!FLAC__stream_decoder_process_until_end_of_metadata(flacDec)) {
|
||||||
(flacDec)) {
|
|
||||||
ERROR("flac problem reading metadata\n");
|
ERROR("flac problem reading metadata\n");
|
||||||
flacPrintErroredState(FLAC__seekable_stream_decoder_get_state
|
flacPrintErroredState(FLAC__stream_decoder_get_state(flacDec));
|
||||||
(flacDec));
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -358,16 +315,16 @@ static int flac_decode(OutputBuffer * cb, DecoderControl * dc,
|
||||||
dc->state = DECODE_STATE_DECODE;
|
dc->state = DECODE_STATE_DECODE;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
FLAC__seekable_stream_decoder_process_single(flacDec);
|
if (!FLAC__stream_decoder_process_single(flacDec))
|
||||||
if (FLAC__seekable_stream_decoder_get_state(flacDec) !=
|
break;
|
||||||
FLAC__SEEKABLE_STREAM_DECODER_OK) {
|
if (FLAC__stream_decoder_get_state(flacDec) ==
|
||||||
|
FLAC__STREAM_DECODER_END_OF_STREAM)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
if (dc->seek) {
|
if (dc->seek) {
|
||||||
FLAC__uint64 sampleToSeek = dc->seekWhere *
|
FLAC__uint64 sampleToSeek = dc->seekWhere *
|
||||||
dc->audioFormat.sampleRate + 0.5;
|
dc->audioFormat.sampleRate + 0.5;
|
||||||
if (FLAC__seekable_stream_decoder_seek_absolute(flacDec,
|
if (FLAC__stream_decoder_seek_absolute(flacDec,
|
||||||
sampleToSeek))
|
sampleToSeek))
|
||||||
{
|
{
|
||||||
clearOutputBuffer(cb);
|
clearOutputBuffer(cb);
|
||||||
data.time = ((float)sampleToSeek) /
|
data.time = ((float)sampleToSeek) /
|
||||||
|
@ -378,12 +335,9 @@ static int flac_decode(OutputBuffer * cb, DecoderControl * dc,
|
||||||
dc->seek = 0;
|
dc->seek = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* I don't think we need this bit here! -shank */
|
|
||||||
/*FLAC__file_decoder_process_until_end_of_file(flacDec); */
|
|
||||||
if (!dc->stop) {
|
if (!dc->stop) {
|
||||||
flacPrintErroredState(FLAC__seekable_stream_decoder_get_state
|
flacPrintErroredState(FLAC__stream_decoder_get_state(flacDec));
|
||||||
(flacDec));
|
FLAC__stream_decoder_finish(flacDec);
|
||||||
FLAC__seekable_stream_decoder_finish(flacDec);
|
|
||||||
}
|
}
|
||||||
/* send last little bit */
|
/* send last little bit */
|
||||||
if (data.chunk_length > 0 && !dc->stop) {
|
if (data.chunk_length > 0 && !dc->stop) {
|
||||||
|
@ -404,7 +358,7 @@ fail:
|
||||||
freeReplayGainInfo(data.replayGainInfo);
|
freeReplayGainInfo(data.replayGainInfo);
|
||||||
|
|
||||||
if (flacDec)
|
if (flacDec)
|
||||||
FLAC__seekable_stream_decoder_delete(flacDec);
|
FLAC__stream_decoder_delete(flacDec);
|
||||||
|
|
||||||
closeInputStream(inStream);
|
closeInputStream(inStream);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue