Log: new logging library API
Prepare to migrate away from GLib. Currently, we're still using GLib as a backend.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <adplug/adplug.h>
|
||||
#include <adplug/emuopl.h>
|
||||
@@ -31,9 +32,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "adplug"
|
||||
|
||||
static unsigned sample_rate;
|
||||
|
||||
static bool
|
||||
@@ -43,7 +41,7 @@ adplug_init(const config_param ¶m)
|
||||
|
||||
sample_rate = param.GetBlockValue("sample_rate", 48000u);
|
||||
if (!audio_check_sample_rate(sample_rate, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,19 +24,19 @@
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <audiofile.h>
|
||||
#include <af_vfs.h>
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "audiofile"
|
||||
#include <assert.h>
|
||||
|
||||
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
|
||||
#define CHUNK_SIZE 1020
|
||||
|
||||
static constexpr Domain audiofile_domain("audiofile");
|
||||
|
||||
static int audiofile_get_duration(const char *file)
|
||||
{
|
||||
int total_time;
|
||||
@@ -59,7 +59,7 @@ audiofile_file_read(AFvirtualfile *vfile, void *data, size_t length)
|
||||
Error error;
|
||||
size_t nbytes = is->LockRead(data, length, error);
|
||||
if (nbytes == 0 && error.IsDefined()) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -143,8 +143,9 @@ audiofile_setup_sample_format(AFfilehandle af_fp)
|
||||
|
||||
afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
|
||||
if (!audio_valid_sample_format(audiofile_bits_to_sample_format(bits))) {
|
||||
g_debug("input file has %d bit samples, converting to 16",
|
||||
bits);
|
||||
FormatDebug(audiofile_domain,
|
||||
"input file has %d bit samples, converting to 16",
|
||||
bits);
|
||||
bits = 16;
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
char chunk[CHUNK_SIZE];
|
||||
|
||||
if (!is->IsSeekable()) {
|
||||
g_warning("not seekable");
|
||||
LogWarning(audiofile_domain, "not seekable");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -176,7 +177,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
|
||||
af_fp = afOpenVirtualFile(vf, "r", nullptr);
|
||||
if (af_fp == AF_NULL_FILEHANDLE) {
|
||||
g_warning("failed to input stream\n");
|
||||
LogWarning(audiofile_domain, "failed to input stream");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +187,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
audiofile_setup_sample_format(af_fp),
|
||||
afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK),
|
||||
error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
afCloseFile(af_fp);
|
||||
return;
|
||||
}
|
||||
@@ -232,8 +233,9 @@ audiofile_scan_file(const char *file,
|
||||
int total_time = audiofile_get_duration(file);
|
||||
|
||||
if (total_time < 0) {
|
||||
g_debug("Failed to get total song time from: %s\n",
|
||||
file);
|
||||
FormatWarning(audiofile_domain,
|
||||
"Failed to get total song time from: %s",
|
||||
file);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,13 +35,11 @@
|
||||
#include "util/Error.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "DsdLib.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h> /* for SEEK_SET, SEEK_CUR */
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "dsdiff"
|
||||
|
||||
struct DsdiffHeader {
|
||||
struct dsdlib_id id;
|
||||
uint32_t size_high, size_low;
|
||||
@@ -437,7 +435,7 @@ dsdiff_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
if (!audio_format_init_checked(audio_format, metadata.sample_rate / 8,
|
||||
SampleFormat::DSD,
|
||||
metadata.channels, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,13 +36,11 @@
|
||||
#include "util/Error.hxx"
|
||||
#include "DsdLib.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h> /* for SEEK_SET, SEEK_CUR */
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "dsf"
|
||||
|
||||
struct DsfMetaData {
|
||||
unsigned sample_rate, channels;
|
||||
bool bitreverse;
|
||||
@@ -290,7 +288,7 @@ dsf_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
if (!audio_format_init_checked(audio_format, metadata.sample_rate / 8,
|
||||
SampleFormat::DSD,
|
||||
metadata.channels, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return;
|
||||
}
|
||||
/* Calculate song time from DSD chunk size and sample frequency */
|
||||
|
||||
@@ -26,18 +26,14 @@
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <neaacdec.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "faad"
|
||||
|
||||
#define AAC_MAX_CHANNELS 6
|
||||
|
||||
static const unsigned adts_sample_rates[] =
|
||||
@@ -395,7 +391,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
|
||||
Error error;
|
||||
ret = faad_decoder_init(decoder, buffer, audio_format, error);
|
||||
if (!ret) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
NeAACDecClose(decoder);
|
||||
return;
|
||||
}
|
||||
@@ -424,21 +420,24 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
|
||||
decoded = faad_decoder_decode(decoder, buffer, &frame_info);
|
||||
|
||||
if (frame_info.error > 0) {
|
||||
g_warning("error decoding AAC stream: %s\n",
|
||||
NeAACDecGetErrorMessage(frame_info.error));
|
||||
FormatWarning(faad_decoder_domain,
|
||||
"error decoding AAC stream: %s",
|
||||
NeAACDecGetErrorMessage(frame_info.error));
|
||||
break;
|
||||
}
|
||||
|
||||
if (frame_info.channels != audio_format.channels) {
|
||||
g_warning("channel count changed from %u to %u",
|
||||
audio_format.channels, frame_info.channels);
|
||||
FormatInfo(faad_decoder_domain,
|
||||
"channel count changed from %u to %u",
|
||||
audio_format.channels, frame_info.channels);
|
||||
break;
|
||||
}
|
||||
|
||||
if (frame_info.samplerate != audio_format.sample_rate) {
|
||||
g_warning("sample rate changed from %u to %lu",
|
||||
audio_format.sample_rate,
|
||||
(unsigned long)frame_info.samplerate);
|
||||
FormatInfo(faad_decoder_domain,
|
||||
"sample rate changed from %u to %lu",
|
||||
audio_format.sample_rate,
|
||||
(unsigned long)frame_info.samplerate);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "InputStream.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "LogV.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -50,27 +52,26 @@ extern "C" {
|
||||
#include <libavutil/dict.h>
|
||||
}
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "ffmpeg"
|
||||
static constexpr Domain ffmpeg_domain("ffmpeg");
|
||||
|
||||
/* suppress the ffmpeg compatibility macro */
|
||||
#ifdef SampleFormat
|
||||
#undef SampleFormat
|
||||
#endif
|
||||
|
||||
static GLogLevelFlags
|
||||
level_ffmpeg_to_glib(int level)
|
||||
static LogLevel
|
||||
import_ffmpeg_level(int level)
|
||||
{
|
||||
if (level <= AV_LOG_FATAL)
|
||||
return G_LOG_LEVEL_CRITICAL;
|
||||
return LogLevel::ERROR;
|
||||
|
||||
if (level <= AV_LOG_ERROR)
|
||||
return G_LOG_LEVEL_WARNING;
|
||||
if (level <= AV_LOG_WARNING)
|
||||
return LogLevel::WARNING;
|
||||
|
||||
if (level <= AV_LOG_INFO)
|
||||
return G_LOG_LEVEL_MESSAGE;
|
||||
return LogLevel::INFO;
|
||||
|
||||
return G_LOG_LEVEL_DEBUG;
|
||||
return LogLevel::DEBUG;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -83,8 +84,9 @@ mpd_ffmpeg_log_callback(gcc_unused void *ptr, int level,
|
||||
cls = *(const AVClass *const*)ptr;
|
||||
|
||||
if (cls != NULL) {
|
||||
char *domain = g_strconcat(G_LOG_DOMAIN, "/", cls->item_name(ptr), NULL);
|
||||
g_logv(domain, level_ffmpeg_to_glib(level), fmt, vl);
|
||||
char *domain = g_strconcat(ffmpeg_domain.GetName(), "/", cls->item_name(ptr), NULL);
|
||||
const Domain d(domain);
|
||||
LogFormatV(d, import_ffmpeg_level(level), fmt, vl);
|
||||
g_free(domain);
|
||||
}
|
||||
}
|
||||
@@ -287,7 +289,8 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
|
||||
|
||||
if (len < 0) {
|
||||
/* if error, we skip the frame */
|
||||
g_message("decoding failed, frame skipped\n");
|
||||
LogInfo(ffmpeg_domain,
|
||||
"decoding failed, frame skipped");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -328,11 +331,13 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
|
||||
const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),
|
||||
sample_fmt);
|
||||
if (name != NULL)
|
||||
g_warning("Unsupported libavcodec SampleFormat value: %s (%d)",
|
||||
name, sample_fmt);
|
||||
FormatError(ffmpeg_domain,
|
||||
"Unsupported libavcodec SampleFormat value: %s (%d)",
|
||||
name, sample_fmt);
|
||||
else
|
||||
g_warning("Unsupported libavcodec SampleFormat value: %d",
|
||||
sample_fmt);
|
||||
FormatError(ffmpeg_domain,
|
||||
"Unsupported libavcodec SampleFormat value: %d",
|
||||
sample_fmt);
|
||||
return SampleFormat::UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -377,12 +382,12 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
||||
if (input_format == NULL)
|
||||
return;
|
||||
|
||||
g_debug("detected input format '%s' (%s)",
|
||||
input_format->name, input_format->long_name);
|
||||
FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)",
|
||||
input_format->name, input_format->long_name);
|
||||
|
||||
AvioStream stream(decoder, input);
|
||||
if (!stream.Open()) {
|
||||
g_warning("Failed to open stream");
|
||||
LogError(ffmpeg_domain, "Failed to open stream");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -391,21 +396,21 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
||||
if (mpd_ffmpeg_open_input(&format_context, stream.io,
|
||||
input->uri.c_str(),
|
||||
input_format) != 0) {
|
||||
g_warning("Open failed\n");
|
||||
LogError(ffmpeg_domain, "Open failed");
|
||||
return;
|
||||
}
|
||||
|
||||
const int find_result =
|
||||
avformat_find_stream_info(format_context, NULL);
|
||||
if (find_result < 0) {
|
||||
g_warning("Couldn't find stream info\n");
|
||||
LogError(ffmpeg_domain, "Couldn't find stream info");
|
||||
avformat_close_input(&format_context);
|
||||
return;
|
||||
}
|
||||
|
||||
int audio_stream = ffmpeg_find_audio_stream(format_context);
|
||||
if (audio_stream == -1) {
|
||||
g_warning("No audio stream inside\n");
|
||||
LogError(ffmpeg_domain, "No audio stream inside");
|
||||
avformat_close_input(&format_context);
|
||||
return;
|
||||
}
|
||||
@@ -414,12 +419,13 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
||||
|
||||
AVCodecContext *codec_context = av_stream->codec;
|
||||
if (codec_context->codec_name[0] != 0)
|
||||
g_debug("codec '%s'", codec_context->codec_name);
|
||||
FormatDebug(ffmpeg_domain, "codec '%s'",
|
||||
codec_context->codec_name);
|
||||
|
||||
AVCodec *codec = avcodec_find_decoder(codec_context->codec_id);
|
||||
|
||||
if (!codec) {
|
||||
g_warning("Unsupported audio codec\n");
|
||||
LogError(ffmpeg_domain, "Unsupported audio codec");
|
||||
avformat_close_input(&format_context);
|
||||
return;
|
||||
}
|
||||
@@ -435,7 +441,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
||||
codec_context->sample_rate,
|
||||
sample_format,
|
||||
codec_context->channels, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
avformat_close_input(&format_context);
|
||||
return;
|
||||
}
|
||||
@@ -447,7 +453,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
||||
|
||||
const int open_result = avcodec_open2(codec_context, codec, NULL);
|
||||
if (open_result < 0) {
|
||||
g_warning("Could not open codec\n");
|
||||
LogError(ffmpeg_domain, "Could not open codec");
|
||||
avformat_close_input(&format_context);
|
||||
return;
|
||||
}
|
||||
@@ -461,7 +467,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
||||
|
||||
AVFrame *frame = avcodec_alloc_frame();
|
||||
if (!frame) {
|
||||
g_warning("Could not allocate frame\n");
|
||||
LogError(ffmpeg_domain, "Could not allocate frame");
|
||||
avformat_close_input(&format_context);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
#include "tag/TagTable.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "ffmpeg"
|
||||
|
||||
static const struct tag_table ffmpeg_tags[] = {
|
||||
{ "year", TAG_DATE },
|
||||
{ "author-sort", TAG_ARTIST_SORT },
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include "FlacPcm.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -74,7 +74,7 @@ flac_got_stream_info(struct flac_data *data,
|
||||
stream_info->sample_rate,
|
||||
flac_sample_format(stream_info->bits_per_sample),
|
||||
stream_info->channels, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
data->unsupported = true;
|
||||
return;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ flac_got_first_frame(struct flac_data *data, const FLAC__FrameHeader *header)
|
||||
header->sample_rate,
|
||||
flac_sample_format(header->bits_per_sample),
|
||||
header->channels, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
data->unsupported = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
#include <FLAC/stream_decoder.h>
|
||||
#include <FLAC/metadata.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "flac"
|
||||
|
||||
struct flac_data : public FlacInput {
|
||||
PcmBuffer buffer;
|
||||
|
||||
|
||||
@@ -19,10 +19,12 @@
|
||||
|
||||
#include "config.h" /* must be first for large file support */
|
||||
#include "FlacDecoderPlugin.h"
|
||||
#include "FlacDomain.hxx"
|
||||
#include "FlacCommon.hxx"
|
||||
#include "FlacMetadata.hxx"
|
||||
#include "OggCodec.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -54,7 +56,7 @@ static void flacPrintErroredState(FLAC__StreamDecoderState state)
|
||||
break;
|
||||
}
|
||||
|
||||
g_warning("%s\n", FLAC__StreamDecoderStateString[state]);
|
||||
LogError(flac_domain, FLAC__StreamDecoderStateString[state]);
|
||||
}
|
||||
|
||||
static void flacMetadata(gcc_unused const FLAC__StreamDecoder * dec,
|
||||
@@ -90,8 +92,9 @@ flac_scan_file(const char *file,
|
||||
{
|
||||
FlacMetadataChain chain;
|
||||
if (!chain.Read(file)) {
|
||||
g_debug("Failed to read FLAC tags: %s",
|
||||
chain.GetStatusString());
|
||||
FormatDebug(flac_domain,
|
||||
"Failed to read FLAC tags: %s",
|
||||
chain.GetStatusString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,8 +108,9 @@ flac_scan_stream(struct input_stream *is,
|
||||
{
|
||||
FlacMetadataChain chain;
|
||||
if (!chain.Read(is)) {
|
||||
g_debug("Failed to read FLAC tags: %s",
|
||||
chain.GetStatusString());
|
||||
FormatDebug(flac_domain,
|
||||
"Failed to read FLAC tags: %s",
|
||||
chain.GetStatusString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,12 +126,14 @@ flac_decoder_new(void)
|
||||
{
|
||||
FLAC__StreamDecoder *sd = FLAC__stream_decoder_new();
|
||||
if (sd == nullptr) {
|
||||
g_warning("FLAC__stream_decoder_new() failed");
|
||||
LogError(flac_domain,
|
||||
"FLAC__stream_decoder_new() failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!FLAC__stream_decoder_set_metadata_respond(sd, FLAC__METADATA_TYPE_VORBIS_COMMENT))
|
||||
g_debug("FLAC__stream_decoder_set_metadata_respond() has failed");
|
||||
LogDebug(flac_domain,
|
||||
"FLAC__stream_decoder_set_metadata_respond() has failed");
|
||||
|
||||
return sd;
|
||||
}
|
||||
@@ -139,7 +145,7 @@ flac_decoder_initialize(struct flac_data *data, FLAC__StreamDecoder *sd,
|
||||
data->total_frames = duration;
|
||||
|
||||
if (!FLAC__stream_decoder_process_until_end_of_metadata(sd)) {
|
||||
g_warning("problem reading metadata");
|
||||
LogWarning(flac_domain, "problem reading metadata");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -265,7 +271,8 @@ flac_decode_internal(struct decoder * decoder,
|
||||
stream_init(flac_dec, &data, is_ogg);
|
||||
if (status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
|
||||
FLAC__stream_decoder_delete(flac_dec);
|
||||
g_warning("%s", FLAC__StreamDecoderInitStatusString[status]);
|
||||
LogWarning(flac_domain,
|
||||
FLAC__StreamDecoderInitStatusString[status]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -299,8 +306,9 @@ oggflac_scan_file(const char *file,
|
||||
{
|
||||
FlacMetadataChain chain;
|
||||
if (!chain.ReadOgg(file)) {
|
||||
g_debug("Failed to read OggFLAC tags: %s",
|
||||
chain.GetStatusString());
|
||||
FormatDebug(flac_domain,
|
||||
"Failed to read OggFLAC tags: %s",
|
||||
chain.GetStatusString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -314,8 +322,9 @@ oggflac_scan_stream(struct input_stream *is,
|
||||
{
|
||||
FlacMetadataChain chain;
|
||||
if (!chain.ReadOgg(is)) {
|
||||
g_debug("Failed to read OggFLAC tags: %s",
|
||||
chain.GetStatusString());
|
||||
FormatDebug(flac_domain,
|
||||
"Failed to read OggFLAC tags: %s",
|
||||
chain.GetStatusString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
24
src/decoder/FlacDomain.cxx
Normal file
24
src/decoder/FlacDomain.cxx
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2012 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "FlacDomain.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
const Domain flac_domain("flac");
|
||||
27
src/decoder/FlacDomain.hxx
Normal file
27
src/decoder/FlacDomain.hxx
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2012 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_FLAC_DOMAIN_HXX
|
||||
#define MPD_FLAC_DOMAIN_HXX
|
||||
|
||||
#include "check.h"
|
||||
|
||||
extern const class Domain flac_domain;
|
||||
|
||||
#endif
|
||||
@@ -19,9 +19,11 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "FlacInput.hxx"
|
||||
#include "FlacDomain.hxx"
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
#include "gcc.h"
|
||||
|
||||
FLAC__StreamDecoderReadStatus
|
||||
@@ -49,8 +51,10 @@ FlacInput::Seek(FLAC__uint64 absolute_byte_offset)
|
||||
return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
|
||||
|
||||
::Error error;
|
||||
if (!input_stream->LockSeek(absolute_byte_offset, SEEK_SET, error))
|
||||
if (!input_stream->LockSeek(absolute_byte_offset, SEEK_SET, error)) {
|
||||
LogError(error);
|
||||
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
|
||||
}
|
||||
|
||||
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
||||
}
|
||||
@@ -89,7 +93,8 @@ FlacInput::Error(FLAC__StreamDecoderErrorStatus status)
|
||||
{
|
||||
if (decoder == nullptr ||
|
||||
decoder_get_command(decoder) != DecoderCommand::STOP)
|
||||
g_warning("%s", FLAC__StreamDecoderErrorStatusString[status]);
|
||||
LogWarning(flac_domain,
|
||||
FLAC__StreamDecoderErrorStatusString[status]);
|
||||
}
|
||||
|
||||
FLAC__StreamDecoderReadStatus
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <fluidsynth.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "fluidsynth"
|
||||
static constexpr Domain fluidsynth_domain("fluidsynth");
|
||||
|
||||
static unsigned sample_rate;
|
||||
static const char *soundfont_path;
|
||||
@@ -36,27 +37,27 @@ static const char *soundfont_path;
|
||||
/**
|
||||
* Convert a fluidsynth log level to a GLib log level.
|
||||
*/
|
||||
static GLogLevelFlags
|
||||
fluidsynth_level_to_glib(enum fluid_log_level level)
|
||||
static LogLevel
|
||||
fluidsynth_level_to_mpd(enum fluid_log_level level)
|
||||
{
|
||||
switch (level) {
|
||||
case FLUID_PANIC:
|
||||
case FLUID_ERR:
|
||||
return G_LOG_LEVEL_CRITICAL;
|
||||
return LogLevel::ERROR;
|
||||
|
||||
case FLUID_WARN:
|
||||
return G_LOG_LEVEL_WARNING;
|
||||
return LogLevel::WARNING;
|
||||
|
||||
case FLUID_INFO:
|
||||
return G_LOG_LEVEL_INFO;
|
||||
return LogLevel::INFO;
|
||||
|
||||
case FLUID_DBG:
|
||||
case LAST_LOG_LEVEL:
|
||||
return G_LOG_LEVEL_DEBUG;
|
||||
return LogLevel::DEBUG;
|
||||
}
|
||||
|
||||
/* invalid fluidsynth log level */
|
||||
return G_LOG_LEVEL_MESSAGE;
|
||||
return LogLevel::INFO;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,8 +67,9 @@ fluidsynth_level_to_glib(enum fluid_log_level level)
|
||||
static void
|
||||
fluidsynth_mpd_log_function(int level, char *message, gcc_unused void *data)
|
||||
{
|
||||
g_log(G_LOG_DOMAIN, fluidsynth_level_to_glib(fluid_log_level(level)),
|
||||
"%s", message);
|
||||
Log(fluidsynth_domain,
|
||||
fluidsynth_level_to_mpd(fluid_log_level(level)),
|
||||
message);
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -77,7 +79,7 @@ fluidsynth_init(const config_param ¶m)
|
||||
|
||||
sample_rate = param.GetBlockValue("sample_rate", 48000u);
|
||||
if (!audio_check_sample_rate(sample_rate, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -125,7 +127,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
|
||||
ret = fluid_synth_sfload(synth, soundfont_path, true);
|
||||
if (ret < 0) {
|
||||
g_warning("fluid_synth_sfload() failed");
|
||||
LogWarning(fluidsynth_domain, "fluid_synth_sfload() failed");
|
||||
delete_fluid_synth(synth);
|
||||
delete_fluid_settings(settings);
|
||||
return;
|
||||
@@ -142,7 +144,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
|
||||
ret = fluid_player_add(player, path_fs);
|
||||
if (ret != 0) {
|
||||
g_warning("fluid_player_add() failed");
|
||||
LogWarning(fluidsynth_domain, "fluid_player_add() failed");
|
||||
delete_fluid_player(player);
|
||||
delete_fluid_synth(synth);
|
||||
delete_fluid_settings(settings);
|
||||
@@ -153,7 +155,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
|
||||
ret = fluid_player_play(player);
|
||||
if (ret != 0) {
|
||||
g_warning("fluid_player_play() failed");
|
||||
LogWarning(fluidsynth_domain, "fluid_player_play() failed");
|
||||
delete_fluid_player(player);
|
||||
delete_fluid_synth(synth);
|
||||
delete_fluid_settings(settings);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
#include <assert.h>
|
||||
@@ -32,11 +34,10 @@
|
||||
|
||||
#include <gme/gme.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "gme"
|
||||
|
||||
#define SUBTUNE_PREFIX "tune_"
|
||||
|
||||
static constexpr Domain gme_domain("gme");
|
||||
|
||||
static constexpr unsigned GME_SAMPLE_RATE = 44100;
|
||||
static constexpr unsigned GME_CHANNELS = 2;
|
||||
static constexpr unsigned GME_BUFFER_FRAMES = 2048;
|
||||
@@ -106,7 +107,7 @@ gme_container_scan(const char *path_fs, const unsigned int tnum)
|
||||
Music_Emu *emu;
|
||||
const char *gme_err = gme_open_file(path_fs, &emu, GME_SAMPLE_RATE);
|
||||
if (gme_err != nullptr) {
|
||||
g_warning("%s", gme_err);
|
||||
LogWarning(gme_domain, gme_err);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
gme_open_file(path_container, &emu, GME_SAMPLE_RATE);
|
||||
g_free(path_container);
|
||||
if (gme_err != nullptr) {
|
||||
g_warning("%s", gme_err);
|
||||
LogWarning(gme_domain, gme_err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
const int song_num = get_song_num(path_fs);
|
||||
gme_err = gme_track_info(emu, &ti, song_num);
|
||||
if (gme_err != nullptr) {
|
||||
g_warning("%s", gme_err);
|
||||
LogWarning(gme_domain, gme_err);
|
||||
gme_delete(emu);
|
||||
return;
|
||||
}
|
||||
@@ -158,7 +159,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
if (!audio_format_init_checked(audio_format, GME_SAMPLE_RATE,
|
||||
SampleFormat::S16, GME_CHANNELS,
|
||||
error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
gme_free_info(ti);
|
||||
gme_delete(emu);
|
||||
return;
|
||||
@@ -168,7 +169,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
|
||||
gme_err = gme_start_track(emu, song_num);
|
||||
if (gme_err != nullptr)
|
||||
g_warning("%s", gme_err);
|
||||
LogWarning(gme_domain, gme_err);
|
||||
|
||||
if (ti->length > 0)
|
||||
gme_set_fade(emu, ti->length);
|
||||
@@ -179,7 +180,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
short buf[GME_BUFFER_SAMPLES];
|
||||
gme_err = gme_play(emu, GME_BUFFER_SAMPLES, buf);
|
||||
if (gme_err != nullptr) {
|
||||
g_warning("%s", gme_err);
|
||||
LogWarning(gme_domain, gme_err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -188,7 +189,7 @@ gme_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
float where = decoder_seek_where(decoder);
|
||||
gme_err = gme_seek(emu, int(where * 1000));
|
||||
if (gme_err != nullptr)
|
||||
g_warning("%s", gme_err);
|
||||
LogWarning(gme_domain, gme_err);
|
||||
decoder_command_finished(decoder);
|
||||
}
|
||||
|
||||
@@ -211,7 +212,7 @@ gme_scan_file(const char *path_fs,
|
||||
gme_open_file(path_container, &emu, GME_SAMPLE_RATE);
|
||||
g_free(path_container);
|
||||
if (gme_err != nullptr) {
|
||||
g_warning("%s", gme_err);
|
||||
LogWarning(gme_domain, gme_err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ gme_scan_file(const char *path_fs,
|
||||
gme_info_t *ti;
|
||||
gme_err = gme_track_info(emu, &ti, song_num);
|
||||
if (gme_err != nullptr) {
|
||||
g_warning("%s", gme_err);
|
||||
LogWarning(gme_domain, gme_err);
|
||||
gme_delete(emu);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
@@ -40,9 +42,6 @@
|
||||
#include <id3tag.h>
|
||||
#endif
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "mad"
|
||||
|
||||
#define FRAMES_CUSHION 2000
|
||||
|
||||
#define READ_BUFFER_SIZE 40960
|
||||
@@ -65,6 +64,8 @@ enum muteframe {
|
||||
|
||||
#define DEFAULT_GAPLESS_MP3_PLAYBACK true
|
||||
|
||||
static constexpr Domain mad_domain("mad");
|
||||
|
||||
static bool gapless_playback;
|
||||
|
||||
static inline int32_t
|
||||
@@ -367,7 +368,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
|
||||
}
|
||||
|
||||
if (count != tagsize) {
|
||||
g_debug("error parsing ID3 tag");
|
||||
LogDebug(mad_domain, "error parsing ID3 tag");
|
||||
g_free(allocated);
|
||||
return;
|
||||
}
|
||||
@@ -482,9 +483,9 @@ MadDecoder::DecodeNextFrameHeader(Tag **tag)
|
||||
if (stream.error == MAD_ERROR_BUFLEN)
|
||||
return DECODE_CONT;
|
||||
else {
|
||||
g_warning("unrecoverable frame level error "
|
||||
"(%s).\n",
|
||||
mad_stream_errorstr(&stream));
|
||||
FormatWarning(mad_domain,
|
||||
"unrecoverable frame level error: %s",
|
||||
mad_stream_errorstr(&stream));
|
||||
return DECODE_BREAK;
|
||||
}
|
||||
}
|
||||
@@ -529,9 +530,9 @@ MadDecoder::DecodeNextFrame()
|
||||
if (stream.error == MAD_ERROR_BUFLEN)
|
||||
return DECODE_CONT;
|
||||
else {
|
||||
g_warning("unrecoverable frame level error "
|
||||
"(%s).\n",
|
||||
mad_stream_errorstr(&stream));
|
||||
FormatWarning(mad_domain,
|
||||
"unrecoverable frame level error: %s",
|
||||
mad_stream_errorstr(&stream));
|
||||
return DECODE_BREAK;
|
||||
}
|
||||
}
|
||||
@@ -702,8 +703,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
|
||||
&lame->version.major, &lame->version.minor) != 2)
|
||||
return false;
|
||||
|
||||
g_debug("detected LAME version %i.%i (\"%s\")\n",
|
||||
lame->version.major, lame->version.minor, lame->encoder);
|
||||
FormatDebug(mad_domain, "detected LAME version %i.%i (\"%s\")",
|
||||
lame->version.major, lame->version.minor, lame->encoder);
|
||||
|
||||
/* The reference volume was changed from the 83dB used in the
|
||||
* ReplayGain spec to 89dB in lame 3.95.1. Bump the gain for older
|
||||
@@ -719,7 +720,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
|
||||
mad_bit_read(ptr, 16);
|
||||
|
||||
lame->peak = mad_f_todouble(mad_bit_read(ptr, 32) << 5); /* peak */
|
||||
g_debug("LAME peak found: %f\n", lame->peak);
|
||||
FormatDebug(mad_domain, "LAME peak found: %f", lame->peak);
|
||||
|
||||
lame->track_gain = 0;
|
||||
name = mad_bit_read(ptr, 3); /* gain name */
|
||||
@@ -728,7 +729,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
|
||||
gain = mad_bit_read(ptr, 9); /* gain*10 */
|
||||
if (gain && name == 1 && orig != 0) {
|
||||
lame->track_gain = ((sign ? -gain : gain) / 10.0) + adj;
|
||||
g_debug("LAME track gain found: %f\n", lame->track_gain);
|
||||
FormatDebug(mad_domain, "LAME track gain found: %f",
|
||||
lame->track_gain);
|
||||
}
|
||||
|
||||
/* tmz reports that this isn't currently written by any version of lame
|
||||
@@ -743,7 +745,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
|
||||
gain = mad_bit_read(ptr, 9); /* gain*10 */
|
||||
if (gain && name == 2 && orig != 0) {
|
||||
lame->album_gain = ((sign ? -gain : gain) / 10.0) + adj;
|
||||
g_debug("LAME album gain found: %f\n", lame->track_gain);
|
||||
FormatDebug(mad_domain, "LAME album gain found: %f",
|
||||
lame->track_gain);
|
||||
}
|
||||
#else
|
||||
mad_bit_read(ptr, 16);
|
||||
@@ -754,8 +757,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
|
||||
lame->encoder_delay = mad_bit_read(ptr, 12);
|
||||
lame->encoder_padding = mad_bit_read(ptr, 12);
|
||||
|
||||
g_debug("encoder delay is %i, encoder padding is %i\n",
|
||||
lame->encoder_delay, lame->encoder_padding);
|
||||
FormatDebug(mad_domain, "encoder delay is %i, encoder padding is %i",
|
||||
lame->encoder_delay, lame->encoder_padding);
|
||||
|
||||
mad_bit_read(ptr, 80);
|
||||
|
||||
@@ -880,8 +883,9 @@ MadDecoder::DecodeFirstFrame(Tag **tag)
|
||||
return false;
|
||||
|
||||
if (max_frames > 8 * 1024 * 1024) {
|
||||
g_warning("mp3 file header indicates too many frames: %lu\n",
|
||||
max_frames);
|
||||
FormatWarning(mad_domain,
|
||||
"mp3 file header indicates too many frames: %lu",
|
||||
max_frames);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1120,8 +1124,8 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
||||
delete tag;
|
||||
|
||||
if (decoder_get_command(decoder) == DecoderCommand::NONE)
|
||||
g_warning
|
||||
("Input does not appear to be a mp3 bit stream.\n");
|
||||
LogError(mad_domain,
|
||||
"Input does not appear to be a mp3 bit stream");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1132,7 +1136,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
||||
SampleFormat::S24_P32,
|
||||
MAD_NCHANNELS(&data.frame.header),
|
||||
error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
delete tag;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "system/FatalError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
#include <mikmod.h>
|
||||
#include <assert.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "mikmod"
|
||||
static constexpr Domain mikmod_domain("mikmod");
|
||||
|
||||
/* this is largely copied from alsaplayer */
|
||||
|
||||
@@ -127,8 +128,9 @@ mikmod_decoder_init(const config_param ¶m)
|
||||
DMODE_16BITS);
|
||||
|
||||
if (MikMod_Init(params)) {
|
||||
g_warning("Could not init MikMod: %s\n",
|
||||
MikMod_strerror(MikMod_errno));
|
||||
FormatError(mikmod_domain,
|
||||
"Could not init MikMod: %s",
|
||||
MikMod_strerror(MikMod_errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,7 +156,8 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
g_free(path2);
|
||||
|
||||
if (handle == nullptr) {
|
||||
g_warning("failed to open mod: %s", path_fs);
|
||||
FormatError(mikmod_domain,
|
||||
"failed to open mod: %s", path_fs);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,7 +190,8 @@ mikmod_decoder_scan_file(const char *path_fs,
|
||||
|
||||
if (handle == nullptr) {
|
||||
g_free(path2);
|
||||
g_debug("Failed to open file: %s", path_fs);
|
||||
FormatDebug(mikmod_domain,
|
||||
"Failed to open file: %s", path_fs);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <libmodplug/modplug.h>
|
||||
|
||||
@@ -29,8 +31,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "modplug"
|
||||
static constexpr Domain modplug_domain("modplug");
|
||||
|
||||
static constexpr size_t MODPLUG_FRAME_SIZE = 4096;
|
||||
static constexpr size_t MODPLUG_PREALLOC_BLOCK = 256 * 1024;
|
||||
@@ -43,12 +44,12 @@ mod_loadfile(struct decoder *decoder, struct input_stream *is)
|
||||
const goffset size = is->GetSize();
|
||||
|
||||
if (size == 0) {
|
||||
g_warning("file is empty");
|
||||
LogWarning(modplug_domain, "file is empty");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (size > MODPLUG_FILE_LIMIT) {
|
||||
g_warning("file too large");
|
||||
LogWarning(modplug_domain, "file too large");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ mod_loadfile(struct decoder *decoder, struct input_stream *is)
|
||||
}
|
||||
|
||||
if (goffset(bdatas->len + ret) > MODPLUG_FILE_LIMIT) {
|
||||
g_warning("stream too large\n");
|
||||
LogWarning(modplug_domain, "stream too large");
|
||||
g_free(data);
|
||||
g_byte_array_free(bdatas, TRUE);
|
||||
return nullptr;
|
||||
@@ -103,7 +104,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
|
||||
bdatas = mod_loadfile(decoder, is);
|
||||
|
||||
if (!bdatas) {
|
||||
g_warning("could not load stream\n");
|
||||
LogWarning(modplug_domain, "could not load stream");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
|
||||
f = ModPlug_Load(bdatas->data, bdatas->len);
|
||||
g_byte_array_free(bdatas, TRUE);
|
||||
if (!f) {
|
||||
g_warning("could not decode stream\n");
|
||||
LogWarning(modplug_domain, "could not decode stream");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <mpc/mpcdec.h>
|
||||
|
||||
@@ -32,14 +34,13 @@
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "mpcdec"
|
||||
|
||||
struct mpc_decoder_data {
|
||||
struct input_stream *is;
|
||||
struct decoder *decoder;
|
||||
};
|
||||
|
||||
static constexpr Domain mpcdec_domain("mpcdec");
|
||||
|
||||
static mpc_int32_t
|
||||
mpc_read_cb(mpc_reader *reader, void *ptr, mpc_int32_t size)
|
||||
{
|
||||
@@ -148,7 +149,8 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
|
||||
mpc_demux *demux = mpc_demux_init(&reader);
|
||||
if (demux == nullptr) {
|
||||
if (decoder_get_command(mpd_decoder) != DecoderCommand::STOP)
|
||||
g_warning("Not a valid musepack stream");
|
||||
LogWarning(mpcdec_domain,
|
||||
"Not a valid musepack stream");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,7 +162,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
|
||||
if (!audio_format_init_checked(audio_format, info.sample_freq,
|
||||
SampleFormat::S24_P32,
|
||||
info.channels, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
mpc_demux_exit(demux);
|
||||
return;
|
||||
}
|
||||
@@ -199,7 +201,8 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
|
||||
frame.buffer = (MPC_SAMPLE_FORMAT *)sample_buffer;
|
||||
mpc_status status = mpc_demux_decode(demux, &frame);
|
||||
if (status != MPC_STATUS_OK) {
|
||||
g_warning("Failed to decode sample");
|
||||
LogWarning(mpcdec_domain,
|
||||
"Failed to decode sample");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,15 @@
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <mpg123.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "mpg123"
|
||||
static constexpr Domain mpg123_domain("mpg123");
|
||||
|
||||
static bool
|
||||
mpd_mpg123_init(gcc_unused const config_param ¶m)
|
||||
@@ -70,8 +71,9 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs,
|
||||
error = mpg123_open(handle, path_dup);
|
||||
g_free(path_dup);
|
||||
if (error != MPG123_OK) {
|
||||
g_warning("libmpg123 failed to open %s: %s",
|
||||
path_fs, mpg123_plain_strerror(error));
|
||||
FormatWarning(mpg123_domain,
|
||||
"libmpg123 failed to open %s: %s",
|
||||
path_fs, mpg123_plain_strerror(error));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -79,21 +81,24 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs,
|
||||
|
||||
error = mpg123_getformat(handle, &rate, &channels, &encoding);
|
||||
if (error != MPG123_OK) {
|
||||
g_warning("mpg123_getformat() failed: %s",
|
||||
mpg123_plain_strerror(error));
|
||||
FormatWarning(mpg123_domain,
|
||||
"mpg123_getformat() failed: %s",
|
||||
mpg123_plain_strerror(error));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (encoding != MPG123_ENC_SIGNED_16) {
|
||||
/* other formats not yet implemented */
|
||||
g_warning("expected MPG123_ENC_SIGNED_16, got %d", encoding);
|
||||
FormatWarning(mpg123_domain,
|
||||
"expected MPG123_ENC_SIGNED_16, got %d",
|
||||
encoding);
|
||||
return false;
|
||||
}
|
||||
|
||||
Error error2;
|
||||
if (!audio_format_init_checked(audio_format, rate, SampleFormat::S16,
|
||||
channels, error2)) {
|
||||
g_warning("%s", error2.GetMessage());
|
||||
LogError(error2);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,8 +117,9 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
|
||||
handle = mpg123_new(nullptr, &error);
|
||||
if (handle == nullptr) {
|
||||
g_warning("mpg123_new() failed: %s",
|
||||
mpg123_plain_strerror(error));
|
||||
FormatError(mpg123_domain,
|
||||
"mpg123_new() failed: %s",
|
||||
mpg123_plain_strerror(error));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,8 +164,9 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
error = mpg123_read(handle, buffer, sizeof(buffer), &nbytes);
|
||||
if (error != MPG123_OK) {
|
||||
if (error != MPG123_DONE)
|
||||
g_warning("mpg123_read() failed: %s",
|
||||
mpg123_plain_strerror(error));
|
||||
FormatWarning(mpg123_domain,
|
||||
"mpg123_read() failed: %s",
|
||||
mpg123_plain_strerror(error));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -204,8 +211,9 @@ mpd_mpg123_scan_file(const char *path_fs,
|
||||
|
||||
handle = mpg123_new(nullptr, &error);
|
||||
if (handle == nullptr) {
|
||||
g_warning("mpg123_new() failed: %s",
|
||||
mpg123_plain_strerror(error));
|
||||
FormatError(mpg123_domain,
|
||||
"mpg123_new() failed: %s",
|
||||
mpg123_plain_strerror(error));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "config.h" /* must be first for large file support */
|
||||
#include "OpusDecoderPlugin.h"
|
||||
#include "OpusDomain.hxx"
|
||||
#include "OpusHead.hxx"
|
||||
#include "OpusTags.hxx"
|
||||
#include "OggUtil.hxx"
|
||||
@@ -31,6 +32,7 @@
|
||||
#include "tag/TagBuilder.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <opus.h>
|
||||
#include <ogg/ogg.h>
|
||||
@@ -40,9 +42,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "opus"
|
||||
|
||||
static const opus_int32 opus_sample_rate = 48000;
|
||||
|
||||
gcc_pure
|
||||
@@ -62,7 +61,7 @@ IsOpusTags(const ogg_packet &packet)
|
||||
static bool
|
||||
mpd_opus_init(gcc_unused const config_param ¶m)
|
||||
{
|
||||
g_debug("%s", opus_get_version_string());
|
||||
LogDebug(opus_domain, opus_get_version_string());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -199,8 +198,8 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
|
||||
opus_decoder = opus_decoder_create(opus_sample_rate, channels,
|
||||
&opus_error);
|
||||
if (opus_decoder == nullptr) {
|
||||
g_warning("libopus error: %s",
|
||||
opus_strerror(opus_error));
|
||||
FormatError(opus_domain, "libopus error: %s",
|
||||
opus_strerror(opus_error));
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
@@ -249,7 +248,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
|
||||
output_buffer, output_size,
|
||||
0);
|
||||
if (nframes < 0) {
|
||||
g_warning("%s", opus_strerror(nframes));
|
||||
LogError(opus_domain, opus_strerror(nframes));
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
|
||||
24
src/decoder/OpusDomain.cxx
Normal file
24
src/decoder/OpusDomain.cxx
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2012 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "OpusDomain.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
const Domain opus_domain("opus");
|
||||
27
src/decoder/OpusDomain.hxx
Normal file
27
src/decoder/OpusDomain.hxx
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2012 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_OPUS_DOMAIN_HXX
|
||||
#define MPD_OPUS_DOMAIN_HXX
|
||||
|
||||
#include "check.h"
|
||||
|
||||
extern const class Domain opus_domain;
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
extern "C" {
|
||||
#include "util/byte_reverse.h"
|
||||
@@ -32,9 +33,6 @@ extern "C" {
|
||||
#include <string.h>
|
||||
#include <stdio.h> /* for SEEK_SET */
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "pcm"
|
||||
|
||||
static void
|
||||
pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
{
|
||||
@@ -86,7 +84,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
if (is->LockSeek(offset, SEEK_SET, error)) {
|
||||
decoder_command_finished(decoder);
|
||||
} else {
|
||||
g_warning("seeking failed: %s", error.GetMessage());
|
||||
LogError(error);
|
||||
decoder_seek_error(decoder);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "sndfile"
|
||||
static constexpr Domain sndfile_domain("sndfile");
|
||||
|
||||
static sf_count_t
|
||||
sndfile_vio_get_filelen(void *user_data)
|
||||
@@ -57,7 +58,7 @@ sndfile_vio_read(void *ptr, sf_count_t count, void *user_data)
|
||||
Error error;
|
||||
size_t nbytes = is->LockRead(ptr, count, error);
|
||||
if (nbytes == 0 && error.IsDefined()) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
|
||||
sf = sf_open_virtual(&vio, SFM_READ, &info, is);
|
||||
if (sf == nullptr) {
|
||||
g_warning("sf_open_virtual() failed");
|
||||
LogWarning(sndfile_domain, "sf_open_virtual() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
|
||||
if (!audio_format_init_checked(audio_format, info.samplerate,
|
||||
SampleFormat::S32,
|
||||
info.channels, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,7 +188,8 @@ sndfile_scan_file(const char *path_fs,
|
||||
|
||||
if (!audio_valid_sample_rate(info.samplerate)) {
|
||||
sf_close(sf);
|
||||
g_warning("Invalid sample rate in %s\n", path_fs);
|
||||
FormatWarning(sndfile_domain,
|
||||
"Invalid sample rate in %s", path_fs);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "config.h"
|
||||
#include "VorbisDecoderPlugin.h"
|
||||
#include "VorbisComments.hxx"
|
||||
#include "VorbisDomain.hxx"
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "OggCodec.hxx"
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#ifndef HAVE_TREMOR
|
||||
#define OV_EXCLUDE_STATIC_CALLBACKS
|
||||
@@ -50,9 +52,6 @@
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "vorbis"
|
||||
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
#define VORBIS_BIG_ENDIAN true
|
||||
#else
|
||||
@@ -144,8 +143,9 @@ vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
|
||||
if (ret < 0) {
|
||||
if (decoder == NULL ||
|
||||
decoder_get_command(decoder) == DecoderCommand::NONE)
|
||||
g_warning("Failed to open Ogg Vorbis stream: %s",
|
||||
vorbis_strerror(ret));
|
||||
FormatWarning(vorbis_domain,
|
||||
"Failed to open Ogg Vorbis stream: %s",
|
||||
vorbis_strerror(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ vorbis_stream_decode(struct decoder *decoder,
|
||||
|
||||
const vorbis_info *vi = ov_info(&vf, -1);
|
||||
if (vi == NULL) {
|
||||
g_warning("ov_info() has failed");
|
||||
LogWarning(vorbis_domain, "ov_info() has failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ vorbis_stream_decode(struct decoder *decoder,
|
||||
SampleFormat::FLOAT,
|
||||
#endif
|
||||
vi->channels, error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,8 @@ vorbis_stream_decode(struct decoder *decoder,
|
||||
if (current_section != prev_section) {
|
||||
vi = ov_info(&vf, -1);
|
||||
if (vi == NULL) {
|
||||
g_warning("ov_info() has failed");
|
||||
LogWarning(vorbis_domain,
|
||||
"ov_info() has failed");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -280,7 +281,8 @@ vorbis_stream_decode(struct decoder *decoder,
|
||||
vi->channels != (int)audio_format.channels) {
|
||||
/* we don't support audio format
|
||||
change yet */
|
||||
g_warning("audio format change, stopping here");
|
||||
LogWarning(vorbis_domain,
|
||||
"audio format change, stopping here");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
24
src/decoder/VorbisDomain.cxx
Normal file
24
src/decoder/VorbisDomain.cxx
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2012 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "VorbisDomain.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
const Domain vorbis_domain("vorbis");
|
||||
27
src/decoder/VorbisDomain.hxx
Normal file
27
src/decoder/VorbisDomain.hxx
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2012 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_VORBIS_DOMAIN_HXX
|
||||
#define MPD_VORBIS_DOMAIN_HXX
|
||||
|
||||
#include "check.h"
|
||||
|
||||
extern const class Domain vorbis_domain;
|
||||
|
||||
#endif
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "tag/ApeTag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <wavpack/wavpack.h>
|
||||
#include <glib.h>
|
||||
@@ -33,11 +35,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "wavpack"
|
||||
|
||||
#define ERRORLEN 80
|
||||
|
||||
static constexpr Domain wavpack_domain("wavpack");
|
||||
|
||||
/** A pointer type for format converter function. */
|
||||
typedef void (*format_samples_t)(
|
||||
int bytes_per_sample,
|
||||
@@ -155,7 +156,7 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
|
||||
WavpackGetSampleRate(wpc),
|
||||
sample_format,
|
||||
WavpackGetNumChannels(wpc), error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
LogError(error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -294,10 +295,9 @@ wavpack_scan_file(const char *fname,
|
||||
|
||||
wpc = WavpackOpenFileInput(fname, error, OPEN_TAGS, 0);
|
||||
if (wpc == NULL) {
|
||||
g_warning(
|
||||
"failed to open WavPack file \"%s\": %s\n",
|
||||
fname, error
|
||||
);
|
||||
FormatError(wavpack_domain,
|
||||
"failed to open WavPack file \"%s\": %s",
|
||||
fname, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -532,7 +532,8 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
|
||||
);
|
||||
|
||||
if (wpc == NULL) {
|
||||
g_warning("failed to open WavPack stream: %s\n", error);
|
||||
FormatError(wavpack_domain,
|
||||
"failed to open WavPack stream: %s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -558,10 +559,9 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
|
||||
OPEN_TAGS | OPEN_WVC | OPEN_NORMALIZE, 23
|
||||
);
|
||||
if (wpc == NULL) {
|
||||
g_warning(
|
||||
"failed to open WavPack file \"%s\": %s\n",
|
||||
fname, error
|
||||
);
|
||||
FormatWarning(wavpack_domain,
|
||||
"failed to open WavPack file \"%s\": %s",
|
||||
fname, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,18 +22,17 @@
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "system/FatalError.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
#include "Log.hxx"
|
||||
|
||||
extern "C" {
|
||||
#include <wildmidi_lib.h>
|
||||
}
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "wildmidi"
|
||||
static constexpr Domain wildmidi_domain("wildmidi");
|
||||
|
||||
static constexpr unsigned WILDMIDI_SAMPLE_RATE = 48000;
|
||||
|
||||
@@ -49,7 +48,9 @@ wildmidi_init(const config_param ¶m)
|
||||
|
||||
if (!FileExists(path)) {
|
||||
const auto utf8 = path.ToUTF8();
|
||||
g_debug("configuration file does not exist: %s", utf8.c_str());
|
||||
FormatDebug(wildmidi_domain,
|
||||
"configuration file does not exist: %s",
|
||||
utf8.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "config.h"
|
||||
#include "../DecoderAPI.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
@@ -30,11 +32,10 @@
|
||||
#include <sidplay/builders/resid.h>
|
||||
#include <sidplay/utils/SidTuneMod.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "sidplay"
|
||||
|
||||
#define SUBTUNE_PREFIX "tune_"
|
||||
|
||||
static constexpr Domain sidplay_domain("sidplay");
|
||||
|
||||
static GPatternSpec *path_with_subtune;
|
||||
static const char *songlength_file;
|
||||
static GKeyFile *songlength_database;
|
||||
@@ -52,8 +53,9 @@ sidplay_load_songlength_db(const char *path)
|
||||
gsize size;
|
||||
|
||||
if (!g_file_get_contents(path, &data, &size, &error)) {
|
||||
g_warning("unable to read songlengths file %s: %s",
|
||||
path, error->message);
|
||||
FormatError(sidplay_domain,
|
||||
"unable to read songlengths file %s: %s",
|
||||
path, error->message);
|
||||
g_error_free(error);
|
||||
return NULL;
|
||||
}
|
||||
@@ -68,8 +70,9 @@ sidplay_load_songlength_db(const char *path)
|
||||
G_KEY_FILE_NONE, &error);
|
||||
g_free(data);
|
||||
if (!success) {
|
||||
g_warning("unable to parse songlengths file %s: %s",
|
||||
path, error->message);
|
||||
FormatError(sidplay_domain,
|
||||
"unable to parse songlengths file %s: %s",
|
||||
path, error->message);
|
||||
g_error_free(error);
|
||||
g_key_file_free(db);
|
||||
return NULL;
|
||||
@@ -162,7 +165,8 @@ get_song_length(const char *path_fs)
|
||||
SidTuneMod tune(sid_file);
|
||||
g_free(sid_file);
|
||||
if(!tune) {
|
||||
g_warning("failed to load file for calculating md5 sum");
|
||||
LogWarning(sidplay_domain,
|
||||
"failed to load file for calculating md5 sum");
|
||||
return -1;
|
||||
}
|
||||
char md5sum[SIDTUNE_MD5_LENGTH+1];
|
||||
@@ -205,7 +209,7 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
SidTune tune(path_container, NULL, true);
|
||||
g_free(path_container);
|
||||
if (!tune) {
|
||||
g_warning("failed to load file");
|
||||
LogWarning(sidplay_domain, "failed to load file");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,7 +224,8 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
sidplay2 player;
|
||||
int iret = player.load(&tune);
|
||||
if (iret != 0) {
|
||||
g_warning("sidplay2.load() failed: %s", player.error());
|
||||
FormatWarning(sidplay_domain,
|
||||
"sidplay2.load() failed: %s", player.error());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -228,19 +233,20 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
|
||||
ReSIDBuilder builder("ReSID");
|
||||
if (!builder) {
|
||||
g_warning("failed to initialize ReSIDBuilder");
|
||||
LogWarning(sidplay_domain,
|
||||
"failed to initialize ReSIDBuilder");
|
||||
return;
|
||||
}
|
||||
|
||||
builder.create(player.info().maxsids);
|
||||
if (!builder) {
|
||||
g_warning("ReSIDBuilder.create() failed");
|
||||
LogWarning(sidplay_domain, "ReSIDBuilder.create() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
builder.filter(filter_setting);
|
||||
if (!builder) {
|
||||
g_warning("ReSIDBuilder.filter() failed");
|
||||
LogWarning(sidplay_domain, "ReSIDBuilder.filter() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -274,7 +280,8 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
||||
|
||||
iret = player.config(config);
|
||||
if (iret != 0) {
|
||||
g_warning("sidplay2.config() failed: %s", player.error());
|
||||
FormatWarning(sidplay_domain,
|
||||
"sidplay2.config() failed: %s", player.error());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user