Adapt most changes from taglib2

This commit is contained in:
Jonas Kvinge
2020-06-26 23:30:30 +02:00
parent 08882639e0
commit 5f71a558b9
374 changed files with 13708 additions and 4418 deletions

View File

@@ -27,13 +27,13 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <tbytevector.h>
#include <tstring.h>
#include <tdebug.h>
#include <tagunion.h>
#include <tstringlist.h>
#include <tpropertymap.h>
#include <tagutils.h>
#include "tbytevector.h"
#include "tstring.h"
#include "tdebug.h"
#include "tagunion.h"
#include "tstringlist.h"
#include "tpropertymap.h"
#include "tagutils.h"
#include "trueaudiofile.h"
#include "id3v1tag.h"
@@ -47,7 +47,8 @@ enum {
TrueAudioID3v2Index = 0,
TrueAudioID3v1Index = 1
};
}
const unsigned int HeaderSize = 18;
} // namespace
class TrueAudio::File::FilePrivate {
public:
@@ -62,12 +63,12 @@ class TrueAudio::File::FilePrivate {
}
const ID3v2::FrameFactory *ID3v2FrameFactory;
long ID3v2Location;
long ID3v2OriginalSize;
long long ID3v2Location;
long long ID3v2OriginalSize;
long ID3v1Location;
long long ID3v1Location;
TagUnion tag;
DoubleTagUnion tag;
AudioProperties *properties;
};
@@ -125,14 +126,6 @@ Strawberry_TagLib::TagLib::Tag *TrueAudio::File::tag() const {
return &d->tag;
}
PropertyMap TrueAudio::File::properties() const {
return d->tag.properties();
}
void TrueAudio::File::removeUnsupportedProperties(const StringList &properties) {
d->tag.removeUnsupportedProperties(properties);
}
PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties) {
if (ID3v1Tag())
@@ -273,7 +266,7 @@ void TrueAudio::File::read(bool readProperties) {
if (readProperties) {
long streamLength;
long long streamLength;
if (d->ID3v1Location >= 0)
streamLength = d->ID3v1Location;
@@ -288,7 +281,7 @@ void TrueAudio::File::read(bool readProperties) {
seek(0);
}
d->properties = new AudioProperties(readBlock(TrueAudio::HeaderSize), streamLength);
d->properties = new AudioProperties(readBlock(HeaderSize), streamLength);
}
}

View File

@@ -123,36 +123,29 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
/*!
* Destroys this instance of the File.
*/
virtual ~File();
~File() override;
/*!
* Returns the Tag for this file.
*/
virtual Strawberry_TagLib::TagLib::Tag *tag() const;
/*!
* Implements the unified property interface -- export function.
* If the file contains both ID3v1 and v2 tags, only ID3v2 will be converted to the PropertyMap.
*/
PropertyMap properties() const;
Strawberry_TagLib::TagLib::Tag *tag() const override;
/*!
* Implements the unified property interface -- import function.
* Creates in ID3v2 tag if necessary. If an ID3v1 tag exists, it will be updated as well, within the limitations of ID3v1.
*/
PropertyMap setProperties(const PropertyMap &);
void removeUnsupportedProperties(const StringList &properties);
PropertyMap setProperties(const PropertyMap &) override;
/*!
* Returns the TrueAudio::AudioProperties for this file.
* If no audio properties were read then this will return a null pointer.
*/
virtual AudioProperties *audioProperties() const;
AudioProperties *audioProperties() const override;
/*!
* Saves the file.
*/
virtual bool save();
bool save() override;
/*!
* Returns a pointer to the ID3v1 tag of the file.
@@ -217,7 +210,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
static bool isSupported(IOStream *stream);
private:
explicit File(const File&);
File(const File&);
File &operator=(const File&);
void read(bool readProperties);

View File

@@ -27,9 +27,8 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <tstring.h>
#include <tdebug.h>
#include <bitset>
#include "tstring.h"
#include "tdebug.h"
#include "trueaudioproperties.h"
#include "trueaudiofile.h"
@@ -38,13 +37,13 @@ using namespace Strawberry_TagLib::TagLib;
class TrueAudio::AudioProperties::AudioPropertiesPrivate {
public:
AudioPropertiesPrivate() : version(0),
length(0),
bitrate(0),
sampleRate(0),
channels(0),
bitsPerSample(0),
sampleFrames(0) {}
explicit AudioPropertiesPrivate() : version(0),
length(0),
bitrate(0),
sampleRate(0),
channels(0),
bitsPerSample(0),
sampleFrames(0) {}
int version;
int length;
@@ -59,7 +58,7 @@ class TrueAudio::AudioProperties::AudioPropertiesPrivate {
// public members
////////////////////////////////////////////////////////////////////////////////
TrueAudio::AudioProperties::AudioProperties(const ByteVector &data, long streamLength, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style), d(new AudioPropertiesPrivate()) {
TrueAudio::AudioProperties::AudioProperties(const ByteVector &data, long long streamLength, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
read(data, streamLength);
}
@@ -103,7 +102,7 @@ int TrueAudio::AudioProperties::ttaVersion() const {
// private members
////////////////////////////////////////////////////////////////////////////////
void TrueAudio::AudioProperties::read(const ByteVector &data, long streamLength) {
void TrueAudio::AudioProperties::read(const ByteVector &data, long long streamLength) {
if (data.size() < 4) {
debug("TrueAudio::AudioProperties::read() -- data is too short.");
@@ -115,7 +114,7 @@ void TrueAudio::AudioProperties::read(const ByteVector &data, long streamLength)
return;
}
unsigned int pos = 3;
size_t pos = 3;
d->version = data[pos] - '0';
pos += 1;
@@ -131,16 +130,16 @@ void TrueAudio::AudioProperties::read(const ByteVector &data, long streamLength)
// Skip the audio format
pos += 2;
d->channels = data.toShort(pos, false);
d->channels = data.toUInt16LE(pos);
pos += 2;
d->bitsPerSample = data.toShort(pos, false);
d->bitsPerSample = data.toUInt16LE(pos);
pos += 2;
d->sampleRate = data.toUInt(pos, false);
d->sampleRate = data.toUInt32LE(pos);
pos += 4;
d->sampleFrames = data.toUInt(pos, false);
d->sampleFrames = data.toUInt32LE(pos);
if (d->sampleFrames > 0 && d->sampleRate > 0) {
const double length = d->sampleFrames * 1000.0 / d->sampleRate;

View File

@@ -38,8 +38,6 @@ namespace TrueAudio {
class File;
static const unsigned int HeaderSize = 18;
//! An implementation of audio property reading for TrueAudio
/*!
@@ -51,41 +49,41 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
/*!
* Create an instance of TrueAudio::AudioProperties with the data read from the ByteVector \a data.
*/
explicit AudioProperties(const ByteVector &data, long streamLength, ReadStyle style = Average);
explicit AudioProperties(const ByteVector &data, long long streamLength, ReadStyle style = Average);
/*!
* Destroys this TrueAudio::AudioProperties instance.
*/
virtual ~AudioProperties();
~AudioProperties() override;
/*!
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
*
* \see lengthInMilliseconds()
*/
virtual int lengthInSeconds() const;
int lengthInSeconds() const override;
/*!
* Returns the length of the file in milliseconds.
*
* \see lengthInSeconds()
*/
virtual int lengthInMilliseconds() const;
int lengthInMilliseconds() const override;
/*!
* Returns the average bit rate of the file in kb/s.
*/
virtual int bitrate() const;
int bitrate() const override;
/*!
* Returns the sample rate in Hz.
*/
virtual int sampleRate() const;
int sampleRate() const override;
/*!
* Returns the number of audio channels.
*/
virtual int channels() const;
int channels() const override;
/*!
* Returns the number of bits per audio sample.
@@ -103,10 +101,7 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
int ttaVersion() const;
private:
explicit AudioProperties(const AudioProperties&);
AudioProperties &operator=(const AudioProperties&);
void read(const ByteVector &data, long streamLength);
void read(const ByteVector &data, long long streamLength);
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;