]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
rawmidi: stream_pair: add an API to drain queued data for attached substream
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 18 Nov 2019 04:22:44 +0000 (13:22 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Sun, 12 Apr 2020 05:30:33 +0000 (14:30 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/rawmidi/alsarawmidi.map
src/rawmidi/stream-pair.c
src/rawmidi/stream-pair.h
tests/alsarawmidi-stream-pair

index 2994533b5157801980b158c3da3f4c5aee27e921..0429bf36faa1e870ca1f5a45dcb92a7f45a38d7e 100644 (file)
@@ -19,6 +19,7 @@ ALSA_GOBJECT_0_0_0 {
     "alsarawmidi_stream_pair_get_substream_status";
     "alsarawmidi_stream_pair_read_from_substream";
     "alsarawmidi_stream_pair_write_to_substream";
+    "alsarawmidi_stream_pair_drain_substream";
 
     "alsarawmidi_substream_params_get_type";
     "alsarawmidi_substream_params_new";
index 0bf91bcd40b3755b2ce8345acf3215871e9820f2..bede69fe0d3ffc9ebf0a068f1fddc4d59a48f643 100644 (file)
@@ -300,3 +300,27 @@ void alsarawmidi_stream_pair_write_to_substream(ALSARawmidiStreamPair *self,
         return;
     }
 }
+
+/**
+ * alsarawmidi_stream_pair_drain:
+ * @self: A #ALSARawmidiStreamPair.
+ * @direction: The direction of substream attached to the stream pair.
+ * @error: A #GError.
+ *
+ * Drain queued data in intermediate buffer for substream attached to the pair
+ * of streams. In a case that the instance is opened without O_NONBLOCK and the
+ * call is for output substream and any data is in the intermediate buffer, the
+ * call is blocked till no data is in the intermediate buffer.
+ */
+void alsarawmidi_stream_pair_drain_substream(ALSARawmidiStreamPair *self,
+                                        ALSARawmidiStreamDirection direction,
+                                        GError **error)
+{
+    ALSARawmidiStreamPairPrivate *priv;
+
+    g_return_if_fail(ALSARAWMIDI_IS_STREAM_PAIR(self));
+    priv = alsarawmidi_stream_pair_get_instance_private(self);
+
+    if (ioctl(priv->fd, SNDRV_RAWMIDI_IOCTL_DRAIN, &direction) < 0)
+        generate_error(error, errno);
+}
index ffa80e67b3185e9848fa7c8c87ab241a0dcaa70f..7f2ddc9ca1fd2426765fcf27e8f2675e8d858343 100644 (file)
@@ -79,6 +79,10 @@ void alsarawmidi_stream_pair_write_to_substream(ALSARawmidiStreamPair *self,
                                         const guint8 *buf, gsize buf_size,
                                         GError **error);
 
+void alsarawmidi_stream_pair_drain_substream(ALSARawmidiStreamPair *self,
+                                        ALSARawmidiStreamDirection direction,
+                                        GError **error);
+
 G_END_DECLS
 
 #endif
index 433c74d94fa72f6c68578c04a606774c8dea4637..7457b9d014375ee97940638a0a1e398484421a58 100644 (file)
@@ -21,6 +21,7 @@ methods = (
     'get_substream_status',
     'read_from_substream',
     'write_to_substream',
+    'drain_substream',
 )
 signals = ()