Mercurial > SDL_sound_CoreAudio
comparison playsound/playsound.c @ 334:f0f894d897bf
--seek argument now specifies minutes, seconds, and milliseconds.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 20 May 2002 11:20:39 +0000 |
parents | 8195b86207bb |
children | 03f47480200f |
comparison
equal
deleted
inserted
replaced
333:565ae12fa74e | 334:f0f894d897bf |
---|---|
129 " U16MSB Unsigned 16-bit (most significant byte first).\n" | 129 " U16MSB Unsigned 16-bit (most significant byte first).\n" |
130 " S16LSB Signed 16-bit (least significant byte first).\n" | 130 " S16LSB Signed 16-bit (least significant byte first).\n" |
131 " S16MSB Signed 16-bit (most significant byte first).\n" | 131 " S16MSB Signed 16-bit (most significant byte first).\n" |
132 "\n" | 132 "\n" |
133 " Valid arguments to the --seek options look like:\n" | 133 " Valid arguments to the --seek options look like:\n" |
134 " --seek=\"mm:ss;mm:ss;mm:ss\"\n" | 134 " --seek \"mm:SS:ss;mm:SS:ss;mm:SS:ss\"\n" |
135 " Where the first \"mm:ss\" is the position, in minutes and\n" | 135 " Where the first \"mm:SS:ss\" is the position, in minutes,\n" |
136 " seconds to seek to at start of playback. The second mm:ss\n" | 136 " seconds and milliseconds to seek to at start of playback. The\n" |
137 " is how long to play audio from that point. The third mm:ss\n" | 137 " next mm:SS:ss is how long to play audio from that point.\n" |
138 " is another seek after the duration of playback has completed.\n" | 138 " The third mm:SS:ss is another seek after the duration of\n" |
139 " If the final playback duration is omitted, playback continues\n" | 139 " playback has completed. If the final playback duration is\n" |
140 " until the end of the file. --loop and --seek can coexist.\n" | 140 " omitted, playback continues until the end of the file.\n" |
141 " The \"mm\" and \"SS\" portions may be omitted. --loop\n" | |
142 " and --seek can coexist.\n" | |
141 "\n", | 143 "\n", |
142 argv0, DEFAULT_DECODEBUF, DEFAULT_AUDIOBUF); | 144 argv0, DEFAULT_DECODEBUF, DEFAULT_AUDIOBUF); |
143 } /* output_usage */ | 145 } /* output_usage */ |
144 | 146 |
145 | 147 |
320 } /* cvtMsToBytePos */ | 322 } /* cvtMsToBytePos */ |
321 | 323 |
322 | 324 |
323 static void do_seek(Sound_Sample *sample) | 325 static void do_seek(Sound_Sample *sample) |
324 { | 326 { |
325 printf("Seeking to %.2d:%.2d...\n", | 327 printf("Seeking to %.2d:%.2d:%.4d...\n", |
326 ((seek_list[seek_index] / 1000) / 60), | 328 (int) ((seek_list[seek_index] / 1000) / 60), |
327 ((seek_list[seek_index] / 1000) % 60)); | 329 (int) ((seek_list[seek_index] / 1000) % 60), |
330 (int) ((seek_list[seek_index] % 1000))); | |
328 | 331 |
329 if (predecode) | 332 if (predecode) |
330 { | 333 { |
331 Uint32 pos = cvtMsToBytePos(&sample->desired, seek_list[seek_index]); | 334 Uint32 pos = cvtMsToBytePos(&sample->desired, seek_list[seek_index]); |
332 if (pos > sample->buffer_size) | 335 if (pos > sample->buffer_size) |
551 | 554 |
552 static Uint32 parse_time_str(char *str) | 555 static Uint32 parse_time_str(char *str) |
553 { | 556 { |
554 Uint32 minutes = 0; | 557 Uint32 minutes = 0; |
555 Uint32 seconds = 0; | 558 Uint32 seconds = 0; |
559 Uint32 ms = 0; | |
560 | |
556 char *ptr = strchr(str, ':'); | 561 char *ptr = strchr(str, ':'); |
557 if (ptr != NULL) | 562 if (ptr != NULL) |
558 { | 563 { |
564 char *ptr2; | |
565 | |
559 *ptr = '\0'; | 566 *ptr = '\0'; |
560 minutes = atoi(str); | 567 ptr2 = strchr(ptr + 1, ':'); |
568 if (ptr2 != NULL) | |
569 { | |
570 *ptr2 = '\0'; | |
571 minutes = atoi(str); | |
572 str = ptr + 1; | |
573 ptr = ptr2; | |
574 } /* if */ | |
575 | |
576 seconds = atoi(str); | |
561 str = ptr + 1; | 577 str = ptr + 1; |
562 } /* if */ | 578 } /* if */ |
563 | 579 |
564 seconds = atoi(str); | 580 ms = atoi(str); |
565 | 581 return( (((minutes * 60) + seconds) * 1000) + ms ); |
566 return( ((minutes * 60) + seconds) * 1000 ); | |
567 } /* parse_time_str */ | 582 } /* parse_time_str */ |
568 | 583 |
569 | 584 |
570 static void parse_seek_list(const char *_list) | 585 static void parse_seek_list(const char *_list) |
571 { | 586 { |