/* release midi synth port */ int snd_seq_midisynth_unregister_port(snd_seq_device_t *dev) { seq_midisynth_client_t *client; seq_midisynth_t *msynth; snd_card_t *card = dev->card; int device = dev->device, p, ports; down(®ister_mutex); client = synths[card->number]; if (client == NULL || client->ports[device] == NULL) { up(®ister_mutex); return -ENODEV; } snd_seq_event_port_detach(client->seq_client, client->ports[device]->seq_port); ports = client->ports_per_device[device]; client->ports_per_device[device] = 0; msynth = client->ports[device]; client->ports[device] = NULL; snd_runtime_check(msynth != NULL || ports <= 0, goto __skip); for (p = 0; p < ports; p++) snd_seq_midisynth_delete(&msynth[p]); kfree(msynth); __skip: client->num_ports--; if (client->num_ports <= 0) { snd_seq_delete_kernel_client(client->seq_client); synths[card->number] = NULL; kfree(client); } up(®ister_mutex); return 0; }
/* * close port */ static int snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg) { struct snd_emux *emu; struct snd_emux_port *p; if (snd_BUG_ON(!arg)) return -ENXIO; p = arg->private_data; if (snd_BUG_ON(!p)) return -ENXIO; emu = p->emu; if (snd_BUG_ON(!emu)) return -ENXIO; mutex_lock(&emu->register_mutex); snd_emux_sounds_off_all(p); snd_soundfont_close_check(emu->sflist, SF_CLIENT_NO(p->chset.port)); snd_seq_event_port_detach(p->chset.client, p->chset.port); snd_emux_dec_count(emu); mutex_unlock(&emu->register_mutex); return 0; }
/* delete given midi synth port */ static void snd_seq_midisynth_delete(struct seq_midisynth *msynth) { if (msynth == NULL) return; if (msynth->seq_client > 0) { /* delete port */ snd_seq_event_port_detach(msynth->seq_client, msynth->seq_port); } snd_midi_event_free(msynth->parser); }
/* * close port */ static int snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg) { struct snd_emux *emu; struct snd_emux_port *p; snd_assert(arg != NULL, return -ENXIO); p = arg->private_data; snd_assert(p != NULL, return -ENXIO); emu = p->emu; snd_assert(emu != NULL, return -ENXIO); mutex_lock(&emu->register_mutex); snd_emux_sounds_off_all(p); snd_soundfont_close_check(emu->sflist, SF_CLIENT_NO(p->chset.port)); snd_seq_event_port_detach(p->chset.client, p->chset.port); snd_emux_dec_count(emu); mutex_unlock(&emu->register_mutex); return 0; }