mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-07-10 13:29:52 -04:00
rbutilqt: Add error handling to TTSCarbon::generateSettings()
Co-authored-by: ChatGPT (GPT-5.3 Mini) <chatgpt@openai.com> Change-Id: Iad04028853e930b508e72c2c9c3e9ebd9504d4bb
This commit is contained in:
parent
92d62cf6ac
commit
1039eb305a
1 changed files with 15 additions and 0 deletions
|
|
@ -117,18 +117,33 @@ void TTSCarbon::generateSettings(void)
|
|||
|
||||
// get system voice
|
||||
error = GetVoiceDescription(NULL, &vdesc, sizeof(vdesc));
|
||||
if (error != 0) {
|
||||
LOG_ERROR() << "GetVoiceDescription() failed with code" << error;
|
||||
return;
|
||||
}
|
||||
systemVoice
|
||||
= QString::fromLocal8Bit((const char*)&vdesc.name[1], vdesc.name[0]);
|
||||
// get list of all voices
|
||||
CountVoices(&numVoices);
|
||||
for(SInt16 i = 1; i < numVoices; ++i) {
|
||||
error = GetIndVoice(i, &vspec);
|
||||
if (error != 0) {
|
||||
LOG_ERROR() << "GetIndVoice(" << i << ") failed with code" << error;
|
||||
continue;
|
||||
}
|
||||
error = GetVoiceDescription(&vspec, &vdesc, sizeof(vdesc));
|
||||
if (error != 0) {
|
||||
LOG_ERROR() << "GetVoiceDescription(" << i << ") failed with code" << error;
|
||||
continue;
|
||||
}
|
||||
// name is pascal string, i.e. the first byte is the length.
|
||||
QString name
|
||||
= QString::fromLocal8Bit((const char*)&vdesc.name[1], vdesc.name[0]);
|
||||
voiceNames.append(name.trimmed());
|
||||
}
|
||||
if (voiceNames.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// voice
|
||||
EncTtsSetting* setting;
|
||||
QString voice
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue