adium 3850:81c9b4c96b97: Play sounds asyncronously from a dispat...
commits at adium.im
commits at adium.im
Fri Apr 8 05:00:57 UTC 2011
details: http://hg.adium.im/adium/rev/81c9b4c96b97
revision: 3850:81c9b4c96b97
branch: (none)
author: Stephen Holt <sholt at adium.im>
date: Thu Apr 07 22:00:45 2011 -0700
Play sounds asyncronously from a dispatch queue. Removes a small but annoyingly noticebale lag when playing sound based events.
diffs (43 lines):
diff -r ccb341b77dd4 -r 81c9b4c96b97 Source/AdiumSound.m
--- a/Source/AdiumSound.m Fri Apr 08 00:42:37 2011 -0400
+++ b/Source/AdiumSound.m Thu Apr 07 22:00:45 2011 -0700
@@ -51,6 +51,8 @@
- (BOOL)processorFamilyIsG5;
@end
+static dispatch_queue_t soundPlayingQueue;
+
static OSStatus systemOutputDeviceDidChange(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress inAddresses[], void* refcon);
@implementation AdiumSound
@@ -65,6 +67,8 @@
soundCacheArray = [[NSMutableArray alloc] init];
soundCacheCleanupTimer = nil;
soundsAreMuted = NO;
+
+ soundPlayingQueue = dispatch_queue_create("im.adium.AdiumSound.soundPlayingQueue", 0);
//Observe workspace activity changes so we can mute sounds as necessary
NSNotificationCenter *workspaceCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
@@ -243,7 +247,9 @@
[sound setCurrentTime:0.0];
//This only has an effect if the movie is not already playing. It won't stop it, and it won't start it over (the latter is what setCurrentTime: is for).
- [sound play];
+ dispatch_async(soundPlayingQueue, ^{
+ [sound play];
+ });
}
#else
QTMovie *movie = [soundCacheDict objectForKey:inPath];
@@ -295,7 +301,9 @@
[movie setCurrentTime:startOfMovie];
//This only has an effect if the movie is not already playing. It won't stop it, and it won't start it over (the latter is what setCurrentTime: is for).
- [movie play];
+ dispatch_async(soundPlayingQueue, ^{
+ [movie play];
+ });
}
#endif
}
More information about the commits
mailing list