2022-07-16  Juan Manuel Guerrero <juan.guerrero@gmx.de>


	* src/audio_out.c [__DJGPP__]: Include required DJGPP specific
	headers.
	(ao_open_file) [__DJGPP__]: For DJGPP, reenable SIGINT and SIGQUIT
	signals if stdin and/or stdout is connected to console and has been
	switched into binary mode.

	* src/config.c (ao_read_config_files): For DJGPP, allow to read
	user config file from current working directory.






diff -aprNU3 libao-1.2.0.orig/src/audio_out.c libao-1.2.0/src/audio_out.c
--- libao-1.2.0.orig/src/audio_out.c	2014-01-15 06:54:48 +0000
+++ libao-1.2.0/src/audio_out.c	2022-07-16 17:44:30 +0000
@@ -1339,6 +1339,12 @@ ao_device *ao_open_live (int driver_id,
 }
 
 
+#if defined(__DJGPP__)
+# include <io.h>           /* declares setmode() */
+# include <fcntl.h>        /* defines O_BINARY */
+# include <unistd.h>       /* declares isatty() */
+# include <sys/exceptn.h>  /* declares __djgpp_set_ctrl_c() */
+#endif
 ao_device *ao_open_file (int driver_id, const char *filename, int overwrite,
 			 ao_sample_format *format, ao_option *options)
 {
@@ -1346,7 +1352,24 @@ ao_device *ao_open_file (int driver_id,
 	ao_device *device;
 
 	if (strcmp("-", filename) == 0)
+#if defined(__DJGPP__)
+	{
+		/* Putting stdin/stdout in binary mode if it is connected to
+		   the console, would make it impossible for the user to
+		   interrupt the program through Ctrl-C or Ctrl-Break.  */
+
+		/* This is DJGPP-specific.  By default, switching console
+		   to binary mode disables SIGINT and SIGQUIT.  But we want
+		   terminal reads to be interruptible.  */
+
+		int fd = fileno(file = stdout);
+		setmode(fd, O_BINARY);
+		if (isatty(fd))
+			__djgpp_set_ctrl_c(1);
+	}
+#else
 		file = stdout;
+#endif
 	else {
 
 		if (!overwrite) {
diff -aprNU3 libao-1.2.0.orig/src/config.c libao-1.2.0/src/config.c
--- libao-1.2.0.orig/src/config.c	2012-02-01 14:38:50 +0000
+++ libao-1.2.0/src/config.c	2022-07-16 17:26:52 +0000
@@ -107,5 +107,13 @@ void ao_read_config_files (ao_config *co
 		strcat(userfile, AO_USER_CONFIG);
 		ao_read_config_file(config, userfile);
 	}
+#if defined(__DJGPP__)
+        else
+	{
+		strncpy(userfile, ".", FILENAME_MAX);
+		strcat(userfile, AO_USER_CONFIG);
+		ao_read_config_file(config, userfile);
+	}
+#endif
 }
 
