From: Takashi Sakamoto Date: Tue, 19 Apr 2022 09:41:08 +0000 (+0900) Subject: rawmidi: fix wrong handling of open flag X-Git-Tag: v0.3.0~196 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=7a5694c351619f661082bbacbe84ab85d3dc191a;p=alsa-gobject.git rawmidi: fix wrong handling of open flag ALSARawmidi.StreamPair.open() has open_flag parameter for flags parameter of open(2) system call, however internally it's not handled correctly. This commit fixes the bug. Fixes: 909ff54d5265 ("rawmidi: stream_pair: add APIs to open ALSA Rawmidi character device") Signed-off-by: Takashi Sakamoto --- diff --git a/src/rawmidi/stream-pair.c b/src/rawmidi/stream-pair.c index c2ca684..517d99f 100644 --- a/src/rawmidi/stream-pair.c +++ b/src/rawmidi/stream-pair.c @@ -217,13 +217,14 @@ void alsarawmidi_stream_pair_open(ALSARawmidiStreamPair *self, guint card_id, ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_INPUT)) == 0); g_return_if_fail(error == NULL || *error == NULL); + open_flag &= ~(O_RDWR | O_WRONLY | O_RDONLY); if ((access_modes & ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_OUTPUT) && (access_modes & ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_INPUT)) - open_flag = O_RDWR; + open_flag |= O_RDWR; else if (access_modes & ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_OUTPUT) - open_flag = O_WRONLY; + open_flag |= O_WRONLY; else if (access_modes & ALSARAWMIDI_STREAM_PAIR_INFO_FLAG_INPUT) - open_flag = O_RDONLY; + open_flag |= O_RDONLY; else g_return_if_reached();