mirror of
https://github.com/openharmony/third_party_tinyalsa.git
synced 2026-07-18 13:25:09 -04:00
Added function, mixer_get_num_ctls_by_name
This function is used to get the number of mixer controls by a given name. It was added for use with mixer_get_ctl_by_name_and_index so that client code can expect the last valid index to pass.
This commit is contained in:
@@ -73,6 +73,8 @@ const char *mixer_get_name(const struct mixer *mixer);
|
||||
|
||||
unsigned int mixer_get_num_ctls(const struct mixer *mixer);
|
||||
|
||||
unsigned int mixer_get_num_ctls_by_name(const struct mixer *mixer, const char *name);
|
||||
|
||||
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);
|
||||
|
||||
+24
@@ -194,6 +194,30 @@ unsigned int mixer_get_num_ctls(const struct mixer *mixer)
|
||||
return mixer->count;
|
||||
}
|
||||
|
||||
/** Gets the number of mixer controls, that go by a specified name, for a given mixer.
|
||||
* @param mixer An initialized mixer handle.
|
||||
* @param name The name of the mixer control
|
||||
* @returns The number of mixer controls, specified by @p name, for the given mixer.
|
||||
* @ingroup libtinyalsa-mixer
|
||||
*/
|
||||
unsigned int mixer_get_num_ctls_by_name(const struct mixer *mixer, const char *name)
|
||||
{
|
||||
unsigned int n;
|
||||
unsigned int count = 0;
|
||||
struct mixer_ctl *ctl;
|
||||
|
||||
if (!mixer)
|
||||
return 0;
|
||||
|
||||
ctl = mixer->ctl;
|
||||
|
||||
for (n = 0; n < mixer->count; n++)
|
||||
if (!strcmp(name, (char*) ctl[n].info.id.name))
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/** 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.
|
||||
|
||||
Reference in New Issue
Block a user