mirror of
https://github.com/buserror/mii_emu.git
synced 2024-11-22 01:30:51 +00:00
speaker: added a _dispose() call
Free memory, turn off alsa Signed-off-by: Michel Pollet <buserror@gmail.com>
This commit is contained in:
parent
60bf0ae000
commit
ba97447894
@ -93,6 +93,16 @@ _mii_mouse_init(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_mii_mouse_dispose(
|
||||
mii_t * mii,
|
||||
struct mii_slot_t *slot )
|
||||
{
|
||||
mii_card_mouse_t *c = slot->drv_priv;
|
||||
free(c);
|
||||
slot->drv_priv = NULL;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
_mii_mouse_access(
|
||||
mii_t * mii,
|
||||
@ -182,6 +192,7 @@ static mii_slot_drv_t _driver = {
|
||||
.name = "mouse",
|
||||
.desc = "Mouse card",
|
||||
.init = _mii_mouse_init,
|
||||
.dispose = _mii_mouse_dispose,
|
||||
.access = _mii_mouse_access,
|
||||
};
|
||||
MI_DRIVER_REGISTER(_driver);
|
||||
|
@ -104,6 +104,11 @@ _mii_nsc_access(
|
||||
uint8_t * byte,
|
||||
bool write)
|
||||
{
|
||||
if (!bank) {
|
||||
printf("%s: disposing of NSC\n", __func__);
|
||||
free(param);
|
||||
return false;
|
||||
}
|
||||
mii_nsc_t * nsc = param;
|
||||
// printf("%s PC:%04x access %s addr %04x byte %02x write %d\n",
|
||||
// __func__, nsc->mii->cpu.PC,
|
||||
|
@ -39,7 +39,6 @@ typedef struct mii_card_sm_t {
|
||||
struct mii_card_sm_t *next;
|
||||
mii_dd_t drive[MII_SM_DRIVE_COUNT];
|
||||
struct mii_slot_t *slot;
|
||||
uint8_t * file;
|
||||
} mii_card_sm_t;
|
||||
|
||||
static void
|
||||
@ -274,6 +273,21 @@ _mii_sm_init(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_mii_sm_dispose(
|
||||
mii_t * mii,
|
||||
struct mii_slot_t *slot )
|
||||
{
|
||||
mii_card_sm_t *c = slot->drv_priv;
|
||||
for (int i = 0; i < MII_SM_DRIVE_COUNT; i++) {
|
||||
free((char *)c->drive[i].name);
|
||||
c->drive[i].name = NULL;
|
||||
}
|
||||
// files attached to drives are automatically freed.
|
||||
free(c);
|
||||
slot->drv_priv = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_mii_sm_command(
|
||||
mii_t * mii,
|
||||
@ -336,6 +350,7 @@ static mii_slot_drv_t _driver = {
|
||||
.name = "smartport",
|
||||
.desc = "SmartPort card",
|
||||
.init = _mii_sm_init,
|
||||
.dispose = _mii_sm_dispose,
|
||||
.access = _mii_sm_access,
|
||||
.command = _mii_sm_command,
|
||||
};
|
||||
|
@ -100,6 +100,20 @@ mii_speaker_init(
|
||||
s->frame[0].start = mii->cycles;
|
||||
}
|
||||
|
||||
void
|
||||
mii_speaker_dispose(
|
||||
mii_speaker_t *speaker)
|
||||
{
|
||||
#ifdef HAS_ALSA
|
||||
if (speaker->alsa_pcm)
|
||||
snd_pcm_close(speaker->alsa_pcm);
|
||||
#endif
|
||||
for (int i = 0; i < MII_SPEAKER_FRAME_COUNT; i++) {
|
||||
free(speaker->frame[i].audio);
|
||||
speaker->frame[i].audio = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Called when $c030 is touched, place a sample at the 'appropriate' time
|
||||
void
|
||||
mii_speaker_click(
|
||||
|
@ -43,6 +43,9 @@ void
|
||||
mii_speaker_init(
|
||||
struct mii_t * mii,
|
||||
mii_speaker_t *speaker);
|
||||
void
|
||||
mii_speaker_dispose(
|
||||
mii_speaker_t *speaker);
|
||||
// Called when $c030 is touched, place a sample at the 'appropriate' time
|
||||
void
|
||||
mii_speaker_click(
|
||||
|
Loading…
Reference in New Issue
Block a user