Pārlūkot izejas kodu

Brought back deprecated code for older ffmpeg builds

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez 3 gadi atpakaļ
vecāks
revīzija
3df27e289b

+ 22 - 1
src/WallpaperEngine/Audio/CAudioStream.cpp

@@ -197,8 +197,12 @@ void CAudioStream::loadCustomContent (const char* filename)
 
 void CAudioStream::initialize ()
 {
+#if FF_API_FIFO_OLD_API
     // allocate the FIFO buffer
     this->m_queue->packetList = av_fifo_alloc2 (1, sizeof (MyAVPacketList), AV_FIFO_FLAG_AUTO_GROW);
+#else
+    this->m_queue->packetList = av_fifo_alloc (sizeof (MyAVPacketList));
+#endif
 
     // setup the queue information
     this->m_queue->mutex = SDL_CreateMutex ();
@@ -233,9 +237,17 @@ bool CAudioStream::doQueue (AVPacket* pkt)
 {
     MyAVPacketList entry { pkt };
 
+#if FF_API_FIFO_OLD_API
     // write the entry if possible
     if (av_fifo_write (this->m_queue->packetList, &entry, 1) < 0)
         return false;
+#else
+    if (av_fifo_space (this->m_queue->packetList) < sizeof (entry))
+        if (av_fifo_grow (this->m_queue->packetList, sizeof (entry)) < 0)
+            return false;
+
+    av_fifo_generic_write (this->m_queue->packetList, &entry, sizeof (entry), nullptr);
+#endif
 
     this->m_queue->nb_packets ++;
     this->m_queue->size += entry.packet->size + sizeof (entry);
@@ -254,8 +266,17 @@ void CAudioStream::dequeuePacket (AVPacket* output)
 
     while (g_KeepRunning)
     {
+        int ret = -1;
+
+#if FF_API_FIFO_OLD_API
+        ret = av_fifo_read (this->m_queue->packetList, &entry, 1);
+#else
+        if (av_fifo_size (this->m_queue->packetList) >= sizeof (entry))
+            ret = av_fifo_generic_read (this->n_queue->packetList, &entry, sizeof (entry), nullptr);
+#endif
+
         // enough data available, read it
-        if (av_fifo_read (this->m_queue->packetList, &entry, 1) >= 0)
+        if (ret >= 0)
         {
             this->m_queue->nb_packets --;
             this->m_queue->size -= entry.packet->size + sizeof (entry);

+ 4 - 0
src/WallpaperEngine/Audio/CAudioStream.h

@@ -81,7 +81,11 @@ namespace WallpaperEngine::Audio
 
         struct PacketQueue
         {
+            #if FF_API_FIFO_OLD_API
             AVFifo* packetList;
+            #else
+            AVFifoBuffer* packetList;
+            #endif
             int nb_packets;
             int size;
             int64_t duration;