[OS/2] ao fixes due to switch from AVFifoBuffer to AVFifi

Dave Yeo <[email protected]> Wed, 25 Sep 2024 21:36:53 -0700
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------26CC380B9E08F74EB9B07011
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi, this diff is needed to fix compilation on OS/2. Based on the changes 
to ao_sdl, 
http://lists.mplayerhq.hu/pipermail/mplayer-cvslog/2024-April/047665.html
The other problem I'm not sure how to fix is that the configure check 
for extern_prefix fails to find the _ prefix due to nm not understanding 
LX executables. Ideas besides hacking the script?
Dave

--------------26CC380B9E08F74EB9B07011
Content-Type: text/x-patch;
 name="os2.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="os2.diff"

Index: libao2/ao_dart.c
===================================================================
--- libao2/ao_dart.c	(revision 38660)
+++ libao2/ao_dart.c	(working copy)
@@ -54,7 +54,7 @@
 
 #define CHUNK_SIZE  ao_data.outburst
 
-static AVFifoBuffer *m_audioBuf;
+static AVFifo *m_audioBuf;
 
 static int m_nBufSize = 0;
 
@@ -62,22 +62,23 @@
 
 static int write_buffer(unsigned char *data, int len)
 {
-    int nFree = av_fifo_space(m_audioBuf);
+    int nFree = av_fifo_can_write(m_audioBuf);
 
     if (len > nFree)
         len = nFree;
 
-    return av_fifo_generic_write(m_audioBuf, data, len, NULL);
+    av_fifo_write(m_audioBuf, data, len);
+    return len;
 }
 
 static int read_buffer(unsigned char *data, int len)
 {
-    int nBuffered = av_fifo_size(m_audioBuf);
+    int nBuffered = av_fifo_can_read(m_audioBuf);
 
     if (len > nBuffered)
         len = nBuffered;
 
-    av_fifo_generic_read(m_audioBuf, data, len, NULL);
+    av_fifo_read(m_audioBuf, data, len);
     return len;
 }
 
@@ -199,7 +200,7 @@
     // and one more chunk plus round up
     m_nBufSize += 2 * CHUNK_SIZE;
 
-    m_audioBuf = av_fifo_alloc(m_nBufSize);
+    m_audioBuf = av_fifo_alloc2(m_nBufSize, 1, 0);
 
     dartPlay();
 
@@ -223,7 +224,7 @@
 
     dartClose();
 
-    av_fifo_free(m_audioBuf);
+    av_fifo_freep2(&m_audioBuf);
 }
 
 // stop playing and empty buffers (for seeking/pause)
@@ -232,7 +233,7 @@
     dartPause();
 
     // Reset ring-buffer state
-    av_fifo_reset(m_audioBuf);
+    av_fifo_reset2(m_audioBuf);
 
     dartResume();
 }
@@ -252,7 +253,7 @@
 // return: how many bytes can be played without blocking
 static int get_space(void)
 {
-    return av_fifo_space(m_audioBuf);
+    return av_fifo_can_write(m_audioBuf);
 }
 
 // plays 'len' bytes of 'data'
@@ -270,7 +271,7 @@
 // return: delay in seconds between first and last sample in buffer
 static float get_delay(void)
 {
-    int nBuffered = av_fifo_size(m_audioBuf); // could be less
+    int nBuffered = av_fifo_can_read(m_audioBuf); // could be less
 
     return (float)nBuffered / (float)ao_data.bps;
 }
Index: libao2/ao_kai.c
===================================================================
--- libao2/ao_kai.c	(revision 38660)
+++ libao2/ao_kai.c	(working copy)
@@ -55,7 +55,7 @@
 
 #define CHUNK_SIZE  ao_data.outburst
 
-static AVFifoBuffer *m_audioBuf;
+static AVFifo *m_audioBuf;
 
 static int m_nBufSize = 0;
 
@@ -67,20 +67,21 @@
 
 static int write_buffer(unsigned char *data, int len)
 {
-    int nFree = av_fifo_space(m_audioBuf);
+    int nFree = av_fifo_can_write(m_audioBuf);
 
     len = FFMIN(len, nFree);
 
-    return av_fifo_generic_write(m_audioBuf, data, len, NULL);
+    av_fifo_write(m_audioBuf, data, len);
+    return len;
 }
 
 static int read_buffer(unsigned char *data, int len)
 {
-    int nBuffered = av_fifo_size(m_audioBuf);
+    int nBuffered = av_fifo_can_read(m_audioBuf);
 
     len = FFMIN(len, nBuffered);
 
-    av_fifo_generic_read(m_audioBuf, data, len, NULL);
+    av_fifo_read(m_audioBuf, data, len);
     return len;
 }
 
@@ -255,7 +256,7 @@
     mp_msg(MSGT_AO, MSGL_V, "KAI: internal audio buffer size = %d bytes\n",
            m_nBufSize);
 
-    m_audioBuf = av_fifo_alloc(m_nBufSize);
+    m_audioBuf = av_fifo_alloc2(m_nBufSize, 1, 0);
 
     kaiPlay(m_hkai);
 
@@ -280,7 +281,7 @@
 
     kaiDone();
 
-    av_fifo_free(m_audioBuf);
+    av_fifo_freep2(&m_audioBuf);
 }
 
 // stop playing and empty buffers (for seeking/pause)
@@ -289,7 +290,7 @@
     kaiPause(m_hkai);
 
     // Reset ring-buffer state
-    av_fifo_reset(m_audioBuf);
+    av_fifo_reset2(m_audioBuf);
 
     kaiResume(m_hkai);
 }
@@ -309,7 +310,7 @@
 // return: how many bytes can be played without blocking
 static int get_space(void)
 {
-    return av_fifo_space(m_audioBuf);
+    return av_fifo_can_write(m_audioBuf);
 }
 
 // plays 'len' bytes of 'data'
@@ -327,7 +328,7 @@
 // return: delay in seconds between first and last sample in buffer
 static float get_delay(void)
 {
-    int nBuffered = av_fifo_size(m_audioBuf); // could be less
+    int nBuffered = av_fifo_can_read(m_audioBuf); // could be less
 
     return (float)nBuffered / (float)ao_data.bps;
 }

--------------26CC380B9E08F74EB9B07011
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng

--------------26CC380B9E08F74EB9B07011--