"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "alsaucm/usecase.c" between
alsa-utils-1.2.1.tar.bz2 and alsa-utils-1.2.2.tar.bz2

About: ALSA (Advanced Linux Sound Architecture) - Utilities.

usecase.c  (alsa-utils-1.2.1.tar.bz2):usecase.c  (alsa-utils-1.2.2.tar.bz2)
skipping to change at line 41 skipping to change at line 41
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <getopt.h> #include <getopt.h>
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include <alsa/use-case.h> #include <alsa/use-case.h>
#include "usecase.h"
#include "aconfig.h" #include "aconfig.h"
#include "version.h" #include "version.h"
#define MAX_BUF 256 #define MAX_BUF 256
struct context {
snd_use_case_mgr_t *uc_mgr;
const char *command;
char *card;
char **argv;
int argc;
int arga;
char *batch;
unsigned int interactive:1;
unsigned int no_open:1;
unsigned int do_exit:1;
};
enum uc_cmd { enum uc_cmd {
/* management */ /* management */
OM_UNKNOWN = 0, OM_UNKNOWN = 0,
OM_OPEN, OM_OPEN,
OM_RESET, OM_RESET,
OM_RELOAD, OM_RELOAD,
OM_LISTCARDS, OM_LISTCARDS,
OM_DUMP,
OM_LIST2, OM_LIST2,
OM_LIST1, OM_LIST1,
/* set/get */ /* set/get */
OM_SET, OM_SET,
OM_GET, OM_GET,
OM_GETI, OM_GETI,
/* misc */ /* misc */
OM_HELP, OM_HELP,
skipping to change at line 91 skipping to change at line 80
int args; int args;
unsigned int opencard:1; unsigned int opencard:1;
const char *id; const char *id;
}; };
static struct cmd cmds[] = { static struct cmd cmds[] = {
{ OM_OPEN, 1, 0, "open" }, { OM_OPEN, 1, 0, "open" },
{ OM_RESET, 0, 1, "reset" }, { OM_RESET, 0, 1, "reset" },
{ OM_RELOAD, 0, 1, "reload" }, { OM_RELOAD, 0, 1, "reload" },
{ OM_LISTCARDS, 0, 0, "listcards" }, { OM_LISTCARDS, 0, 0, "listcards" },
{ OM_DUMP, 1, 1, "dump" },
{ OM_LIST1, 1, 1, "list1" }, { OM_LIST1, 1, 1, "list1" },
{ OM_LIST2, 1, 1, "list" }, { OM_LIST2, 1, 1, "list" },
{ OM_SET, 2, 1, "set" }, { OM_SET, 2, 1, "set" },
{ OM_GET, 1, 1, "get" }, { OM_GET, 1, 1, "get" },
{ OM_GETI, 1, 1, "geti" }, { OM_GETI, 1, 1, "geti" },
{ OM_DUMP, 1, 1, "dump" },
{ OM_HELP, 0, 0, "help" }, { OM_HELP, 0, 0, "help" },
{ OM_QUIT, 0, 0, "quit" }, { OM_QUIT, 0, 0, "quit" },
{ OM_HELP, 0, 0, "h" }, { OM_HELP, 0, 0, "h" },
{ OM_HELP, 0, 0, "?" }, { OM_HELP, 0, 0, "?" },
{ OM_QUIT, 0, 0, "q" }, { OM_QUIT, 0, 0, "q" },
{ OM_UNKNOWN, 0, 0, NULL } { OM_UNKNOWN, 0, 0, NULL }
}; };
static void dump_help(struct context *context) static void dump_help(struct context *context)
{ {
skipping to change at line 120 skipping to change at line 111
" -h,--help this help\n" " -h,--help this help\n"
" -c,--card NAME open card NAME\n" " -c,--card NAME open card NAME\n"
" -i,--interactive interactive mode\n" " -i,--interactive interactive mode\n"
" -b,--batch FILE batch mode (use '-' for the stdin input)\n" " -b,--batch FILE batch mode (use '-' for the stdin input)\n"
" -n,--no-open do not open first card found\n" " -n,--no-open do not open first card found\n"
"\nAvailable commands:\n" "\nAvailable commands:\n"
" open NAME open card NAME\n" " open NAME open card NAME\n"
" reset reset sound card to default state\n" " reset reset sound card to default state\n"
" reload reload configuration\n" " reload reload configuration\n"
" listcards list available cards\n" " listcards list available cards\n"
" dump FORMAT dump all config information (format: text,json)\n"
" list IDENTIFIER list command, for items with value + comment\n" " list IDENTIFIER list command, for items with value + comment\n"
" list1 IDENTIFIER list command, for items without comments\n" " list1 IDENTIFIER list command, for items without comments\n"
" get IDENTIFIER get string value\n" " get IDENTIFIER get string value\n"
" geti IDENTIFIER get integer value\n" " geti IDENTIFIER get integer value\n"
" set IDENTIFIER VALUE set string value\n" " set IDENTIFIER VALUE set string value\n"
" h,help help\n" " h,help help\n"
" q,quit quit\n" " q,quit quit\n"
); );
} }
skipping to change at line 188 skipping to change at line 180
if (context->arga > 0) if (context->arga > 0)
free(context->argv); free(context->argv);
if (context->card) if (context->card)
free(context->card); free(context->card);
if (context->batch) if (context->batch)
free(context->batch); free(context->batch);
free(context); free(context);
snd_config_update_free_global(); snd_config_update_free_global();
exit(exitcode); exit(exitcode);
} }
static void do_initial_open(struct context *context) static void do_initial_open(struct context *context)
{ {
const char **list; int card, err;
int err; char name[16];
if (!context->no_open && context->card == NULL) { if (!context->no_open && context->card == NULL) {
err = snd_use_case_card_list(&list); card = -1;
err = snd_card_next(&card);
if (err < 0) { if (err < 0) {
fprintf(stderr, "%s: unable to obtain card list: %s\n", fprintf(stderr, "%s: no sound card found: %s\n",
context->command, snd_strerror(err)); context->command, snd_strerror(err));
my_exit(context, EXIT_FAILURE); my_exit(context, EXIT_FAILURE);
} }
if (err == 0) { snprintf(name, sizeof(name), "hw:%d", card);
printf("No card found\n"); context->card = strdup(name);
my_exit(context, EXIT_SUCCESS);
}
context->card = strdup(list[0]);
snd_use_case_free_list(list, err);
} }
/* open library */ /* open library */
if (!context->no_open) { if (!context->no_open) {
err = snd_use_case_mgr_open(&context->uc_mgr, err = snd_use_case_mgr_open(&context->uc_mgr,
context->card); context->card);
if (err < 0) { if (err < 0) {
fprintf(stderr, fprintf(stderr,
"%s: error failed to open sound card %s: %s\n", "%s: error failed to open sound card %s: %s\n",
context->command, context->card, snd_strerror(err )); context->command, context->card, snd_strerror(err ));
skipping to change at line 294 skipping to change at line 282
printf(" list is empty\n"); printf(" list is empty\n");
return 0; return 0;
} }
for (i = 0; i < err / 2; i++) { for (i = 0; i < err / 2; i++) {
printf(" %i: %s\n", i, list[i*2]); printf(" %i: %s\n", i, list[i*2]);
if (list[i*2+1]) if (list[i*2+1])
printf(" %s\n", list[i*2+1]); printf(" %s\n", list[i*2+1]);
} }
snd_use_case_free_list(list, err); snd_use_case_free_list(list, err);
break; break;
case OM_DUMP:
dump(context, argv[0]);
break;
case OM_LIST1: case OM_LIST1:
case OM_LIST2: case OM_LIST2:
switch (cmd->code) { switch (cmd->code) {
case OM_LIST1: case OM_LIST1:
entries = 1; entries = 1;
break; break;
case OM_LIST2: case OM_LIST2:
entries = 2; entries = 2;
break; break;
} }
 End of changes. 12 change blocks. 
24 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)