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 @@ ...@@ -10,47 +10,27 @@
#if (defined __macos__) && defined QGC_SPEECH_ENABLED #if (defined __macos__) && defined QGC_SPEECH_ENABLED
#include <ApplicationServices/ApplicationServices.h> #include <ApplicationServices/ApplicationServices.h>
#include <MacTypes.h>
static SpeechChannel sc; void macSpeak(const char* words)
static Fixed volume; {
static SpeechChannel sc = NULL;
static void speechDone(SpeechChannel sc2, void *) { while (SpeechBusy()) {
if (sc2 == sc) QGC::SLEEP::msleep(100);
{
DisposeSpeechChannel(sc);
} }
} 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); NewSpeechChannel(NULL, &sc);
SetSpeechInfo(sc, soVolume, &volume); CFNumberRef volumeRef = CFNumberCreate(NULL, kCFNumberFloat32Type, &volume);
SetSpeechInfo(sc, soSpeechDoneCallBack, reinterpret_cast<void *>(speechDone)); SetSpeechProperty(sc, kSpeechVolumeProperty, volumeRef);
CFStringRef cfstr = CFStringCreateWithCString(NULL, words, kCFStringEncodingUTF8); CFRelease(volumeRef);
SpeakCFString(sc, cfstr, NULL);
}
void setVolume(int v)
{
volume = FixRatio(v, 100);
} }
}; CFStringRef strRef = CFStringCreateWithCString(NULL, words, kCFStringEncodingUTF8);
SpeakCFString(sc, strRef, NULL);
//-- Singleton CFRelease(strRef);
MacSpeech macSpeech; }
#endif #endif
#if (defined __ios__) && defined QGC_SPEECH_ENABLED #if (defined __ios__) && defined QGC_SPEECH_ENABLED
...@@ -154,7 +134,7 @@ void QGCAudioWorker::say(QString inText) ...@@ -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_Synth(text.toStdString().c_str(), espeak_size, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL);
espeak_Synchronize(); espeak_Synchronize();
#elif (defined __macos__) && defined QGC_SPEECH_ENABLED #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 #elif (defined __ios__) && defined QGC_SPEECH_ENABLED
iOSSpeak(text); iOSSpeak(text);
#else #else
...@@ -172,7 +152,7 @@ void QGCAudioWorker::mute(bool mute) ...@@ -172,7 +152,7 @@ void QGCAudioWorker::mute(bool mute)
this->muted = mute; this->muted = mute;
QSettings settings; QSettings settings;
settings.setValue(QGC_GAUDIOOUTPUT_KEY + "muted", this->muted); 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