* @ALSATIMER_USER_INSTANCE_ERROR_TIMER_NOT_FOUND: The timer instance is not found.
* @ALSATIMER_USER_INSTANCE_ERROR_NOT_ATTACHED: The timer instance is not attached to any timer
* device or the other instance.
+ * @ALSATIMER_USER_INSTANCE_ERROR_ATTACHED: The timer instance is already attached to timer
+ * device or the other instance.
*
* A set of error code for GError with domain which equals to #alsatimer_user_instance_error_quark()
*/
ALSATIMER_USER_INSTANCE_ERROR_FAILED,
ALSATIMER_USER_INSTANCE_ERROR_TIMER_NOT_FOUND,
ALSATIMER_USER_INSTANCE_ERROR_NOT_ATTACHED,
+ ALSATIMER_USER_INSTANCE_ERROR_ATTACHED,
} ALSATimerUserInstanceError;
#endif
static const char *const err_msgs[] = {
[ALSATIMER_USER_INSTANCE_ERROR_TIMER_NOT_FOUND] = "The timer instance is not found",
[ALSATIMER_USER_INSTANCE_ERROR_NOT_ATTACHED] = "The timer instance is not attached to any timer device or the other instance",
+ [ALSATIMER_USER_INSTANCE_ERROR_ATTACHED] = "The timer instance is already attached to timer device or the other instance",
};
#define generate_local_error(exception, code) \
g_return_if_fail(error == NULL || *error == NULL);
tread = (int)event_data_type;
- if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_TREAD, &tread) < 0)
- generate_syscall_error(error, errno, "ioctl(%s)", "TREAD");
- else
+ if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_TREAD, &tread) < 0) {
+ if (errno == EBUSY)
+ generate_local_error(error, ALSATIMER_USER_INSTANCE_ERROR_ATTACHED);
+ else
+ generate_syscall_error(error, errno, "ioctl(%s)", "TREAD");
+ } else {
priv->event_data_type = event_data_type;
+ }
}
/**