]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
rawmidi: stream_pair: add an API to drop 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 0429bf36faa1e870ca1f5a45dcb92a7f45a38d7e..9f81ab183cfb3c4ca8a3585cf971341556c2f307 100644 (file)
@@ -20,6 +20,7 @@ ALSA_GOBJECT_0_0_0 {
     "alsarawmidi_stream_pair_read_from_substream";
     "alsarawmidi_stream_pair_write_to_substream";
     "alsarawmidi_stream_pair_drain_substream";
+    "alsarawmidi_stream_pair_drop_substream";
 
     "alsarawmidi_substream_params_get_type";
     "alsarawmidi_substream_params_new";
index bede69fe0d3ffc9ebf0a068f1fddc4d59a48f643..265e0c2eaf6028239644bdd71723fa5f69d601c4 100644 (file)
@@ -324,3 +324,26 @@ void alsarawmidi_stream_pair_drain_substream(ALSARawmidiStreamPair *self,
     if (ioctl(priv->fd, SNDRV_RAWMIDI_IOCTL_DRAIN, &direction) < 0)
         generate_error(error, errno);
 }
+
+/**
+ * alsarawmidi_stream_pair_drop:
+ * @self: A #ALSARawmidiStreamPair.
+ * @direction: The direction of substream attached to the stream pair.
+ * @err: A #GError.
+ *
+ * Drop queued data in intermediate buffer immediately for substream attached
+ * to the pair of streams. In implementation of ALSA rawmidi core, the
+ * direction should be for output substream.
+ */
+void alsarawmidi_stream_pair_drop_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_DROP, &direction) < 0)
+        generate_error(error, errno);
+}
index 7f2ddc9ca1fd2426765fcf27e8f2675e8d858343..79a4d8e8202d562e3443af70f6fe026966ef5804 100644 (file)
@@ -83,6 +83,10 @@ void alsarawmidi_stream_pair_drain_substream(ALSARawmidiStreamPair *self,
                                         ALSARawmidiStreamDirection direction,
                                         GError **error);
 
+void alsarawmidi_stream_pair_drop_substream(ALSARawmidiStreamPair *self,
+                                        ALSARawmidiStreamDirection direction,
+                                        GError **error);
+
 G_END_DECLS
 
 #endif
index 7457b9d014375ee97940638a0a1e398484421a58..300246117ed1a48256149ef8d4d8cf812400b7ef 100644 (file)
@@ -22,6 +22,7 @@ methods = (
     'read_from_substream',
     'write_to_substream',
     'drain_substream',
+    'drop_substream',
 )
 signals = ()