diff options
Diffstat (limited to 'intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp')
-rw-r--r-- | intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp index 5f9006b0ec0..f67c819ff10 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp @@ -25,31 +25,24 @@ #include "AUD_FFMPEGFactory.h" #include "AUD_FFMPEGReader.h" -#include "AUD_Space.h" - -extern "C" { -#include <libavformat/avformat.h> -} +#include "AUD_Buffer.h" AUD_FFMPEGFactory::AUD_FFMPEGFactory(const char* filename) { - if(filename != 0) + if(filename != NULL) { m_filename = new char[strlen(filename)+1]; AUD_NEW("string") strcpy(m_filename, filename); } else - m_filename = 0; - m_buffer = 0; - m_size = 0; + m_filename = NULL; } AUD_FFMPEGFactory::AUD_FFMPEGFactory(unsigned char* buffer, int size) { - m_filename = 0; - m_buffer = (unsigned char*)av_malloc(size); AUD_NEW("buffer") - m_size = size; - memcpy(m_buffer, buffer, size); + m_filename = NULL; + m_buffer = AUD_Reference<AUD_Buffer>(new AUD_Buffer(size)); + memcpy(m_buffer.get()->getBuffer(), buffer, size); } AUD_FFMPEGFactory::~AUD_FFMPEGFactory() @@ -58,31 +51,15 @@ AUD_FFMPEGFactory::~AUD_FFMPEGFactory() { delete[] m_filename; AUD_DELETE("string") } - if(m_buffer) - { - av_free(m_buffer); AUD_DELETE("buffer") - } } AUD_IReader* AUD_FFMPEGFactory::createReader() { - try - { - AUD_IReader* reader; - if(m_filename) - reader = new AUD_FFMPEGReader(m_filename); - else - reader = new AUD_FFMPEGReader(m_buffer, m_size); - AUD_NEW("reader") - return reader; - } - catch(AUD_Exception e) - { - // return 0 if ffmpeg cannot read the file - if(e.error == AUD_ERROR_FFMPEG) - return 0; - // but throw an exception if the file doesn't exist - else - throw; - } + AUD_IReader* reader; + if(m_filename) + reader = new AUD_FFMPEGReader(m_filename); + else + reader = new AUD_FFMPEGReader(m_buffer); + AUD_NEW("reader") + return reader; } |