|
@@ -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);
|