#include <string.h>
#include <getopt.h>
#include <sys/errno.h>
+#include <sys/signal.h>
#include <errno.h>
#include "config.h"
return bytes_read;
}
+static void ac3dec_signal_handler(int signal)
+{
+ if (!quiet)
+ fprintf(stderr, "Aborted...\n");
+ // it's important to close the PCM handle(s), because
+ // some driver settings have to be recovered
+ output_close();
+ fclose(in_file);
+ exit(EXIT_FAILURE);
+}
+
int main(int argc,char *argv[])
{
struct option long_option[] =
fprintf(stderr, "Output open failed\n");
exit(EXIT_FAILURE);
}
+ signal(SIGINT, ac3dec_signal_handler);
+ signal(SIGTERM, ac3dec_signal_handler);
+ signal(SIGABRT, ac3dec_signal_handler);
do {
//Send the samples to the output device
output_play(ac3_frame->audio_data, 256 * 6);
} else {
uint_8 *start, *end;
init_spdif();
- output_open(&out_config);
+ if (output_open(&out_config) < 0) {
+ fprintf(stderr, "Output open failed\n");
+ exit(EXIT_FAILURE);
+ }
+ signal(SIGINT, ac3dec_signal_handler);
+ signal(SIGTERM, ac3dec_signal_handler);
+ signal(SIGABRT, ac3dec_signal_handler);
while (fill_buffer(&start, &end) > 0)
if (output_spdif(start, end) < 0)
break;