* 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>
* Source/NSBitmapImageRep+GIF.m (-_bitmapIsGIF:): Prepare for

View file

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