2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2019-06-17 11:17:30 +02:00
|
|
|
* Copyright 2003-2019 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2013-05-05 14:19:04 +02:00
|
|
|
#include "FlacDecoderPlugin.h"
|
2016-07-10 21:21:35 +02:00
|
|
|
#include "FlacStreamDecoder.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
#include "FlacDomain.hxx"
|
2013-05-05 14:19:04 +02:00
|
|
|
#include "FlacCommon.hxx"
|
2018-07-07 14:09:26 +02:00
|
|
|
#include "lib/xiph/FlacMetadataChain.hxx"
|
2013-01-07 22:12:09 +01:00
|
|
|
#include "OggCodec.hxx"
|
2018-07-07 14:22:22 +02:00
|
|
|
#include "input/InputStream.hxx"
|
2014-02-07 18:52:19 +01:00
|
|
|
#include "fs/Path.hxx"
|
2015-03-05 09:13:51 +01:00
|
|
|
#include "fs/NarrowPath.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
#include "Log.hxx"
|
2009-11-11 16:43:34 +01:00
|
|
|
|
2012-10-02 10:04:44 +02:00
|
|
|
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
|
|
|
|
#error libFLAC is too old
|
|
|
|
#endif
|
|
|
|
|
2006-12-04 05:45:44 +01:00
|
|
|
static void flacPrintErroredState(FLAC__StreamDecoderState state)
|
2004-05-05 01:39:02 +02:00
|
|
|
{
|
2006-07-20 18:02:40 +02:00
|
|
|
switch (state) {
|
2006-12-04 05:45:44 +01:00
|
|
|
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
|
|
|
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;
|
2012-02-11 12:26:45 +01:00
|
|
|
|
2006-12-04 05:45:44 +01:00
|
|
|
case FLAC__STREAM_DECODER_OGG_ERROR:
|
|
|
|
case FLAC__STREAM_DECODER_SEEK_ERROR:
|
|
|
|
case FLAC__STREAM_DECODER_ABORTED:
|
|
|
|
case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
|
|
|
|
case FLAC__STREAM_DECODER_UNINITIALIZED:
|
2012-02-11 12:26:45 +01:00
|
|
|
break;
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
2008-11-21 20:15:50 +01:00
|
|
|
|
2013-09-27 22:31:24 +02:00
|
|
|
LogError(flac_domain, FLAC__StreamDecoderStateString[state]);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2013-08-04 23:48:01 +02:00
|
|
|
static void flacMetadata(gcc_unused const FLAC__StreamDecoder * dec,
|
2006-07-20 18:02:40 +02:00
|
|
|
const FLAC__StreamMetadata * block, void *vdata)
|
2004-05-05 01:39:02 +02:00
|
|
|
{
|
2016-07-11 22:45:29 +02:00
|
|
|
auto &fd = *(FlacDecoder *)vdata;
|
|
|
|
fd.OnMetadata(*block);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-01-15 19:50:28 +01:00
|
|
|
static FLAC__StreamDecoderWriteStatus
|
2009-11-11 16:59:28 +01:00
|
|
|
flac_write_cb(const FLAC__StreamDecoder *dec, const FLAC__Frame *frame,
|
2009-01-15 19:50:28 +01:00
|
|
|
const FLAC__int32 *const buf[], void *vdata)
|
2004-05-05 01:39:02 +02:00
|
|
|
{
|
2016-07-11 22:45:29 +02:00
|
|
|
auto &fd = *(FlacDecoder *)vdata;
|
|
|
|
return fd.OnWrite(*frame, buf, fd.GetDeltaPosition(*dec));
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2012-02-11 19:12:02 +01:00
|
|
|
static bool
|
2018-07-05 19:07:05 +02:00
|
|
|
flac_scan_file(Path path_fs, TagHandler &handler) noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-05-05 14:19:04 +02:00
|
|
|
FlacMetadataChain chain;
|
2015-03-05 09:13:51 +01:00
|
|
|
if (!chain.Read(NarrowPath(path_fs))) {
|
2013-09-27 22:31:24 +02:00
|
|
|
FormatDebug(flac_domain,
|
|
|
|
"Failed to read FLAC tags: %s",
|
|
|
|
chain.GetStatusString());
|
2012-10-04 07:11:41 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:07:05 +02:00
|
|
|
chain.Scan(handler);
|
2012-10-04 07:11:41 +02:00
|
|
|
return true;
|
2004-05-31 03:54:10 +02:00
|
|
|
}
|
|
|
|
|
2012-10-04 07:09:31 +02:00
|
|
|
static bool
|
2018-07-05 19:07:05 +02:00
|
|
|
flac_scan_stream(InputStream &is, TagHandler &handler) noexcept
|
2012-10-04 07:09:31 +02:00
|
|
|
{
|
2013-05-05 14:19:04 +02:00
|
|
|
FlacMetadataChain chain;
|
2012-10-04 07:09:31 +02:00
|
|
|
if (!chain.Read(is)) {
|
2013-09-27 22:31:24 +02:00
|
|
|
FormatDebug(flac_domain,
|
|
|
|
"Failed to read FLAC tags: %s",
|
|
|
|
chain.GetStatusString());
|
2012-10-04 07:09:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:07:05 +02:00
|
|
|
chain.Scan(handler);
|
2012-10-04 07:09:31 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-11-11 18:56:10 +01:00
|
|
|
/**
|
|
|
|
* Some glue code around FLAC__stream_decoder_new().
|
|
|
|
*/
|
2016-07-10 21:21:35 +02:00
|
|
|
static FlacStreamDecoder
|
2009-11-11 18:56:10 +01:00
|
|
|
flac_decoder_new(void)
|
|
|
|
{
|
2016-07-10 21:21:35 +02:00
|
|
|
FlacStreamDecoder sd;
|
|
|
|
if(!FLAC__stream_decoder_set_metadata_respond(sd.get(), FLAC__METADATA_TYPE_VORBIS_COMMENT))
|
2013-09-27 22:31:24 +02:00
|
|
|
LogDebug(flac_domain,
|
|
|
|
"FLAC__stream_decoder_set_metadata_respond() has failed");
|
2009-11-11 18:56:10 +01:00
|
|
|
|
|
|
|
return sd;
|
|
|
|
}
|
|
|
|
|
2009-11-11 19:01:31 +01:00
|
|
|
static bool
|
2016-07-10 21:50:38 +02:00
|
|
|
flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd)
|
2009-11-11 19:01:31 +01:00
|
|
|
{
|
|
|
|
if (!FLAC__stream_decoder_process_until_end_of_metadata(sd)) {
|
2016-07-08 23:12:49 +02:00
|
|
|
if (FLAC__stream_decoder_get_state(sd) != FLAC__STREAM_DECODER_END_OF_STREAM)
|
|
|
|
LogWarning(flac_domain, "problem reading metadata");
|
2009-11-11 19:01:31 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-03-21 18:21:47 +01:00
|
|
|
if (data->initialized) {
|
2010-01-06 09:54:09 +01:00
|
|
|
/* done */
|
|
|
|
return true;
|
2010-03-21 18:21:47 +01:00
|
|
|
}
|
2010-01-06 09:54:09 +01:00
|
|
|
|
2016-07-10 21:53:47 +02:00
|
|
|
if (data->GetInputStream().IsSeekable())
|
2010-01-06 09:54:09 +01:00
|
|
|
/* allow the workaround below only for nonseekable
|
|
|
|
streams*/
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* no stream_info packet found; try to initialize the decoder
|
|
|
|
from the first frame header */
|
|
|
|
FLAC__stream_decoder_process_single(sd);
|
2010-01-05 21:46:12 +01:00
|
|
|
return data->initialized;
|
2009-11-11 19:01:31 +01:00
|
|
|
}
|
|
|
|
|
2018-02-17 13:10:02 +01:00
|
|
|
static DecoderCommand
|
|
|
|
FlacSubmitToClient(DecoderClient &client, FlacDecoder &d) noexcept
|
|
|
|
{
|
2018-02-17 13:37:03 +01:00
|
|
|
if (d.tag.IsEmpty() && d.chunk.empty())
|
2018-02-17 13:10:04 +01:00
|
|
|
return client.GetCommand();
|
|
|
|
|
2018-02-17 13:10:02 +01:00
|
|
|
if (!d.tag.IsEmpty()) {
|
|
|
|
auto cmd = client.SubmitTag(d.GetInputStream(),
|
|
|
|
std::move(d.tag));
|
|
|
|
d.tag.Clear();
|
2018-02-17 13:10:04 +01:00
|
|
|
if (cmd != DecoderCommand::NONE)
|
|
|
|
return cmd;
|
|
|
|
}
|
|
|
|
|
2018-02-17 13:37:03 +01:00
|
|
|
if (!d.chunk.empty()) {
|
2018-02-17 13:10:04 +01:00
|
|
|
auto cmd = client.SubmitData(d.GetInputStream(),
|
|
|
|
d.chunk.data,
|
|
|
|
d.chunk.size,
|
|
|
|
d.kbit_rate);
|
|
|
|
d.chunk = nullptr;
|
|
|
|
if (cmd != DecoderCommand::NONE)
|
|
|
|
return cmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DecoderCommand::NONE;
|
2018-02-17 13:10:02 +01:00
|
|
|
}
|
|
|
|
|
2009-11-11 13:59:45 +01:00
|
|
|
static void
|
2016-07-10 21:50:38 +02:00
|
|
|
flac_decoder_loop(FlacDecoder *data, FLAC__StreamDecoder *flac_dec)
|
2009-11-11 13:59:45 +01:00
|
|
|
{
|
2016-11-18 07:13:35 +01:00
|
|
|
DecoderClient &client = *data->GetClient();
|
2009-11-11 13:59:45 +01:00
|
|
|
|
|
|
|
while (true) {
|
2018-02-17 13:10:02 +01:00
|
|
|
DecoderCommand cmd = FlacSubmitToClient(client, *data);
|
2009-11-11 13:59:45 +01:00
|
|
|
|
2013-09-27 12:11:37 +02:00
|
|
|
if (cmd == DecoderCommand::SEEK) {
|
2016-11-18 08:15:07 +01:00
|
|
|
FLAC__uint64 seek_sample = client.GetSeekFrame();
|
2016-07-08 21:59:30 +02:00
|
|
|
if (FLAC__stream_decoder_seek_absolute(flac_dec, seek_sample)) {
|
2009-11-11 13:59:45 +01:00
|
|
|
data->position = 0;
|
2016-11-18 08:15:07 +01:00
|
|
|
client.CommandFinished();
|
2009-11-11 13:59:45 +01:00
|
|
|
} else
|
2016-11-18 08:15:07 +01:00
|
|
|
client.SeekError();
|
2018-02-17 13:10:03 +01:00
|
|
|
|
|
|
|
/* FLAC__stream_decoder_seek_absolute()
|
|
|
|
decodes one frame and may have provided
|
|
|
|
data to be submitted to the client */
|
|
|
|
continue;
|
2016-07-05 19:27:40 +02:00
|
|
|
} else if (cmd == DecoderCommand::STOP)
|
2009-11-11 13:59:45 +01:00
|
|
|
break;
|
|
|
|
|
2016-07-05 19:27:40 +02:00
|
|
|
switch (FLAC__stream_decoder_get_state(flac_dec)) {
|
|
|
|
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
|
|
|
case FLAC__STREAM_DECODER_READ_METADATA:
|
|
|
|
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
|
|
|
|
case FLAC__STREAM_DECODER_READ_FRAME:
|
|
|
|
/* continue decoding */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FLAC__STREAM_DECODER_END_OF_STREAM:
|
|
|
|
/* regular end of stream */
|
|
|
|
return;
|
|
|
|
|
|
|
|
case FLAC__STREAM_DECODER_SEEK_ERROR:
|
2016-07-05 19:29:22 +02:00
|
|
|
/* try to recover from seek error */
|
|
|
|
if (!FLAC__stream_decoder_flush(flac_dec)) {
|
|
|
|
LogError(flac_domain, "FLAC__stream_decoder_flush() failed");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-11 13:59:45 +01:00
|
|
|
break;
|
|
|
|
|
2016-07-05 19:29:22 +02:00
|
|
|
case FLAC__STREAM_DECODER_OGG_ERROR:
|
2016-07-05 19:27:40 +02:00
|
|
|
case FLAC__STREAM_DECODER_ABORTED:
|
|
|
|
case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
|
|
|
|
/* an error, fatal enough for us to abort the
|
|
|
|
decoder */
|
|
|
|
return;
|
|
|
|
|
|
|
|
case FLAC__STREAM_DECODER_UNINITIALIZED:
|
|
|
|
/* we shouldn't see this, ever - bail out */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-11 12:47:43 +01:00
|
|
|
if (!FLAC__stream_decoder_process_single(flac_dec) &&
|
2016-11-18 08:15:07 +01:00
|
|
|
client.GetCommand() == DecoderCommand::NONE) {
|
2012-02-11 12:47:43 +01:00
|
|
|
/* a failure that was not triggered by a
|
|
|
|
decoder command */
|
|
|
|
flacPrintErroredState(FLAC__stream_decoder_get_state(flac_dec));
|
|
|
|
break;
|
2009-11-11 13:59:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-11 11:50:26 +01:00
|
|
|
static FLAC__StreamDecoderInitStatus
|
2016-07-10 21:50:38 +02:00
|
|
|
stream_init_oggflac(FLAC__StreamDecoder *flac_dec, FlacDecoder *data)
|
2012-02-11 11:50:26 +01:00
|
|
|
{
|
|
|
|
return FLAC__stream_decoder_init_ogg_stream(flac_dec,
|
2013-05-05 14:19:04 +02:00
|
|
|
FlacInput::Read,
|
|
|
|
FlacInput::Seek,
|
|
|
|
FlacInput::Tell,
|
|
|
|
FlacInput::Length,
|
|
|
|
FlacInput::Eof,
|
2012-02-11 11:50:26 +01:00
|
|
|
flac_write_cb,
|
|
|
|
flacMetadata,
|
2013-05-05 14:19:04 +02:00
|
|
|
FlacInput::Error,
|
2012-02-11 11:50:26 +01:00
|
|
|
data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static FLAC__StreamDecoderInitStatus
|
2016-07-10 21:50:38 +02:00
|
|
|
stream_init_flac(FLAC__StreamDecoder *flac_dec, FlacDecoder *data)
|
2012-02-11 11:50:26 +01:00
|
|
|
{
|
|
|
|
return FLAC__stream_decoder_init_stream(flac_dec,
|
2013-05-05 14:19:04 +02:00
|
|
|
FlacInput::Read,
|
|
|
|
FlacInput::Seek,
|
|
|
|
FlacInput::Tell,
|
|
|
|
FlacInput::Length,
|
|
|
|
FlacInput::Eof,
|
2012-10-02 19:27:30 +02:00
|
|
|
flac_write_cb,
|
2012-02-11 11:50:26 +01:00
|
|
|
flacMetadata,
|
2013-05-05 14:19:04 +02:00
|
|
|
FlacInput::Error,
|
2012-02-11 11:50:26 +01:00
|
|
|
data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static FLAC__StreamDecoderInitStatus
|
2016-07-10 21:50:38 +02:00
|
|
|
stream_init(FLAC__StreamDecoder *flac_dec, FlacDecoder *data, bool is_ogg)
|
2012-02-11 11:50:26 +01:00
|
|
|
{
|
|
|
|
return is_ogg
|
|
|
|
? stream_init_oggflac(flac_dec, data)
|
|
|
|
: stream_init_flac(flac_dec, data);
|
|
|
|
}
|
|
|
|
|
2016-07-08 23:03:49 +02:00
|
|
|
static bool
|
2016-07-10 21:50:38 +02:00
|
|
|
FlacInitAndDecode(FlacDecoder &data, FLAC__StreamDecoder *sd, bool is_ogg)
|
2016-07-08 23:03:49 +02:00
|
|
|
{
|
|
|
|
auto init_status = stream_init(sd, &data, is_ogg);
|
|
|
|
if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
|
|
|
|
LogWarning(flac_domain,
|
|
|
|
FLAC__StreamDecoderInitStatusString[init_status]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool result = flac_decoder_initialize(&data, sd);
|
|
|
|
if (result)
|
|
|
|
flac_decoder_loop(&data, sd);
|
|
|
|
|
|
|
|
FLAC__stream_decoder_finish(sd);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-11-11 17:13:44 +01:00
|
|
|
static void
|
2016-11-18 07:13:35 +01:00
|
|
|
flac_decode_internal(DecoderClient &client,
|
2013-10-23 22:08:59 +02:00
|
|
|
InputStream &input_stream,
|
2008-10-30 08:38:54 +01:00
|
|
|
bool is_ogg)
|
2006-12-04 05:45:41 +01:00
|
|
|
{
|
2016-07-10 21:21:35 +02:00
|
|
|
auto flac_dec = flac_decoder_new();
|
|
|
|
if (!flac_dec)
|
2008-11-11 17:13:44 +01:00
|
|
|
return;
|
2009-11-11 18:56:10 +01:00
|
|
|
|
2016-11-18 07:13:35 +01:00
|
|
|
FlacDecoder data(client, input_stream);
|
2007-12-07 00:01:28 +01:00
|
|
|
|
2016-07-10 21:21:35 +02:00
|
|
|
FlacInitAndDecode(data, flac_dec.get(), is_ogg);
|
2006-12-04 05:45:50 +01:00
|
|
|
}
|
|
|
|
|
2008-11-11 17:13:44 +01:00
|
|
|
static void
|
2016-11-18 07:13:35 +01:00
|
|
|
flac_decode(DecoderClient &client, InputStream &input_stream)
|
2006-12-04 05:45:50 +01:00
|
|
|
{
|
2016-11-18 07:13:35 +01:00
|
|
|
flac_decode_internal(client, input_stream, false);
|
2006-12-04 05:45:50 +01:00
|
|
|
}
|
|
|
|
|
2008-11-09 22:01:47 +01:00
|
|
|
static bool
|
2015-01-21 22:13:44 +01:00
|
|
|
oggflac_init(gcc_unused const ConfigBlock &block)
|
2008-11-09 22:01:47 +01:00
|
|
|
{
|
|
|
|
return !!FLAC_API_SUPPORTS_OGG_FLAC;
|
|
|
|
}
|
|
|
|
|
2012-02-11 19:12:02 +01:00
|
|
|
static bool
|
2018-07-05 19:07:05 +02:00
|
|
|
oggflac_scan_file(Path path_fs, TagHandler &handler) noexcept
|
2006-12-04 05:45:50 +01:00
|
|
|
{
|
2013-05-05 14:19:04 +02:00
|
|
|
FlacMetadataChain chain;
|
2015-03-05 09:13:51 +01:00
|
|
|
if (!chain.ReadOgg(NarrowPath(path_fs))) {
|
2013-09-27 22:31:24 +02:00
|
|
|
FormatDebug(flac_domain,
|
|
|
|
"Failed to read OggFLAC tags: %s",
|
|
|
|
chain.GetStatusString());
|
2012-02-11 19:12:02 +01:00
|
|
|
return false;
|
2012-02-11 11:50:26 +01:00
|
|
|
}
|
|
|
|
|
2018-07-05 19:07:05 +02:00
|
|
|
chain.Scan(handler);
|
2012-02-11 19:12:02 +01:00
|
|
|
return true;
|
2006-12-04 05:45:41 +01:00
|
|
|
}
|
|
|
|
|
2012-10-04 07:09:31 +02:00
|
|
|
static bool
|
2018-07-05 19:07:05 +02:00
|
|
|
oggflac_scan_stream(InputStream &is, TagHandler &handler) noexcept
|
2012-10-04 07:09:31 +02:00
|
|
|
{
|
2013-05-05 14:19:04 +02:00
|
|
|
FlacMetadataChain chain;
|
2012-10-04 07:09:31 +02:00
|
|
|
if (!chain.ReadOgg(is)) {
|
2013-09-27 22:31:24 +02:00
|
|
|
FormatDebug(flac_domain,
|
|
|
|
"Failed to read OggFLAC tags: %s",
|
|
|
|
chain.GetStatusString());
|
2012-10-04 07:09:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:07:05 +02:00
|
|
|
chain.Scan(handler);
|
2012-10-04 07:09:31 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-11-11 17:13:44 +01:00
|
|
|
static void
|
2016-11-18 07:13:35 +01:00
|
|
|
oggflac_decode(DecoderClient &client, InputStream &input_stream)
|
2006-12-04 05:45:50 +01:00
|
|
|
{
|
2016-11-18 07:13:35 +01:00
|
|
|
if (ogg_codec_detect(&client, input_stream) != OGG_CODEC_FLAC)
|
2008-11-11 17:13:44 +01:00
|
|
|
return;
|
2006-12-04 05:45:50 +01:00
|
|
|
|
2012-09-04 13:05:12 +02:00
|
|
|
/* rewind the stream, because ogg_codec_detect() has
|
2008-11-10 15:07:01 +01:00
|
|
|
moved it */
|
2016-09-09 18:47:42 +02:00
|
|
|
try {
|
|
|
|
input_stream.LockRewind();
|
2017-12-19 10:56:23 +01:00
|
|
|
} catch (...) {
|
2016-09-09 18:47:42 +02:00
|
|
|
}
|
2008-11-10 15:07:01 +01:00
|
|
|
|
2016-11-18 07:13:35 +01:00
|
|
|
flac_decode_internal(client, input_stream, true);
|
2006-12-04 05:45:50 +01:00
|
|
|
}
|
|
|
|
|
2012-10-02 10:56:44 +02:00
|
|
|
static const char *const oggflac_suffixes[] = { "ogg", "oga", nullptr };
|
2008-11-01 14:55:23 +01:00
|
|
|
static const char *const oggflac_mime_types[] = {
|
|
|
|
"application/ogg",
|
|
|
|
"application/x-ogg",
|
2009-12-29 22:33:46 +01:00
|
|
|
"audio/ogg",
|
|
|
|
"audio/x-flac+ogg",
|
|
|
|
"audio/x-ogg",
|
2012-10-02 10:56:44 +02:00
|
|
|
nullptr
|
2008-11-01 14:55:23 +01:00
|
|
|
};
|
2006-12-04 05:45:50 +01:00
|
|
|
|
2019-06-15 14:44:37 +02:00
|
|
|
constexpr DecoderPlugin oggflac_decoder_plugin =
|
|
|
|
DecoderPlugin("oggflac", oggflac_decode, oggflac_scan_stream,
|
|
|
|
nullptr, oggflac_scan_file)
|
|
|
|
.WithInit(oggflac_init)
|
|
|
|
.WithSuffixes(oggflac_suffixes)
|
|
|
|
.WithMimeTypes(oggflac_mime_types);
|
2006-12-04 05:45:50 +01:00
|
|
|
|
2012-10-02 10:56:44 +02:00
|
|
|
static const char *const flac_suffixes[] = { "flac", nullptr };
|
2008-11-01 14:55:23 +01:00
|
|
|
static const char *const flac_mime_types[] = {
|
2009-12-29 22:33:46 +01:00
|
|
|
"application/flac",
|
|
|
|
"application/x-flac",
|
|
|
|
"audio/flac",
|
|
|
|
"audio/x-flac",
|
2012-10-02 10:56:44 +02:00
|
|
|
nullptr
|
2008-11-01 14:55:23 +01:00
|
|
|
};
|
2004-05-31 03:54:10 +02:00
|
|
|
|
2019-06-15 14:44:37 +02:00
|
|
|
constexpr DecoderPlugin flac_decoder_plugin =
|
|
|
|
DecoderPlugin("flac", flac_decode, flac_scan_stream,
|
|
|
|
nullptr, flac_scan_file)
|
|
|
|
.WithSuffixes(flac_suffixes)
|
|
|
|
.WithMimeTypes(flac_mime_types);
|