]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
rawmidi: fix wrong handling of open flag
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 3 Apr 2022 01:51:39 +0000 (10:51 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 3 Apr 2022 02:02:41 +0000 (11:02 +0900)
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")
src/rawmidi/stream-pair.c

index 919a0d2092c6202a4c5f66a8a3a3e9948724ae2c..96f05de6bc6fac8578d3e8dd73c5eed4b9944f47 100644 (file)
@@ -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();