$OpenBSD: patch-akode_plugins_ffmpeg_decoder_ffmpeg_decoder_cpp,v 1.5 2012/04/29 07:09:23 ajacoutot Exp $
--- akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp.orig	Thu Aug 10 14:37:20 2006
+++ akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp	Sat Apr 28 23:59:11 2012
@@ -26,9 +26,11 @@
 #include "decoder.h"
 
 #include <assert.h>
-#include <ffmpeg/avcodec.h>
-#include <ffmpeg/avformat.h>
-#include <ffmpeg/avio.h>
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+#include <libavformat/avio.h>
+}
 
 #include "ffmpeg_decoder.h"
 #include <iostream>
@@ -45,7 +47,7 @@ extern "C" {
         aKode::File *file = (aKode::File*)opaque;
         return file->write((char*)buf, size);
     }
-    static offset_t akode_seek(void* opaque, offset_t pos, int whence)
+    static int64_t akode_seek(void* opaque, int64_t pos, int whence)
     {
         aKode::File *file = (aKode::File*)opaque;
         return file->seek(pos, whence);
@@ -95,7 +97,8 @@ struct FFMPEGDecoder::private_data
     int retries;
 
     unsigned char file_buffer[FILE_BUFFER_SIZE];
-    char buffer[AVCODEC_MAX_AUDIO_FRAME_SIZE];
+    /* DECLARE_ALIGNED magic from ffplay.c */
+    DECLARE_ALIGNED(16,uint8_t,buffer)[(AVCODEC_MAX_AUDIO_FRAME_SIZE*3)/2];
     int buffer_size;
 };
 
@@ -200,10 +203,10 @@ bool FFMPEGDecoder::openFile() {
     d->audioStream = -1;
     d->videoStream = -1;
     for (int i = 0; i < d->ic->nb_streams; i++) {
-        if (d->ic->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO)
+        if (d->ic->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
             d->audioStream = i;
         else
-        if (d->ic->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
+        if (d->ic->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
             d->videoStream = i;
     }
     if (d->audioStream == -1)
@@ -313,10 +316,12 @@ bool FFMPEGDecoder::readFrame(AudioFrame* frame)
 
     assert(d->packet.stream_index == d->audioStream);
 
+    d->buffer_size = sizeof(d->buffer);
+
 retry:
-    int len = avcodec_decode_audio( d->ic->streams[d->audioStream]->codec,
-                                    (short*)d->buffer, &d->buffer_size,
-                                    d->packetData, d->packetSize );
+    int len = avcodec_decode_audio3( d->ic->streams[d->audioStream]->codec,
+                                    (int16_t*)d->buffer, &d->buffer_size,
+                                    &d->packet );
 
     if (len <= 0) {
         d->retries++;
@@ -349,7 +354,7 @@ retry:
             assert(false);
     }
     if (length == 0) return readFrame(frame);
-    std::cout << "akode: FFMPEG: Frame length: " << length << "\n";
+    // std::cout << "akode: FFMPEG: Frame length: " << length << "\n";
 
     if( d->packetSize <= 0 )
         av_free_packet( &d->packet );
