aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tinyalsa/mixer.h2
-rw-r--r--src/mixer.c16
2 files changed, 18 insertions, 0 deletions
diff --git a/include/tinyalsa/mixer.h b/include/tinyalsa/mixer.h
index fb862f3..a54b5c1 100644
--- a/include/tinyalsa/mixer.h
+++ b/include/tinyalsa/mixer.h
@@ -73,6 +73,8 @@ const char *mixer_get_name(const struct mixer *mixer);
unsigned int mixer_get_num_ctls(const struct mixer *mixer);
+const struct mixer_ctl *mixer_get_ctl_const(const struct mixer *mixer, unsigned int id);
+
struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id);
struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name);
diff --git a/src/mixer.c b/src/mixer.c
index 5fed4a8..4bb1756 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -195,6 +195,22 @@ unsigned int mixer_get_num_ctls(const struct mixer *mixer)
}
/** Gets a mixer control handle, by the mixer control's id.
+ * For non-const access, see @ref mixer_get_ctl
+ * @param mixer An initialized mixer handle.
+ * @param id The control's id in the given mixer.
+ * @returns A handle to the mixer control.
+ * @ingroup libtinyalsa-mixer
+ */
+const struct mixer_ctl *mixer_get_ctl_const(const struct mixer *mixer, unsigned int id)
+{
+ if (mixer && (id < mixer->count))
+ return mixer->ctl + id;
+
+ return NULL;
+}
+
+/** Gets a mixer control handle, by the mixer control's id.
+ * For const access, see @ref mixer_get_ctl_const
* @param mixer An initialized mixer handle.
* @param id The control's id in the given mixer.
* @returns A handle to the mixer control.