From: Takashi Sakamoto Date: Mon, 16 Nov 2020 02:45:41 +0000 (+0900) Subject: rawmidi: stream_pair: report error about write-only file descriptor X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=f6d6c5381129d6990c1baad513d4806222d427ed;p=alsa-gobject.git rawmidi: stream_pair: report error about write-only file descriptor In design of ALSA rawmidi interface, one character device can handle operations for both capture and playback. Applications can indicate usage of both or either by flags of open system call. The libalsarawmidi library checks the flag by fcntl(2) system call to create GSource for capture. When the file descriptor is not configured for read, the call returns error. This commit handles the error for local error reporting. Signed-off-by: Takashi Sakamoto --- diff --git a/src/rawmidi/alsarawmidi-enum-types.h b/src/rawmidi/alsarawmidi-enum-types.h index 6da9cb2..7c385b1 100644 --- a/src/rawmidi/alsarawmidi-enum-types.h +++ b/src/rawmidi/alsarawmidi-enum-types.h @@ -35,12 +35,14 @@ typedef enum /*< flags >*/ * ALSARawmidiStreamPairError: * @ALSARAWMIDI_STREAM_PAIR_ERROR_FAILED: The system call failed. * @ALSARAWMIDI_STREAM_PAIR_ERROR_DISCONNECTED: The card associated to the instance is in disconnect state. + * @ALSARAWMIDI_STREAM_PAIR_ERROR_UNREADABLE: The instance is not for read operation. * * A set of error code for GError with domain which equals to #alsarawmidi_stream_pair_error_quark() */ typedef enum { ALSARAWMIDI_STREAM_PAIR_ERROR_FAILED, ALSARAWMIDI_STREAM_PAIR_ERROR_DISCONNECTED, + ALSARAWMIDI_STREAM_PAIR_ERROR_UNREADABLE, } ALSARawmidiStreamPairError; #endif diff --git a/src/rawmidi/stream-pair.c b/src/rawmidi/stream-pair.c index 9c4b034..3e62dc1 100644 --- a/src/rawmidi/stream-pair.c +++ b/src/rawmidi/stream-pair.c @@ -52,6 +52,7 @@ G_DEFINE_QUARK(alsarawmidi-stream-pair-error-quark, alsarawmidi_stream_pair_erro static const char *const err_msgs[] = { [ALSARAWMIDI_STREAM_PAIR_ERROR_DISCONNECTED] = "The card is in disconnect state", + [ALSARAWMIDI_STREAM_PAIR_ERROR_UNREADABLE] = "The instance is not for read operation", }; #define generate_local_error(error, code) \ @@ -662,7 +663,7 @@ void alsarawmidi_stream_pair_create_source(ALSARawmidiStreamPair *self, } if (!(access_modes & O_RDWR) && !(access_modes & O_WRONLY)) { - generate_error(error, ENOTSUP); + generate_local_error(error, ALSARAWMIDI_STREAM_PAIR_ERROR_UNREADABLE); return; }