mirror of
https://github.com/buserror/mii_emu.git
synced 2025-01-08 18:30:25 +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;
|
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
|
static uint8_t
|
||||||
_mii_mouse_access(
|
_mii_mouse_access(
|
||||||
mii_t * mii,
|
mii_t * mii,
|
||||||
@ -182,6 +192,7 @@ static mii_slot_drv_t _driver = {
|
|||||||
.name = "mouse",
|
.name = "mouse",
|
||||||
.desc = "Mouse card",
|
.desc = "Mouse card",
|
||||||
.init = _mii_mouse_init,
|
.init = _mii_mouse_init,
|
||||||
|
.dispose = _mii_mouse_dispose,
|
||||||
.access = _mii_mouse_access,
|
.access = _mii_mouse_access,
|
||||||
};
|
};
|
||||||
MI_DRIVER_REGISTER(_driver);
|
MI_DRIVER_REGISTER(_driver);
|
||||||
|
@ -104,6 +104,11 @@ _mii_nsc_access(
|
|||||||
uint8_t * byte,
|
uint8_t * byte,
|
||||||
bool write)
|
bool write)
|
||||||
{
|
{
|
||||||
|
if (!bank) {
|
||||||
|
printf("%s: disposing of NSC\n", __func__);
|
||||||
|
free(param);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mii_nsc_t * nsc = param;
|
mii_nsc_t * nsc = param;
|
||||||
// printf("%s PC:%04x access %s addr %04x byte %02x write %d\n",
|
// printf("%s PC:%04x access %s addr %04x byte %02x write %d\n",
|
||||||
// __func__, nsc->mii->cpu.PC,
|
// __func__, nsc->mii->cpu.PC,
|
||||||
|
@ -39,7 +39,6 @@ typedef struct mii_card_sm_t {
|
|||||||
struct mii_card_sm_t *next;
|
struct mii_card_sm_t *next;
|
||||||
mii_dd_t drive[MII_SM_DRIVE_COUNT];
|
mii_dd_t drive[MII_SM_DRIVE_COUNT];
|
||||||
struct mii_slot_t *slot;
|
struct mii_slot_t *slot;
|
||||||
uint8_t * file;
|
|
||||||
} mii_card_sm_t;
|
} mii_card_sm_t;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -274,6 +273,21 @@ _mii_sm_init(
|
|||||||
return 0;
|
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
|
static int
|
||||||
_mii_sm_command(
|
_mii_sm_command(
|
||||||
mii_t * mii,
|
mii_t * mii,
|
||||||
@ -336,6 +350,7 @@ static mii_slot_drv_t _driver = {
|
|||||||
.name = "smartport",
|
.name = "smartport",
|
||||||
.desc = "SmartPort card",
|
.desc = "SmartPort card",
|
||||||
.init = _mii_sm_init,
|
.init = _mii_sm_init,
|
||||||
|
.dispose = _mii_sm_dispose,
|
||||||
.access = _mii_sm_access,
|
.access = _mii_sm_access,
|
||||||
.command = _mii_sm_command,
|
.command = _mii_sm_command,
|
||||||
};
|
};
|
||||||
|
@ -100,6 +100,20 @@ mii_speaker_init(
|
|||||||
s->frame[0].start = mii->cycles;
|
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
|
// Called when $c030 is touched, place a sample at the 'appropriate' time
|
||||||
void
|
void
|
||||||
mii_speaker_click(
|
mii_speaker_click(
|
||||||
|
@ -43,6 +43,9 @@ void
|
|||||||
mii_speaker_init(
|
mii_speaker_init(
|
||||||
struct mii_t * mii,
|
struct mii_t * mii,
|
||||||
mii_speaker_t *speaker);
|
mii_speaker_t *speaker);
|
||||||
|
void
|
||||||
|
mii_speaker_dispose(
|
||||||
|
mii_speaker_t *speaker);
|
||||||
// Called when $c030 is touched, place a sample at the 'appropriate' time
|
// Called when $c030 is touched, place a sample at the 'appropriate' time
|
||||||
void
|
void
|
||||||
mii_speaker_click(
|
mii_speaker_click(
|
||||||
|
Loading…
Reference in New Issue
Block a user