/**
* ALSASeqUserClientError:
- * @ALSASEQ_USER_CLIENT_ERROR_FAILED: The system call failed.
+ * @ALSASEQ_USER_CLIENT_ERROR_FAILED: The system call failed.
+ * @ALSASEQ_USER_CLIENT_ERROR_PORT_PERMISSION: The operation fails due to access permission of port.
*
* 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,
} ALSASeqUserClientError;
#endif
*/
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",
+};
+
+#define generate_local_error(exception, code) \
+ g_set_error_literal(exception, ALSASEQ_USER_CLIENT_ERROR, code, err_msgs[code])
+
#define generate_syscall_error(exception, errno, fmt, arg) \
g_set_error(exception, ALSASEQ_USER_CLIENT_ERROR, ALSASEQ_USER_CLIENT_ERROR_FAILED, \
fmt" %d(%s)", arg, errno, strerror(errno))
label = "UNSUBSCRIBE_PORT";
}
- if (ioctl(priv->fd, request, data) < 0)
- generate_syscall_error(error, errno, "ioctl(%s)", label);
+ if (ioctl(priv->fd, request, data) < 0) {
+ if (errno == EPERM)
+ generate_local_error(error, ALSASEQ_USER_CLIENT_ERROR_PORT_PERMISSION);
+ else
+ generate_syscall_error(error, errno, "ioctl(%s)", label);
+ }
}
/**