--- aplay.c.orig 2011-01-31 15:19:55.000000000 +0100 +++ aplay.c 2011-04-15 01:44:05.000000000 +0200 @@ -86,6 +86,7 @@ unsigned int rate; } hwparams, rhwparams; static int timelimit = 0; +static int seek_length = 0; static int quiet_mode = 0; static int file_type = FORMAT_DEFAULT; static int open_mode = 0; @@ -186,6 +187,7 @@ "-c, --channels=# channels\n" "-f, --format=FORMAT sample format (case insensitive)\n" "-r, --rate=# sample rate\n" +"-S, --seek=# seek to position # before playing\n" "-d, --duration=# interrupt after # seconds\n" "-M, --mmap mmap stream\n" "-N, --nonblock nonblocking mode\n" @@ -404,7 +406,7 @@ int main(int argc, char *argv[]) { int option_index; - static const char short_options[] = "hnlLD:qt:c:f:r:d:MNF:A:R:T:B:vV:IPC"; + static const char short_options[] = "hnlLD:qt:c:f:r:S:d:MNF:A:R:T:B:vV:IPC"; static const struct option long_options[] = { {"help", 0, 0, 'h'}, {"version", 0, 0, OPT_VERSION}, @@ -417,6 +419,7 @@ {"channels", 1, 0, 'c'}, {"format", 1, 0, 'f'}, {"rate", 1, 0, 'r'}, + {"seek", 1, 0, 'S'}, {"duration", 1, 0 ,'d'}, {"mmap", 0, 0, 'M'}, {"nonblock", 0, 0, 'N'}, @@ -550,6 +553,9 @@ return 1; } break; + case 'S': + seek_length = atoi(optarg); + break; case 'd': timelimit = strtol(optarg, NULL, 0); break; @@ -2457,6 +2463,8 @@ } if (test_au(fd, audiobuf) >= 0) { rhwparams.format = hwparams.format; + if (seek_length != 0) + lseek(fd, seek_length, SEEK_SET); pbrec_count = calc_count(); playback_go(fd, 0, pbrec_count, FORMAT_AU, name); goto __end; @@ -2468,17 +2476,23 @@ prg_exit(EXIT_FAILURE);; } if ((ofs = test_vocfile(audiobuf)) >= 0) { + if (seek_length != 0) + lseek(fd, seek_length, SEEK_SET); pbrec_count = calc_count(); voc_play(fd, ofs, name); goto __end; } /* read bytes for WAVE-header */ if ((dtawave = test_wavefile(fd, audiobuf, dta)) >= 0) { + if (seek_length != 0) + lseek(fd, seek_length, SEEK_SET); pbrec_count = calc_count(); playback_go(fd, dtawave, pbrec_count, FORMAT_WAVE, name); } else { /* should be raw data */ init_raw_data(); + if (seek_length != 0) + lseek(fd, seek_length, SEEK_SET); pbrec_count = calc_count(); playback_go(fd, dta, pbrec_count, FORMAT_RAW, name); }