From a7e74c74a744660f0159670c328ac78f2be02fd5 Mon Sep 17 00:00:00 2001 From: kaienfr Date: Sat, 29 Mar 2014 19:36:53 +0100 Subject: [PATCH] Cleanup SimpleAudioDec and remove unused AudioCreate fonction, it can be down in the class constructor. --- Core/HW/MediaEngine.cpp | 2 +- Core/HW/SimpleAudioDec.cpp | 55 ++++++++------------------------------ Core/HW/SimpleAudioDec.h | 2 -- 3 files changed, 12 insertions(+), 47 deletions(-) diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index 145212df41..082bd87753 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -286,7 +286,7 @@ bool MediaEngine::openContext() { return false; setVideoDim(); - m_audioContext = AudioCreate(m_audioType); + m_audioContext = new SimpleAudio(m_audioType); m_isVideoEnd = false; m_noAudioData = false; m_mpegheaderReadPos++; diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index 8567641c79..73f98f05d6 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -60,12 +60,13 @@ bool SimpleAudio::GetAudioCodecID(int audioType){ } SimpleAudio::SimpleAudio(int audioType) -: codec_(0), -codecCtx_(0), -swrCtx_(0) { - SimpleAudio::audioType = audioType; +: codec_(0), codecCtx_(0), swrCtx_(0), audioType(audioType){ #ifdef USE_FFMPEG - frame_ = av_frame_alloc(); + avcodec_register_all(); + av_register_all(); + InitFFmpeg(); + + frame_ = av_frame_alloc(); // Get Audio Codec ID if (!GetAudioCodecID(audioType)){ @@ -100,12 +101,12 @@ swrCtx_(0) { SimpleAudio::SimpleAudio(u32 ctxPtr, int audioType) -: codec_(0), -codecCtx_(0), -swrCtx_(0) { - SimpleAudio::ctxPtr = ctxPtr; - SimpleAudio::audioType = audioType; +: codec_(0), codecCtx_(0), swrCtx_(0), ctxPtr(ctxPtr), audioType(audioType){ #ifdef USE_FFMPEG + avcodec_register_all(); + av_register_all(); + InitFFmpeg(); + frame_ = av_frame_alloc(); // Get Audio Codec ID @@ -211,40 +212,6 @@ bool SimpleAudio::Decode(void* inbuf, int inbytes, uint8_t *outbuf, int *outbyte } -SimpleAudio *AudioCreate(int audioType) { -#ifdef USE_FFMPEG - avcodec_register_all(); - av_register_all(); - InitFFmpeg(); - - SimpleAudio *Audio = new SimpleAudio(audioType); - if (!Audio->IsOK()) { - delete Audio; - return 0; - } - return Audio; -#else - return 0; -#endif // USE_FFMPEG -} - -SimpleAudio *AudioCreate(u32 ctxPtr, int audioType) { -#ifdef USE_FFMPEG - avcodec_register_all(); - av_register_all(); - InitFFmpeg(); - - SimpleAudio *Audio = new SimpleAudio(ctxPtr, audioType); - if (!Audio->IsOK()) { - delete Audio; - return 0; - } - return Audio; -#else - return 0; -#endif // USE_FFMPEG -} - bool AudioDecode(SimpleAudio *ctx, void* inbuf, int inbytes, int *outbytes, uint8_t *outbuf) { #ifdef USE_FFMPEG return ctx->Decode(inbuf, inbytes, outbuf, outbytes); diff --git a/Core/HW/SimpleAudioDec.h b/Core/HW/SimpleAudioDec.h index 535541ac14..0a9c6503aa 100644 --- a/Core/HW/SimpleAudioDec.h +++ b/Core/HW/SimpleAudioDec.h @@ -79,8 +79,6 @@ static const char *const codecNames[4] = { "AT3+", "AT3", "MP3", "AAC", }; - -SimpleAudio *AudioCreate(int audioType); bool AudioDecode(SimpleAudio *ctx, void* inbuf, int inbytes, int *outbytes, uint8_t* outbuf); void AudioClose(SimpleAudio **ctx); static const char *GetCodecName(int codec) {