[alsa-devel] [PATCH alsa-lib 0/2] pcm: minor code cleanup
Hi,
This includes two patches from my previous RFC for minor code cleanup: [alsa-devel] [alsa-lib][RFC][PATCH 0/9] pcm: handle status/control mapping independently http://mailman.alsa-project.org/pipermail/alsa-devel/2017-June/122130.html
Takashi Sakamoto (2): pcm: obsolete 'mmap_emulation' parameter of snd_pcm_hw_open_fd() pcm: minor code cleanup for ioctl call
src/pcm/pcm_direct.c | 2 +- src/pcm/pcm_hw.c | 9 +++------ src/pcm/pcm_local.h | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-)
A function, snd_pcm_hw_open_fd(), is just for internal use. This function has an obsoleted parameter and we can remove it without any compatibility issue.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- src/pcm/pcm_direct.c | 2 +- src/pcm/pcm_hw.c | 6 ++---- src/pcm/pcm_local.h | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 43702601..9fd376d8 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -1523,7 +1523,7 @@ int snd_pcm_direct_open_secondary_client(snd_pcm_t **spcmp, snd_pcm_direct_t *dm int ret; snd_pcm_t *spcm;
- ret = snd_pcm_hw_open_fd(spcmp, client_name, dmix->hw_fd, 0, 0); + ret = snd_pcm_hw_open_fd(spcmp, client_name, dmix->hw_fd, 0); if (ret < 0) { SNDERR("unable to open hardware"); return ret; diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 30cd5d0f..f0efcde3 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -1410,15 +1410,13 @@ static const snd_pcm_fast_ops_t snd_pcm_hw_fast_ops_timer = { * \param pcmp Returns created PCM handle * \param name Name of PCM * \param fd File descriptor - * \param mmap_emulation Obsoleted parameter * \param sync_ptr_ioctl Boolean flag for sync_ptr ioctl * \retval zero on success otherwise a negative error code * \warning Using of this function might be dangerous in the sense * of compatibility reasons. The prototype might be freely * changed in future. */ -int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, - int fd, int mmap_emulation ATTRIBUTE_UNUSED, +int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, int sync_ptr_ioctl) { int ver, mode; @@ -1615,7 +1613,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, } } snd_ctl_close(ctl); - return snd_pcm_hw_open_fd(pcmp, name, fd, 0, sync_ptr_ioctl); + return snd_pcm_hw_open_fd(pcmp, name, fd, sync_ptr_ioctl); _err: snd_ctl_close(ctl); return ret; diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index e4f65218..7600daa3 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -935,7 +935,8 @@ snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root,
#define snd_pcm_conf_generic_id(id) _snd_conf_generic_id(id)
-int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, int mmap_emulation, int sync_ptr_ioctl); +int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, + int sync_ptr_ioctl); int __snd_pcm_mmap_emul_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int close_slave);
When error occurs, return value from ioctl(2) is -1 and error code can be got thread local variable, errno. It's OK just to check the return value without any assignment.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- src/pcm/pcm_hw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index f0efcde3..de6fd1af 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -132,8 +132,7 @@ static int sync_ptr1(snd_pcm_hw_t *hw, unsigned int flags) { int err; hw->sync_ptr->flags = flags; - err = ioctl((hw)->fd, SNDRV_PCM_IOCTL_SYNC_PTR, (hw)->sync_ptr); - if (err < 0) { + if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SYNC_PTR, hw->sync_ptr) < 0) { err = -errno; SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err); return err;
On Fri, 23 Jun 2017 15:09:22 +0200, Takashi Sakamoto wrote:
Hi,
This includes two patches from my previous RFC for minor code cleanup: [alsa-devel] [alsa-lib][RFC][PATCH 0/9] pcm: handle status/control mapping independently http://mailman.alsa-project.org/pipermail/alsa-devel/2017-June/122130.html
Takashi Sakamoto (2): pcm: obsolete 'mmap_emulation' parameter of snd_pcm_hw_open_fd() pcm: minor code cleanup for ioctl call
Applied both patches now. Thanks.
Takashi
participants (2)
-
Takashi Iwai
-
Takashi Sakamoto