diff options
author | Joerg Mueller <nexyon@gmail.com> | 2010-07-28 13:36:03 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2010-07-28 13:36:03 +0400 |
commit | 7296600434c49b40215ba842af73a8b1517e12eb (patch) | |
tree | ba41a61f147073c91cf370c1f470b7c519397766 /intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp | |
parent | 3e3f874a65e9c20353fdc26a20a2f5da9b41e90e (diff) |
Audaspace: HUGE Refactor.
Some points of the refactor not sorted by importance:
* Fixed immutability of readers and factories (there are exceptions...)
* Fixed copy constructors and = operators
* Removed messaging system
* Removed reader types
* Added const where possible
* Using initalisers when possible
* Avoided use of pointers when possible
* Removed AUD_NEW and AUD_DELETE macros
* Removed useless NULL pointer checks
* Fixed exception catching
* Fixed some yet unknown bugs
* Lots of other stuff
Diffstat (limited to 'intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp')
-rw-r--r-- | intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp index 8e71c97baec..cad64d70790 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp @@ -24,45 +24,29 @@ */ // needed for INT64_C +#ifndef __STDC_CONSTANT_MACROS #define __STDC_CONSTANT_MACROS +#endif #include "AUD_FFMPEGFactory.h" #include "AUD_FFMPEGReader.h" #include "AUD_Buffer.h" -AUD_FFMPEGFactory::AUD_FFMPEGFactory(const char* filename) +AUD_FFMPEGFactory::AUD_FFMPEGFactory(std::string filename) : + m_filename(filename) { - if(filename != NULL) - { - m_filename = new char[strlen(filename)+1]; AUD_NEW("string") - strcpy(m_filename, filename); - } - else - m_filename = NULL; } -AUD_FFMPEGFactory::AUD_FFMPEGFactory(unsigned char* buffer, int size) +AUD_FFMPEGFactory::AUD_FFMPEGFactory(const data_t* buffer, int size) : + m_buffer(new AUD_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() -{ - if(m_filename) - { - delete[] m_filename; AUD_DELETE("string") - } -} - -AUD_IReader* AUD_FFMPEGFactory::createReader() +AUD_IReader* AUD_FFMPEGFactory::createReader() const { - AUD_IReader* reader; - if(m_filename) - reader = new AUD_FFMPEGReader(m_filename); + if(m_buffer.get()) + return new AUD_FFMPEGReader(m_buffer); else - reader = new AUD_FFMPEGReader(m_buffer); - AUD_NEW("reader") - return reader; + return new AUD_FFMPEGReader(m_filename); } |