Hopefully fixed crashes with spoken messages on builds using libespeak.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4612 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
bb0a795fe7
commit
68889d1253
@ -8347,24 +8347,26 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context)
|
||||
{
|
||||
NSData *utf8 = [text dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
if (utf8 != nil)
|
||||
if (utf8 != nil) // we have a valid UTF-8 string
|
||||
{
|
||||
const char *bytes = [utf8 bytes];
|
||||
size_t length = strlen(bytes);
|
||||
espeak_Synth([text UTF8String], length + 1 /* inc. NULL */, 0, POS_CHARACTER, length, espeakCHARS_UTF8 | espeakPHONEMES | espeakENDPAUSE, NULL, NULL);
|
||||
const char *stringToSay = [text UTF8String];
|
||||
espeak_Synth(stringToSay, strlen(stringToSay) + 1 /* inc. NULL */, 0, POS_CHARACTER, 0, espeakCHARS_UTF8 | espeakPHONEMES | espeakENDPAUSE, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) stopSpeaking
|
||||
{
|
||||
espeak_Cancel();
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) isSpeaking
|
||||
{
|
||||
return espeak_IsPlaying();
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) voiceName:(unsigned int) index
|
||||
{
|
||||
if (index >= espeak_voice_count)
|
||||
@ -8372,6 +8374,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context)
|
||||
return [NSString stringWithCString: espeak_voices[index]->name];
|
||||
}
|
||||
|
||||
|
||||
- (unsigned int) voiceNumber:(NSString *) name
|
||||
{
|
||||
if (name == nil)
|
||||
@ -8387,6 +8390,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context)
|
||||
return (index < espeak_voice_count) ? index : UINT_MAX;
|
||||
}
|
||||
|
||||
|
||||
- (unsigned int) nextVoice:(unsigned int) index
|
||||
{
|
||||
if (++index >= espeak_voice_count)
|
||||
@ -8394,6 +8398,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context)
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
- (unsigned int) prevVoice:(unsigned int) index
|
||||
{
|
||||
if (--index >= espeak_voice_count)
|
||||
@ -8401,6 +8406,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context)
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
- (unsigned int) setVoice:(unsigned int) index withGenderM:(BOOL) isMale
|
||||
{
|
||||
if (index == UINT_MAX)
|
||||
|
Loading…
x
Reference in New Issue
Block a user