Commit 17fae0a3 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4404 from DonLakeFlyer/MacSpeech

Switch away from deprecated APIs
parents 0b451410 b6b222ba
......@@ -10,47 +10,27 @@
#if (defined __macos__) && defined QGC_SPEECH_ENABLED
#include <ApplicationServices/ApplicationServices.h>
#include <MacTypes.h>
static SpeechChannel sc;
static Fixed volume;
void macSpeak(const char* words)
{
static SpeechChannel sc = NULL;
static void speechDone(SpeechChannel sc2, void *) {
if (sc2 == sc)
{
DisposeSpeechChannel(sc);
while (SpeechBusy()) {
QGC::SLEEP::msleep(100);
}
}
if (sc == NULL) {
Float32 volume = 1.0;
class MacSpeech
{
public:
MacSpeech()
{
setVolume(100);
}
~MacSpeech()
{
}
void say(const char* words)
{
while (SpeechBusy()) {
QGC::SLEEP::msleep(100);
}
NewSpeechChannel(NULL, &sc);
SetSpeechInfo(sc, soVolume, &volume);
SetSpeechInfo(sc, soSpeechDoneCallBack, reinterpret_cast<void *>(speechDone));
CFStringRef cfstr = CFStringCreateWithCString(NULL, words, kCFStringEncodingUTF8);
SpeakCFString(sc, cfstr, NULL);
}
void setVolume(int v)
{
volume = FixRatio(v, 100);
CFNumberRef volumeRef = CFNumberCreate(NULL, kCFNumberFloat32Type, &volume);
SetSpeechProperty(sc, kSpeechVolumeProperty, volumeRef);
CFRelease(volumeRef);
}
};
//-- Singleton
MacSpeech macSpeech;
CFStringRef strRef = CFStringCreateWithCString(NULL, words, kCFStringEncodingUTF8);
SpeakCFString(sc, strRef, NULL);
CFRelease(strRef);
}
#endif
#if (defined __ios__) && defined QGC_SPEECH_ENABLED
......@@ -154,7 +134,7 @@ void QGCAudioWorker::say(QString inText)
espeak_Synth(text.toStdString().c_str(), espeak_size, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL);
espeak_Synchronize();
#elif (defined __macos__) && defined QGC_SPEECH_ENABLED
macSpeech.say(text.toStdString().c_str());
macSpeak(text.toStdString().c_str());
#elif (defined __ios__) && defined QGC_SPEECH_ENABLED
iOSSpeak(text);
#else
......@@ -172,7 +152,7 @@ void QGCAudioWorker::mute(bool mute)
this->muted = mute;
QSettings settings;
settings.setValue(QGC_GAUDIOOUTPUT_KEY + "muted", this->muted);
// emit mutedChanged(muted);
// emit mutedChanged(muted);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment