Skip to content

Commit 6fa3db1

Browse files
committed
C bindings, fileref, fix warnings
1 parent 4546c00 commit 6fa3db1

23 files changed

Lines changed: 225 additions & 52 deletions

bindings/c/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ if(WITH_SHORTEN)
6363
${CMAKE_CURRENT_SOURCE_DIR}/../../taglib/shorten
6464
)
6565
endif()
66+
if(WITH_MATROSKA)
67+
set(tag_c_HDR_DIRS ${tag_c_HDR_DIRS}
68+
${CMAKE_CURRENT_SOURCE_DIR}/../../taglib/matroska
69+
${CMAKE_CURRENT_SOURCE_DIR}/../../taglib/matroska/ebml
70+
)
71+
endif()
6672
include_directories(${tag_c_HDR_DIRS})
6773

6874
set(tag_c_HDRS tag_c.h)

bindings/c/tag_c.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
#ifdef TAGLIB_WITH_SHORTEN
8181
#include "shortenfile.h"
8282
#endif
83+
#ifdef TAGLIB_WITH_MATROSKA
84+
#include "matroskafile.h"
85+
#endif
8386

8487
using namespace TagLib;
8588

@@ -241,6 +244,11 @@ TagLib_File *taglib_file_new_type_any_char(const T *filename, TagLib_File_Type t
241244
case TagLib_File_SHORTEN:
242245
file = new Shorten::File(filename);
243246
break;
247+
#endif
248+
#ifdef TAGLIB_WITH_MATROSKA
249+
case TagLib_File_MATROSKA:
250+
file = new Matroska::File(filename);
251+
break;
244252
#endif
245253
default:
246254
break;

bindings/c/tag_c.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ typedef enum {
132132
TagLib_File_Opus,
133133
TagLib_File_DSF,
134134
TagLib_File_DSDIFF,
135-
TagLib_File_SHORTEN
135+
TagLib_File_SHORTEN,
136+
TagLib_File_MATROSKA
136137
} TagLib_File_Type;
137138

138139
/*!

taglib/fileref.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ namespace
296296
else if(Shorten::File::isSupported(stream))
297297
file = new Shorten::File(stream, readAudioProperties, audioPropertiesStyle);
298298
#endif
299+
#ifdef TAGLIB_WITH_MATROSKA
300+
else if(Matroska::File::isSupported(stream))
301+
file = new Matroska::File(stream, readAudioProperties, audioPropertiesStyle);
302+
#endif
299303

300304
// isSupported() only does a quick check, so double check the file here.
301305

@@ -520,6 +524,11 @@ StringList FileRef::defaultFileExtensions()
520524
#ifdef TAGLIB_WITH_SHORTEN
521525
l.append("shn");
522526
#endif
527+
#ifdef TAGLIB_WITH_MATROSKA
528+
l.append("mkv");
529+
l.append("mka");
530+
l.append("webm");
531+
#endif
523532

524533
return l;
525534
}

taglib/matroska/ebml/ebmlmksegment.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ namespace TagLib {
5151
Matroska::Segment* parseSegment();
5252

5353
private:
54-
offset_t dataOffset = 0;
5554
MkTags *tags = nullptr;
5655
MkAttachments *attachments = nullptr;
5756
MkSeekHead *seekHead = nullptr;
58-
5957
};
6058
}
6159
}

taglib/matroska/ebml/ebmlstringelement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ByteVector EBML::StringElement<t>::render()
5454
std::string string = value.to8Bit(t == String::UTF8);
5555
dataSize = string.size();
5656
buffer.append(renderVINT(dataSize, 0));
57-
buffer.append(ByteVector(string.data(), dataSize));
57+
buffer.append(ByteVector(string.data(), static_cast<unsigned int>(dataSize)));
5858
return buffer;
5959
}
6060
template ByteVector EBML::StringElement<String::UTF8>::render();

taglib/matroska/ebml/ebmlutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ std::pair<int, T> EBML::readVINT(File &file)
6464

6565
if(nb_bytes > 1)
6666
buffer.append(file.readBlock(nb_bytes - 1));
67-
int bits_to_shift = (sizeof(T) * 8) - (7 * nb_bytes);
67+
int bits_to_shift = static_cast<int>(sizeof(T) * 8) - (7 * nb_bytes);
6868
offset_t mask = 0xFFFFFFFFFFFFFFFF >> bits_to_shift;
6969
return { nb_bytes, static_cast<T>(buffer.toLongLong(true)) & mask };
7070
}
@@ -83,7 +83,7 @@ std::pair<int, T> EBML::parseVINT(const ByteVector &buffer)
8383
if(!numBytes)
8484
return {0, 0};
8585

86-
int bits_to_shift = (sizeof(T) * 8) - (7 * numBytes);
86+
int bits_to_shift = static_cast<int>(sizeof(T) * 8) - (7 * numBytes);
8787
offset_t mask = 0xFFFFFFFFFFFFFFFF >> bits_to_shift;
8888
return { numBytes, static_cast<T>(buffer.toLongLong(true)) & mask };
8989
}

taglib/matroska/ebml/ebmlvoidelement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ ByteVector EBML::VoidElement::render()
3232
offset_t bytesNeeded = targetSize;
3333
ByteVector buffer = renderId();
3434
bytesNeeded -= buffer.size();
35-
sizeLength = std::min(bytesNeeded, static_cast<offset_t>(8));
35+
sizeLength = static_cast<int>(std::min(bytesNeeded, static_cast<offset_t>(8)));
3636
bytesNeeded -= sizeLength;
3737
dataSize = bytesNeeded;
3838
buffer.append(renderVINT(dataSize, sizeLength));
3939
if (dataSize)
40-
buffer.append(ByteVector(dataSize, 0));
40+
buffer.append(ByteVector(static_cast<unsigned int>(dataSize), 0));
4141

4242
return buffer;
4343
}

taglib/matroska/matroskaattachedfile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ namespace TagLib {
4848

4949
private:
5050
class AttachedFilePrivate;
51+
TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
5152
std::unique_ptr<AttachedFilePrivate> d;
52-
5353
};
5454
}
5555
}
5656

57-
#endif
57+
#endif

taglib/matroska/matroskaattachments.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ namespace TagLib {
5555
friend class EBML::MkAttachments;
5656
friend class Matroska::File;
5757
class AttachmentsPrivate;
58+
TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
5859
std::unique_ptr<AttachmentsPrivate> d;
59-
6060
};
6161
}
6262
}
6363

64-
#endif
64+
#endif

0 commit comments

Comments
 (0)