X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain.c;h=1e17bebd9be4e09620f28b676bc1d8b68acd24da;hb=HEAD;hp=c88aa3b39bfabd7f80f3ea86a2325abc92804ad7;hpb=6e29178202fe1876a0fb0231e71fa0e75a7b6460;p=dos_auplay diff --git a/src/main.c b/src/main.c index c88aa3b..1e17beb 100644 --- a/src/main.c +++ b/src/main.c @@ -12,12 +12,12 @@ 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; @@ -27,7 +27,14 @@ int main(int argc, char **argv) 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 { @@ -83,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"); @@ -94,14 +101,14 @@ static int play_file(const char *fname) vol += 32; if(vol > 255) vol = 255; audio_setvolume(AUDIO_DEFAULT, vol); - printf("volume: %d%%\n", 101 * vol / 256); + printf("\nvolume: %d%%\n", 101 * vol / 256); break; case '-': vol -= 32; if(vol < 0) vol = 0; audio_setvolume(AUDIO_DEFAULT, vol); - printf("volume: %d%%\n", 101 * vol / 256); + printf("\nvolume: %d%%\n", 101 * vol / 256); break; case 'm': @@ -123,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(); } @@ -131,6 +139,7 @@ static int play_file(const char *fname) } end: + putchar('\n'); au_close(au); #ifdef DBG_PRELOAD free(dbg_samples); @@ -168,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"); }