Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* moved beginBackgroundTask outside of AudioQueueStart block

* don't call AudioQueueGet* if AudioQueue hasn't started (progress)
  • Loading branch information...
commit 032f41d553e3181258d6d2813f73d44dbc1f3d92 1 parent 39e4179
authored

Showing 1 changed file with 19 additions and 21 deletions. Show diff stats Hide diff stats

  1. 40  Classes/AudioStreamer.m
40  Classes/AudioStreamer.m
@@ -1150,7 +1150,8 @@ - (double)progress
1150 1150
 			}
1151 1151
 			else if (err)
1152 1152
 			{
1153  
-				[self failWithErrorCode:AS_GET_AUDIO_TIME_FAILED];
  1153
+                if (self.shouldStartPlaying) [self failWithErrorCode:AS_GET_AUDIO_TIME_FAILED];
  1154
+                else return 0.0;
1154 1155
 			}
1155 1156
 
1156 1157
 			double progress = seekTime + queueTime.mSampleTime / sampleRate;
@@ -1719,17 +1720,16 @@ - (void)enqueueBuffer
1719 1720
 			//
1720 1721
 			if (state == AS_FLUSHING_EOF || buffersUsed == kNumAQBufs - 1)
1721 1722
 			{
  1723
+#if TARGET_OS_IPHONE                    
  1724
+                if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) {
  1725
+                    bgTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
  1726
+                }
  1727
+#endif	
1722 1728
 				if (self.state == AS_BUFFERING)
1723 1729
 				{
1724  
-                    NSLog(@"[enqueueBuffer] HERE1");
1725 1730
                     if (self.shouldStartPlaying) {
1726  
-                        NSLog(@"[enqueueBuffer] HERE3");
1727 1731
                         err = AudioQueueStart(audioQueue, NULL);
1728  
-#if TARGET_OS_IPHONE                    
1729  
-                        if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) {
1730  
-                            bgTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
1731  
-                        }
1732  
-#endif					
  1732
+				
1733 1733
                         if (err)
1734 1734
                         {
1735 1735
                             [self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
@@ -1737,7 +1737,6 @@ - (void)enqueueBuffer
1737 1737
                         }
1738 1738
                         self.state = AS_PLAYING;
1739 1739
                     } else {
1740  
-                        NSLog(@"[enqueueBuffer] HERE4");
1741 1740
                         self.state = AS_PAUSED;
1742 1741
                     }
1743 1742
 
@@ -1745,20 +1744,19 @@ - (void)enqueueBuffer
1745 1744
                 }
1746 1745
 				else
1747 1746
 				{
1748  
-                    NSLog(@"[enqueueBuffer] HERE2");
1749 1747
 					self.state = AS_WAITING_FOR_QUEUE_TO_START;
1750 1748
 
1751  
-					err = AudioQueueStart(audioQueue, NULL);
1752  
-#if TARGET_OS_IPHONE 
1753  
-					if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) {
1754  
-						bgTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
1755  
-					}
1756  
-#endif					
1757  
-					if (err)
1758  
-					{
1759  
-						[self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
1760  
-						return;
1761  
-					}
  1749
+					if (self.shouldStartPlaying) {
  1750
+                        err = AudioQueueStart(audioQueue, NULL);
  1751
+		
  1752
+                        if (err)
  1753
+                        {
  1754
+                            [self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
  1755
+                            return;
  1756
+                        }
  1757
+                    } else {
  1758
+                        self.state = AS_PAUSED;
  1759
+                    }
1762 1760
 				}
1763 1761
 			}
1764 1762
 		}

0 notes on commit 032f41d

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