update dict
[QFreeRecite.git] / src / gui / WinSpeaker.cpp
blob4bd3d26be23f7b77aedf0084a6134c6cf17190ee
1 #include <windows.h>
2 #include <cstdio>
3 #include "WinSpeaker.h"
5 //By default, mutex should be nonrecursive.
6 QMutex WinSpeaker::mutex(QMutex::NonRecursive);
8 WinSpeaker::WinSpeaker(QObject *parent)
9 : QThread(parent) {
10 /*Do Nothing Here!*/
13 bool WinSpeaker::speak(const std::string &wordFile) {
14 if(!mutex.tryLock()){
15 return false;
16 }else {
17 word = wordFile;
18 start();
19 return true;
23 void WinSpeaker::run() {
24 PlaySound(word.c_str(), 0, SND_FILENAME|SND_ASYNC);
25 mutex.unlock();