Re: [AD] too strict assert? |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 2005-06-28, Elias Pschernig <elias@xxxxxxxxxx> wrote:
> The attached patch removes an ASSERT which I think is too strict.
...
>
> voice_get_volume returns -1 for some voices (I don't know when, but it
> does), which then gets passed to voice_set_volume. So now sound doesn't
> work in debug mode since it asserts at the -1 in voice_set_volume.
Perhaps this patch is better? (untested) I just copied the description
of voice_get_volume() from sound.c.
Maybe you're right that voice_set_volume() is too strict though, in
which case both patches should be in.
Peter
Index: docs/src/allegro._tx
===================================================================
RCS file: /cvsroot/alleg/allegro/docs/src/allegro._tx,v
retrieving revision 1.347
diff -u -r1.347 allegro._tx
--- docs/src/allegro._tx 27 Jun 2005 07:32:19 -0000 1.347
+++ docs/src/allegro._tx 29 Jun 2005 08:45:54 -0000
@@ -9227,7 +9227,9 @@
@@int @voice_get_volume(int voice);
@xref Voice control, voice_set_volume
@shortdesc Returns the current volume of the voice.
- Returns the current volume of the voice, range 0-255.
+ Returns the current volume of the voice, range 0-255. Otherwise it
+ returns -1 if that cannot be determined (because it has finished or
+ been preempted by a different sound).
@@void @voice_set_volume(int voice, int volume);
@xref Voice control, voice_get_volume, voice_ramp_volume
Index: src/sound.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/sound.c,v
retrieving revision 1.26
diff -u -r1.26 sound.c
--- src/sound.c 26 Jun 2005 14:46:29 -0000 1.26
+++ src/sound.c 29 Jun 2005 08:45:54 -0000
@@ -748,8 +748,10 @@
_digi_volume = MID(0, digi_volume, 255);
/* Set the new (relative) volume for each voice. */
- for (i=0; i<VIRTUAL_VOICES; i++)
- voice_set_volume(i, voice_vol[i]);
+ for (i=0; i<VIRTUAL_VOICES; i++) {
+ if (voice_vol[i] >= 0)
+ voice_set_volume(i, voice_vol[i]);
+ }
free(voice_vol);
}