]> git.vomp.tv Git - vompclient.git/commitdiff
Investigate deprecated avcodec_decode_audio4
authorChris Tallon <chris@vomp.tv>
Thu, 16 Feb 2023 17:45:15 +0000 (17:45 +0000)
committerChris Tallon <chris@vomp.tv>
Thu, 16 Feb 2023 17:45:15 +0000 (17:45 +0000)
src/audioomx.cc
src/audioomx.h

index dfa1d7ea3ce00d2191325e222ad61720c5c3109e..1492455f0dae5e91717a701b257ed88853a66fe8 100644 (file)
@@ -2138,9 +2138,20 @@ u4 AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const u1* buffer,
 
                                if ((int)gotframesize <= incoming_paket_libav.size) {
                                        if (gotframesize>0) incoming_paket_libav.size=gotframesize;
-                                       // FIXME deprecated
+
+                                       // FIXME
+                                       // avcodec_decode_audio4 is deprecated
+                                       // DO_NOT_USE() works, but assumes all decoded data is returned
+                                       // in the first call to avcodec_receive_frame which is
+                                       // definitely bad code.
+                                       // This all needs reworking to handle this properly.
+                                       // Leaving DO_NOT_USE in the code in case we have to switch to it
                                        len = avcodec_decode_audio4(current_context, decode_frame_libav,
                                                &gotta, &incoming_paket_libav);
+
+                                       //len = DO_NOT_USE(current_context, decode_frame_libav,
+                                       //      &gotta, &incoming_paket_libav);
+
                                } else {
                                        //LogNT::getInstance()->debug(TAG, "FRAME:E {} {}",gotframesize,incoming_paket_libav.size);
                                        gotta=0;
@@ -2382,7 +2393,7 @@ void AudioOMX::ResetTimeOffsets()
   vw->ResetTimeOffsets();
 }
 
-
+// FIXME
 int AudioOMX::badMinimumFunction(u4 a, int b)
 {
   printf("MIN: P1: %u, P2: %i\n", a, b);
@@ -2390,3 +2401,31 @@ int AudioOMX::badMinimumFunction(u4 a, int b)
   if (a > b) return b;
   else return a;
 }
+
+int AudioOMX::DO_NOT_USE(AVCodecContext* avctx,    // used - sent to avcodec_send_packet
+                                                 AVFrame* frame,          // used - object for receive to write to
+                                                 int* got_frame_ptr,      // out param
+                                                 const AVPacket* avpkt)   // used - sent to avcodec_send_packet
+{
+  // Set this to error here. Any error point returns -9999 and *got_frame_ptr = 0
+  *got_frame_ptr = 0; // Replicate old API behaviour
+
+  int sendReturn = avcodec_send_packet(avctx, avpkt);
+  if (sendReturn < 0) return -9999; // error, shouldn't happen, just crash out.
+
+  // Don't use this code
+  // avcodec_receive_frame needs to be called multiple times
+  // to ensure reception of all decoded data
+  int recReturn = avcodec_receive_frame(avctx, frame);
+  if (recReturn == 0) // success
+  {
+       // set got_frame_ptr to 1, this is the old behaviour
+    *got_frame_ptr = 1;
+       // return number of bytes consumed
+       // guessing here that the calling code only ever supplies whole packets
+       return avpkt->size;
+  }
+
+  // error
+  return -9999; // no idea. looks like calling code checks got_frame_ptr
+}
index 9e4146d348497579651de7b3af42e94991f23902..a82b1db2425caa89140bd24162c55ac2e9cf5f25 100644 (file)
@@ -199,6 +199,8 @@ class AudioOMX : public Audio
 
 
     int badMinimumFunction(u4 a, int b);
+
+    int DO_NOT_USE(AVCodecContext* avctx, AVFrame* frame, int* got_frame_ptr, const AVPacket* avpkt);
 };
 
 #endif