///////////////////////////////////////////////////// // Deletes vocs in the 3D sound queue with no owners ///////////////////////////////////////////////////// void DeleteNoSoundOwner(short spritenum) { VOC3D_INFOp vp, dp; vp = voc3dstart; while (vp) { dp = NULL; if (vp->owner == spritenum && vp->owner >= 0 && (vp->vp->voc_flags & vf_loop)) { //DSPRINTF(ds,"Deleting owner %d\n",vp->owner); //MONO_PRINT(ds); // Make sure to stop active // sounds if (FX_SoundActive(vp->handle)) { FX_StopSound(vp->handle); } #if 0 // Clean up the sound active counter for cacheing locks if (vp->FX_Ok) // Only decrement if sound ever played vp->vp->playing--; // Decrement instance of sound playing if (vp->vp->playing == 0 && vp->vp->lock > CACHE_UNLOCK_MAX) vp->vp->lock = CACHE_UNLOCK_MAX; #endif dp = vp; // Point to sound to be deleted if (vp->prev) { vp->prev->next = vp->next; } else { voc3dstart = vp->next; // New first item if (voc3dstart) voc3dstart->prev = NULL; } if (vp->next) { vp->next->prev = vp->prev; // Middle element } else { voc3dend = vp->prev; // Delete last element } } vp = vp->next; if (dp != NULL) FreeMem(dp); // Return memory to heap } }
static int32_t S_TakeSlot(int32_t num) { S_Cleanup(); uint32_t dist = 0, clock = UINT32_MAX; int32_t i = 0, j = 0; while (j < MAXSOUNDINSTANCES && g_sounds[num].SoundOwner[j].voice > 0) { if (g_sounds[num].SoundOwner[j].sndist > dist || (g_sounds[num].SoundOwner[j].sndist == dist && g_sounds[num].SoundOwner[j].clock < clock)) { clock = g_sounds[num].SoundOwner[j].clock; dist = g_sounds[num].SoundOwner[j].sndist; i = j; } j++; } if (j != MAXSOUNDINSTANCES) return j; if (FX_SoundActive(g_sounds[num].SoundOwner[i].voice)) FX_StopSound(g_sounds[num].SoundOwner[i].voice); mutex_lock(&s_mutex); dq[dnum++] = (num * MAXSOUNDINSTANCES) + i; mutex_unlock(&s_mutex); S_Cleanup(); return i; }
// This is called from KillSprite to kill a follow sound with no valid sprite owner // Stops and active sound with the follow bit set, even play once sounds. void DeleteNoFollowSoundOwner(short spritenum) { VOC3D_INFOp vp, dp; SPRITEp sp = &sprite[spritenum]; vp = voc3dstart; while (vp) { dp = NULL; // If the follow flag is set, compare the x and y addresses. if ((vp->flags & v3df_follow) && vp->x == &sp->x && vp->y == &sp->y) { if (FX_SoundActive(vp->handle)) { FX_StopSound(vp->handle); } #if 0 if (vp->FX_Ok) // Only decrement if sound ever played vp->vp->playing--; // Decrement instance of sound playing if (vp->vp->playing == 0 && vp->vp->lock > CACHE_UNLOCK_MAX) vp->vp->lock = CACHE_UNLOCK_MAX; #endif dp = vp; // Point to sound to be deleted if (vp->prev) { vp->prev->next = vp->next; } else { voc3dstart = vp->next; // New first item if (voc3dstart) voc3dstart->prev = NULL; } if (vp->next) { vp->next->prev = vp->prev; // Middle element } else { voc3dend = vp->prev; // Delete last element } } vp = vp->next; if (dp != NULL) FreeMem(dp); // Return memory to heap } }
void playsong(const char * song) { int voice; int length; char * data; FILE * fp; fp = fopen(song, "rb"); if (!fp) { fprintf(stderr, "Error opening %s\n", song); return; } fseek(fp, 0, SEEK_END); length = ftell(fp); if (length <= 0) { fclose(fp); return; } data = (char *) malloc(length); if (!data) { fclose(fp); return; } fseek(fp, 0, SEEK_SET); if (fread(data, length, 1, fp) != 1) { fclose(fp); free(data); return; } fclose(fp); voice = FX_PlayAuto(data, length, 0, 255, 255, 255, FX_MUSIC_PRIORITY, 1); if (voice >= FX_Ok) { while (FX_SoundActive(voice)) { ASS_Sleep(500); } } else { fprintf(stderr, "Error playing sound\n"); } free(data); }
int DoZillaMove(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum]; short choose; static int handle; //if (TEST(u->Flags,SPR_SLIDING)) //DoActorSlide(SpriteNum); // Random Zilla taunts if (!FX_SoundActive(handle)) { choose = STD_RANDOM_RANGE(1000); if (choose > 990) handle = PlaySound(DIGI_Z16004,&sp->x,&sp->y,&sp->z,v3df_none); else if (choose > 985) handle = PlaySound(DIGI_Z16004,&sp->x,&sp->y,&sp->z,v3df_none); else if (choose > 980) handle = PlaySound(DIGI_Z16004,&sp->x,&sp->y,&sp->z,v3df_none); else if (choose > 975) handle = PlaySound(DIGI_Z16004,&sp->x,&sp->y,&sp->z,v3df_none); } if (u->track >= 0) ActorFollowTrack(SpriteNum, ACTORMOVETICS); else (*u->ActorActionFunc)(SpriteNum); KeepActorOnFloor(SpriteNum); if (DoActorSectorDamage(SpriteNum)) { return 0; } return 0; }