diff options
Diffstat (limited to 'src/decoder')
78 files changed, 233 insertions, 344 deletions
diff --git a/src/decoder/AdPlugDecoderPlugin.cxx b/src/decoder/AdPlugDecoderPlugin.cxx index c79fca5f9..89dcea06b 100644 --- a/src/decoder/AdPlugDecoderPlugin.cxx +++ b/src/decoder/AdPlugDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/AdPlugDecoderPlugin.h b/src/decoder/AdPlugDecoderPlugin.h index a827fdc7d..539dbbf0a 100644 --- a/src/decoder/AdPlugDecoderPlugin.h +++ b/src/decoder/AdPlugDecoderPlugin.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2012 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/AudiofileDecoderPlugin.cxx b/src/decoder/AudiofileDecoderPlugin.cxx index ab3557e52..9ef9ef263 100644 --- a/src/decoder/AudiofileDecoderPlugin.cxx +++ b/src/decoder/AudiofileDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/AudiofileDecoderPlugin.hxx b/src/decoder/AudiofileDecoderPlugin.hxx index 5a17281b0..61129076d 100644 --- a/src/decoder/AudiofileDecoderPlugin.hxx +++ b/src/decoder/AudiofileDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/DsdLib.cxx b/src/decoder/DsdLib.cxx index 67cc7e945..eb3dd5e06 100644 --- a/src/decoder/DsdLib.cxx +++ b/src/decoder/DsdLib.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -27,8 +27,6 @@ #include "DsdLib.hxx" #include "DecoderAPI.hxx" #include "InputStream.hxx" -#include "util/bit_reverse.h" -#include "tag/TagHandler.hxx" #include "tag/TagId3.hxx" #include "util/Error.hxx" diff --git a/src/decoder/DsdLib.hxx b/src/decoder/DsdLib.hxx index 53160cf1e..4c5e83114 100644 --- a/src/decoder/DsdLib.hxx +++ b/src/decoder/DsdLib.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index a3c0149b9..643ee23bd 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -38,9 +38,6 @@ #include "DsdLib.hxx" #include "Log.hxx" -#include <unistd.h> -#include <stdio.h> /* for SEEK_SET, SEEK_CUR */ - struct DsdiffHeader { DsdId id; DffDsdUint64 size; diff --git a/src/decoder/DsdiffDecoderPlugin.hxx b/src/decoder/DsdiffDecoderPlugin.hxx index be14fc9cd..7aa36752b 100644 --- a/src/decoder/DsdiffDecoderPlugin.hxx +++ b/src/decoder/DsdiffDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx index 5ef94e647..fbc49ab62 100644 --- a/src/decoder/DsfDecoderPlugin.cxx +++ b/src/decoder/DsfDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -39,9 +39,6 @@ #include "tag/TagHandler.hxx" #include "Log.hxx" -#include <unistd.h> -#include <stdio.h> /* for SEEK_SET, SEEK_CUR */ - struct DsfMetaData { unsigned sample_rate, channels; bool bitreverse; diff --git a/src/decoder/DsfDecoderPlugin.hxx b/src/decoder/DsfDecoderPlugin.hxx index 921c94698..02bea0b5c 100644 --- a/src/decoder/DsfDecoderPlugin.hxx +++ b/src/decoder/DsfDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx index 9fd20167d..5e7ccda52 100644 --- a/src/decoder/FaadDecoderPlugin.cxx +++ b/src/decoder/FaadDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -24,6 +24,7 @@ #include "InputStream.hxx" #include "CheckAudioFormat.hxx" #include "tag/TagHandler.hxx" +#include "util/ConstBuffer.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -66,16 +67,11 @@ adts_check_frame(const unsigned char *data) static size_t adts_find_frame(DecoderBuffer *buffer) { - size_t length, frame_length; - bool ret; - while (true) { - const uint8_t *data = (const uint8_t *) - decoder_buffer_read(buffer, &length); - if (data == nullptr || length < 8) { + auto data = ConstBuffer<uint8_t>::FromVoid(decoder_buffer_read(buffer)); + if (data.size < 8) { /* not enough data yet */ - ret = decoder_buffer_fill(buffer); - if (!ret) + if (!decoder_buffer_fill(buffer)) /* failed */ return 0; @@ -83,21 +79,22 @@ adts_find_frame(DecoderBuffer *buffer) } /* find the 0xff marker */ - const uint8_t *p = (const uint8_t *)memchr(data, 0xff, length); + const uint8_t *p = (const uint8_t *) + memchr(data.data, 0xff, data.size); if (p == nullptr) { /* no marker - discard the buffer */ - decoder_buffer_consume(buffer, length); + decoder_buffer_clear(buffer); continue; } - if (p > data) { + if (p > data.data) { /* discard data before 0xff */ - decoder_buffer_consume(buffer, p - data); + decoder_buffer_consume(buffer, p - data.data); continue; } /* is it a frame? */ - frame_length = adts_check_frame(data); + size_t frame_length = adts_check_frame(data.data); if (frame_length == 0) { /* it's just some random 0xff byte; discard it and continue searching */ @@ -105,19 +102,15 @@ adts_find_frame(DecoderBuffer *buffer) continue; } - if (length < frame_length) { + if (data.size < frame_length) { /* available buffer size is smaller than the frame will be - attempt to read more data */ - ret = decoder_buffer_fill(buffer); - if (!ret) { + if (!decoder_buffer_fill(buffer)) { /* not enough data; discard this frame to prevent a possible buffer overflow */ - data = (const uint8_t *) - decoder_buffer_read(buffer, &length); - if (data != nullptr) - decoder_buffer_consume(buffer, length); + decoder_buffer_clear(buffer); } continue; @@ -131,31 +124,27 @@ adts_find_frame(DecoderBuffer *buffer) static float adts_song_duration(DecoderBuffer *buffer) { - unsigned int frames, frame_length; unsigned sample_rate = 0; - float frames_per_second; /* Read all frames to ensure correct time and bitrate */ - for (frames = 0;; frames++) { - frame_length = adts_find_frame(buffer); + unsigned frames = 0; + for (;; frames++) { + unsigned frame_length = adts_find_frame(buffer); if (frame_length == 0) break; - if (frames == 0) { - size_t buffer_length; - const uint8_t *data = (const uint8_t *) - decoder_buffer_read(buffer, &buffer_length); - assert(data != nullptr); - assert(frame_length <= buffer_length); + auto data = ConstBuffer<uint8_t>::FromVoid(decoder_buffer_read(buffer)); + assert(!data.IsEmpty()); + assert(frame_length <= data.size); - sample_rate = adts_sample_rates[(data[2] & 0x3c) >> 2]; + sample_rate = adts_sample_rates[(data.data[2] & 0x3c) >> 2]; } decoder_buffer_consume(buffer, frame_length); } - frames_per_second = (float)sample_rate / 1024.0; + float frames_per_second = (float)sample_rate / 1024.0; if (frames_per_second <= 0) return -1; @@ -165,66 +154,58 @@ adts_song_duration(DecoderBuffer *buffer) static float faad_song_duration(DecoderBuffer *buffer, InputStream &is) { - size_t fileread; - size_t tagsize; - size_t length; - bool success; - const auto size = is.GetSize(); - fileread = size >= 0 ? size : 0; + const size_t fileread = size >= 0 ? size : 0; decoder_buffer_fill(buffer); - const uint8_t *data = (const uint8_t *) - decoder_buffer_read(buffer, &length); - if (data == nullptr) + auto data = ConstBuffer<uint8_t>::FromVoid(decoder_buffer_read(buffer)); + if (data.IsEmpty()) return -1; - tagsize = 0; - if (length >= 10 && !memcmp(data, "ID3", 3)) { + size_t tagsize = 0; + if (data.size >= 10 && !memcmp(data.data, "ID3", 3)) { /* skip the ID3 tag */ - tagsize = (data[6] << 21) | (data[7] << 14) | - (data[8] << 7) | (data[9] << 0); + tagsize = (data.data[6] << 21) | (data.data[7] << 14) | + (data.data[8] << 7) | (data.data[9] << 0); tagsize += 10; - success = decoder_buffer_skip(buffer, tagsize) && + bool success = decoder_buffer_skip(buffer, tagsize) && decoder_buffer_fill(buffer); if (!success) return -1; - data = (const uint8_t *)decoder_buffer_read(buffer, &length); - if (data == nullptr) + data = ConstBuffer<uint8_t>::FromVoid(decoder_buffer_read(buffer)); + if (data.IsEmpty()) return -1; } - if (is.IsSeekable() && length >= 2 && - data[0] == 0xFF && ((data[1] & 0xF6) == 0xF0)) { + if (is.IsSeekable() && data.size >= 2 && + data.data[0] == 0xFF && ((data.data[1] & 0xF6) == 0xF0)) { /* obtain the duration from the ADTS header */ float song_length = adts_song_duration(buffer); is.LockSeek(tagsize, SEEK_SET, IgnoreError()); - data = (const uint8_t *)decoder_buffer_read(buffer, &length); - if (data != nullptr) - decoder_buffer_consume(buffer, length); + decoder_buffer_clear(buffer); decoder_buffer_fill(buffer); return song_length; - } else if (length >= 5 && memcmp(data, "ADIF", 4) == 0) { + } else if (data.size >= 5 && memcmp(data.data, "ADIF", 4) == 0) { /* obtain the duration from the ADIF header */ unsigned bit_rate; - size_t skip_size = (data[4] & 0x80) ? 9 : 0; + size_t skip_size = (data.data[4] & 0x80) ? 9 : 0; - if (8 + skip_size > length) + if (8 + skip_size > data.size) /* not enough data yet; skip parsing this header */ return -1; - bit_rate = ((data[4 + skip_size] & 0x0F) << 19) | - (data[5 + skip_size] << 11) | - (data[6 + skip_size] << 3) | - (data[7 + skip_size] & 0xE0); + bit_rate = ((data.data[4 + skip_size] & 0x0F) << 19) | + (data.data[5 + skip_size] << 11) | + (data.data[6 + skip_size] << 3) | + (data.data[7 + skip_size] & 0xE0); if (fileread != 0 && bit_rate != 0) return fileread * 8.0 / bit_rate; @@ -242,9 +223,7 @@ static bool faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer *buffer, AudioFormat &audio_format, Error &error) { - int32_t nbytes; uint32_t sample_rate; - uint8_t channels; #ifdef HAVE_FAAD_LONG /* neaacdec.h declares all arguments as "unsigned long", but internally expects uint32_t pointers. To avoid gcc @@ -254,19 +233,18 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer *buffer, uint32_t *sample_rate_p = &sample_rate; #endif - size_t length; - const unsigned char *data = (const unsigned char *) - decoder_buffer_read(buffer, &length); - if (data == nullptr) { + auto data = ConstBuffer<uint8_t>::FromVoid(decoder_buffer_read(buffer)); + if (data.IsEmpty()) { error.Set(faad_decoder_domain, "Empty file"); return false; } - nbytes = NeAACDecInit(decoder, - /* deconst hack, libfaad requires this */ - const_cast<unsigned char *>(data), - length, - sample_rate_p, &channels); + uint8_t channels; + int32_t nbytes = NeAACDecInit(decoder, + /* deconst hack, libfaad requires this */ + const_cast<uint8_t *>(data.data), + data.size, + sample_rate_p, &channels); if (nbytes < 0) { error.Set(faad_decoder_domain, "Not an AAC stream"); return false; @@ -286,16 +264,14 @@ static const void * faad_decoder_decode(NeAACDecHandle decoder, DecoderBuffer *buffer, NeAACDecFrameInfo *frame_info) { - size_t length; - const unsigned char *data = (const unsigned char *) - decoder_buffer_read(buffer, &length); - if (data == nullptr) + auto data = ConstBuffer<uint8_t>::FromVoid(decoder_buffer_read(buffer)); + if (data.IsEmpty()) return nullptr; return NeAACDecDecode(decoder, frame_info, /* deconst hack, libfaad requires this */ - const_cast<unsigned char *>(data), - length); + const_cast<uint8_t *>(data.data), + data.size); } /** @@ -306,17 +282,12 @@ faad_decoder_decode(NeAACDecHandle decoder, DecoderBuffer *buffer, static float faad_get_file_time_float(InputStream &is) { - DecoderBuffer *buffer; - float length; - - buffer = decoder_buffer_new(nullptr, is, - FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS); - length = faad_song_duration(buffer, is); + DecoderBuffer *buffer = + decoder_buffer_new(nullptr, is, + FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS); + float length = faad_song_duration(buffer, is); if (length < 0) { - bool ret; - AudioFormat audio_format; - NeAACDecHandle decoder = NeAACDecOpen(); NeAACDecConfigurationPtr config = @@ -326,9 +297,9 @@ faad_get_file_time_float(InputStream &is) decoder_buffer_fill(buffer); - ret = faad_decoder_init(decoder, buffer, audio_format, - IgnoreError()); - if (ret) + AudioFormat audio_format; + if (faad_decoder_init(decoder, buffer, audio_format, + IgnoreError())) length = 0; NeAACDecClose(decoder); @@ -359,15 +330,10 @@ faad_get_file_time(InputStream &is) static void faad_stream_decode(Decoder &mpd_decoder, InputStream &is) { - float total_time = 0; - AudioFormat audio_format; - bool ret; - uint16_t bit_rate = 0; - DecoderBuffer *buffer; - - buffer = decoder_buffer_new(&mpd_decoder, is, - FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS); - total_time = faad_song_duration(buffer, is); + DecoderBuffer *buffer = + decoder_buffer_new(&mpd_decoder, is, + FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS); + const float total_time = faad_song_duration(buffer, is); /* create the libfaad decoder */ @@ -389,8 +355,8 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is) /* initialize it */ Error error; - ret = faad_decoder_init(decoder, buffer, audio_format, error); - if (!ret) { + AudioFormat audio_format; + if (!faad_decoder_init(decoder, buffer, audio_format, error)) { LogError(error); NeAACDecClose(decoder); decoder_buffer_free(buffer); @@ -404,6 +370,7 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is) /* the decoder loop */ DecoderCommand cmd; + unsigned bit_rate = 0; do { size_t frame_size; const void *decoded; @@ -483,7 +450,7 @@ static const char *const faad_mime_types[] = { "audio/aac", "audio/aacp", nullptr }; -const struct DecoderPlugin faad_decoder_plugin = { +const DecoderPlugin faad_decoder_plugin = { "faad", nullptr, nullptr, diff --git a/src/decoder/FaadDecoderPlugin.hxx b/src/decoder/FaadDecoderPlugin.hxx index 817927d5e..968433e9b 100644 --- a/src/decoder/FaadDecoderPlugin.hxx +++ b/src/decoder/FaadDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx index 593f42d39..0d4256bd9 100644 --- a/src/decoder/FfmpegDecoderPlugin.cxx +++ b/src/decoder/FfmpegDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FfmpegDecoderPlugin.hxx b/src/decoder/FfmpegDecoderPlugin.hxx index 23bf74fce..0a3e78e4b 100644 --- a/src/decoder/FfmpegDecoderPlugin.hxx +++ b/src/decoder/FfmpegDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FfmpegMetaData.cxx b/src/decoder/FfmpegMetaData.cxx index 6e92b4a13..a39466945 100644 --- a/src/decoder/FfmpegMetaData.cxx +++ b/src/decoder/FfmpegMetaData.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FfmpegMetaData.hxx b/src/decoder/FfmpegMetaData.hxx index 998cdf5a8..5eb41db68 100644 --- a/src/decoder/FfmpegMetaData.hxx +++ b/src/decoder/FfmpegMetaData.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacCommon.cxx b/src/decoder/FlacCommon.cxx index e4b906c12..7b67585a0 100644 --- a/src/decoder/FlacCommon.cxx +++ b/src/decoder/FlacCommon.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -25,14 +25,10 @@ #include "FlacCommon.hxx" #include "FlacMetadata.hxx" #include "FlacPcm.hxx" -#include "MixRampInfo.hxx" #include "CheckAudioFormat.hxx" #include "util/Error.hxx" -#include "util/Domain.hxx" #include "Log.hxx" -#include <assert.h> - flac_data::flac_data(Decoder &_decoder, InputStream &_input_stream) :FlacInput(_input_stream, &_decoder), @@ -107,8 +103,8 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block, decoder_mixramp(data->decoder, flac_parse_mixramp(block)); - flac_vorbis_comments_to_tag(data->tag, - &block->data.vorbis_comment); + data->tag = flac_vorbis_comments_to_tag(&block->data.vorbis_comment); + break; default: break; diff --git a/src/decoder/FlacCommon.hxx b/src/decoder/FlacCommon.hxx index de000dfa1..cb9bfef75 100644 --- a/src/decoder/FlacCommon.hxx +++ b/src/decoder/FlacCommon.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -29,7 +29,6 @@ #include "pcm/PcmBuffer.hxx" #include <FLAC/stream_decoder.h> -#include <FLAC/metadata.h> struct flac_data : public FlacInput { PcmBuffer buffer; diff --git a/src/decoder/FlacDecoderPlugin.cxx b/src/decoder/FlacDecoderPlugin.cxx index 1b5734434..17949f8c5 100644 --- a/src/decoder/FlacDecoderPlugin.cxx +++ b/src/decoder/FlacDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -26,10 +26,6 @@ #include "util/Error.hxx" #include "Log.hxx" -#include <glib.h> - -#include <assert.h> - #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 #error libFLAC is too old #endif diff --git a/src/decoder/FlacDecoderPlugin.h b/src/decoder/FlacDecoderPlugin.h index 936423fbf..fcdecf869 100644 --- a/src/decoder/FlacDecoderPlugin.h +++ b/src/decoder/FlacDecoderPlugin.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2012 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacDomain.cxx b/src/decoder/FlacDomain.cxx index 5858004de..fc5cc5498 100644 --- a/src/decoder/FlacDomain.cxx +++ b/src/decoder/FlacDomain.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacDomain.hxx b/src/decoder/FlacDomain.hxx index cf357332f..a06c6c6b4 100644 --- a/src/decoder/FlacDomain.hxx +++ b/src/decoder/FlacDomain.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacIOHandle.cxx b/src/decoder/FlacIOHandle.cxx index b471ecf64..aecee638b 100644 --- a/src/decoder/FlacIOHandle.cxx +++ b/src/decoder/FlacIOHandle.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacIOHandle.hxx b/src/decoder/FlacIOHandle.hxx index b6e563fa3..1f95b83d1 100644 --- a/src/decoder/FlacIOHandle.hxx +++ b/src/decoder/FlacIOHandle.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacInput.cxx b/src/decoder/FlacInput.cxx index ce193101d..51b1b0baf 100644 --- a/src/decoder/FlacInput.cxx +++ b/src/decoder/FlacInput.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacInput.hxx b/src/decoder/FlacInput.hxx index ddd5649f8..30ed55fd0 100644 --- a/src/decoder/FlacInput.hxx +++ b/src/decoder/FlacInput.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacMetadata.cxx b/src/decoder/FlacMetadata.cxx index 17cc4cd8d..b921e8481 100644 --- a/src/decoder/FlacMetadata.cxx +++ b/src/decoder/FlacMetadata.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -21,43 +21,45 @@ #include "FlacMetadata.hxx" #include "XiphTags.hxx" #include "MixRampInfo.hxx" -#include "tag/Tag.hxx" #include "tag/TagHandler.hxx" #include "tag/TagTable.hxx" #include "tag/TagBuilder.hxx" +#include "tag/Tag.hxx" #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" +#include "util/SplitString.hxx" -#include <glib.h> - -#include <assert.h> #include <string.h> +static const char * +vorbis_comment_value(const FLAC__StreamMetadata *block, + const char *name) +{ + int offset = + FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, + name); + if (offset < 0) + return nullptr; + + size_t name_length = strlen(name); + + const FLAC__StreamMetadata_VorbisComment_Entry &vc = + block->data.vorbis_comment.comments[offset]; + const char *comment = (const char *)vc.entry; + + /* 1 is for '=' */ + return comment + name_length + 1; +} + static bool flac_find_float_comment(const FLAC__StreamMetadata *block, const char *cmnt, float *fl) { - int offset; - size_t pos; - int len; - unsigned char tmp, *p; - - offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, - cmnt); - if (offset < 0) - return false; - - pos = strlen(cmnt) + 1; /* 1 is for '=' */ - len = block->data.vorbis_comment.comments[offset].length - pos; - if (len <= 0) + const char *value = vorbis_comment_value(block, cmnt); + if (value == nullptr) return false; - p = &block->data.vorbis_comment.comments[offset].entry[pos]; - tmp = p[len]; - p[len] = '\0'; - *fl = (float)atof((char *)p); - p[len] = tmp; - + *fl = (float)atof(value); return true; } @@ -88,23 +90,11 @@ gcc_pure static std::string flac_find_string_comment(const FLAC__StreamMetadata *block, const char *cmnt) { - int offset; - size_t pos; - int len; - const unsigned char *p; - - offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, - cmnt); - if (offset < 0) + const char *value = vorbis_comment_value(block, cmnt); + if (value == nullptr) return std::string(); - pos = strlen(cmnt) + 1; /* 1 is for '=' */ - len = block->data.vorbis_comment.comments[offset].length - pos; - if (len <= 0) - return std::string(); - - p = &block->data.vorbis_comment.comments[offset].entry[pos]; - return std::string((const char *)p, len); + return std::string(value); } MixRampInfo @@ -118,21 +108,19 @@ flac_parse_mixramp(const FLAC__StreamMetadata *block) /** * Checks if the specified name matches the entry's name, and if yes, - * returns the comment value (not null-temrinated). + * returns the comment value; */ static const char * flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry, - const char *name, size_t *length_r) + const char *name) { size_t name_length = strlen(name); const char *comment = (const char*)entry->entry; - if (entry->length <= name_length || - !StringEqualsCaseASCII(comment, name, name_length)) + if (!StringEqualsCaseASCII(comment, name, name_length)) return nullptr; if (comment[name_length] == '=') { - *length_r = entry->length - name_length - 1; return comment + name_length + 1; } @@ -148,14 +136,9 @@ flac_copy_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *name, TagType tag_type, const struct tag_handler *handler, void *handler_ctx) { - const char *value; - size_t value_length; - - value = flac_comment_value(entry, name, &value_length); + const char *value = flac_comment_value(entry, name); if (value != nullptr) { - char *p = g_strndup(value, value_length); - tag_handler_invoke_tag(handler, handler_ctx, tag_type, p); - g_free(p); + tag_handler_invoke_tag(handler, handler_ctx, tag_type, value); return true; } @@ -167,16 +150,12 @@ flac_scan_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry, const struct tag_handler *handler, void *handler_ctx) { if (handler->pair != nullptr) { - char *name = g_strdup((const char*)entry->entry); - char *value = strchr(name, '='); - - if (value != nullptr && value > name) { - *value++ = 0; + const char *comment = (const char *)entry->entry; + const SplitString split(comment, '='); + if (split.IsDefined() && !split.IsEmpty()) tag_handler_invoke_pair(handler, handler_ctx, - name, value); - } - - g_free(name); + split.GetFirst(), + split.GetSecond()); } for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i) @@ -221,13 +200,12 @@ flac_scan_metadata(const FLAC__StreamMetadata *block, } } -void -flac_vorbis_comments_to_tag(Tag &tag, - const FLAC__StreamMetadata_VorbisComment *comment) +Tag +flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment) { TagBuilder tag_builder; flac_scan_comments(comment, &add_tag_handler, &tag_builder); - tag_builder.Commit(tag); + return tag_builder.Commit(); } void diff --git a/src/decoder/FlacMetadata.hxx b/src/decoder/FlacMetadata.hxx index 96c61b8e6..e0449b2a2 100644 --- a/src/decoder/FlacMetadata.hxx +++ b/src/decoder/FlacMetadata.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -27,6 +27,7 @@ #include <assert.h> +struct tag_handler; class MixRampInfo; class FlacMetadataChain { @@ -81,7 +82,7 @@ public: return FLAC__Metadata_ChainStatusString[GetStatus()]; } - void Scan(const struct tag_handler *handler, void *handler_ctx); + void Scan(const tag_handler *handler, void *handler_ctx); }; class FLACMetadataIterator { @@ -110,7 +111,6 @@ public: } }; -struct tag_handler; struct Tag; struct ReplayGainInfo; @@ -130,12 +130,11 @@ flac_parse_replay_gain(ReplayGainInfo &rgi, MixRampInfo flac_parse_mixramp(const FLAC__StreamMetadata *block); -void -flac_vorbis_comments_to_tag(Tag &tag, - const FLAC__StreamMetadata_VorbisComment *comment); +Tag +flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment); void flac_scan_metadata(const FLAC__StreamMetadata *block, - const struct tag_handler *handler, void *handler_ctx); + const tag_handler *handler, void *handler_ctx); #endif diff --git a/src/decoder/FlacPcm.cxx b/src/decoder/FlacPcm.cxx index 569879371..311500f26 100644 --- a/src/decoder/FlacPcm.cxx +++ b/src/decoder/FlacPcm.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FlacPcm.hxx b/src/decoder/FlacPcm.hxx index 6cb2d5062..30c318725 100644 --- a/src/decoder/FlacPcm.hxx +++ b/src/decoder/FlacPcm.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FluidsynthDecoderPlugin.cxx b/src/decoder/FluidsynthDecoderPlugin.cxx index fa946f219..596aba1fd 100644 --- a/src/decoder/FluidsynthDecoderPlugin.cxx +++ b/src/decoder/FluidsynthDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/FluidsynthDecoderPlugin.hxx b/src/decoder/FluidsynthDecoderPlugin.hxx index 9771898a5..cd8ec2d62 100644 --- a/src/decoder/FluidsynthDecoderPlugin.hxx +++ b/src/decoder/FluidsynthDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/GmeDecoderPlugin.cxx b/src/decoder/GmeDecoderPlugin.cxx index 815fd8d69..506c647bf 100644 --- a/src/decoder/GmeDecoderPlugin.cxx +++ b/src/decoder/GmeDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,7 @@ #include "DecoderAPI.hxx" #include "CheckAudioFormat.hxx" #include "tag/TagHandler.hxx" +#include "util/Alloc.hxx" #include "util/FormatString.hxx" #include "util/UriUtil.hxx" #include "util/Error.hxx" @@ -53,7 +54,7 @@ static char * get_container_name(const char *path_fs) { const char *subtune_suffix = uri_get_suffix(path_fs); - char *path_container = g_strdup(path_fs); + char *path_container = xstrdup(path_fs); char pat[64]; snprintf(pat, sizeof(pat), "%s%s", @@ -137,7 +138,7 @@ gme_file_decode(Decoder &decoder, const char *path_fs) Music_Emu *emu; const char *gme_err = gme_open_file(path_container, &emu, GME_SAMPLE_RATE); - g_free(path_container); + free(path_container); if (gme_err != nullptr) { LogWarning(gme_domain, gme_err); return; diff --git a/src/decoder/GmeDecoderPlugin.hxx b/src/decoder/GmeDecoderPlugin.hxx index e46dc766a..f4885b6e4 100644 --- a/src/decoder/GmeDecoderPlugin.hxx +++ b/src/decoder/GmeDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx index 9dd86c55f..5a61d7d96 100644 --- a/src/decoder/MadDecoderPlugin.cxx +++ b/src/decoder/MadDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -26,23 +26,23 @@ #include "tag/TagRva2.hxx" #include "tag/TagHandler.hxx" #include "CheckAudioFormat.hxx" +#include "util/StringUtil.hxx" #include "util/ASCII.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" -#include <assert.h> -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <glib.h> #include <mad.h> #ifdef HAVE_ID3TAG #include <id3tag.h> #endif +#include <assert.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + #define FRAMES_CUSHION 2000 #define READ_BUFFER_SIZE 40960 @@ -349,24 +349,14 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag) id3_data = stream.this_frame; mad_stream_skip(&(stream), tagsize); } else { - allocated = (id3_byte_t *)g_malloc(tagsize); + allocated = new id3_byte_t[tagsize]; memcpy(allocated, stream.this_frame, count); mad_stream_skip(&(stream), count); - while (count < tagsize) { - size_t len; - - len = decoder_read(decoder, input_stream, - allocated + count, tagsize - count); - if (len == 0) - break; - else - count += len; - } - - if (count != tagsize) { + if (!decoder_read_full(decoder, input_stream, + allocated + count, tagsize - count)) { LogDebug(mad_domain, "error parsing ID3 tag"); - g_free(allocated); + delete[] allocated; return; } @@ -375,7 +365,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag) id3_tag = id3_tag_parse(id3_data, tagsize); if (id3_tag == nullptr) { - g_free(allocated); + delete[] allocated; return; } @@ -400,7 +390,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag) id3_tag_delete(id3_tag); - g_free(allocated); + delete[] allocated; #else /* !HAVE_ID3TAG */ (void)mpd_tag; @@ -413,20 +403,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag) mad_stream_skip(&stream, tagsize); } else { mad_stream_skip(&stream, count); - - while (count < tagsize) { - size_t len = tagsize - count; - char ignored[1024]; - if (len > sizeof(ignored)) - len = sizeof(ignored); - - len = decoder_read(decoder, input_stream, - ignored, len); - if (len == 0) - break; - else - count += len; - } + decoder_skip(decoder, input_stream, tagsize - count); } #endif } @@ -690,7 +667,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) /* This is technically incorrect, since the encoder might not be lame. * But there's no other way to determine if this is a lame tag, and we * wouldn't want to go reading a tag that's not there. */ - if (!g_str_has_prefix(lame->encoder, "LAME")) + if (!StringStartsWith(lame->encoder, "LAME")) return false; if (sscanf(lame->encoder+4, "%u.%u", diff --git a/src/decoder/MadDecoderPlugin.hxx b/src/decoder/MadDecoderPlugin.hxx index 450323670..eb2a10d6f 100644 --- a/src/decoder/MadDecoderPlugin.hxx +++ b/src/decoder/MadDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/MikmodDecoderPlugin.cxx b/src/decoder/MikmodDecoderPlugin.cxx index 34381aafa..313b368ca 100644 --- a/src/decoder/MikmodDecoderPlugin.cxx +++ b/src/decoder/MikmodDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -25,8 +25,8 @@ #include "util/Domain.hxx" #include "Log.hxx" -#include <glib.h> #include <mikmod.h> + #include <assert.h> static constexpr Domain mikmod_domain("mikmod"); diff --git a/src/decoder/MikmodDecoderPlugin.hxx b/src/decoder/MikmodDecoderPlugin.hxx index d25c5f6e7..27ba2a823 100644 --- a/src/decoder/MikmodDecoderPlugin.hxx +++ b/src/decoder/MikmodDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx index e75f5479c..eabcd9d02 100644 --- a/src/decoder/ModplugDecoderPlugin.cxx +++ b/src/decoder/ModplugDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/ModplugDecoderPlugin.hxx b/src/decoder/ModplugDecoderPlugin.hxx index 4cd9f5b25..08f2ecb12 100644 --- a/src/decoder/ModplugDecoderPlugin.hxx +++ b/src/decoder/ModplugDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/MpcdecDecoderPlugin.cxx b/src/decoder/MpcdecDecoderPlugin.cxx index dc258623c..b27ea6ac2 100644 --- a/src/decoder/MpcdecDecoderPlugin.cxx +++ b/src/decoder/MpcdecDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -30,8 +30,6 @@ #include <mpc/mpcdec.h> -#include <assert.h> -#include <unistd.h> #include <math.h> struct mpc_decoder_data { diff --git a/src/decoder/MpcdecDecoderPlugin.hxx b/src/decoder/MpcdecDecoderPlugin.hxx index 23ecc801e..7f71311fa 100644 --- a/src/decoder/MpcdecDecoderPlugin.hxx +++ b/src/decoder/MpcdecDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/Mpg123DecoderPlugin.cxx b/src/decoder/Mpg123DecoderPlugin.cxx index df23f7847..670e44e69 100644 --- a/src/decoder/Mpg123DecoderPlugin.cxx +++ b/src/decoder/Mpg123DecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -26,9 +26,8 @@ #include "util/Domain.hxx" #include "Log.hxx" -#include <glib.h> - #include <mpg123.h> + #include <stdio.h> static constexpr Domain mpg123_domain("mpg123"); diff --git a/src/decoder/Mpg123DecoderPlugin.hxx b/src/decoder/Mpg123DecoderPlugin.hxx index 10f7c37f5..fd089c6a4 100644 --- a/src/decoder/Mpg123DecoderPlugin.hxx +++ b/src/decoder/Mpg123DecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OggCodec.cxx b/src/decoder/OggCodec.cxx index 565dbafcf..f9b3c3527 100644 --- a/src/decoder/OggCodec.cxx +++ b/src/decoder/OggCodec.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -23,6 +23,7 @@ #include "config.h" #include "OggCodec.hxx" +#include "DecoderAPI.hxx" #include <string.h> diff --git a/src/decoder/OggCodec.hxx b/src/decoder/OggCodec.hxx index 857871607..6643d85ad 100644 --- a/src/decoder/OggCodec.hxx +++ b/src/decoder/OggCodec.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -24,7 +24,8 @@ #ifndef MPD_OGG_CODEC_HXX #define MPD_OGG_CODEC_HXX -#include "DecoderAPI.hxx" +struct Decoder; +struct InputStream; enum ogg_codec { OGG_CODEC_UNKNOWN, diff --git a/src/decoder/OggFind.cxx b/src/decoder/OggFind.cxx index 65c7fa3ce..df4318da2 100644 --- a/src/decoder/OggFind.cxx +++ b/src/decoder/OggFind.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OggFind.hxx b/src/decoder/OggFind.hxx index ad51ccdf3..71b53323b 100644 --- a/src/decoder/OggFind.hxx +++ b/src/decoder/OggFind.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -25,7 +25,6 @@ #include <ogg/ogg.h> -struct InputStream; class OggSyncState; /** diff --git a/src/decoder/OggSyncState.hxx b/src/decoder/OggSyncState.hxx index 5235c1bd8..024902fff 100644 --- a/src/decoder/OggSyncState.hxx +++ b/src/decoder/OggSyncState.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OggUtil.cxx b/src/decoder/OggUtil.cxx index fd137f110..ceacd2962 100644 --- a/src/decoder/OggUtil.cxx +++ b/src/decoder/OggUtil.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OggUtil.hxx b/src/decoder/OggUtil.hxx index 41fc755ba..3289702a3 100644 --- a/src/decoder/OggUtil.hxx +++ b/src/decoder/OggUtil.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx index f3d7b342e..93b043065 100644 --- a/src/decoder/OpusDecoderPlugin.cxx +++ b/src/decoder/OpusDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -22,12 +22,10 @@ #include "OpusDomain.hxx" #include "OpusHead.hxx" #include "OpusTags.hxx" -#include "OggUtil.hxx" #include "OggFind.hxx" #include "OggSyncState.hxx" #include "DecoderAPI.hxx" #include "OggCodec.hxx" -#include "CheckAudioFormat.hxx" #include "tag/TagHandler.hxx" #include "tag/TagBuilder.hxx" #include "InputStream.hxx" @@ -294,8 +292,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet) !tag_builder.IsEmpty()) { decoder_replay_gain(decoder, &rgi); - Tag tag; - tag_builder.Commit(tag); + Tag tag = tag_builder.Commit(); cmd = decoder_tag(decoder, input_stream, std::move(tag)); } else cmd = decoder_get_command(decoder); diff --git a/src/decoder/OpusDecoderPlugin.h b/src/decoder/OpusDecoderPlugin.h index 263ac6e2d..260dab99a 100644 --- a/src/decoder/OpusDecoderPlugin.h +++ b/src/decoder/OpusDecoderPlugin.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2012 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OpusDomain.cxx b/src/decoder/OpusDomain.cxx index b00e2a553..1efd64a48 100644 --- a/src/decoder/OpusDomain.cxx +++ b/src/decoder/OpusDomain.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OpusDomain.hxx b/src/decoder/OpusDomain.hxx index 2b56c427c..fb19e0301 100644 --- a/src/decoder/OpusDomain.hxx +++ b/src/decoder/OpusDomain.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OpusHead.cxx b/src/decoder/OpusHead.cxx index 0417d3905..bfa41d618 100644 --- a/src/decoder/OpusHead.cxx +++ b/src/decoder/OpusHead.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -21,7 +21,6 @@ #include "OpusHead.hxx" #include <stdint.h> -#include <string.h> struct OpusHead { char signature[8]; diff --git a/src/decoder/OpusHead.hxx b/src/decoder/OpusHead.hxx index fa6a2b666..c478d8d90 100644 --- a/src/decoder/OpusHead.hxx +++ b/src/decoder/OpusHead.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OpusReader.hxx b/src/decoder/OpusReader.hxx index 2bb39b748..c5b8e9107 100644 --- a/src/decoder/OpusReader.hxx +++ b/src/decoder/OpusReader.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OpusTags.cxx b/src/decoder/OpusTags.cxx index f7729e5ad..aff5479c0 100644 --- a/src/decoder/OpusTags.cxx +++ b/src/decoder/OpusTags.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/OpusTags.hxx b/src/decoder/OpusTags.hxx index e1f1a1ff1..be3ac3a8d 100644 --- a/src/decoder/OpusTags.hxx +++ b/src/decoder/OpusTags.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/PcmDecoderPlugin.cxx b/src/decoder/PcmDecoderPlugin.cxx index dbc38fb76..35ccc5d12 100644 --- a/src/decoder/PcmDecoderPlugin.cxx +++ b/src/decoder/PcmDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -25,8 +25,6 @@ #include "util/ByteReverse.hxx" #include "Log.hxx" -#include <glib.h> -#include <unistd.h> #include <string.h> #include <stdio.h> /* for SEEK_SET */ diff --git a/src/decoder/PcmDecoderPlugin.hxx b/src/decoder/PcmDecoderPlugin.hxx index 38e4a5020..3582e5856 100644 --- a/src/decoder/PcmDecoderPlugin.hxx +++ b/src/decoder/PcmDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/SidplayDecoderPlugin.cxx b/src/decoder/SidplayDecoderPlugin.cxx index 160337594..8b3e3f8c0 100644 --- a/src/decoder/SidplayDecoderPlugin.cxx +++ b/src/decoder/SidplayDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include "SidplayDecoderPlugin.hxx" #include "../DecoderAPI.hxx" #include "tag/TagHandler.hxx" +#include "util/Alloc.hxx" #include "util/Domain.hxx" #include "system/ByteOrder.hxx" #include "Log.hxx" @@ -121,7 +122,7 @@ sidplay_finish() static char * get_container_name(const char *path_fs) { - char *path_container=g_strdup(path_fs); + char *path_container = strdup(path_fs); if(!g_pattern_match(path_with_subtune, strlen(path_container), path_container, nullptr)) @@ -163,9 +164,9 @@ get_song_length(const char *path_fs) if (songlength_database == nullptr) return -1; - gchar *sid_file=get_container_name(path_fs); + char *sid_file = get_container_name(path_fs); SidTuneMod tune(sid_file); - g_free(sid_file); + free(sid_file); if(!tune) { LogWarning(sidplay_domain, "failed to load file for calculating md5 sum"); @@ -209,7 +210,7 @@ sidplay_file_decode(Decoder &decoder, const char *path_fs) char *path_container=get_container_name(path_fs); SidTune tune(path_container, nullptr, true); - g_free(path_container); + free(path_container); if (!tune) { LogWarning(sidplay_domain, "failed to load file"); return; @@ -346,7 +347,7 @@ sidplay_scan_file(const char *path_fs, char *path_container=get_container_name(path_fs); SidTune tune(path_container, nullptr, true); - g_free(path_container); + free(path_container); if (!tune) return false; diff --git a/src/decoder/SidplayDecoderPlugin.hxx b/src/decoder/SidplayDecoderPlugin.hxx index 16544801f..58786e646 100644 --- a/src/decoder/SidplayDecoderPlugin.hxx +++ b/src/decoder/SidplayDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/SndfileDecoderPlugin.cxx b/src/decoder/SndfileDecoderPlugin.cxx index 3360cd1bf..941df33ab 100644 --- a/src/decoder/SndfileDecoderPlugin.cxx +++ b/src/decoder/SndfileDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/SndfileDecoderPlugin.hxx b/src/decoder/SndfileDecoderPlugin.hxx index f8aa65680..d56acdd5a 100644 --- a/src/decoder/SndfileDecoderPlugin.hxx +++ b/src/decoder/SndfileDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/VorbisComments.cxx b/src/decoder/VorbisComments.cxx index d4f019b58..2a0820ab5 100644 --- a/src/decoder/VorbisComments.cxx +++ b/src/decoder/VorbisComments.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -20,16 +20,13 @@ #include "config.h" #include "VorbisComments.hxx" #include "XiphTags.hxx" -#include "tag/Tag.hxx" #include "tag/TagTable.hxx" #include "tag/TagHandler.hxx" #include "tag/TagBuilder.hxx" #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" +#include "util/SplitString.hxx" -#include <glib.h> - -#include <assert.h> #include <stddef.h> #include <string.h> #include <stdlib.h> @@ -104,16 +101,11 @@ vorbis_scan_comment(const char *comment, const struct tag_handler *handler, void *handler_ctx) { if (handler->pair != nullptr) { - char *name = g_strdup((const char*)comment); - char *value = strchr(name, '='); - - if (value != nullptr && value > name) { - *value++ = 0; + const SplitString split(comment, '='); + if (split.IsDefined() && !split.IsEmpty()) tag_handler_invoke_pair(handler, handler_ctx, - name, value); - } - - g_free(name); + split.GetFirst(), + split.GetSecond()); } for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i) @@ -145,5 +137,5 @@ vorbis_comments_to_tag(char **comments) vorbis_comments_scan(comments, &add_tag_handler, &tag_builder); return tag_builder.IsEmpty() ? nullptr - : tag_builder.Commit(); + : tag_builder.CommitNew(); } diff --git a/src/decoder/VorbisComments.hxx b/src/decoder/VorbisComments.hxx index e5a48ef6b..893c89277 100644 --- a/src/decoder/VorbisComments.hxx +++ b/src/decoder/VorbisComments.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -31,7 +31,7 @@ vorbis_comments_to_replay_gain(ReplayGainInfo &rgi, char **comments); void vorbis_comments_scan(char **comments, - const struct tag_handler *handler, void *handler_ctx); + const tag_handler *handler, void *handler_ctx); Tag * vorbis_comments_to_tag(char **comments); diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx index 4d3e48528..c69ad4386 100644 --- a/src/decoder/VorbisDecoderPlugin.cxx +++ b/src/decoder/VorbisDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -25,9 +25,7 @@ #include "InputStream.hxx" #include "OggCodec.hxx" #include "util/Error.hxx" -#include "util/UriUtil.hxx" #include "util/Macros.hxx" -#include "system/ByteOrder.hxx" #include "CheckAudioFormat.hxx" #include "tag/TagHandler.hxx" #include "Log.hxx" @@ -48,7 +46,6 @@ #define ov_time_seek_page(VF, S) (ov_time_seek_page(VF, (S)*1000)) #endif /* HAVE_TREMOR */ -#include <assert.h> #include <errno.h> struct vorbis_input_stream { diff --git a/src/decoder/VorbisDecoderPlugin.h b/src/decoder/VorbisDecoderPlugin.h index 54953d83a..b54df2e97 100644 --- a/src/decoder/VorbisDecoderPlugin.h +++ b/src/decoder/VorbisDecoderPlugin.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2012 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/VorbisDomain.cxx b/src/decoder/VorbisDomain.cxx index 32ff4d6b7..e3d880efa 100644 --- a/src/decoder/VorbisDomain.cxx +++ b/src/decoder/VorbisDomain.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/VorbisDomain.hxx b/src/decoder/VorbisDomain.hxx index a35edd041..48715e328 100644 --- a/src/decoder/VorbisDomain.hxx +++ b/src/decoder/VorbisDomain.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -22,6 +22,8 @@ #include "check.h" -extern const class Domain vorbis_domain; +class Domain; + +extern const Domain vorbis_domain; #endif diff --git a/src/decoder/WavpackDecoderPlugin.cxx b/src/decoder/WavpackDecoderPlugin.cxx index 98555c5e8..3aceb3ae7 100644 --- a/src/decoder/WavpackDecoderPlugin.cxx +++ b/src/decoder/WavpackDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/WavpackDecoderPlugin.hxx b/src/decoder/WavpackDecoderPlugin.hxx index 3a2d94532..2e5f9bd42 100644 --- a/src/decoder/WavpackDecoderPlugin.hxx +++ b/src/decoder/WavpackDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/WildmidiDecoderPlugin.cxx b/src/decoder/WildmidiDecoderPlugin.cxx index 3da3f1387..3bc433b4b 100644 --- a/src/decoder/WildmidiDecoderPlugin.cxx +++ b/src/decoder/WildmidiDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/WildmidiDecoderPlugin.hxx b/src/decoder/WildmidiDecoderPlugin.hxx index a6289612e..fc87aab80 100644 --- a/src/decoder/WildmidiDecoderPlugin.hxx +++ b/src/decoder/WildmidiDecoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/XiphTags.cxx b/src/decoder/XiphTags.cxx index b9958a19a..a5e534086 100644 --- a/src/decoder/XiphTags.cxx +++ b/src/decoder/XiphTags.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/decoder/XiphTags.hxx b/src/decoder/XiphTags.hxx index 606dfef10..48a27425f 100644 --- a/src/decoder/XiphTags.hxx +++ b/src/decoder/XiphTags.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify |