104{
110
111
113
114#ifdef OS_DARWIN
117#endif
118
119
120 for (
i = 1;
i < argc;
i++) {
121 if (argv[
i][0] ==
'-' && argv[
i][1] ==
'D')
123 else if (argv[
i][0] ==
'-') {
124 if (
i + 1 >= argc || argv[
i + 1][0] ==
'-')
126 if (argv[
i][1] ==
'e')
128 else if (argv[
i][1] ==
'h')
130 else if (argv[
i][1] ==
'c')
131 speech_program = argv[++
i];
132 else if (argv[
i][1] ==
't')
134 else if (argv[
i][1] ==
'u')
136 else if (argv[
i][1] ==
's')
138 else {
140 printf
141 ("usage: mlxspeaker [-h Hostname] [-e Experiment] [-c command] [-D] daemon\n");
142 printf(" [-t mt_talk] Specify the mt_talk alert command\n");
143 printf(" [-u mt_user] Specify the mt_user alert command\n");
144 printf(" [-s shut up time] Specify the min time interval between alert [s]\n");
145 printf(" The -t & -u switch require a command equivalent to:\n");
146 printf(" '-t play --volume=0.3 file.wav'\n");
147 printf(" [-c command] Used to start the speech synthesizer,\n");
148 printf(" which should read text from it's standard input.\n");
149 printf(" eg: mlxspeaker -c 'festival --tts -'\n\n");
150 return 0;
151 }
152 }
153 }
154
156 printf("Becoming a daemon...\n");
158 }
159
160
163
164 fp = popen(speech_program,
"w");
166 cm_msg(
MERROR,
"Speaker",
"Unable to start \"%s\": %s\n",
167 speech_program, strerror(errno));
169 exit(2);
170 }
171
172
175 return 1;
176
178
179 printf(
"Midas Message Speaker connected to %s. Press \"!\" to exit.\n",
host_name[0] ?
host_name :
"local host");
180
181
183
184 do {
188 if (ch == -1)
189 ch = getchar();
190 if (ch == '!')
192 }
193
195
196#if defined(SIGPIPE) && defined(SIG_IGN)
197 signal(SIGPIPE, SIG_IGN);
198#endif
199
200
202
204
206 return 1;
207}
INT cm_yield(INT millisec)
INT cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
INT cm_disconnect_experiment(void)
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
INT ss_getchar(BOOL reset)
INT ss_daemon_init(BOOL keep_stdout)
INT cm_msg_register(EVENT_HANDLER *func)
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
char exp_name[NAME_LENGTH]
char host_name[HOST_NAME_LENGTH]
void sigpipehandler(int sig)
void receive_message(HNDLE hBuf, HNDLE id, EVENT_HEADER *header, void *message)
void siginthandler(int sig)