X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmain.c;h=1e17bebd9be4e09620f28b676bc1d8b68acd24da;hb=3932cfd54ab14cec36729db7bb32461a58658675;hp=f62fdac11a82858c2a1846e96f3673bd12731e13;hpb=43cd2e73225cd66e61d1e9754afcaa7eca02fcb7;p=dos_auplay diff --git a/src/main.c b/src/main.c index f62fdac..1e17beb 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))) { @@ -82,7 +90,7 @@ static int play_file(const char *fname) paused = !paused; if(paused) { audio_pause(); - printf("pause\n"); + printf("\npause\n"); } else { audio_resume(); printf("resume\n"); @@ -92,15 +100,24 @@ static int play_file(const char *fname) case '=': vol += 32; if(vol > 255) vol = 255; - audio_volume(vol); - printf("volume: %d%%\n", 101 * vol / 256); + audio_setvolume(AUDIO_DEFAULT, vol); + printf("\nvolume: %d%%\n", 101 * vol / 256); break; case '-': vol -= 32; if(vol < 0) vol = 0; - audio_volume(vol); - printf("volume: %d%%\n", 101 * vol / 256); + audio_setvolume(AUDIO_DEFAULT, vol); + printf("\nvolume: %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: @@ -113,7 +130,8 @@ static int play_file(const char *fname) prev = dbg_cur_offs; _enable(); - printf("%3d%% - offs: %lu/%lu\n", 100 * prev / au->size, prev, au->size); + printf("%3d%% - offs: %lu/%lu \r", 100 * prev / au->size, prev, au->size); + fflush(stdout); } else { _enable(); } @@ -121,6 +139,7 @@ static int play_file(const char *fname) } end: + putchar('\n'); au_close(au); #ifdef DBG_PRELOAD free(dbg_samples); @@ -158,5 +177,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"); }