Skip to content
This repository
Browse code

dvdplayer audio: fix invalid format after 5852fd7

  • Loading branch information...
commit ac9c144bec5eaef9aadac17b43c3f918202442b3 1 parent 756598b
Rainer Hochecker authored January 11, 2014
25  xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
@@ -46,7 +46,6 @@ CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg() : CDVDAudioCodec()
46 46
   m_layout = 0;
47 47
   
48 48
   m_bLpcmMode = false;
49  
-  m_bNeedConversion = false;
50 49
 
51 50
   m_pFrame1 = NULL;
52 51
   m_iSampleFormat = AV_SAMPLE_FMT_NONE;
@@ -118,8 +117,6 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
118 117
   m_bOpenedCodec = true;
119 118
   m_iSampleFormat = AV_SAMPLE_FMT_NONE;
120 119
 
121  
-  // check if conversion is needed
122  
-  GetDataFormat();
123 120
   return true;
124 121
 }
125 122
 
@@ -185,8 +182,23 @@ int CDVDAudioCodecFFmpeg::Decode(uint8_t* pData, int iSize)
185 182
     m_iBuffered += iBytesUsed;
186 183
   else
187 184
     m_iBuffered = 0;
188  
-    
189  
-  if(m_bLpcmMode || m_bNeedConversion)
  185
+  
  186
+  bool convert = false;
  187
+  switch(m_pCodecContext->sample_fmt)
  188
+  {
  189
+    case AV_SAMPLE_FMT_U8:
  190
+    case AV_SAMPLE_FMT_S16:
  191
+    case AV_SAMPLE_FMT_S32:
  192
+    case AV_SAMPLE_FMT_FLT:
  193
+    case AV_SAMPLE_FMT_DBL:
  194
+      break;
  195
+    case AV_SAMPLE_FMT_NONE:
  196
+      CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::Decode - invalid data format");
  197
+      return -1;
  198
+    default:
  199
+      convert = true;
  200
+  }
  201
+  if(m_bLpcmMode || convert)
190 202
     ConvertToFloat();
191 203
 
192 204
   return iBytesUsed;
@@ -312,10 +324,9 @@ enum AEDataFormat CDVDAudioCodecFFmpeg::GetDataFormat()
312 324
       case AV_SAMPLE_FMT_FLT: return AE_FMT_FLOAT;
313 325
       case AV_SAMPLE_FMT_DBL: return AE_FMT_DOUBLE;
314 326
       case AV_SAMPLE_FMT_NONE:
315  
-        assert(false);
  327
+        CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::GetDataFormat - invalid data format");
316 328
         return AE_FMT_INVALID;
317 329
       default:
318  
-        m_bNeedConversion = true;
319 330
         return AE_FMT_FLOAT;
320 331
     }
321 332
   }
3  xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h
@@ -50,8 +50,7 @@ class CDVDAudioCodecFFmpeg : public CDVDAudioCodec
50 50
   SwrContext*         m_pConvert;
51 51
   enum AVSampleFormat m_iSampleFormat;  
52 52
   CAEChannelInfo      m_channelLayout;
53  
-  bool                m_bLpcmMode;  
54  
-  bool                m_bNeedConversion;
  53
+  bool                m_bLpcmMode;
55 54
 
56 55
   AVFrame* m_pFrame1;
57 56
   int      m_iBufferSize1;

0 notes on commit ac9c144

Please sign in to comment.
Something went wrong with that request. Please try again.