@@ -55,7 +55,11 @@ - (void)handleBufferCompleteForQueue:(AudioQueueRef)inAQ
55
55
buffer : (AudioQueueBufferRef)inBuffer ;
56
56
- (void )handlePropertyChangeForQueue : (AudioQueueRef)inAQ
57
57
propertyID : (AudioQueuePropertyID)inID ;
58
+
59
+ #ifdef TARGET_OS_IPHONE
58
60
- (void )handleInterruptionChangeToState : (AudioQueuePropertyID)inInterruptionState ;
61
+ #endif
62
+
59
63
- (void )enqueueBuffer ;
60
64
- (void )handleReadFromStream : (CFReadStreamRef )aStream
61
65
eventType : (CFStreamEventType )eventType ;
@@ -327,6 +331,12 @@ + (NSString *)stringForErrorCode:(AudioStreamerErrorCode)anErrorCode
327
331
return AS_GET_AUDIO_TIME_FAILED_STRING;
328
332
case AS_NETWORK_CONNECTION_FAILED:
329
333
return AS_NETWORK_CONNECTION_FAILED_STRING;
334
+ case AS_AUDIO_QUEUE_STOP_FAILED:
335
+ return AS_AUDIO_QUEUE_STOP_FAILED_STRING;
336
+ case AS_AUDIO_STREAMER_FAILED:
337
+ return AS_AUDIO_STREAMER_FAILED_STRING;
338
+ default :
339
+ return AS_AUDIO_STREAMER_FAILED_STRING;
330
340
}
331
341
332
342
return AS_AUDIO_STREAMER_FAILED_STRING;
@@ -584,6 +594,7 @@ - (BOOL)openFileStream
584
594
kCFStreamPropertyHTTPShouldAutoredirect ,
585
595
kCFBooleanTrue ) == false )
586
596
{
597
+ #ifdef TARGET_OS_IPHONE
587
598
UIAlertView *alert =
588
599
[[UIAlertView alloc ]
589
600
initWithTitle: NSLocalizedStringFromTable(@" File Error" , @" Errors" , nil )
@@ -597,6 +608,20 @@ - (BOOL)openFileStream
597
608
withObject: nil
598
609
waitUntilDone: YES ];
599
610
[alert release ];
611
+ #else
612
+ NSAlert *alert =
613
+ [NSAlert
614
+ alertWithMessageText: NSLocalizedStringFromTable(@" File Error" , @" Errors" , nil )
615
+ defaultButton: NSLocalizedString(@" OK" , @" " )
616
+ alternateButton: nil
617
+ otherButton: nil
618
+ informativeTextWithFormat: NSLocalizedStringFromTable(@" Unable to configure network read stream." , @" Errors" , nil )];
619
+ [alert
620
+ performSelector: @selector (runModal )
621
+ onThread: [NSThread mainThread ]
622
+ withObject: nil
623
+ waitUntilDone: NO ];
624
+ #endif
600
625
return NO ;
601
626
}
602
627
@@ -624,6 +649,7 @@ - (BOOL)openFileStream
624
649
if (!CFReadStreamOpen (stream))
625
650
{
626
651
CFRelease (stream);
652
+ #ifdef TARGET_OS_IPHONE
627
653
UIAlertView *alert =
628
654
[[UIAlertView alloc ]
629
655
initWithTitle: NSLocalizedStringFromTable(@" File Error" , @" Errors" , nil )
@@ -637,6 +663,20 @@ - (BOOL)openFileStream
637
663
withObject: nil
638
664
waitUntilDone: YES ];
639
665
[alert release ];
666
+ #else
667
+ NSAlert *alert =
668
+ [NSAlert
669
+ alertWithMessageText: NSLocalizedStringFromTable(@" File Error" , @" Errors" , nil )
670
+ defaultButton: NSLocalizedString(@" OK" , @" " )
671
+ alternateButton: nil
672
+ otherButton: nil
673
+ informativeTextWithFormat: NSLocalizedStringFromTable(@" Unable to configure network read stream." , @" Errors" , nil )];
674
+ [alert
675
+ performSelector: @selector (runModal )
676
+ onThread: [NSThread mainThread ]
677
+ withObject: nil
678
+ waitUntilDone: NO ];
679
+ #endif
640
680
return NO ;
641
681
}
642
682
@@ -821,6 +861,8 @@ - (void)start
821
861
}
822
862
else if (state == AS_INITIALIZED)
823
863
{
864
+ NSAssert ([[NSThread currentThread ] isEqual: [NSThread mainThread ]],
865
+ @" Playback can only be started from the main thread." );
824
866
notificationCenter =
825
867
[[NSNotificationCenter defaultCenter ] retain ];
826
868
self.state = AS_STARTING_FILE_THREAD;
@@ -1547,6 +1589,7 @@ - (void)handlePropertyChangeForQueue:(AudioQueueRef)inAQ
1547
1589
[pool release ];
1548
1590
}
1549
1591
1592
+ #ifdef TARGET_OS_IPHONE
1550
1593
//
1551
1594
// handleInterruptionChangeForQueue:propertyID:
1552
1595
//
@@ -1567,6 +1610,7 @@ - (void)handleInterruptionChangeToState:(AudioQueuePropertyID)inInterruptionStat
1567
1610
[self pause ];
1568
1611
}
1569
1612
}
1613
+ #endif
1570
1614
1571
1615
@end
1572
1616
0 commit comments