alsa/alsa-lib-pcm-show-errno.diff

337 lines
11 KiB
Diff

From a55e1ded9914788c1a02bb25857e17d98ab676b5 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Wed, 10 Mar 2010 09:40:02 +0100
Subject: [PATCH] pcm_hw - show errno codes
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
src/pcm/pcm_hw.c | 72 +++++++++++++++++++++++++++---------------------------
1 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 265335c..9d243d5 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -135,7 +135,7 @@ static int sync_ptr1(snd_pcm_hw_t *hw, unsigned int flags)
err = ioctl((hw)->fd, SNDRV_PCM_IOCTL_SYNC_PTR, (hw)->sync_ptr);
if (err < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed");
+ SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err);
return err;
}
return 0;
@@ -202,7 +202,7 @@ static int snd_pcm_hw_nonblock(snd_pcm_t *pcm, int nonblock)
if ((flags = fcntl(fd, F_GETFL)) < 0) {
err = -errno;
- SYSMSG("F_GETFL failed");
+ SYSMSG("F_GETFL failed (%i)", err);
return err;
}
if (nonblock)
@@ -211,7 +211,7 @@ static int snd_pcm_hw_nonblock(snd_pcm_t *pcm, int nonblock)
flags &= ~O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) < 0) {
err = -errno;
- SYSMSG("F_SETFL for O_NONBLOCK failed");
+ SYSMSG("F_SETFL for O_NONBLOCK failed (%i)", err);
return err;
}
return 0;
@@ -225,7 +225,7 @@ static int snd_pcm_hw_async(snd_pcm_t *pcm, int sig, pid_t pid)
if ((flags = fcntl(fd, F_GETFL)) < 0) {
err = -errno;
- SYSMSG("F_GETFL failed");
+ SYSMSG("F_GETFL failed (%i)", err);
return err;
}
if (sig >= 0)
@@ -234,19 +234,19 @@ static int snd_pcm_hw_async(snd_pcm_t *pcm, int sig, pid_t pid)
flags &= ~O_ASYNC;
if (fcntl(fd, F_SETFL, flags) < 0) {
err = -errno;
- SYSMSG("F_SETFL for O_ASYNC failed");
+ SYSMSG("F_SETFL for O_ASYNC failed (%i)", err);
return err;
}
if (sig < 0)
return 0;
if (fcntl(fd, F_SETSIG, (long)sig) < 0) {
err = -errno;
- SYSMSG("F_SETSIG failed");
+ SYSMSG("F_SETSIG failed (%i)", err);
return err;
}
if (fcntl(fd, F_SETOWN, (long)pid) < 0) {
err = -errno;
- SYSMSG("F_SETOWN failed");
+ SYSMSG("F_SETOWN failed (%i)", err);
return err;
}
return 0;
@@ -258,7 +258,7 @@ static int snd_pcm_hw_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, info) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_INFO failed");
+ SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", err);
return err;
}
return 0;
@@ -323,7 +323,7 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
int err;
if (hw_params_call(hw, params) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_HW_PARAMS failed");
+ SYSMSG("SNDRV_PCM_IOCTL_HW_PARAMS failed (%i)", err);
return err;
}
params->info &= ~0xf0000000;
@@ -421,7 +421,7 @@ static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)
snd_pcm_hw_change_timer(pcm, 0);
if (ioctl(fd, SNDRV_PCM_IOCTL_HW_FREE) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_HW_FREE failed");
+ SYSMSG("SNDRV_PCM_IOCTL_HW_FREE failed (%i)", err);
return err;
}
return 0;
@@ -445,7 +445,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
}
if (ioctl(fd, SNDRV_PCM_IOCTL_SW_PARAMS, params) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed");
+ SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err);
return err;
}
params->period_event = old_period_event;
@@ -467,7 +467,7 @@ static int snd_pcm_hw_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info
i.channel = info->channel;
if (ioctl(fd, SNDRV_PCM_IOCTL_CHANNEL_INFO, &i) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_CHANNEL_INFO failed");
+ SYSMSG("SNDRV_PCM_IOCTL_CHANNEL_INFO failed (%i)", err);
return err;
}
info->channel = i.channel;
@@ -486,7 +486,7 @@ static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_STATUS, status) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_STATUS failed");
+ SYSMSG("SNDRV_PCM_IOCTL_STATUS failed (%i)", err);
return err;
}
if (SNDRV_PROTOCOL_VERSION(2, 0, 5) > hw->version) {
@@ -511,7 +511,7 @@ static int snd_pcm_hw_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_DELAY, delayp) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_DELAY failed");
+ SYSMSG("SNDRV_PCM_IOCTL_DELAY failed (%i)", err);
return err;
}
return 0;
@@ -529,7 +529,7 @@ static int snd_pcm_hw_hwsync(snd_pcm_t *pcm)
} else {
if (ioctl(fd, SNDRV_PCM_IOCTL_HWSYNC) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_HWSYNC failed");
+ SYSMSG("SNDRV_PCM_IOCTL_HWSYNC failed (%i)", err);
return err;
}
}
@@ -555,7 +555,7 @@ static int snd_pcm_hw_prepare(snd_pcm_t *pcm)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_PREPARE) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_PREPARE failed");
+ SYSMSG("SNDRV_PCM_IOCTL_PREPARE failed (%i)", err);
return err;
}
return sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL);
@@ -567,7 +567,7 @@ static int snd_pcm_hw_reset(snd_pcm_t *pcm)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_RESET) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_RESET failed");
+ SYSMSG("SNDRV_PCM_IOCTL_RESET failed (%i)", err);
return err;
}
return sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL);
@@ -584,7 +584,7 @@ static int snd_pcm_hw_start(snd_pcm_t *pcm)
sync_ptr(hw, 0);
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_START) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_START failed");
+ SYSMSG("SNDRV_PCM_IOCTL_START failed (%i)", err);
#if 0
if (err == -EBADFD)
SNDERR("PCM state = %s", snd_pcm_state_name(snd_pcm_hw_state(pcm)));
@@ -600,7 +600,7 @@ static int snd_pcm_hw_drop(snd_pcm_t *pcm)
int err;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_DROP) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_DROP failed");
+ SYSMSG("SNDRV_PCM_IOCTL_DROP failed (%i)", err);
return err;
} else {
}
@@ -613,7 +613,7 @@ static int snd_pcm_hw_drain(snd_pcm_t *pcm)
int err;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_DRAIN) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_DRAIN failed");
+ SYSMSG("SNDRV_PCM_IOCTL_DRAIN failed (%i)", err);
return err;
}
return 0;
@@ -625,7 +625,7 @@ static int snd_pcm_hw_pause(snd_pcm_t *pcm, int enable)
int err;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_PAUSE, enable) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_PAUSE failed");
+ SYSMSG("SNDRV_PCM_IOCTL_PAUSE failed (%i)", err);
return err;
}
return 0;
@@ -642,7 +642,7 @@ static snd_pcm_sframes_t snd_pcm_hw_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t fra
int err;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_REWIND, &frames) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_REWIND failed");
+ SYSMSG("SNDRV_PCM_IOCTL_REWIND failed (%i)", err);
return err;
}
err = sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL);
@@ -663,7 +663,7 @@ static snd_pcm_sframes_t snd_pcm_hw_forward(snd_pcm_t *pcm, snd_pcm_uframes_t fr
if (SNDRV_PROTOCOL_VERSION(2, 0, 4) <= hw->version) {
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_FORWARD, &frames) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_FORWARD failed");
+ SYSMSG("SNDRV_PCM_IOCTL_FORWARD failed (%i)", err);
return err;
}
err = sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL);
@@ -706,7 +706,7 @@ static int snd_pcm_hw_resume(snd_pcm_t *pcm)
int fd = hw->fd, err;
if (ioctl(fd, SNDRV_PCM_IOCTL_RESUME) < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_RESUME failed");
+ SYSMSG("SNDRV_PCM_IOCTL_RESUME failed (%i)", err);
return err;
}
return 0;
@@ -717,7 +717,7 @@ static int hw_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
snd_pcm_hw_t *hw1 = pcm1->private_data;
snd_pcm_hw_t *hw2 = pcm2->private_data;
if (ioctl(hw1->fd, SNDRV_PCM_IOCTL_LINK, hw2->fd) < 0) {
- SYSMSG("SNDRV_PCM_IOCTL_LINK failed");
+ SYSMSG("SNDRV_PCM_IOCTL_LINK failed (%i)", -errno);
return -errno;
}
return 0;
@@ -726,7 +726,7 @@ static int hw_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
static int snd_pcm_hw_link_slaves(snd_pcm_t *pcm, snd_pcm_t *master)
{
if (master->type != SND_PCM_TYPE_HW) {
- SYSMSG("Invalid type for SNDRV_PCM_IOCTL_LINK");
+ SYSMSG("Invalid type for SNDRV_PCM_IOCTL_LINK (%i)", master->type);
return -EINVAL;
}
return hw_link(master, pcm);
@@ -747,7 +747,7 @@ static int snd_pcm_hw_unlink(snd_pcm_t *pcm)
snd_pcm_hw_t *hw = pcm->private_data;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_UNLINK) < 0) {
- SYSMSG("SNDRV_PCM_IOCTL_UNLINK failed");
+ SYSMSG("SNDRV_PCM_IOCTL_UNLINK failed (%i)", -errno);
return -errno;
}
return 0;
@@ -847,7 +847,7 @@ static int snd_pcm_hw_mmap_status(snd_pcm_t *pcm)
err = ioctl(hw->fd, SNDRV_PCM_IOCTL_SYNC_PTR, &sync_ptr);
if (err < 0) {
err = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed");
+ SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err);
return err;
}
hw->sync_ptr = calloc(1, sizeof(struct sndrv_pcm_sync_ptr));
@@ -874,7 +874,7 @@ static int snd_pcm_hw_mmap_control(snd_pcm_t *pcm)
hw->fd, SNDRV_PCM_MMAP_OFFSET_CONTROL);
if (ptr == MAP_FAILED || ptr == NULL) {
err = -errno;
- SYSMSG("control mmap failed");
+ SYSMSG("control mmap failed (%i)", err);
return err;
}
hw->mmap_control = ptr;
@@ -895,7 +895,7 @@ static int snd_pcm_hw_munmap_status(snd_pcm_t *pcm)
} else {
if (munmap((void*)hw->mmap_status, page_align(sizeof(*hw->mmap_status))) < 0) {
err = -errno;
- SYSMSG("status munmap failed");
+ SYSMSG("status munmap failed (%i)", err);
return err;
}
}
@@ -912,7 +912,7 @@ static int snd_pcm_hw_munmap_control(snd_pcm_t *pcm)
} else {
if (munmap(hw->mmap_control, page_align(sizeof(*hw->mmap_control))) < 0) {
err = -errno;
- SYSMSG("control munmap failed");
+ SYSMSG("control munmap failed (%i)", err);
return err;
}
}
@@ -935,7 +935,7 @@ static int snd_pcm_hw_close(snd_pcm_t *pcm)
int err = 0;
if (close(hw->fd)) {
err = -errno;
- SYSMSG("close failed\n");
+ SYSMSG("close failed (%i)\n", err);
}
snd_pcm_hw_munmap_status(pcm);
snd_pcm_hw_munmap_control(pcm);
@@ -1129,7 +1129,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
memset(&info, 0, sizeof(info));
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) < 0) {
ret = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_INFO failed");
+ SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", ret);
close(fd);
return ret;
@@ -1148,7 +1148,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
if (ioctl(fd, SNDRV_PCM_IOCTL_PVERSION, &ver) < 0) {
ret = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_PVERSION failed");
+ SYSMSG("SNDRV_PCM_IOCTL_PVERSION failed (%i)", ret);
close(fd);
return ret;
}
@@ -1290,14 +1290,14 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
fd = snd_open_device(filename, fmode);
if (fd < 0) {
ret = -errno;
- SYSMSG("open %s failed", filename);
+ SYSMSG("open '%s' failed (%i)", filename, ret);
goto _err;
}
if (subdevice >= 0) {
memset(&info, 0, sizeof(info));
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) < 0) {
ret = -errno;
- SYSMSG("SNDRV_PCM_IOCTL_INFO failed");
+ SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", ret);
goto _err;
}
if (info.subdevice != (unsigned int) subdevice) {
--
1.7.0.2