fix: casts on old ffmpeg versions

This commit is contained in:
Almamu 2025-09-05 03:45:48 +02:00
parent 8012056342
commit 822891008d
2 changed files with 21 additions and 13 deletions

View File

@ -252,7 +252,7 @@ bool CAudioStream::doQueue (AVPacket* pkt) {
MyAVPacketList entry {pkt}; MyAVPacketList entry {pkt};
#if FF_API_FIFO_OLD_API #if FF_API_FIFO_OLD_API
if (av_fifo_space (this->m_queue->packetList) < sizeof (entry)) if (av_fifo_space (this->m_queue->packetList) < static_cast <int> (sizeof (entry)))
if (av_fifo_grow (this->m_queue->packetList, sizeof (entry)) < 0) if (av_fifo_grow (this->m_queue->packetList, sizeof (entry)) < 0)
return false; return false;
@ -281,7 +281,7 @@ void CAudioStream::dequeuePacket (AVPacket* output) {
#if FF_API_FIFO_OLD_API #if FF_API_FIFO_OLD_API
int ret = -1; int ret = -1;
if (av_fifo_size (this->m_queue->packetList) >= sizeof (entry)) if (av_fifo_size (this->m_queue->packetList) >= static_cast <int> (sizeof (entry)))
ret = av_fifo_generic_read (this->m_queue->packetList, &entry, sizeof (entry), nullptr); ret = av_fifo_generic_read (this->m_queue->packetList, &entry, sizeof (entry), nullptr);
#else #else
int ret = av_fifo_read (this->m_queue->packetList, &entry, 1); int ret = av_fifo_read (this->m_queue->packetList, &entry, 1);

View File

@ -40,13 +40,17 @@ class VectorBuilder {
if (first == nullptr) { if (first == nullptr) {
sLog.exception ("Invalid vector format: " + str + " (too few values, expected: 2, 3 or 4)"); sLog.exception ("Invalid vector format: " + str + " (too few values, expected: 2, 3 or 4)");
} else if (second == nullptr) {
return 2;
} else if (third == nullptr) {
return 3;
} else {
return 4;
} }
if (second == nullptr) {
return 2;
}
if (third == nullptr) {
return 3;
}
return 4;
} }
/** /**
@ -64,6 +68,9 @@ class VectorBuilder {
*/ */
template <int length, typename type, glm::qualifier qualifier> template <int length, typename type, glm::qualifier qualifier>
[[nodiscard]] static glm::vec<length, type, qualifier> parse (const std::string& str) { [[nodiscard]] static glm::vec<length, type, qualifier> parse (const std::string& str) {
// ensure a valid type is used, only 1 to 4 vectors are supported
static_assert (length >= 1 && length <= 4, "Invalid vector length");
const char* p = str.c_str (); const char* p = str.c_str ();
// get up to 4 spaces // get up to 4 spaces
@ -79,21 +86,22 @@ class VectorBuilder {
} else if constexpr (length == 2) { } else if constexpr (length == 2) {
if (first == nullptr) { if (first == nullptr) {
sLog.exception ("Invalid vector format: " + str + " (too few values, expected: ", length, ")"); sLog.exception ("Invalid vector format: " + str + " (too few values, expected: ", length, ")");
} else if (second != nullptr) { }
if (second != nullptr) {
sLog.exception ("Invalid vector format: " + str + " (too many values, expected: ", length, ")"); sLog.exception ("Invalid vector format: " + str + " (too many values, expected: ", length, ")");
} }
} else if constexpr (length == 3) { } else if constexpr (length == 3) {
if (first == nullptr || second == nullptr) { if (first == nullptr || second == nullptr) {
sLog.exception ("Invalid vector format: " + str + " (too few values, expected: ", length, ")"); sLog.exception ("Invalid vector format: " + str + " (too few values, expected: ", length, ")");
} else if (third != nullptr) { }
if (third != nullptr) {
sLog.exception ("Invalid vector format: " + str + " (too many values, expected: ", length, ")"); sLog.exception ("Invalid vector format: " + str + " (too many values, expected: ", length, ")");
} }
} else if constexpr (length == 4) { } else if constexpr (length == 4) {
if (first == nullptr || second == nullptr || third == nullptr) { if (first == nullptr || second == nullptr || third == nullptr) {
sLog.exception ("Invalid vector format: " + str + " (too few values, expected: ", length, ")"); sLog.exception ("Invalid vector format: " + str + " (too few values, expected: ", length, ")");
} }
} else {
sLog.exception ("Invalid vector length: ", length);
} }
// lengths validated, values can be used directly without issues // lengths validated, values can be used directly without issues
@ -112,7 +120,7 @@ class VectorBuilder {
convert <type> (first + 1), convert <type> (first + 1),
convert <type> (second + 1) convert <type> (second + 1)
}; };
} else { } else if constexpr (length == 4) {
return { return {
convert <type> (p), convert <type> (p),
convert <type> (first + 1), convert <type> (first + 1),