Changeset 34 for GPL/trunk/alsa-kernel/synth/emux/emux.c
- Timestamp:
- Dec 11, 2005, 5:57:39 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/synth/emux/emux.c
r33 r34 23 23 #include <linux/sched.h> 24 24 #include <linux/slab.h> 25 #include <linux/string.h> 25 26 #include <sound/core.h> 26 27 #include <sound/emux_synth.h> … … 35 36 * create a new hardware dependent device for Emu8000/Emu10k1 36 37 */ 37 int snd_emux_new(snd_emux_t **remu) 38 { 39 snd_emux_t *emu; 40 41 *remu = NULL; 42 emu = kcalloc(1, sizeof(*emu), GFP_KERNEL); 43 if (emu == NULL) 44 return -ENOMEM; 45 46 spin_lock_init(&emu->voice_lock); 47 init_MUTEX(&emu->register_mutex); 48 49 emu->client = -1; 50 #ifdef CONFIG_SND_OSSEMUL 51 emu->oss_synth = NULL; 52 #endif 53 emu->max_voices = 0; 54 emu->use_time = 0; 55 56 emu->tlist.function = snd_emux_timer_callback; 57 emu->tlist.data = (unsigned long)emu; 58 emu->timer_active = 0; 59 60 *remu = emu; 61 return 0; 62 } 63 64 65 /* 66 */ 67 int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name) 68 { 69 snd_sf_callback_t sf_cb; 70 71 snd_assert(emu->hw != NULL, return -EINVAL); 72 snd_assert(emu->max_voices > 0, return -EINVAL); 73 snd_assert(card != NULL, return -EINVAL); 74 snd_assert(name != NULL, return -EINVAL); 75 76 emu->card = card; 77 emu->name = snd_kmalloc_strdup(name, GFP_KERNEL); 78 emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL); 79 if (emu->voices == NULL) 80 return -ENOMEM; 81 82 /* create soundfont list */ 83 memset(&sf_cb, 0, sizeof(sf_cb)); 84 sf_cb.private_data = emu; 85 sf_cb.sample_new = (snd_sf_sample_new_t)emu->ops.sample_new; 86 sf_cb.sample_free = (snd_sf_sample_free_t)emu->ops.sample_free; 87 sf_cb.sample_reset = (snd_sf_sample_reset_t)emu->ops.sample_reset; 88 emu->sflist = snd_sf_new(&sf_cb, emu->memhdr); 89 if (emu->sflist == NULL) 90 return -ENOMEM; 91 92 snd_emux_init_voices(emu); 93 94 snd_emux_init_seq(emu, card, index); 95 #ifdef CONFIG_SND_OSSEMUL 96 snd_emux_init_seq_oss(emu); 97 #endif 98 snd_emux_init_virmidi(emu, card); 38 int snd_emux_new(struct snd_emux **remu) 39 { 40 struct snd_emux *emu; 41 42 *remu = NULL; 43 emu = kzalloc(sizeof(*emu), GFP_KERNEL); 44 if (emu == NULL) 45 return -ENOMEM; 46 47 spin_lock_init(&emu->voice_lock); 48 init_MUTEX(&emu->register_mutex); 49 50 emu->client = -1; 51 #ifdef CONFIG_SND_SEQUENCER_OSS 52 emu->oss_synth = NULL; 53 #endif 54 emu->max_voices = 0; 55 emu->use_time = 0; 56 57 init_timer(&emu->tlist); 58 emu->tlist.function = snd_emux_timer_callback; 59 emu->tlist.data = (unsigned long)emu; 60 emu->timer_active = 0; 61 62 *remu = emu; 63 return 0; 64 } 65 66 67 /* 68 */ 69 static int sf_sample_new(void *private_data, struct snd_sf_sample *sp, 70 struct snd_util_memhdr *hdr, 71 const void __user *buf, long count) 72 { 73 struct snd_emux *emu = private_data; 74 return emu->ops.sample_new(emu, sp, hdr, buf, count); 75 76 } 77 78 static int sf_sample_free(void *private_data, struct snd_sf_sample *sp, 79 struct snd_util_memhdr *hdr) 80 { 81 struct snd_emux *emu = private_data; 82 return emu->ops.sample_free(emu, sp, hdr); 83 84 } 85 86 static void sf_sample_reset(void *private_data) 87 { 88 struct snd_emux *emu = private_data; 89 emu->ops.sample_reset(emu); 90 } 91 92 int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name) 93 { 94 int err; 95 struct snd_sf_callback sf_cb; 96 97 snd_assert(emu->hw != NULL, return -EINVAL); 98 snd_assert(emu->max_voices > 0, return -EINVAL); 99 snd_assert(card != NULL, return -EINVAL); 100 snd_assert(name != NULL, return -EINVAL); 101 102 emu->card = card; 103 emu->name = kstrdup(name, GFP_KERNEL); 104 emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice), 105 GFP_KERNEL); 106 if (emu->voices == NULL) 107 return -ENOMEM; 108 109 /* create soundfont list */ 110 memset(&sf_cb, 0, sizeof(sf_cb)); 111 sf_cb.private_data = emu; 112 if (emu->ops.sample_new) 113 sf_cb.sample_new = sf_sample_new; 114 if (emu->ops.sample_free) 115 sf_cb.sample_free = sf_sample_free; 116 if (emu->ops.sample_reset) 117 sf_cb.sample_reset = sf_sample_reset; 118 emu->sflist = snd_sf_new(&sf_cb, emu->memhdr); 119 if (emu->sflist == NULL) 120 return -ENOMEM; 121 122 if ((err = snd_emux_init_hwdep(emu)) < 0) 123 return err; 124 125 snd_emux_init_voices(emu); 126 127 snd_emux_init_seq(emu, card, index); 128 #ifdef CONFIG_SND_SEQUENCER_OSS 129 snd_emux_init_seq_oss(emu); 130 #endif 131 snd_emux_init_virmidi(emu, card); 99 132 100 133 #ifdef CONFIG_PROC_FS 101 102 #endif 103 104 } 105 106 107 /* 108 */ 109 int snd_emux_free(s nd_emux_t*emu)110 { 111 112 113 114 115 116 117 118 119 134 snd_emux_proc_init(emu, card, index); 135 #endif 136 return 0; 137 } 138 139 140 /* 141 */ 142 int snd_emux_free(struct snd_emux *emu) 143 { 144 unsigned long flags; 145 146 if (! emu) 147 return -EINVAL; 148 149 spin_lock_irqsave(&emu->voice_lock, flags); 150 if (emu->timer_active) 151 del_timer(&emu->tlist); 152 spin_unlock_irqrestore(&emu->voice_lock, flags); 120 153 121 154 #ifdef CONFIG_PROC_FS 122 snd_emux_proc_free(emu); 123 #endif 124 snd_emux_delete_virmidi(emu); 125 #ifdef CONFIG_SND_OSSEMUL 126 snd_emux_detach_seq_oss(emu); 127 #endif 128 snd_emux_detach_seq(emu); 129 130 if (emu->sflist) 131 snd_sf_free(emu->sflist); 132 133 if (emu->voices) 134 kfree(emu->voices); 135 136 if (emu->name) 137 kfree(emu->name); 138 139 kfree(emu); 140 return 0; 155 snd_emux_proc_free(emu); 156 #endif 157 snd_emux_delete_virmidi(emu); 158 #ifdef CONFIG_SND_SEQUENCER_OSS 159 snd_emux_detach_seq_oss(emu); 160 #endif 161 snd_emux_detach_seq(emu); 162 163 snd_emux_delete_hwdep(emu); 164 165 if (emu->sflist) 166 snd_sf_free(emu->sflist); 167 168 kfree(emu->voices); 169 kfree(emu->name); 170 kfree(emu); 171 return 0; 141 172 } 142 173 … … 150 181 EXPORT_SYMBOL(snd_emux_unlock_voice); 151 182 183 /* soundfont.c */ 184 EXPORT_SYMBOL(snd_sf_linear_to_log); 185 152 186 153 187 /* … … 157 191 static int __init alsa_emux_init(void) 158 192 { 159 193 return 0; 160 194 } 161 195
Note:
See TracChangeset
for help on using the changeset viewer.