[xmp] Fix special case driver selection

- automatically select file or wav if -o is selected
- generalized selection of null driver (can use either -dnull or -n)

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent 0235056205
commit dfa44865b0
  1. 2
      src/common.h
  2. 12
      src/main.c
  3. 6
      src/options.c
  4. 4
      src/sound.c
  5. 2
      src/sound_null.c

@ -16,7 +16,7 @@ struct options {
int silent; /* silent output */
int info; /* display information and exit */
int probeonly; /* probe sound driver and exit */
char *drv_id; /* sound driver ID */
char *driver_id; /* sound driver ID */
char *out_file; /* output file name */
char *ins_path; /* instrument path */
char *driver_parm[MAX_DRV_PARM]; /* driver parameters */

@ -16,10 +16,8 @@
#endif
extern int optind;
extern struct sound_driver sound_null;
struct sound_driver *sound;
static struct sound_driver *sound;
static int background = 0;
static int refresh_status;
@ -152,7 +150,7 @@ int main(int argc, char **argv)
memset(&control, 0, sizeof (struct control));
options.verbose = 1;
options.rate = 44100;
options.drv_id = NULL;
options.driver_id = NULL;
get_options(argc, argv, &options);
@ -164,11 +162,11 @@ int main(int argc, char **argv)
}
if (options.silent) {
sound = &sound_null;
} else {
sound = select_sound_driver(&options);
options.driver_id = "null";
}
sound = select_sound_driver(&options);
if (sound == NULL) {
fprintf(stderr, "%s: can't initialize sound\n", argv[0]);
if (f != NULL) {

@ -151,7 +151,7 @@ void get_options(int argc, char **argv, struct options *options)
options->driver_parm[dparm++] = optarg;
break;
case 'd':
options->drv_id = optarg;
options->driver_id = optarg;
break;
#if 0
case OPT_FX9BUG:
@ -190,7 +190,9 @@ void get_options(int argc, char **argv, struct options *options)
options->out_file = optarg;
if (strlen(optarg) >= 4 &&
!strcasecmp(optarg + strlen(optarg) - 4, ".wav")) {
//options->drv_id = "wav";
options->driver_id = "wav";
} else {
options->driver_id = "file";
}
break;
case 'P':

@ -2,6 +2,7 @@
#include <string.h>
#include "sound.h"
extern struct sound_driver sound_null;
extern struct sound_driver sound_wav;
extern struct sound_driver sound_file;
extern struct sound_driver sound_oss;
@ -72,13 +73,14 @@ void init_sound_drivers()
#endif
register_sound_driver(&sound_wav);
register_sound_driver(&sound_file);
register_sound_driver(&sound_null);
}
struct sound_driver *select_sound_driver(struct options *options)
{
struct list_head *head;
struct sound_driver *sd;
char *pref = options->drv_id;
char *pref = options->driver_id;
if (pref) {
list_for_each(head, &sound_driver_list) {

@ -29,7 +29,7 @@ static void onresume()
struct sound_driver sound_null = {
"null",
"No output",
"null output",
NULL,
init,
deinit,

Loading…
Cancel
Save