[Adium-commits] adium 2027:3063c2f304a0: Rewrite sound to use NSSound. Hooray 10...
adium-commits at adiumx.com
adium-commits at adiumx.com
Wed Apr 29 04:22:27 UTC 2009
details: http://hg.adiumx.com/adium/rev/3063c2f304a0
revision: 2027:3063c2f304a0
author: David Smith <catfish.man at gmail.com>
date: Tue Apr 28 16:15:05 2009 -0700
Rewrite sound to use NSSound. Hooray 10.5 :D
Subject: adium 2028:a05663e2f17d: Automated merge with ssh://hg@hg.adiumx.com/adium
details: http://hg.adiumx.com/adium/rev/a05663e2f17d
revision: 2028:a05663e2f17d
author: David Smith <catfish.man at gmail.com>
date: Tue Apr 28 16:16:23 2009 -0700
Automated merge with ssh://hg@hg.adiumx.com/adium
Subject: adium 2029:b00ce814efa0: Don't need this anymore
details: http://hg.adiumx.com/adium/rev/b00ce814efa0
revision: 2029:b00ce814efa0
author: David Smith <catfish.man at gmail.com>
date: Tue Apr 28 20:23:09 2009 -0700
Don't need this anymore
Subject: adium 2030:e72c1ec0419a: Fast enumerate this while I'm in here
details: http://hg.adiumx.com/adium/rev/e72c1ec0419a
revision: 2030:e72c1ec0419a
author: David Smith <catfish.man at gmail.com>
date: Tue Apr 28 20:29:28 2009 -0700
Fast enumerate this while I'm in here
Subject: adium 2031:61080b398496: Automated merge with ssh://hg@hg.adiumx.com/adium
details: http://hg.adiumx.com/adium/rev/61080b398496
revision: 2031:61080b398496
author: David Smith <catfish.man at gmail.com>
date: Tue Apr 28 20:29:44 2009 -0700
Automated merge with ssh://hg@hg.adiumx.com/adium
diffstat:
Adium.xcodeproj/project.pbxproj | 10 -
ChangeLogs/Changes.txt | 2 +
Frameworks/Adium Framework/Source/AIContactHidingController.m | 2 +-
Frameworks/Adium Framework/Source/AIListGroup.m | 2 +-
Plugins/Purple Service/SLPurpleCocoaAdapter.m | 12 +-
Plugins/Purple Service/adiumPurpleConversation.m | 26 +-
Source/AIListWindowController.m | 3 +-
Source/AIURLHandlerPlugin.m | 22 +-
Source/AdiumSound.m | 115 ++++--------
9 files changed, 81 insertions(+), 113 deletions(-)
diffs (455 lines):
diff -r 460e4914297f -r 61080b398496 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj Tue Apr 28 02:54:34 2009 -0700
+++ b/Adium.xcodeproj/project.pbxproj Tue Apr 28 20:29:44 2009 -0700
@@ -195,10 +195,8 @@
31455C9A0CC353F800D231A0 /* TestDataAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 31455C990CC353F800D231A0 /* TestDataAdditions.m */; };
317D83680E89F40500298BDB /* bookmark_chat.png in Resources */ = {isa = PBXBuildFile; fileRef = 317D83670E89F40500298BDB /* bookmark_chat.png */; };
318EA69C0D7A659900EDB105 /* TestColorAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 318EA69B0D7A659900EDB105 /* TestColorAdditions.m */; };
- 31918ED80C5E486C00717F0A /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31918ED70C5E486C00717F0A /* QTKit.framework */; };
319B29800CE8EC6F00C65398 /* TestDateAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 319B297F0CE8EC6E00C65398 /* TestDateAdditions.m */; };
31A764B90DA572B8000AC729 /* AutoHyperlinks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3496A8EA07CE6CA30055BBAB /* AutoHyperlinks.framework */; };
- 31E0CD580C5EEEFA00271DB1 /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34D836F307CBF960006466F2 /* QuickTime.framework */; };
31E0CD810C5EEF5200271DB1 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31E0CD800C5EEF5200271DB1 /* CoreAudio.framework */; };
31FA804C0D4A8EB200ABE634 /* Adium.sdef in Resources */ = {isa = PBXBuildFile; fileRef = 0CAC6A130C0C657A0090AE95 /* Adium.sdef */; };
3402D5A5080DBC91004E50B4 /* SortConfiguration.nib in Resources */ = {isa = PBXBuildFile; fileRef = 347E791D07CAA52300350507 /* SortConfiguration.nib */; };
@@ -697,7 +695,6 @@
34D8337507CBD808006466F2 /* pref-events.png in Resources */ = {isa = PBXBuildFile; fileRef = 34D8336C07CBD807006466F2 /* pref-events.png */; };
34D8337707CBD808006466F2 /* pref-advanced.png in Resources */ = {isa = PBXBuildFile; fileRef = 34D8336E07CBD807006466F2 /* pref-advanced.png */; };
34D836E507CBF593006466F2 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F531836F019E40BB01A80165 /* Carbon.framework */; };
- 34D836F407CBF960006466F2 /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34D836F307CBF960006466F2 /* QuickTime.framework */; };
34DC12FC0A81415D00D710F3 /* ESApplescriptabilityController.m in Sources */ = {isa = PBXBuildFile; fileRef = 344C0D4E06B6D63800DA7200 /* ESApplescriptabilityController.m */; };
34DC13040A81417600D710F3 /* AILoginWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F57938C2033E73AC01A8010A /* AILoginWindowController.m */; };
34DC13050A81417700D710F3 /* LoginSelect.nib in Resources */ = {isa = PBXBuildFile; fileRef = 34575E3407CBA7DF004A4FFF /* LoginSelect.nib */; };
@@ -1935,7 +1932,6 @@
317D83670E89F40500298BDB /* bookmark_chat.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = bookmark_chat.png; path = Resources/bookmark_chat.png; sourceTree = "<group>"; };
318EA69A0D7A659900EDB105 /* TestColorAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestColorAdditions.h; path = UnitTests/TestColorAdditions.h; sourceTree = "<group>"; };
318EA69B0D7A659900EDB105 /* TestColorAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TestColorAdditions.m; path = UnitTests/TestColorAdditions.m; sourceTree = "<group>"; };
- 31918ED70C5E486C00717F0A /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; };
319B29420CE8D28300C65398 /* TestDateAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestDateAdditions.h; path = UnitTests/TestDateAdditions.h; sourceTree = "<group>"; };
319B297F0CE8EC6E00C65398 /* TestDateAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TestDateAdditions.m; path = UnitTests/TestDateAdditions.m; sourceTree = "<group>"; };
31E0CD800C5EEF5200271DB1 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = /System/Library/Frameworks/CoreAudio.framework; sourceTree = "<absolute>"; };
@@ -3623,7 +3619,6 @@
34D8344D07CBE6E2006466F2 /* JVFontPreviewField.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = JVFontPreviewField.h; path = "Frameworks/Adium Framework/Source/JVFontPreviewField.h"; sourceTree = "<group>"; };
34D8346B07CBE6F4006466F2 /* SUSpeaker.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SUSpeaker.m; path = "Frameworks/Adium Framework/Source/SUSpeaker.m"; sourceTree = "<group>"; };
34D8346C07CBE6F4006466F2 /* SUSpeaker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SUSpeaker.h; path = "Frameworks/Adium Framework/Source/SUSpeaker.h"; sourceTree = "<group>"; };
- 34D836F307CBF960006466F2 /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = "<absolute>"; };
34D8B3D60D15A40C0066F013 /* fr_CA */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = fr_CA; path = Resources/fr_CA.lproj/Statuses.strings; sourceTree = "<group>"; };
34DC84280A7EA012003E1636 /* nl */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = nl; path = Resources/nl.lproj/ESFileTransferProgressView.nib; sourceTree = "<group>"; };
34DFF46007A5EABF00B92233 /* ESSecureMessagingPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ESSecureMessagingPlugin.h; path = "Plugins/Secure Messaging/ESSecureMessagingPlugin.h"; sourceTree = "<group>"; };
@@ -4719,8 +4714,6 @@
8163F99C0B318824002005EE /* Sparkle.framework in Frameworks */,
11AA1EFA0BCAE9C3003DDA66 /* Quartz.framework in Frameworks */,
340C1ABF0BD58FAB00D09235 /* Security.framework in Frameworks */,
- 31918ED80C5E486C00717F0A /* QTKit.framework in Frameworks */,
- 31E0CD580C5EEEFA00271DB1 /* QuickTime.framework in Frameworks */,
31E0CD810C5EEF5200271DB1 /* CoreAudio.framework in Frameworks */,
11879DF80F6FFC0B00CACFB1 /* OAuthConsumer.framework in Frameworks */,
);
@@ -4734,7 +4727,6 @@
636D92840E4E968A00E5F558 /* AddressBook.framework in Frameworks */,
34D836E507CBF593006466F2 /* Carbon.framework in Frameworks */,
3448761406D1EC0C00DA778C /* Cocoa.framework in Frameworks */,
- 34D836F407CBF960006466F2 /* QuickTime.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4967,7 +4959,6 @@
11879DF70F6FFC0B00CACFB1 /* OAuthConsumer.framework */,
312ED3D40C7E878300A6BDA9 /* SenTestingKit.framework */,
31E0CD800C5EEF5200271DB1 /* CoreAudio.framework */,
- 31918ED70C5E486C00717F0A /* QTKit.framework */,
11AA1EF90BCAE9C3003DDA66 /* Quartz.framework */,
377EC8930AE9525B00CB7BDF /* PSMTabBarControl.framework */,
9E1E1DFC0A96741500E16DFC /* LMX.framework */,
@@ -4985,7 +4976,6 @@
340C1ABE0BD58FAB00D09235 /* Security.framework */,
811035170CDE783800EC6038 /* SecurityInterface.framework */,
34B588A0058D833A00E7EF0D /* ExceptionHandling.framework */,
- 34D836F307CBF960006466F2 /* QuickTime.framework */,
34E839050583207E00F2AADB /* SystemConfiguration.framework */,
9C103FAE057127A500F3C158 /* WebKit.framework */,
);
diff -r 460e4914297f -r 61080b398496 ChangeLogs/Changes.txt
--- a/ChangeLogs/Changes.txt Tue Apr 28 02:54:34 2009 -0700
+++ b/ChangeLogs/Changes.txt Tue Apr 28 20:29:44 2009 -0700
@@ -74,6 +74,7 @@
* Fixed a bug where the view menu would show incorrect settings.
* Status message is no longer searched when searching the contact list.
* Fixed a lot of drag and drop bugs, such as being able to drag a group into another group.
+ * Tooltips now display for collapsed groups. (#11951)
Message Styles
* You can now specify a different style for group chats, and customize all of the preferences independently of a regular chat. (#87)
@@ -117,6 +118,7 @@
* Group chats which are not anonymous now display the actual contact in the user list. (#11841)
* Fixed receiving colors and fonts from iChat. (#1323)
* Enabled support for custom emoticons as an account option defaulting to on.
+ * Fixed joining a group chat from an xmpp URL. (#11785)
MSN
* Possibly fixed a crash on connect. (#11508)
diff -r 460e4914297f -r 61080b398496 Frameworks/Adium Framework/Source/AIContactHidingController.m
--- a/Frameworks/Adium Framework/Source/AIContactHidingController.m Tue Apr 28 02:54:34 2009 -0700
+++ b/Frameworks/Adium Framework/Source/AIContactHidingController.m Tue Apr 28 20:29:44 2009 -0700
@@ -168,7 +168,7 @@
return NO;
}
- if (!showIdleContacts && [listObject valueForProperty:@"IdleSince"])
+ if (!showIdleContacts && [listObject boolValueForProperty:@"IsIdle"])
return NO;
if (!showMobileContacts && listObject.isMobile)
diff -r 460e4914297f -r 61080b398496 Frameworks/Adium Framework/Source/AIListGroup.m
--- a/Frameworks/Adium Framework/Source/AIListGroup.m Tue Apr 28 02:54:34 2009 -0700
+++ b/Frameworks/Adium Framework/Source/AIListGroup.m Tue Apr 28 20:29:44 2009 -0700
@@ -115,7 +115,7 @@
NSSet *modifiedProperties = nil;
if (inModifiedKeys == nil ||
[inModifiedKeys containsObject:@"Online"] ||
- [inModifiedKeys containsObject:@"IdleSince"] ||
+ [inModifiedKeys containsObject:@"IsIdle"] ||
[inModifiedKeys containsObject:@"Signed Off"] ||
[inModifiedKeys containsObject:@"Signed On"] ||
[inModifiedKeys containsObject:@"New Object"] ||
diff -r 460e4914297f -r 61080b398496 Plugins/Purple Service/SLPurpleCocoaAdapter.m
--- a/Plugins/Purple Service/SLPurpleCocoaAdapter.m Tue Apr 28 02:54:34 2009 -0700
+++ b/Plugins/Purple Service/SLPurpleCocoaAdapter.m Tue Apr 28 20:29:44 2009 -0700
@@ -1162,7 +1162,11 @@
- (BOOL)contact:(AIListContact *)inContact isIgnoredInChat:(AIChat *)inChat
{
- PurpleConversation *conv = convLookupFromChat(inChat, inChat.account);
+ PurpleConversation *conv = existingConvLookupFromChat(inChat);
+
+ if (!conv)
+ return NO;
+
PurpleConvChat *convChat = purple_conversation_get_chat_data(conv);
return (purple_conv_chat_is_user_ignored(convChat, [inContact.UID UTF8String]) ? YES : NO);
@@ -1170,7 +1174,11 @@
- (void)setContact:(AIListContact *)inContact ignored:(BOOL)inIgnored inChat:(AIChat *)inChat
{
- PurpleConversation *conv = convLookupFromChat(inChat, inChat.account);
+ PurpleConversation *conv = existingConvLookupFromChat(inChat);
+
+ if (!conv)
+ return;
+
PurpleConvChat *convChat = purple_conversation_get_chat_data(conv);
if ([self contact:inContact isIgnoredInChat:inChat]) {
diff -r 460e4914297f -r 61080b398496 Plugins/Purple Service/adiumPurpleConversation.m
--- a/Plugins/Purple Service/adiumPurpleConversation.m Tue Apr 28 02:54:34 2009 -0700
+++ b/Plugins/Purple Service/adiumPurpleConversation.m Tue Apr 28 20:29:44 2009 -0700
@@ -276,23 +276,27 @@
PurplePluginProtocolInfo *prpl_info = (prpl ? PURPLE_PLUGIN_PROTOCOL_INFO(prpl) : NULL);
PurpleConvChat *convChat = purple_conversation_get_chat_data(conv);
+ char *uid = NULL;
+
NSString *normalizedUID;
if (prpl_info && prpl_info->get_cb_real_name) {
// Get the real name of the buddy for use as a UID, if available.
- char *uid = prpl_info->get_cb_real_name(purple_account_get_connection(account),
- purple_conv_chat_get_id(convChat),
- who);
-
- normalizedUID = [NSString stringWithUTF8String:purple_normalize(account, uid)];
-
- // We have to free the result of get_cb_real_name.
- g_free(uid);
- } else {
- // Otherwise use the normalized name for the UID.
- normalizedUID = [NSString stringWithUTF8String:purple_normalize(account, who)];
+ uid = prpl_info->get_cb_real_name(purple_account_get_connection(account),
+ purple_conv_chat_get_id(convChat),
+ who);
}
+ if (!uid) {
+ // strdup it, mostly so the free below won't have to be cased out.
+ uid = g_strdup(who);
+ }
+
+ normalizedUID = [NSString stringWithUTF8String:purple_normalize(account, uid)];
+
+ // We have to free the result of get_cb_real_name.
+ g_free(uid);
+
return normalizedUID;
}
diff -r 460e4914297f -r 61080b398496 Source/AIListWindowController.m
--- a/Source/AIListWindowController.m Tue Apr 28 02:54:34 2009 -0700
+++ b/Source/AIListWindowController.m Tue Apr 28 20:29:44 2009 -0700
@@ -1545,8 +1545,7 @@
}
// Filter bar resizing
- // Create a new variable here, because we want the bar's view to be based, visually, on the location of the contact list, not its enclosing super view.
- NSRect barTargetFrame = contactListView.frame;
+ NSRect barTargetFrame = contactListView.enclosingScrollView.frame;
if (filterBarIsVisible) {
barTargetFrame.size.height = NSHeight(barTargetFrame) + NSHeight(filterBarView.bounds);
} else {
diff -r 460e4914297f -r 61080b398496 Source/AIURLHandlerPlugin.m
--- a/Source/AIURLHandlerPlugin.m Tue Apr 28 02:54:34 2009 -0700
+++ b/Source/AIURLHandlerPlugin.m Tue Apr 28 20:29:44 2009 -0700
@@ -390,10 +390,8 @@
// xmpp:johndoe at jabber.org?remove
// xmpp:johndoe at jabber.org?unsubscribe
- } else if (([query caseInsensitiveCompare:@"join"] == NSOrderedSame) &&
- ([scheme caseInsensitiveCompare:@"xmpp"] == NSOrderedSame)) {
+ } else if ([query rangeOfString:@"join"].location == 0) {
NSString *password = [[url queryArgumentForKey:@"password"] stringByDecodingURLEscapes];
- //TODO: password support: xmpp:darkcave at macbeth.shakespeare.lit?join;password=cauldronburn
[self _openXMPPGroupChat:[url user]
onServer:[url host]
@@ -529,15 +527,15 @@
}
if (name && account) {
- [adium.chatController chatWithName:name
- identifier:nil
- onAccount:account
- chatCreationInfo:[NSDictionary dictionaryWithObjectsAndKeys:
- name, @"room",
- server, @"server",
- account.formattedUID, @"handle",
- password, @"password", /* may be nil, so should be last */
- nil]];
+ [adium.chatController chatWithName:[NSString stringWithFormat:@"%@@%@", name, server]
+ identifier:nil
+ onAccount:account
+ chatCreationInfo:[NSDictionary dictionaryWithObjectsAndKeys:
+ name, @"room",
+ server, @"server",
+ account.displayName, @"handle",
+ password, @"password", /* may be nil, so should be last */
+ nil]];
} else {
NSBeep();
}
diff -r 460e4914297f -r 61080b398496 Source/AdiumSound.m
--- a/Source/AdiumSound.m Tue Apr 28 02:54:34 2009 -0700
+++ b/Source/AdiumSound.m Tue Apr 28 20:29:44 2009 -0700
@@ -18,7 +18,7 @@
#import "AISoundController.h"
#import <AIUtilities/AIDictionaryAdditions.h>
#import <AIUtilities/AISleepNotification.h>
-#import <QTKit/QTKit.h>
+#import <CoreAudio/AudioHardware.h>
#import <CoreServices/CoreServices.h>
#import <sys/sysctl.h>
@@ -30,8 +30,8 @@
- (void)_setVolumeOfAllSoundsTo:(CGFloat)inVolume;
- (void)cachedPlaySound:(NSString *)inPath;
- (void)_uncacheLeastRecentlyUsedSound;
-- (QTAudioContextRef)createAudioContextWithSystemOutputDevice;
-- (void)configureAudioContextForMovie:(QTMovie *)movie;
+- (NSString *)systemAudioDeviceID;
+- (void)configureAudioContextForSound:(NSSound *)sound;
- (NSArray *)allSounds;
@end
@@ -124,9 +124,9 @@
- (void)stopPlayingSoundAtPath:(NSString *)inPath
{
- QTMovie *movie = [soundCacheDict objectForKey:inPath];
- if (movie) {
- [movie stop];
+ NSSound *sound = [soundCacheDict objectForKey:inPath];
+ if (sound) {
+ [sound stop];
}
}
@@ -162,25 +162,22 @@
*/
- (void)_setVolumeOfAllSoundsTo:(CGFloat)inVolume
{
- NSEnumerator *enumerator = [soundCacheDict objectEnumerator];
- QTMovie *movie;
-
- while((movie = [enumerator nextObject])){
- [movie setVolume:inVolume];
+ for (NSSound *sound in [soundCacheDict objectEnumerator]) {
+ [sound setVolume:inVolume];
}
}
/*!
- * @brief Play a QTMovie, possibly cached
+ * @brief Play an NSSound, possibly cached
*
* @param inPath path to the sound file
*/
- (void)cachedPlaySound:(NSString *)inPath
{
- QTMovie *movie = [soundCacheDict objectForKey:inPath];
+ NSSound *sound = [soundCacheDict objectForKey:inPath];
//Load the sound if necessary
- if (!movie) {
+ if (!sound) {
//If the cache is full, remove the least recently used cached sound
if ([soundCacheDict count] >= MAX_CACHED_SOUNDS) {
[self _uncacheLeastRecentlyUsedSound];
@@ -188,46 +185,39 @@
//Load and cache the sound
NSError *error = nil;
- movie = [[QTMovie alloc] initWithFile:inPath
- error:&error];
- if (movie) {
+ sound = [[NSSound alloc] initWithContentsOfFile:inPath byReference:NO];
+ if (sound) {
//Insert the player at the front of our cache
[soundCacheArray insertObject:inPath atIndex:0];
- [soundCacheDict setObject:movie forKey:inPath];
- [movie release];
+ [soundCacheDict setObject:sound forKey:inPath];
+ [sound release];
//Set the volume (otherwise #2283 happens)
- [movie setVolume:customVolume];
+ [sound setVolume:customVolume];
- [self configureAudioContextForMovie:movie];
+ [self configureAudioContextForSound:sound];
} else {
AILogWithSignature(@"Error loading %@: %@", inPath, error);
}
- } else {
+ } else {
//Move this sound to the front of the cache (This will naturally move lesser used sounds to the back for removal)
[soundCacheArray removeObject:inPath];
[soundCacheArray insertObject:inPath atIndex:0];
if (reconfigureAudioContextBeforeEachPlay) {
- [movie stop];
- [self configureAudioContextForMovie:movie];
+ [sound stop];
+ [self configureAudioContextForSound:sound];
}
- }
+ }
- //Engage!
- if (movie) {
- //Ensure the sound is starting from the beginning; necessary for cached sounds that have already been played
- QTTime startOfMovie = {
- .timeValue = 0LL,
- .timeScale = [[movie attributeForKey:QTMovieTimeScaleAttribute] longValue],
- .flags = 0,
- };
- [movie setCurrentTime:startOfMovie];
+ //Engage!
+ if (sound) {
+ [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).
- [movie play];
- }
+ //This only has an effect if the sound 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];
+ }
}
/*!
@@ -236,18 +226,17 @@
- (void)_uncacheLeastRecentlyUsedSound
{
NSString *lastCachedPath = [soundCacheArray lastObject];
- QTMovie *movie = [soundCacheDict objectForKey:lastCachedPath];
+ NSSound *sound = [soundCacheDict objectForKey:lastCachedPath];
- //If a movie is stopped, then its rate is zero. Thus, this tests whether the movie is playing. We remove it from the cache only if it is not playing.
- if ([movie rate] == 0.0) {
+ //Remove it from the cache only if it is not playing.
+ if (![sound isPlaying]) {
[soundCacheDict removeObjectForKey:lastCachedPath];
[soundCacheArray removeLastObject];
}
}
-- (QTAudioContextRef)createAudioContextWithSystemOutputDevice
+- (NSString *)systemAudioDeviceID
{
- QTAudioContextRef newAudioContext = NULL;
OSStatus err;
UInt32 dataSize;
@@ -268,41 +257,22 @@
NSLog(@"%s: Could not get the device UID for device %p: AudioDeviceGetProperty returned error %i", __PRETTY_FUNCTION__, systemOutputDevice, err);
return NULL;
}
- [(NSObject *)deviceUID autorelease];
-
- //Create an audio context for this device so that our movies can play into it.
- err = QTAudioContextCreateForAudioDevice(kCFAllocatorDefault, deviceUID, /*options*/ NULL, &newAudioContext);
- if (err != noErr) {
- NSLog(@"%s: QTAudioContextCreateForAudioDevice with device UID %@ returned error %i", __PRETTY_FUNCTION__, deviceUID, err);
- return NULL;
- }
-
- return newAudioContext;
+ [(NSString *)deviceUID autorelease];
+
+ return (NSString *)deviceUID;
}
-- (void)configureAudioContextForMovie:(QTMovie *)movie
+- (void)configureAudioContextForSound:(NSSound *)sound
{
- //QTMovie gets confused if we're playing when we do this, so pause momentarily.
- CGFloat savedRate = [movie rate];
- [movie setRate:0.0];
+ [sound pause];
//Exchange the audio context for a new one with the new device.
- QTAudioContextRef newAudioContext = [self createAudioContextWithSystemOutputDevice];
+ NSString *deviceUID = [self systemAudioDeviceID];
- if (newAudioContext) {
- OSStatus err = SetMovieAudioContext([movie quickTimeMovie], newAudioContext);
- if (err != noErr) {
- NSLog(@"%s: Could not set audio context of movie %@ to %p: SetMovieAudioContext returned error %i. Sounds may be routed to the default audio device instead of the system alert audio device.", __PRETTY_FUNCTION__, movie, newAudioContext, err);
- }
-
- //We created it, so we must release it.
- QTAudioContextRelease(newAudioContext);
- } else {
- NSLog(@"%s: Could not set audio context because -[AdiumSound createAudioContextWithSystemOutputDevice] returned NULL", __PRETTY_FUNCTION__);
- }
+ [sound setPlaybackDeviceIdentifier:deviceUID];
//Resume playback, now on the new device.
- [movie setRate:savedRate];
+ [sound resume];
}
- (NSArray *)allSounds
@@ -345,11 +315,8 @@
- (void)systemOutputDeviceDidChange
{
- NSEnumerator *soundsEnum = [[self allSounds] objectEnumerator];
- QTMovie *movie;
-
- while ((movie = [soundsEnum nextObject])) {
- [self configureAudioContextForMovie:movie];
+ for (NSSound *sound in [self allSounds]) {
+ [self configureAudioContextForSound:sound];
}
}
More information about the commits
mailing list