X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dos_auplay;a=blobdiff_plain;f=src%2Fmain.c;h=f8ca49db2cc180cfe2b5f636b3d3bec8bb44351a;hp=f62fdac11a82858c2a1846e96f3673bd12731e13;hb=2d7c576f4ab90819ca1bd05e92375a00804fdfd7;hpb=43cd2e73225cd66e61d1e9754afcaa7eca02fcb7 diff --git a/src/main.c b/src/main.c index f62fdac..f8ca49d 100644 --- a/src/main.c +++ b/src/main.c @@ -12,21 +12,29 @@ static int play_file(const char *fname); static int cbfunc(void *buf, int size, void *cls); static void print_usage(const char *argv0); -static int vol = 220; +static int vol = 255; static int quit; int main(int argc, char **argv) { - int i; + int i, vol; if(audio_init() == -1) { return 1; } - audio_volume(vol); + audio_setvolume(AUDIO_MASTER, 255); + audio_setvolume(AUDIO_PCM, 255); for(i=1; i 100) { + fprintf(stderr, "%s must be followed by a number 1-100\n", argv[-1]); + return 1; + } + audio_setvolume(AUDIO_DEFAULT, vol * 255 / 100); + + } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) { print_usage(argv[0]); return 0; } else { @@ -47,7 +55,7 @@ static int dbg_cur_offs; static int play_file(const char *fname) { struct au_file *au; - int paused = 0; + int paused = 0, muted = 0; unsigned long prev; if(!(au = au_open(fname))) { @@ -92,17 +100,26 @@ static int play_file(const char *fname) case '=': vol += 32; if(vol > 255) vol = 255; - audio_volume(vol); + audio_setvolume(AUDIO_DEFAULT, vol); printf("volume: %d%%\n", 101 * vol / 256); break; case '-': vol -= 32; if(vol < 0) vol = 0; - audio_volume(vol); + audio_setvolume(AUDIO_DEFAULT, vol); printf("volume: %d%%\n", 101 * vol / 256); break; + case 'm': + muted = !muted; + if(muted) { + audio_setvolume(AUDIO_DEFAULT, 0); + } else { + audio_setvolume(AUDIO_DEFAULT, vol); + } + break; + default: break; } @@ -158,5 +175,6 @@ static void print_usage(const char *argv0) { printf("Usage: %s [options] ... \n", argv0); printf("options:\n"); + printf(" -v,-volume : set audio volume (1-100)\n"); printf(" -h,-help: print usage and exit\n"); }