* Tools/speech/GSSpeechSynthesizer.m: Use object_getClass()

instead of isa. Make exitIfUnneeded: a class method. Reformat
code.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36460 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2013-04-03 18:43:40 +00:00
parent c9301f8873
commit 5d5a94d6ac
2 changed files with 85 additions and 66 deletions

View file

@ -1,3 +1,8 @@
2013-04-03 Fred Kiefer <FredKiefer@gmx.de>
* Tools/speech/GSSpeechSynthesizer.m: Use object_getClass()
instead of isa. Make exitIfUnneeded: a class method. Reformat code.
2013-04-03 Fred Kiefer <FredKiefer@gmx.de> 2013-04-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSBitmapImageRep+GIF.m (-_bitmapIsGIF:): Prepare for * Source/NSBitmapImageRep+GIF.m (-_bitmapIsGIF:): Prepare for

View file

@ -16,8 +16,8 @@ static int clients;
selector: @selector(connectionDied:) selector: @selector(connectionDied:)
name: NSConnectionDidDieNotification name: NSConnectionDidDieNotification
object: nil]; object: nil];
} }
/** /**
* If the remote end exits before freeing the GSSpeechSynthesizer then we need * If the remote end exits before freeing the GSSpeechSynthesizer then we need
* to send it a -release message to make sure it dies. * to send it a -release message to make sure it dies.
@ -33,36 +33,45 @@ static int clients;
} }
} }
} }
/** /**
* If no clients have been active for some time, kill the speech server to * If no clients have been active for some time, kill the speech server to
* conserve resources. * conserve resources.
*/ */
- (void)exitIfUnneeded: (NSTimer*)sender + (void)exitIfUnneeded: (NSTimer*)sender
{ {
if (clients == 0) if (clients == 0)
{ {
exit(0); exit(0);
} }
} }
- (id)initWithVoice: (NSString*)aVoice - (id)initWithVoice: (NSString*)aVoice
{ {
clients++; clients++;
if (nil == (self = [super init])) { return nil; } if (nil == (self = [super init]))
{
return nil;
}
[self setVoice: currentVoice]; [self setVoice: currentVoice];
return self; return self;
} }
- (id)init - (id)init
{ {
return [self initWithVoice: nil]; return [self initWithVoice: nil];
} }
- (NSString*)voice - (NSString*)voice
{ {
return currentVoice; return currentVoice;
} }
- (id)delegate - (id)delegate
{ {
return delegate; return delegate;
} }
- (void)setDelegate: (id)aDelegate - (void)setDelegate: (id)aDelegate
{ {
// Either -retain or -release can throw an exception due to DO. // Either -retain or -release can throw an exception due to DO.
@ -76,6 +85,7 @@ static int clients;
NS_ENDHANDLER NS_ENDHANDLER
delegate = aDelegate; delegate = aDelegate;
} }
- (void)setVoice: (NSString*)aVoice - (void)setVoice: (NSString*)aVoice
{ {
if (nil == aVoice) if (nil == aVoice)
@ -84,11 +94,13 @@ static int clients;
} }
ASSIGN(currentVoice, aVoice); ASSIGN(currentVoice, aVoice);
} }
- (BOOL)startSpeakingString: (NSString*)aString - (BOOL)startSpeakingString: (NSString*)aString
{ {
[server setVoice: currentVoice]; [server setVoice: currentVoice];
return [server startSpeakingString: aString notifyWhenDone: self]; return [server startSpeakingString: aString notifyWhenDone: self];
} }
- (void)didFinishSpeaking: (BOOL)didFinish - (void)didFinishSpeaking: (BOOL)didFinish
{ {
// Throw the delegate away if it is throwing exceptions during // Throw the delegate away if it is throwing exceptions during
@ -104,10 +116,12 @@ static int clients;
NS_ENDHANDLER NS_ENDHANDLER
NS_ENDHANDLER NS_ENDHANDLER
} }
- (void)stopSpeaking - (void)stopSpeaking
{ {
[server stopSpeaking]; [server stopSpeaking];
} }
- (void)dealloc - (void)dealloc
{ {
clients--; clients--;
@ -115,7 +129,7 @@ static int clients;
if (clients == 0) if (clients == 0)
{ {
[NSTimer scheduledTimerWithTimeInterval: 600 [NSTimer scheduledTimerWithTimeInterval: 600
target: isa target: object_getClass()
selector: @selector(exitIfUnneeded:) selector: @selector(exitIfUnneeded:)
userInfo: nil userInfo: nil
repeats: NO]; repeats: NO];