Merge pull request #5764 from kaienfr/cleanup

Cleanup SimpleAudioDec
This commit is contained in:
Henrik Rydgård 2014-04-06 12:01:05 +02:00
commit c724a6c06a
3 changed files with 12 additions and 47 deletions

View File

@ -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++;

View File

@ -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);

View File

@ -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) {