Diffstat (limited to 'noncore/apps/opie-reader/flitecmd.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/flitecmd.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/flitecmd.cpp b/noncore/apps/opie-reader/flitecmd.cpp new file mode 100644 index 0000000..bb7e303 --- a/dev/null +++ b/noncore/apps/opie-reader/flitecmd.cpp | |||
@@ -0,0 +1,43 @@ | |||
1 | #include <unistd.h> | ||
2 | #include <sys/types.h> | ||
3 | #include <sys/wait.h> | ||
4 | #include <errno.h> | ||
5 | #include "flitecmd.h" | ||
6 | |||
7 | void CFliteCmd::output(const QString& txt) | ||
8 | { | ||
9 | pid_t pid; | ||
10 | if ((pid = fork()) <0) | ||
11 | { | ||
12 | qDebug("No memory"); | ||
13 | } | ||
14 | else if (pid == 0) | ||
15 | { | ||
16 | execlp("flite", "flite", "-t", (const char*)txt, NULL); | ||
17 | _exit(127); | ||
18 | qDebug("Can't find flite"); | ||
19 | } | ||
20 | else | ||
21 | { | ||
22 | int status; | ||
23 | while (waitpid(pid, &status, 0) < 0) | ||
24 | { | ||
25 | if (errno != EINTR) | ||
26 | { | ||
27 | qDebug("Error from flite"); | ||
28 | break; | ||
29 | } | ||
30 | } | ||
31 | qDebug("flite status:%d", status); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | QString CFliteCmd::about() | ||
36 | { | ||
37 | return QString("FliteCmd output codec (c) Tim Wentford\n"); | ||
38 | } | ||
39 | |||
40 | extern "C" | ||
41 | { | ||
42 | COutput* newcodec() { return new CFliteCmd; } | ||
43 | } | ||