From 8fa9027e1589e6c950ae157c2e257f7e32e0f2fa Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 19 Mar 2017 17:54:30 +0900 Subject: [PATCH] Move pcmobj array to music_pcm static --- src/music_pcm.c | 35 ++++++++++++++++++++--------------- src/music_pcm.h | 2 -- src/music_private.h | 12 ------------ 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/music_pcm.c b/src/music_pcm.c index f1c169e..f8dceb6 100644 --- a/src/music_pcm.c +++ b/src/music_pcm.c @@ -54,7 +54,12 @@ struct _pcmobj { }; typedef struct _pcmobj pcmobj_t; -#define IS_LOADED(slot) (prv.pcm[(slot)]) +// 0: S comman 用 +// 1-128: wavXXX 用 +static pcmobj_t *pcmobj[128 + 1]; + + +#define IS_LOADED(slot) (pcmobj[(slot)]) static int load_chunk(int slot, Mix_Chunk *chunk); static int load_wai(); @@ -187,7 +192,7 @@ static int load_chunk(int slot, Mix_Chunk *chunk) { obj->slot = slot; obj->playing = FALSE; - prv.pcm[slot] = obj; + pcmobj[slot] = obj; return OK; } @@ -197,7 +202,7 @@ int muspcm_start(int slot, int loop) { pcmobj_t *obj; // printf("pcm start slot = %d, loop = %d\n", slot, loop); - obj = prv.pcm[slot]; + obj = pcmobj[slot]; if (obj == NULL) return NG; obj->channel = Mix_PlayChannel(-1, obj->chunk, loop - 1); @@ -212,7 +217,7 @@ int muspcm_start(int slot, int loop) { int muspcm_stop(int slot) { pcmobj_t *obj; - obj = prv.pcm[slot]; + obj = pcmobj[slot]; if (obj == NULL) return NG; if (obj->playing) { @@ -228,7 +233,7 @@ int muspcm_fadeout(int slot, int msec) { if (msec == 0) return muspcm_stop(slot); - pcmobj_t *obj = prv.pcm[slot]; + pcmobj_t *obj = pcmobj[slot]; if (obj == NULL) return NG; if (obj->playing) { @@ -243,7 +248,7 @@ int muspcm_fadeout(int slot, int msec) { int muspcm_unload(int slot) { pcmobj_t *obj; - obj = prv.pcm[slot]; + obj = pcmobj[slot]; if (obj == NULL) return NG; if (obj->playing) muspcm_stop(slot); @@ -251,23 +256,23 @@ int muspcm_unload(int slot) { Mix_FreeChunk(obj->chunk); free(obj); - prv.pcm[slot] = NULL; + pcmobj[slot] = NULL; return OK; } // PCMデータå†�生一時å�œæ­¢ int muspcm_pause(int slot) { - if (prv.pcm[slot] != NULL) { - Mix_Pause(prv.pcm[slot]->channel); + if (pcmobj[slot] != NULL) { + Mix_Pause(pcmobj[slot]->channel); } return OK; } // PCMデータå†�生一時å�œæ­¢è§£é™¤ int muspcm_unpause(int slot) { - if (prv.pcm[slot] != NULL) { - Mix_Resume(prv.pcm[slot]->channel); + if (pcmobj[slot] != NULL) { + Mix_Resume(pcmobj[slot]->channel); } return OK; } @@ -277,7 +282,7 @@ int muspcm_getpos(int slot) { pcmobj_t *obj; uint64_t len; - obj = prv.pcm[slot]; + obj = pcmobj[slot]; if (obj == NULL) return 0; if (!obj->playing) return 0; @@ -290,7 +295,7 @@ int muspcm_getpos(int slot) { int muspcm_setvol(int dev, int slot, int lv) { pcmobj_t *obj; - obj = prv.pcm[slot]; + obj = pcmobj[slot]; if (obj == NULL) return NG; Mix_VolumeChunk(obj->chunk, lv * MIX_MAX_VOLUME / 100); @@ -302,7 +307,7 @@ int muspcm_setvol(int dev, int slot, int lv) { int muspcm_getwavelen(int slot) { pcmobj_t *obj; - obj = prv.pcm[slot]; + obj = pcmobj[slot]; if (obj == NULL) return 0; long len = obj->chunk->alen * 1000 / (44100 * 4); @@ -314,7 +319,7 @@ int muspcm_getwavelen(int slot) { boolean muspcm_isplaying(int slot) { pcmobj_t *obj; - obj = prv.pcm[slot]; + obj = pcmobj[slot]; if (obj == NULL) return FALSE; return obj->playing; diff --git a/src/music_pcm.h b/src/music_pcm.h index 69116fa..3e33bba 100644 --- a/src/music_pcm.h +++ b/src/music_pcm.h @@ -26,8 +26,6 @@ #include -struct _pcmobj; - extern int muspcm_init(); extern int muspcm_exit(); extern int muspcm_load_no(int slot, int no); diff --git a/src/music_private.h b/src/music_private.h index 10d0fe6..45718dc 100644 --- a/src/music_private.h +++ b/src/music_private.h @@ -23,7 +23,6 @@ #define __MUSIC_PRIVATE_H__ #include "portab.h" -#include "list.h" #include "cdrom.h" #include "midi.h" #include "music_cdrom.h" @@ -41,13 +40,6 @@ struct _musprvdat { cdobj_t cdrom; // cdrom object midiobj_t midi; // midi object - // pcm object - /* - 0: S comman ÍÑ - 1-128: wavXXX ÍÑ - */ - struct _pcmobj *pcm[128 + 1]; - // ¥²¡¼¥àÆâ¤Ç¤Î volume ÀßÄê (%ÃÍ) int vol_master; int vol_pcm; @@ -58,10 +50,6 @@ struct _musprvdat { // ºÇÂç¥È¥é¥Ã¥¯¿ô int cd_maxtrk; - - List *pcmplist; // PCM¿½ÅºÆÀ¸Íѥꥹ¥È - List *fadelist; // Fader¥ê¥¹¥È - }; #define prv musprv