mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 13:22:23 +08:00
Brought back deprecated code for older ffmpeg builds
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
ecd8ff3757
commit
3df27e289b
@ -197,8 +197,12 @@ void CAudioStream::loadCustomContent (const char* filename)
|
|||||||
|
|
||||||
void CAudioStream::initialize ()
|
void CAudioStream::initialize ()
|
||||||
{
|
{
|
||||||
|
#if FF_API_FIFO_OLD_API
|
||||||
// allocate the FIFO buffer
|
// allocate the FIFO buffer
|
||||||
this->m_queue->packetList = av_fifo_alloc2 (1, sizeof (MyAVPacketList), AV_FIFO_FLAG_AUTO_GROW);
|
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
|
// setup the queue information
|
||||||
this->m_queue->mutex = SDL_CreateMutex ();
|
this->m_queue->mutex = SDL_CreateMutex ();
|
||||||
@ -233,9 +237,17 @@ bool CAudioStream::doQueue (AVPacket* pkt)
|
|||||||
{
|
{
|
||||||
MyAVPacketList entry { pkt };
|
MyAVPacketList entry { pkt };
|
||||||
|
|
||||||
|
#if FF_API_FIFO_OLD_API
|
||||||
// write the entry if possible
|
// write the entry if possible
|
||||||
if (av_fifo_write (this->m_queue->packetList, &entry, 1) < 0)
|
if (av_fifo_write (this->m_queue->packetList, &entry, 1) < 0)
|
||||||
return false;
|
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->nb_packets ++;
|
||||||
this->m_queue->size += entry.packet->size + sizeof (entry);
|
this->m_queue->size += entry.packet->size + sizeof (entry);
|
||||||
@ -254,8 +266,17 @@ void CAudioStream::dequeuePacket (AVPacket* output)
|
|||||||
|
|
||||||
while (g_KeepRunning)
|
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
|
// 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->nb_packets --;
|
||||||
this->m_queue->size -= entry.packet->size + sizeof (entry);
|
this->m_queue->size -= entry.packet->size + sizeof (entry);
|
||||||
|
@ -81,7 +81,11 @@ namespace WallpaperEngine::Audio
|
|||||||
|
|
||||||
struct PacketQueue
|
struct PacketQueue
|
||||||
{
|
{
|
||||||
|
#if FF_API_FIFO_OLD_API
|
||||||
AVFifo* packetList;
|
AVFifo* packetList;
|
||||||
|
#else
|
||||||
|
AVFifoBuffer* packetList;
|
||||||
|
#endif
|
||||||
int nb_packets;
|
int nb_packets;
|
||||||
int size;
|
int size;
|
||||||
int64_t duration;
|
int64_t duration;
|
||||||
|
Loading…
Reference in New Issue
Block a user