summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--audio/out/ao_oss.c13
-rw-r--r--common/common.c9
-rw-r--r--common/common.h3
-rw-r--r--input/joystick.c15
-rw-r--r--input/lirc.c3
-rw-r--r--options/parse_configfile.c3
-rw-r--r--stream/ai_oss.c5
-rw-r--r--stream/audio_in.c5
-rw-r--r--stream/cache.c3
-rw-r--r--stream/stream.c4
-rw-r--r--stream/stream_dvd.c9
-rw-r--r--stream/stream_file.c3
-rw-r--r--stream/stream_pvr.c39
-rw-r--r--stream/tvi_v4l2.c88
-rw-r--r--video/out/vo_image.c3
-rw-r--r--video/out/vo_x11.c2
16 files changed, 117 insertions, 90 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);
diff --git a/common/common.c b/common/common.c
index 449c95be26..4c1f9f327a 100644
--- a/common/common.c
+++ b/common/common.c
@@ -20,6 +20,7 @@
#include <assert.h>
#include <libavutil/common.h>
+#include <libavutil/error.h>
#include "talloc.h"
#include "misc/bstr.h"
@@ -243,3 +244,11 @@ bool mp_append_escaped_string(void *talloc_ctx, bstr *dst, bstr *src)
}
return false;
}
+
+// Behaves like strerror()/strerror_r(), but is thread- and GNU-safe.
+char *mp_strerror_buf(char *buf, size_t buf_size, int errnum)
+{
+ // This handles the nasty details of calling the right function for us.
+ av_strerror(AVERROR(errnum), buf, buf_size);
+ return buf;
+}
diff --git a/common/common.h b/common/common.h
index 3e5ee1190f..e3411427a5 100644
--- a/common/common.h
+++ b/common/common.h
@@ -89,4 +89,7 @@ bool mp_append_escaped_string_noalloc(void *talloc_ctx, struct bstr *dst,
bool mp_append_escaped_string(void *talloc_ctx, struct bstr *dst,
struct bstr *src);
+char *mp_strerror_buf(char *buf, size_t buf_size, int errnum);
+#define mp_strerror(e) mp_strerror_buf((char[80]){0}, 80, e)
+
#endif /* MPLAYER_MPCOMMON_H */
diff --git a/input/joystick.c b/input/joystick.c
index ba71da8b52..e3df106735 100644
--- a/input/joystick.c
+++ b/input/joystick.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <poll.h>
+#include "common/common.h"
#include "common/msg.h"
#include "keycodes.h"
@@ -65,7 +66,8 @@ static struct ctx *joystick_init(struct input_ctx *ictx, struct mp_log *log, cha
fd = open( dev ? dev : JS_DEV , O_RDONLY | O_NONBLOCK );
if(fd < 0) {
- mp_err(log, "Can't open joystick device %s: %s\n",dev ? dev : JS_DEV,strerror(errno));
+ mp_err(log, "Can't open joystick device %s: %s\n",dev ? dev : JS_DEV,
+ mp_strerror(errno));
return NULL;
}
@@ -83,7 +85,8 @@ static struct ctx *joystick_init(struct input_ctx *ictx, struct mp_log *log, cha
initialized = 1;
break;
}
- MP_ERR(ctx, "Error while reading joystick device: %s\n",strerror(errno));
+ MP_ERR(ctx, "Error while reading joystick device: %s\n",
+ mp_strerror(errno));
close(fd);
talloc_free(ctx);
return NULL;
@@ -117,10 +120,12 @@ static int mp_input_joystick_read(void *pctx, int fd) {
continue;
else if(errno == EAGAIN)
return 0;
- if( r < 0)
- MP_ERR(ctx, "Error while reading joystick device: %s\n",strerror(errno));
- else
+ if( r < 0) {
+ MP_ERR(ctx, "Error while reading joystick device: %s\n",
+ mp_strerror(errno));
+ } else {
MP_ERR(ctx, "Error while reading joystick device: %s\n","EOF");
+ }
return -1;
}
l += r;
diff --git a/input/lirc.c b/input/lirc.c
index 2805043c03..db8d4f8e79 100644
--- a/input/lirc.c
+++ b/input/lirc.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <poll.h>
+#include "common/common.h"
#include "common/msg.h"
#include "input.h"
@@ -49,7 +50,7 @@ static struct ctx *mp_input_lirc_init(struct input_ctx *ictx, struct mp_log *log
mode = fcntl(lirc_sock, F_GETFL);
if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) {
- mp_err(log, "setting non-blocking mode failed: %s\n", strerror(errno));
+ mp_err(log, "setting non-blocking mode failed: %s\n", mp_strerror(errno));
lirc_deinit();
return NULL;
}
diff --git a/options/parse_configfile.c b/options/parse_configfile.c
index 48a2c25318..1f0834959c 100644
--- a/options/parse_configfile.c
+++ b/options/parse_configfile.c
@@ -27,6 +27,7 @@
#include "osdep/io.h"
#include "parse_configfile.h"
+#include "common/common.h"
#include "common/msg.h"
#include "misc/ctype.h"
#include "m_option.h"
@@ -79,7 +80,7 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile,
MP_VERBOSE(config, "\n");
if ((fp = fopen(conffile, "r")) == NULL) {
- MP_VERBOSE(config, "Can't open config file: %s\n", strerror(errno));
+ MP_VERBOSE(config, "Can't open config file: %s\n", mp_strerror(errno));
ret = 0;
goto out;
}
diff --git a/stream/ai_oss.c b/stream/ai_oss.c
index 98477d10f3..98f65a7ad1 100644
--- a/stream/ai_oss.c
+++ b/stream/ai_oss.c
@@ -21,7 +21,7 @@
#include "config.h"
-#include <string.h> /* strerror */
+#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -39,6 +39,7 @@
#include "osdep/io.h"
#include "audio_in.h"
+#include "common/common.h"
#include "common/msg.h"
int ai_oss_set_samplerate(audio_in_t *ai)
@@ -91,7 +92,7 @@ int ai_oss_init(audio_in_t *ai)
if (ai->oss.audio_fd < 0)
{
MP_ERR(ai, "Unable to open '%s': %s\n",
- ai->oss.device, strerror(errno));
+ ai->oss.device, mp_strerror(errno));
return -1;
}
diff --git a/stream/audio_in.c b/stream/audio_in.c
index 8e956630b7..3584ee447d 100644
--- a/stream/audio_in.c
+++ b/stream/audio_in.c
@@ -23,6 +23,7 @@
#include "config.h"
#include "audio_in.h"
+#include "common/common.h"
#include "common/msg.h"
#include <string.h>
#include <errno.h>
@@ -268,7 +269,7 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
ret = read(ai->oss.audio_fd, buffer, ai->blocksize);
if (ret != ai->blocksize) {
if (ret < 0) {
- MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno));
+ MP_ERR(ai, "\nError reading audio: %s\n", mp_strerror(errno));
} else {
MP_ERR(ai, "\nNot enough audio samples!\n");
@@ -282,7 +283,7 @@ int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
ret = sio_read(ai->sndio.hdl, buffer, ai->blocksize);
if (ret != ai->blocksize) {
if (ret < 0) {
- MP_ERR(ai, "\nError reading audio: %s\n", strerror(errno));
+ MP_ERR(ai, "\nError reading audio: %s\n", mp_strerror(errno));
} else {
MP_ERR(ai, "\nNot enough audio samples!\n");
}
diff --git a/stream/cache.c b/stream/cache.c
index 12c66a32bb..f076ff47fb 100644
--- a/stream/cache.c
+++ b/stream/cache.c
@@ -651,8 +651,7 @@ int stream_cache_init(stream_t *cache, stream_t *stream,
s->seekable = stream->seekable;
if (pthread_create(&s->cache_thread, NULL, cache_thread, s) != 0) {
- MP_ERR(s, "Starting cache process/thread failed: %s.\n",
- strerror(errno));
+ MP_ERR(s, "Starting cache thread failed.\n");
return -1;
}
s->cache_thread_running = true;
diff --git a/stream/stream.c b/stream/stream.c
index 2a851e82ec..4b161e6c1c 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -446,7 +446,7 @@ static void stream_capture_write(stream_t *s, void *buf, size_t len)
{
if (s->capture_file && len > 0) {
if (fwrite(buf, len, 1, s->capture_file) < 1) {
- MP_ERR(s, "Error writing capture file: %s\n", strerror(errno));
+ MP_ERR(s, "Error writing capture file: %s\n", mp_strerror(errno));
stream_set_capture_file(s, NULL);
}
}
@@ -467,7 +467,7 @@ void stream_set_capture_file(stream_t *s, const char *filename)
if (s->buf_pos < s->buf_len)
stream_capture_write(s, s->buffer, s->buf_len);
} else {
- MP_ERR(s, "Error opening capture file: %s\n", strerror(errno));
+ MP_ERR(s, "Error opening capture file: %s\n", mp_strerror(errno));
}
}
}
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index eb055abc13..5ec1e522bd 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -682,12 +682,14 @@ static int open_s(stream_t *stream)
snprintf(temp_device, len, "/dev/rdisk%d", i);
dvd = DVDOpen(temp_device);
if(!dvd) {
- MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno));
+ MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",temp_device,
+ mp_strerror(errno));
} else {
#if DVDREAD_VERSION <= LIBDVDREAD_VERSION(0,9,4)
dvd_file_t *dvdfile = DVDOpenFile(dvd,d->dvd_title,DVD_READ_INFO_FILE);
if(!dvdfile) {
- MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno));
+ MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",temp_device,
+ mp_strerror(errno));
DVDClose(dvd);
continue;
}
@@ -706,7 +708,8 @@ static int open_s(stream_t *stream)
{
dvd = DVDOpen(d->dvd_device_current);
if(!dvd) {
- MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",d->dvd_device_current, strerror(errno));
+ MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",
+ d->dvd_device_current, mp_strerror(errno));
return STREAM_UNSUPPORTED;
}
}
diff --git a/stream/stream_file.c b/stream/stream_file.c
index eef0dcc5cc..a78cda1f89 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -29,6 +29,7 @@
#include "osdep/io.h"
+#include "common/common.h"
#include "common/msg.h"
#include "stream.h"
#include "options/m_option.h"
@@ -253,7 +254,7 @@ static int open_f(stream_t *stream)
fd = open(filename, m | O_BINARY, openmode);
if (fd < 0) {
MP_ERR(stream, "Cannot open file '%s': %s\n",
- filename, strerror(errno));
+ filename, mp_strerror(errno));
return STREAM_ERROR;
}
struct stat st;
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index 50a8ee5cba..c75a9597cd 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -45,6 +45,7 @@
#include "osdep/io.h"
#include "common/msg.h"
+#include "common/common.h"
#include "options/options.h"
#include "stream.h"
@@ -530,7 +531,7 @@ get_v4l2_freq (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
{
MP_ERR(pvr, "%s can't set tuner (%s).\n",
- LOG_LEVEL_V4L2, strerror (errno));
+ LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
@@ -581,7 +582,7 @@ set_v4l2_freq (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
{
MP_ERR(pvr, "%s can't get tuner (%s).\n",
- LOG_LEVEL_V4L2, strerror (errno));
+ LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
@@ -594,7 +595,7 @@ set_v4l2_freq (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_FREQUENCY, &vf) < 0)
{
MP_ERR(pvr, "%s can't set frequency (%s).\n",
- LOG_LEVEL_V4L2, strerror (errno));
+ LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
@@ -602,7 +603,7 @@ set_v4l2_freq (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
{
MP_ERR(pvr, "%s can't set tuner (%s).\n",
- LOG_LEVEL_V4L2, strerror (errno));
+ LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
@@ -1070,7 +1071,7 @@ set_encoder_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0)
{
MP_ERR(pvr, "%s Error setting MPEG controls (%s).\n",
- LOG_LEVEL_ENCODER, strerror (errno));
+ LOG_LEVEL_ENCODER, mp_strerror (errno));
free (ext_ctrl);
return -1;
}
@@ -1166,7 +1167,7 @@ set_v4l2_settings (struct pvr_t *pvr)
ctrl.value = 1;
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
- MP_ERR(pvr, "%s can't mute (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't mute (%s).\n", LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
}
@@ -1176,7 +1177,7 @@ set_v4l2_settings (struct pvr_t *pvr)
{
if (ioctl (pvr->dev_fd, VIDIOC_S_INPUT, &pvr->input) < 0)
{
- MP_ERR(pvr, "%s can't set input (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't set input (%s)\n", LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
}
@@ -1189,7 +1190,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &std) < 0)
{
- MP_ERR(pvr, "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
@@ -1197,7 +1198,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_STD, &std.id) < 0)
{
- MP_ERR(pvr, "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
}
@@ -1217,7 +1218,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
MP_ERR(pvr, "%s can't set brightness to %d (%s).\n",
- LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
+ LOG_LEVEL_V4L2, ctrl.value, mp_strerror (errno));
return -1;
}
}
@@ -1237,7 +1238,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
MP_ERR(pvr, "%s can't set contrast to %d (%s).\n",
- LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
+ LOG_LEVEL_V4L2, ctrl.value, mp_strerror (errno));
return -1;
}
}
@@ -1257,7 +1258,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
MP_ERR(pvr, "%s can't set hue to %d (%s).\n",
- LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
+ LOG_LEVEL_V4L2, ctrl.value, mp_strerror (errno));
return -1;
}
}
@@ -1277,7 +1278,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
{
MP_ERR(pvr, "%s can't set saturation to %d (%s).\n",
- LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
+ LOG_LEVEL_V4L2, ctrl.value, mp_strerror (errno));
return -1;
}
}
@@ -1293,7 +1294,7 @@ set_v4l2_settings (struct pvr_t *pvr)
if (ioctl (pvr->dev_fd, VIDIOC_S_FMT, &vfmt) < 0)
{
MP_ERR(pvr, "%s can't set resolution to %dx%d (%s).\n",
- LOG_LEVEL_V4L2, pvr->width, pvr->height, strerror (errno));
+ LOG_LEVEL_V4L2, pvr->width, pvr->height, mp_strerror (errno));
return -1;
}
}
@@ -1405,7 +1406,7 @@ v4l2_display_settings (struct pvr_t *pvr)
vin.index = input;
if (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) < 0)
{
- MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
else
@@ -1413,7 +1414,7 @@ v4l2_display_settings (struct pvr_t *pvr)
}
else
{
- MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
@@ -1424,7 +1425,7 @@ v4l2_display_settings (struct pvr_t *pvr)
}
else
{
- MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't get input (%s).\n", LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
@@ -1445,7 +1446,7 @@ v4l2_display_settings (struct pvr_t *pvr)
}
else
{
- MP_ERR(pvr, "%s can't get norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
+ MP_ERR(pvr, "%s can't get norm (%s)\n", LOG_LEVEL_V4L2, mp_strerror (errno));
return -1;
}
@@ -1549,7 +1550,7 @@ pvr_stream_open (stream_t *stream)
if (ioctl (pvr->dev_fd, VIDIOC_QUERYCAP, &vcap) < 0)
{
MP_ERR(pvr, "%s device is not V4L2 compliant (%s).\n",
- LOG_LEVEL_PVR, strerror (errno));
+ LOG_LEVEL_PVR, mp_strerror (errno));
pvr_uninit (pvr);
return STREAM_ERROR;
}
diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c
index eac99ba042..8eca53fd13 100644
--- a/stream/tvi_v4l2.c
+++ b/stream/tvi_v4l2.c
@@ -465,7 +465,7 @@ static int getfmt(priv_t *priv)
priv->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if ((i = v4l2_ioctl(priv->video_fd, VIDIOC_G_FMT, &priv->format)) < 0) {
MP_ERR(priv, "ioctl get format failed: %s\n",
- strerror(errno));
+ mp_strerror(errno));
}
return i;
}
@@ -492,7 +492,7 @@ static int getstd(priv_t *priv)
return 0;
}
- MP_ERR(priv, "ioctl get standard failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl get standard failed: %s\n", mp_strerror(errno));
return -1;
}
do {
@@ -542,7 +542,7 @@ static int set_mute(priv_t *priv, int value)
control.id = V4L2_CID_AUDIO_MUTE;
control.value = value;
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_CTRL, &control) < 0) {
- MP_ERR(priv, "ioctl set mute failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set mute failed: %s\n", mp_strerror(errno));
return 0;
}
return 1;
@@ -556,7 +556,7 @@ static int set_control(priv_t *priv, struct v4l2_control *control, int val_signe
struct v4l2_queryctrl qctrl;
qctrl.id = control->id;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
- MP_ERR(priv, "ioctl query control failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl query control failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
@@ -581,7 +581,7 @@ static int set_control(priv_t *priv, struct v4l2_control *control, int val_signe
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_CTRL, control) < 0) {
MP_ERR(priv, "ioctl set %s %d failed: %s\n",
- qctrl.name, control->value, strerror(errno));
+ qctrl.name, control->value, mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
MP_VERBOSE(priv, "set %s: %d [%d, %d]\n",
@@ -599,12 +599,12 @@ static int get_control(priv_t *priv, struct v4l2_control *control, int val_signe
qctrl.id = control->id;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
- MP_ERR(priv, "ioctl query control failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl query control failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_CTRL, control) < 0) {
- MP_ERR(priv, "ioctl get %s failed: %s\n", qctrl.name, strerror(errno));
+ MP_ERR(priv, "ioctl get %s failed: %s\n", qctrl.name, mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
MP_VERBOSE(priv, "get %s: %d [%d, %d]\n",
@@ -673,7 +673,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
MP_VERBOSE(priv, "set format: %s\n",
pixfmt2name(buf, priv->format.fmt.pix.pixelformat));
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
- MP_ERR(priv, "ioctl set format failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set format failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
/* according to the v4l2 specs VIDIOC_S_FMT should not fail, inflexible drivers
@@ -700,7 +700,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
priv->format.fmt.pix.width = *(int *)arg;
MP_VERBOSE(priv, "set width: %d\n", *(int *)arg);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
- MP_ERR(priv, "ioctl set width failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set width failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
@@ -717,7 +717,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
priv->format.fmt.pix.field = V4L2_FIELD_ANY;
MP_VERBOSE(priv, "set height: %d\n", *(int *)arg);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
- MP_ERR(priv, "ioctl set height failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set height failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
@@ -803,7 +803,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
frequency.tuner = 0;
frequency.type = V4L2_TUNER_ANALOG_TV;
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_FREQUENCY, &frequency) < 0) {
- MP_ERR(priv, "ioctl get frequency failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl get frequency failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
*(int *)arg = frequency.frequency;
@@ -817,7 +817,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
frequency.type = V4L2_TUNER_ANALOG_TV;
frequency.frequency = *(int *)arg;
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FREQUENCY, &frequency) < 0) {
- MP_ERR(priv, "ioctl set frequency failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set frequency failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
#if 0
@@ -828,14 +828,14 @@ static int do_control(priv_t *priv, int cmd, void *arg)
case TVI_CONTROL_TUN_GET_TUNER:
MP_VERBOSE(priv, "get tuner\n");
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
- MP_ERR(priv, "ioctl get tuner failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl get tuner failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
case TVI_CONTROL_TUN_SET_TUNER:
MP_VERBOSE(priv, "set tuner\n");
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_TUNER, &priv->tuner) < 0) {
- MP_ERR(priv, "ioctl set tuner failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set tuner failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
@@ -844,7 +844,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
return TVI_CONTROL_TRUE;
case TVI_CONTROL_TUN_GET_SIGNAL:
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
- MP_ERR(priv, "ioctl get tuner failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl get tuner failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
*(int*)arg=100*(priv->tuner.signal>>8)/255;
@@ -852,12 +852,12 @@ static int do_control(priv_t *priv, int cmd, void *arg)
case TVI_CONTROL_TUN_SET_NORM:
priv->standard.index = *(int *)arg;
if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMSTD, &priv->standard) < 0) {
- MP_ERR(priv, "ioctl enum norm failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl enum norm failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
MP_VERBOSE(priv, "set norm: %s\n", priv->standard.name);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_STD, &priv->standard.id) < 0) {
- MP_ERR(priv, "ioctl set norm failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set norm failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
@@ -879,7 +879,7 @@ static int do_control(priv_t *priv, int cmd, void *arg)
}
case TVI_CONTROL_SPC_GET_INPUT:
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_INPUT, (int *)arg) < 0) {
- MP_ERR(priv, "ioctl get input failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl get input failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
@@ -887,11 +887,11 @@ static int do_control(priv_t *priv, int cmd, void *arg)
MP_VERBOSE(priv, "set input: %d\n", *(int *)arg);
priv->input.index = *(int *)arg;
if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMINPUT, &priv->input) < 0) {
- MP_ERR(priv, "ioctl enum input failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl enum input failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_INPUT, (int *)arg) < 0) {
- MP_ERR(priv, "ioctl set input failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set input failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
return TVI_CONTROL_TRUE;
@@ -977,14 +977,14 @@ static int uninit(priv_t *priv)
/* turn off streaming */
if (v4l2_ioctl(priv->video_fd, VIDIOC_STREAMOFF, &(priv->map[0].buf.type)) < 0) {
- MP_ERR(priv, "ioctl streamoff failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl streamoff failed: %s\n", mp_strerror(errno));
}
priv->streamon = 0;
/* unqueue all remaining buffers (not sure if this code is correct) */
for (i = 0; i < priv->mapcount; i++) {
if (v4l2_ioctl(priv->video_fd, VIDIOC_DQBUF, &priv->map[i].buf) < 0) {
- MP_ERR(priv, "VIDIOC_DQBUF failed: %s\n", strerror(errno));
+ MP_ERR(priv, "VIDIOC_DQBUF failed: %s\n", mp_strerror(errno));
}
}
}
@@ -992,7 +992,7 @@ static int uninit(priv_t *priv)
/* unmap all buffers */
for (i = 0; i < priv->mapcount; i++) {
if (v4l2_munmap(priv->map[i].addr, priv->map[i].len) < 0) {
- MP_ERR(priv, "munmap capture buffer failed: %s\n", strerror(errno));
+ MP_ERR(priv, "munmap capture buffer failed: %s\n", mp_strerror(errno));
}
}
@@ -1048,7 +1048,7 @@ static int init(priv_t *priv)
/* Open the video device. */
priv->video_fd = v4l2_open(priv->video_dev, O_RDWR);
if (priv->video_fd < 0) {
- MP_ERR(priv, "unable to open '%s': %s\n", priv->video_dev, strerror(errno));
+ MP_ERR(priv, "unable to open '%s': %s\n", priv->video_dev, mp_strerror(errno));
uninit(priv);
return 0;
}
@@ -1059,7 +1059,7 @@ static int init(priv_t *priv)
** for further control calls.
*/
if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCAP, &priv->capability) < 0) {
- MP_ERR(priv, "ioctl query capabilities failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl query capabilities failed: %s\n", mp_strerror(errno));
uninit(priv);
return 0;
}
@@ -1082,7 +1082,7 @@ static int init(priv_t *priv)
*/
if (priv->capability.capabilities & V4L2_CAP_TUNER) {
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
- MP_ERR(priv, "ioctl get tuner failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl get tuner failed: %s\n", mp_strerror(errno));
uninit(priv);
return 0;
}
@@ -1143,7 +1143,7 @@ static int init(priv_t *priv)
}
i = -1;
if (v4l2_ioctl(priv->video_fd, VIDIOC_G_INPUT, &i) < 0) {
- MP_ERR(priv, "ioctl get input failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl get input failed: %s\n", mp_strerror(errno));
}
char buf[80];
MP_INFO(priv, "\n Current input: %d\n", i);
@@ -1167,7 +1167,7 @@ static int init(priv_t *priv)
priv->format.fmt.pix.width = 640;
priv->format.fmt.pix.height = 480;
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
- MP_ERR(priv, "ioctl set format failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set format failed: %s\n", mp_strerror(errno));
uninit(priv);
return 0;
}
@@ -1180,7 +1180,7 @@ static int init(priv_t *priv)
MP_VERBOSE(priv, "setting audio mode\n");
priv->tuner.audmode = amode2v4l(priv->tv_param->amode);
if (v4l2_ioctl(priv->video_fd, VIDIOC_S_TUNER, &priv->tuner) < 0) {
- MP_ERR(priv, "ioctl set tuner failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl set tuner failed: %s\n", mp_strerror(errno));
return TVI_CONTROL_FALSE;
}
}
@@ -1249,18 +1249,18 @@ static int start(priv_t *priv)
setup_audio_buffer_sizes(priv);
priv->audio_skew_buffer = calloc(priv->aud_skew_cnt, sizeof(long long));
if (!priv->audio_skew_buffer) {
- MP_ERR(priv, "cannot allocate skew buffer: %s\n", strerror(errno));
+ MP_ERR(priv, "cannot allocate skew buffer: %s\n", mp_strerror(errno));
return 0;
}
priv->audio_skew_delta_buffer = calloc(priv->aud_skew_cnt, sizeof(long long));
if (!priv->audio_skew_delta_buffer) {
- MP_ERR(priv, "cannot allocate skew buffer: %s\n", strerror(errno));
+ MP_ERR(priv, "cannot allocate skew buffer: %s\n", mp_strerror(errno));
return 0;
}
priv->audio_ringbuffer = calloc(priv->audio_in.blocksize, priv->audio_buffer_size);
if (!priv->audio_ringbuffer) {
- MP_ERR(priv, "cannot allocate audio buffer: %s\n", strerror(errno));
+ MP_ERR(priv, "cannot allocate audio buffer: %s\n", mp_strerror(errno));
return 0;
}
@@ -1304,7 +1304,7 @@ static int start(priv_t *priv)
priv->video_ringbuffer = calloc(priv->video_buffer_size_max, sizeof(video_buffer_entry));
if (!priv->video_ringbuffer) {
- MP_ERR(priv, "cannot allocate video buffer: %s\n", strerror(errno));
+ MP_ERR(priv, "cannot allocate video buffer: %s\n", mp_strerror(errno));
return 0;
}
pthread_mutex_init(&priv->video_buffer_mutex, NULL);
@@ -1319,13 +1319,13 @@ static int start(priv_t *priv)
request.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
request.memory = V4L2_MEMORY_MMAP;
if (v4l2_ioctl(priv->video_fd, VIDIOC_REQBUFS, &request) < 0) {
- MP_ERR(priv, "ioctl request buffers failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl request buffers failed: %s\n", mp_strerror(errno));
return 0;
}
/* query buffers */
if (!(priv->map = calloc(request.count, sizeof(struct map)))) {
- MP_ERR(priv, "malloc capture buffers failed: %s\n", strerror(errno));
+ MP_ERR(priv, "malloc capture buffers failed: %s\n", mp_strerror(errno));
return 0;
}
@@ -1335,7 +1335,7 @@ static int start(priv_t *priv)
priv->map[i].buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
priv->map[i].buf.memory = V4L2_MEMORY_MMAP;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYBUF, &(priv->map[i].buf)) < 0) {
- MP_ERR(priv, "ioctl query buffer failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl query buffer failed: %s\n", mp_strerror(errno));
free(priv->map);
priv->map = NULL;
return 0;
@@ -1343,7 +1343,7 @@ static int start(priv_t *priv)
priv->map[i].addr = v4l2_mmap (0, priv->map[i].buf.length, PROT_READ |
PROT_WRITE, MAP_SHARED, priv->video_fd, priv->map[i].buf.m.offset);
if (priv->map[i].addr == MAP_FAILED) {
- MP_ERR(priv, "mmap capture buffer failed: %s\n", strerror(errno));
+ MP_ERR(priv, "mmap capture buffer failed: %s\n", mp_strerror(errno));
priv->map[i].len = 0;
return 0;
}
@@ -1359,7 +1359,7 @@ static int start(priv_t *priv)
priv->mapcount++;
if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
- MP_ERR(priv, "ioctl queue buffer failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl queue buffer failed: %s\n", mp_strerror(errno));
return 0;
}
}
@@ -1413,7 +1413,7 @@ static void *video_grabber(void *data)
MP_VERBOSE(priv, "going to capture\n");
if (v4l2_ioctl(priv->video_fd, VIDIOC_STREAMON, &(priv->format.type)) < 0) {
- MP_ERR(priv, "ioctl streamon failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl streamon failed: %s\n", mp_strerror(errno));
return 0;
}
priv->streamon = 1;
@@ -1441,7 +1441,7 @@ static void *video_grabber(void *data)
i = select(priv->video_fd + 1, &rdset, NULL, NULL, &timeout);
if (i < 0) {
- MP_ERR(priv, "select failed: %s\n", strerror(errno));
+ MP_ERR(priv, "select failed: %s\n", mp_strerror(errno));
continue;
}
else if (i == 0) {
@@ -1467,7 +1467,7 @@ static void *video_grabber(void *data)
don't know if is it a bug or (mis)feature
*/
MP_ERR(priv, "ioctl dequeue buffer failed: %s, idx = %d\n",
- strerror(errno), buf.index);
+ mp_strerror(errno), buf.index);
for (i = 0; i < priv->mapcount; i++) {
memset(&buf,0,sizeof(buf));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1476,13 +1476,13 @@ static void *video_grabber(void *data)
ret = v4l2_ioctl(priv->video_fd, VIDIOC_QUERYBUF, &buf);
if (ret < 0) {
MP_ERR(priv, "ioctl query buffer failed: %s, idx = %d\n",
- strerror(errno), buf.index);
+ mp_strerror(errno), buf.index);
return 0;
}
if ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE)) == V4L2_BUF_FLAG_MAPPED) {
if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
MP_ERR(priv, "ioctl queue buffer failed: %s\n",
- strerror(errno));
+ mp_strerror(errno));
return 0;
}
}
@@ -1568,7 +1568,7 @@ static void *video_grabber(void *data)
priv->video_cnt++;
}
if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &buf) < 0) {
- MP_ERR(priv, "ioctl queue buffer failed: %s\n", strerror(errno));
+ MP_ERR(priv, "ioctl queue buffer failed: %s\n", mp_strerror(errno));
return 0;
}
}
diff --git a/video/out/vo_image.c b/video/out/vo_image.c
index a130048e54..ccb8fba830 100644
--- a/video/out/vo_image.c
+++ b/video/out/vo_image.c
@@ -29,6 +29,7 @@
#include "osdep/io.h"
#include "options/path.h"
#include "talloc.h"
+#include "common/common.h"
#include "common/msg.h"
#include "video/out/vo.h"
#include "video/csputils.h"
@@ -52,7 +53,7 @@ static bool checked_mkdir(struct vo *vo, const char *buf)
{
MP_INFO(vo, "Creating output directory '%s'...\n", buf);
if (mkdir(buf, 0755) < 0) {
- char *errstr = strerror(errno);
+ char *errstr = mp_strerror(errno);
if (errno == EEXIST) {
struct stat stat_p;
if (stat(buf, &stat_p ) == 0 && S_ISDIR(stat_p.st_mode))
diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c
index 38a60c1be8..90e3eb52be 100644
--- a/video/out/vo_x11.c
+++ b/video/out/vo_x11.c
@@ -180,8 +180,6 @@ static void getMyXImage(struct priv *p, int foo)
IPC_CREAT | 0777);
if (p->Shminfo[foo].shmid < 0) {
XDestroyImage(p->myximage[foo]);
- MP_VERBOSE(vo, "%s\n", strerror(errno));
- //perror( strerror( errno ) );
MP_WARN(vo, "Shared memory error,disabling ( seg id error )\n");
goto shmemerror;
}