aboutsummaryrefslogtreecommitdiff
path: root/tinymix.c
diff options
context:
space:
mode:
authorSimon Wilson <simonwilson@google.com>2012-03-08 10:15:08 -0800
committerSimon Wilson <simonwilson@google.com>2012-03-08 10:27:40 -0800
commitb29ac1ab6b1f4d78017d652e850a96893347fc29 (patch)
treeb1485ed7c365ad8d7827fb0ba1690d4c293dbd94 /tinymix.c
parent174d874d977cc198a577369e5d161af34fbc0952 (diff)
mixer: simplify string get APIs
Just like the pcm_get_error() API, simplify the mixer API functions to return pointers to constant strings instead of making copies of strings.
Diffstat (limited to 'tinymix.c')
-rw-r--r--tinymix.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/tinymix.c b/tinymix.c
index e7bd276..6427a02 100644
--- a/tinymix.c
+++ b/tinymix.c
@@ -77,9 +77,8 @@ int main(int argc, char **argv)
static void tinymix_list_controls(struct mixer *mixer)
{
struct mixer_ctl *ctl;
- const char *type;
+ const char *name, *type;
unsigned int num_ctls, num_values;
- char buffer[256];
unsigned int i;
num_ctls = mixer_get_num_ctls(mixer);
@@ -90,10 +89,10 @@ static void tinymix_list_controls(struct mixer *mixer)
for (i = 0; i < num_ctls; i++) {
ctl = mixer_get_ctl(mixer, i);
- mixer_ctl_get_name(ctl, buffer, sizeof(buffer));
+ name = mixer_ctl_get_name(ctl);
type = mixer_ctl_get_type_string(ctl);
num_values = mixer_ctl_get_num_values(ctl);
- printf("%d\t%s\t%d\t%-40s", i, type, num_values, buffer);
+ printf("%d\t%s\t%d\t%-40s", i, type, num_values, name);
tinymix_detail_control(mixer, i, 0);
}
}
@@ -101,18 +100,18 @@ static void tinymix_list_controls(struct mixer *mixer)
static void tinymix_print_enum(struct mixer_ctl *ctl, int print_all)
{
unsigned int num_enums;
- char buffer[256];
unsigned int i;
+ const char *string;
num_enums = mixer_ctl_get_num_enums(ctl);
for (i = 0; i < num_enums; i++) {
- mixer_ctl_get_enum_string(ctl, i, buffer, sizeof(buffer));
+ string = mixer_ctl_get_enum_string(ctl, i);
if (print_all)
printf("\t%s%s", mixer_ctl_get_value(ctl, 0) == (int)i ? ">" : "",
- buffer);
+ string);
else if (mixer_ctl_get_value(ctl, 0) == (int)i)
- printf(" %-s", buffer);
+ printf(" %-s", string);
}
}
@@ -122,7 +121,6 @@ static void tinymix_detail_control(struct mixer *mixer, unsigned int id,
struct mixer_ctl *ctl;
enum mixer_ctl_type type;
unsigned int num_values;
- char buffer[256];
unsigned int i;
int min, max;
@@ -133,12 +131,11 @@ static void tinymix_detail_control(struct mixer *mixer, unsigned int id,
ctl = mixer_get_ctl(mixer, id);
- mixer_ctl_get_name(ctl, buffer, sizeof(buffer));
type = mixer_ctl_get_type(ctl);
num_values = mixer_ctl_get_num_values(ctl);
if (print_all)
- printf("%s:", buffer);
+ printf("%s:", mixer_ctl_get_name(ctl));
for (i = 0; i < num_values; i++) {
switch (type)