--- FusionSound-1.6.2/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c.orig 2012-09-20 18:01:15.000000000 +0200 +++ FusionSound-1.6.2/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c 2012-10-05 20:04:42.281925937 +0200 @@ -77,7 +77,7 @@ DirectStream *stream; #if (LIBAVFORMAT_VERSION_MAJOR >= 53) - AVIOContext pb; + AVIOContext *pb; #else ByteIOContext pb; #endif @@ -410,6 +410,11 @@ data->dest.buffer = NULL; } + if (data->pb) { + av_free( data->pb ); + data->pb = NULL; + } + /* release output buffer */ if (data->buf) { D_FREE( data->buf ); @@ -1247,16 +1252,26 @@ return D_OOM(); } - if (init_put_byte( &data->pb, data->iobuf, 4096, 0, + if ((data->pb = avio_alloc_context( data->iobuf, 4096, 0, (void*)data, av_read_callback, NULL, - direct_stream_seekable( stream ) ? av_seek_callback : NULL ) < 0) { - D_ERROR( "IFusionSoundMusicProvider_FFmpeg: init_put_byte() failed!\n" ); + direct_stream_seekable( stream ) ? av_seek_callback : NULL )) == NULL) { + D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avio_alloc_context() failed!\n" ); IFusionSoundMusicProvider_FFmpeg_Destruct( thiz ); return DR_INIT; } - if (av_open_input_stream( &data->ctx, &data->pb, filename, fmt, NULL ) < 0) { - D_ERROR( "IFusionSoundMusicProvider_FFmpeg: av_open_input_stream() failed!\n" ); + if(data->ctx == NULL) { + data->ctx = avformat_alloc_context(); + if (data->ctx == NULL) { + D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avformat_alloc_context() failed!\n" ); + IFusionSoundMusicProvider_FFmpeg_Destruct( thiz ); + return DR_FAILURE; + } + } + + data->ctx->pb = data->pb; + if (avformat_open_input( &data->ctx, filename, fmt, NULL ) < 0) { + D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avformat_open_input() failed!\n" ); IFusionSoundMusicProvider_FFmpeg_Destruct( thiz ); return DR_FAILURE; }