summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_oss.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-26 21:21:56 +0100
committerwm4 <wm4@nowhere>2014-11-26 21:21:56 +0100
commitcc5437746312127aed4e4c8e62091707ec61153c (patch)
treedd0f5b575d3081d0057a0957ff3cb8556f817086 /audio/out/ao_oss.c
parent3fe57e3cb691d75dc8813c29cada5e3ddfd2a295 (diff)
downloadmpv-cc5437746312127aed4e4c8e62091707ec61153c.tar.bz2
mpv-cc5437746312127aed4e4c8e62091707ec61153c.tar.xz
Do not call strerror()
...because everything is terrible. strerror() is not documented as having to be thread-safe by POSIX and C11. (Which is pretty much bullshit, because both mandate threads and some form of thread-local storage - so there's no excuse why implementation couldn't implement this in a thread-safe way. Especially with C11 this is ridiculous, because there is no way to use threads and convert error numbers to strings at the same time!) Since we heavily use threads now, we should avoid unsafe functions like strerror(). strerror_r() is in POSIX, but GNU/glibc deliberately fucks it up and gives the function different semantics than the POSIX one. It's a bit of work to convince this piece of shit to expose the POSIX standard function, and not the messed up GNU one. strerror_l() is also in POSIX, but only since the 2008 standard, and thus is not widespread. The solution is using avlibc (libavutil, by its official name), which handles the unportable details for us, mostly. We avoid some pain.
Diffstat (limited to 'audio/out/ao_oss.c')
-rw-r--r--audio/out/ao_oss.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c
index 826bb1cf2f..3b8c9106fe 100644
--- a/audio/out/ao_oss.c
+++ b/audio/out/ao_oss.c
@@ -38,6 +38,7 @@
#include "config.h"
#include "options/options.h"
+#include "common/common.h"
#include "common/msg.h"
#include "osdep/timer.h"
#include "osdep/endian.h"
@@ -107,11 +108,11 @@ static const struct mp_chmap oss_layouts[MP_NUM_CHANNELS + 1] = {
#endif
#if !defined(AFMT_U32_NE) && defined(AFMT_U32_LE) && defined(AFMT_U32_BE)
-#define AFMT_U32MP_SELECT_LE_BE(AFMT_U32_LE, AFMT_U32_BE)
+#define AFMT_U32_NE AFMT_U32MP_SELECT_LE_BE(AFMT_U32_LE, AFMT_U32_BE)
#endif
#if !defined(AFMT_S32_NE) && defined(AFMT_S32_LE) && defined(AFMT_S32_BE)
-#define AFMT_S32MP_SELECT_LE_BE(AFMT_S32_LE, AFMT_S32_BE)
+#define AFMT_S32_NE AFMT_S32MP_SELECT_LE_BE(AFMT_S32_LE, AFMT_S32_BE)
#endif
static const int format_table[][2] = {
@@ -305,14 +306,16 @@ static int reopen_device(struct ao *ao, bool allow_format_changes)
p->audio_fd = open(p->dsp, O_WRONLY);
#endif
if (p->audio_fd < 0) {
- MP_ERR(ao, "Can't open audio device %s: %s\n", p->dsp, strerror(errno));
+ MP_ERR(ao, "Can't open audio device %s: %s\n",
+ p->dsp, mp_strerror(errno));
goto fail;
}
#ifdef __linux__
/* Remove the non-blocking flag */
if (fcntl(p->audio_fd, F_SETFL, 0) < 0) {
- MP_ERR(ao, "Can't make file descriptor blocking: %s\n", strerror(errno));
+ MP_ERR(ao, "Can't make file descriptor blocking: %s\n",
+ mp_strerror(errno));
goto fail;
}
#endif
@@ -434,7 +437,7 @@ static int init(struct ao *ao)
if ((fd = open(p->oss_mixer_device, O_RDONLY)) == -1) {
MP_ERR(ao, "Can't open mixer device %s: %s\n",
- p->oss_mixer_device, strerror(errno));
+ p->oss_mixer_device, mp_strerror(errno));
} else {
ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs);
close(fd);