Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "get" routines for channel and filter masks? #82

Open
mhalog78 opened this issue Jan 24, 2025 · 0 comments
Open

Add "get" routines for channel and filter masks? #82

mhalog78 opened this issue Jan 24, 2025 · 0 comments

Comments

@mhalog78
Copy link

Would 'get' methods for the channel and filter masks be worthwhile?
Here's a diff:

--- portmidi.c-ORIG	2025-01-07 17:42:22.000000000 -0600
+++ portmidi.c	2025-01-22 15:35:13.000000000 -0600
@@ -1138,6 +1140,18 @@
     return pm_errmsg(err);
 }
 
+PMEXPORT PmError Pm_GetChannelMask(PortMidiStream *stream, int *mask)
+{
+    PmInternal *midi = (PmInternal *) stream;
+    PmError err = pmNoError;
+
+    if (midi == NULL)
+        err = pmBadPtr;
+    else 
+        *mask = midi->channel_mask;
+    return pm_errmsg(err);
+}
+
 
 PMEXPORT PmError Pm_SetFilter(PortMidiStream *stream, int32_t filters)
 {
@@ -1154,6 +1168,21 @@
     return pm_errmsg(err);
 }
 
+PMEXPORT PmError Pm_GetFilter(PortMidiStream *stream, int32_t *filters)
+{
+    PmInternal *midi = (PmInternal *) stream;
+    PmError err = pmNoError;
+
+    /* arg checking */
+    if (midi == NULL)
+        err = pmBadPtr;
+    else if (!pm_descriptors[midi->device_id].pub.opened)
+        err = pmBadPtr;
+    else 
+        *filters = midi->filters;
+    return pm_errmsg(err);
+}
+
 
 PMEXPORT PmError Pm_Close(PortMidiStream *stream)
 {

Oops! I should test 'mask' and 'filters' for NULL, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant