Permalink
Browse files

dvdplayer audio: fix invalid format after 5852fd7

  • Loading branch information...
1 parent 756598b commit ac9c144bec5eaef9aadac17b43c3f918202442b3 @FernetMenta FernetMenta committed Jan 11, 2014
View
25 xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
@@ -46,7 +46,6 @@ CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg() : CDVDAudioCodec()
m_layout = 0;
m_bLpcmMode = false;
- m_bNeedConversion = false;
m_pFrame1 = NULL;
m_iSampleFormat = AV_SAMPLE_FMT_NONE;
@@ -118,8 +117,6 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
m_bOpenedCodec = true;
m_iSampleFormat = AV_SAMPLE_FMT_NONE;
- // check if conversion is needed
- GetDataFormat();
return true;
}
@@ -185,8 +182,23 @@ int CDVDAudioCodecFFmpeg::Decode(uint8_t* pData, int iSize)
m_iBuffered += iBytesUsed;
else
m_iBuffered = 0;
-
- if(m_bLpcmMode || m_bNeedConversion)
+
+ bool convert = false;
+ switch(m_pCodecContext->sample_fmt)
+ {
+ case AV_SAMPLE_FMT_U8:
+ case AV_SAMPLE_FMT_S16:
+ case AV_SAMPLE_FMT_S32:
+ case AV_SAMPLE_FMT_FLT:
+ case AV_SAMPLE_FMT_DBL:
+ break;
+ case AV_SAMPLE_FMT_NONE:
+ CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::Decode - invalid data format");
+ return -1;
+ default:
+ convert = true;
+ }
+ if(m_bLpcmMode || convert)
ConvertToFloat();
return iBytesUsed;
@@ -312,10 +324,9 @@ enum AEDataFormat CDVDAudioCodecFFmpeg::GetDataFormat()
case AV_SAMPLE_FMT_FLT: return AE_FMT_FLOAT;
case AV_SAMPLE_FMT_DBL: return AE_FMT_DOUBLE;
case AV_SAMPLE_FMT_NONE:
- assert(false);
+ CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::GetDataFormat - invalid data format");
return AE_FMT_INVALID;
default:
- m_bNeedConversion = true;
return AE_FMT_FLOAT;
}
}
View
3 xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h
@@ -50,8 +50,7 @@ class CDVDAudioCodecFFmpeg : public CDVDAudioCodec
SwrContext* m_pConvert;
enum AVSampleFormat m_iSampleFormat;
CAEChannelInfo m_channelLayout;
- bool m_bLpcmMode;
- bool m_bNeedConversion;
+ bool m_bLpcmMode;
AVFrame* m_pFrame1;
int m_iBufferSize1;

0 comments on commit ac9c144

Please sign in to comment.