From: Takashi Sakamoto Date: Sun, 15 Nov 2020 02:54:07 +0000 (+0900) Subject: seq: user_client: report error for queue access permission X-Git-Tag: v0.1.99~42 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=1dfb6979c0f47ace670bcc5dc6969a0c94c4be15;p=alsa-gobject.git seq: user_client: report error for queue access permission Queue in ALSA sequencer has locking mechanism and client has access permission to operate the queue. When unpermitted, the operation fails and return EPERM error code. This commit handles the code for local error. Signed-off-by: Takashi Sakamoto --- diff --git a/src/seq/alsaseq-enum-types.h b/src/seq/alsaseq-enum-types.h index b741e81..b7f3f91 100644 --- a/src/seq/alsaseq-enum-types.h +++ b/src/seq/alsaseq-enum-types.h @@ -366,12 +366,14 @@ typedef enum /*< flags >*/ * ALSASeqUserClientError: * @ALSASEQ_USER_CLIENT_ERROR_FAILED: The system call failed. * @ALSASEQ_USER_CLIENT_ERROR_PORT_PERMISSION: The operation fails due to access permission of port. + * @ALSASEQ_USER_CLIENT_ERROR_QUEUE_PERMISSION: The operation fails due to access permission of queue. * * A set of error code for GError with domain which equals to #alsaseq_user_client_error_quark() */ typedef enum { ALSASEQ_USER_CLIENT_ERROR_FAILED, ALSASEQ_USER_CLIENT_ERROR_PORT_PERMISSION, + ALSASEQ_USER_CLIENT_ERROR_QUEUE_PERMISSION, } ALSASeqUserClientError; #endif diff --git a/src/seq/user-client.c b/src/seq/user-client.c index 2f1b3dd..e289f70 100644 --- a/src/seq/user-client.c +++ b/src/seq/user-client.c @@ -45,6 +45,7 @@ G_DEFINE_QUARK(alsaseq-user-client-error-quark, alsaseq_user_client_error) static const char *const err_msgs[] = { [ALSASEQ_USER_CLIENT_ERROR_PORT_PERMISSION] = "The operation fails due to access permission of port", + [ALSASEQ_USER_CLIENT_ERROR_QUEUE_PERMISSION] = "The operation fails due to access permission of queue", }; #define generate_local_error(exception, code) \ @@ -780,8 +781,12 @@ void alsaseq_user_client_update_queue(ALSASeqUserClient *self, seq_queue_info_refer_private(queue_info, &info); - if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_INFO, info) < 0) - generate_syscall_error(error, errno, "ioctl(%s)", "SET_QUEUE_INFO"); + if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_INFO, info) < 0) { + if (errno == EPERM) + generate_local_error(error, ALSASEQ_USER_CLIENT_ERROR_QUEUE_PERMISSION); + else + generate_syscall_error(error, errno, "ioctl(%s)", "SET_QUEUE_INFO"); + } } /** @@ -880,8 +885,12 @@ void alsaseq_user_client_set_queue_tempo(ALSASeqUserClient *self, seq_queue_tempo_refer_private(queue_tempo, &tempo); tempo->queue = queue_id; - if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO, tempo) < 0) - generate_syscall_error(error, errno, "ioctl(%s)", "SET_QUEUE_TEMPO"); + if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO, tempo) < 0) { + if (errno == EPERM) + generate_local_error(error, ALSASEQ_USER_CLIENT_ERROR_QUEUE_PERMISSION); + else + generate_syscall_error(error, errno, "ioctl(%s)", "SET_QUEUE_TEMPO"); + } } /** @@ -959,8 +968,12 @@ void alsaseq_user_client_set_queue_timer(ALSASeqUserClient *self, } timer->queue = queue_id; - if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER, timer) < 0) - generate_syscall_error(error, errno, "ioctl(%s)", "SET_QUEUE_TIMER"); + if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER, timer) < 0) { + if (errno == EPERM) + generate_local_error(error, ALSASEQ_USER_CLIENT_ERROR_QUEUE_PERMISSION); + else + generate_syscall_error(error, errno, "ioctl(%s)", "SET_QUEUE_TIMER"); + } } /** diff --git a/tests/alsaseq-enums b/tests/alsaseq-enums index 602ea8c..88c0af0 100644 --- a/tests/alsaseq-enums +++ b/tests/alsaseq-enums @@ -167,6 +167,7 @@ remove_filter_flags = ( user_client_error_types = ( 'FAILED', 'PORT_PERMISSION', + 'QUEUE_PERMISSION', ) types = {