Re: [AD] tiny seekmidi fix

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sat, 2002-08-17 at 22:35, Eric Botcazou wrote: 

> Ok, definitively this time :-) While you are at it, could you correct
> the comment line 1397 ?
> 
> 
> diff -u -r1.69 allegro._tx
> --- docs/src/allegro._tx 14 Aug 2002 19:36:15 -0000 1.69
> +++ docs/src/allegro._tx 16 Aug 2002 06:14:29 -0000
> @@ -5498,8 +5498,8 @@
>     beginning; otherwise it seeks from the current position. Returns zero if 
>     successful, non-zero if it hit the end of the file (1 means it stopped 
>     playing, 2 means it looped back to the start). If this function stops 
> -   because it reached EOF, midi_pos will be set to the negative length of 
> -   the MIDI file.
> +   because it reached EOF, and no looping is in effect, midi_pos will be
> +   set to the negative length of the MIDI file.
>  
>  
> I think it would be better to merge the last sentence into the previous one.
> 
Updated patch attached. 

-- 
Elias Pschernig 

Index: src/midi.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/midi.c,v
retrieving revision 1.14
diff -u -r1.14 midi.c
--- src/midi.c	21 Mar 2002 09:33:45 -0000	1.14
+++ src/midi.c	19 Aug 2002 13:59:28 -0000
@@ -1341,7 +1341,7 @@
       prepare_to_play(midifile);
 
    /* now sit back and let midi_player get to the position */
-   while ((midi_pos < target) && (midi_pos != -1)) {
+   while ((midi_pos < target) && (midi_pos >= 0)) {
       int mmpc = midi_pos_counter;
       int mmp = midi_pos;
 
@@ -1362,7 +1362,7 @@
    midi_driver = old_driver;
    midi_seeking = 0;
 
-   if (midi_pos != -1) {
+   if (midi_pos >= 0) {
       /* refresh the driver with any changed parameters */
       if (midi_driver->raw_midi) {
 	 for (c=0; c<16; c++) {
@@ -1394,7 +1394,7 @@
       return 0;
    }
 
-   if ((midi_loop) && (!midi_looping)) {  /* was file was looped? */
+   if ((midi_loop) && (!midi_looping)) {  /* was file looped? */
       prepare_to_play(old_midifile);
       install_int(midi_player, 20);
       return 2;                           /* seek past EOF => file restarted */
Index: docs/src/allegro._tx
===================================================================
RCS file: /cvsroot/alleg/allegro/docs/src/allegro._tx,v
retrieving revision 1.71
diff -u -r1.71 allegro._tx
--- docs/src/allegro._tx	18 Aug 2002 12:07:13 -0000	1.71
+++ docs/src/allegro._tx	19 Aug 2002 14:00:19 -0000
@@ -5502,10 +5769,11 @@
    Seeks to the given midi_pos in the current MIDI file. If the target is 
    earlier in the file than the current midi_pos it seeks from the 
    beginning; otherwise it seeks from the current position. Returns zero if 
-   successful, non-zero if it hit the end of the file (1 means it stopped 
-   playing, 2 means it looped back to the start). If this function stops 
-   because it reached EOF, midi_pos will be set to the negative length of 
-   the MIDI file.
+   it could successfully seek to the requested position. Otherwise, a
+   return value of 1 means it stopped playing, and midi_pos is set to the
+   negative length of the MIDI file (so you can use this function to
+   determine the length of a MIDI). A return value of 2 means the MIDI
+   looped back to the start.
 
 @@void @midi_out(unsigned char *data, int length);
 @xref install_sound, load_midi_patches, midi_recorder


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/