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 <o-takashi@sakamocchi.jp>
* 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
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) \
}
if (!(access_modes & O_RDWR) && !(access_modes & O_WRONLY)) {
- generate_error(error, ENOTSUP);
+ generate_local_error(error, ALSARAWMIDI_STREAM_PAIR_ERROR_UNREADABLE);
return;
}