Skip to content
This repository
Browse code

Merge pull request #3316 from FernetMenta/paplayer

Paplayer fixes (hail to the king baby)
  • Loading branch information...
commit c23ec5920877b716277b366b16020fd80dfaee08 2 parents e858506 + 51a1224
Peter Frühberger authored September 22, 2013
16  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
@@ -1041,10 +1041,20 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
1041 1041
 CActiveAEStream* CActiveAE::CreateStream(MsgStreamNew *streamMsg)
1042 1042
 {
1043 1043
   // we only can handle a single pass through stream
1044  
-  if (!m_streams.empty())
  1044
+  bool hasRawStream = false;
  1045
+  bool hasStream = false;
  1046
+  std::list<CActiveAEStream*>::iterator it;
  1047
+  for(it = m_streams.begin(); it != m_streams.end(); ++it)
1045 1048
   {
1046  
-    if (AE_IS_RAW(m_streams.front()->m_format.m_dataFormat) || AE_IS_RAW(streamMsg->format.m_dataFormat))
1047  
-      return NULL;
  1049
+    if((*it)->IsDrained())
  1050
+      continue;
  1051
+    if(AE_IS_RAW((*it)->m_format.m_dataFormat))
  1052
+      hasRawStream = true;
  1053
+    hasStream = true;
  1054
+  }
  1055
+  if (hasRawStream || (hasStream && AE_IS_RAW(streamMsg->format.m_dataFormat)))
  1056
+  {
  1057
+    return NULL;
1048 1058
   }
1049 1059
 
1050 1060
   // create the stream
30  xbmc/cores/paplayer/PAPlayer.cpp
@@ -317,7 +317,9 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */, b
317 317
 
318 318
   // check if we advance a track of a CUE sheet
319 319
   // if this is the case we don't need to open a new stream
320  
-  if (file.GetMusicInfoTag()->GetURL().Equals(m_FileItem->GetMusicInfoTag()->GetURL()) &&
  320
+  std::string newURL = file.GetMusicInfoTag() ? file.GetMusicInfoTag()->GetURL() : file.GetPath();
  321
+  std::string oldURL = m_FileItem->GetMusicInfoTag() ? m_FileItem->GetMusicInfoTag()->GetURL() : m_FileItem->GetPath();
  322
+  if (newURL.compare(oldURL) == 0 &&
321 323
       file.m_lStartOffset &&
322 324
       file.m_lStartOffset == m_FileItem->m_lEndOffset &&
323 325
       m_currentStream && m_currentStream->m_prepareTriggered)
@@ -368,8 +370,6 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */, b
368 370
     CThread::Sleep(1);
369 371
   }
370 372
 
371  
-  UpdateCrossfadeTime(file);
372  
-
373 373
   /* init the streaminfo struct */
374 374
   si->m_decoder.GetDataFormat(&si->m_channelInfo, &si->m_sampleRate, &si->m_encodedSampleRate, &si->m_dataFormat);
375 375
   si->m_startOffset        = file.m_lStartOffset * 1000 / 75;
@@ -398,10 +398,22 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */, b
398 398
       si->m_prepareNextAtFrame = (int)((streamTotalTime - TIME_TO_CACHE_NEXT_FILE - m_defaultCrossfadeMS) * si->m_sampleRate / 1000.0f);
399 399
   }
400 400
 
401  
-  si->m_prepareTriggered = false;
  401
+  if (m_currentStream && (AE_IS_RAW(m_currentStream->m_dataFormat) || AE_IS_RAW(si->m_dataFormat)))
  402
+  {
  403
+    m_currentStream->m_prepareTriggered = false;
  404
+    m_currentStream->m_waitOnDrain = true;
  405
+    m_currentStream->m_prepareNextAtFrame = 0;
  406
+    si->m_decoder.Destroy();
  407
+    delete si;
  408
+    return false;
  409
+  }
  410
+
  411
+  UpdateCrossfadeTime(file);
402 412
 
  413
+  si->m_prepareTriggered = false;
403 414
   si->m_playNextAtFrame = 0;
404 415
   si->m_playNextTriggered = false;
  416
+  si->m_waitOnDrain = false;
405 417
 
406 418
   if (!PrepareStream(si))
407 419
   {
@@ -606,6 +618,11 @@ inline void PAPlayer::ProcessStreams(double &delay, double &buffer)
606 618
     {
607 619
       if (!si->m_prepareTriggered)
608 620
       {
  621
+        if (si->m_waitOnDrain)
  622
+        {
  623
+          si->m_stream->Drain(true);
  624
+          si->m_waitOnDrain = false;
  625
+        }
609 626
         si->m_prepareTriggered = true;
610 627
         m_callback.OnQueueNextItem();
611 628
       }
@@ -621,6 +638,11 @@ inline void PAPlayer::ProcessStreams(double &delay, double &buffer)
621 638
           /* if it didnt trigger the next queue item */
622 639
           if (!si->m_prepareTriggered)
623 640
           {
  641
+            if (si->m_waitOnDrain)
  642
+            {
  643
+              si->m_stream->Drain(true);
  644
+              si->m_waitOnDrain = false;
  645
+            }
624 646
             m_callback.OnQueueNextItem();
625 647
             si->m_prepareTriggered = true;
626 648
           }
1  xbmc/cores/paplayer/PAPlayer.h
@@ -120,6 +120,7 @@ friend class CQueueNextFileJob;
120 120
     float             m_volume;              /* the initial volume level to set the stream to on creation */
121 121
 
122 122
     bool              m_isSlaved;            /* true if the stream has been slaved to another */
  123
+    bool              m_waitOnDrain;         /* wait for stream being drained in AE */
123 124
   } StreamInfo;
124 125
 
125 126
   typedef std::list<StreamInfo*> StreamList;

0 notes on commit c23ec59

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