fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / sound / synth / emux / emux.c
index 0476d06..573e370 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/wait.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/emux_synth.h>
 #include <linux/init.h>
@@ -34,17 +35,17 @@ MODULE_LICENSE("GPL");
 /*
  * create a new hardware dependent device for Emu8000/Emu10k1
  */
-int snd_emux_new(snd_emux_t **remu)
+int snd_emux_new(struct snd_emux **remu)
 {
-       snd_emux_t *emu;
+       struct snd_emux *emu;
 
        *remu = NULL;
-       emu = kcalloc(1, sizeof(*emu), GFP_KERNEL);
+       emu = kzalloc(sizeof(*emu), GFP_KERNEL);
        if (emu == NULL)
                return -ENOMEM;
 
        spin_lock_init(&emu->voice_lock);
-       init_MUTEX(&emu->register_mutex);
+       mutex_init(&emu->register_mutex);
 
        emu->client = -1;
 #ifdef CONFIG_SND_SEQUENCER_OSS
@@ -62,13 +63,37 @@ int snd_emux_new(snd_emux_t **remu)
        return 0;
 }
 
+EXPORT_SYMBOL(snd_emux_new);
 
 /*
  */
-int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name)
+static int sf_sample_new(void *private_data, struct snd_sf_sample *sp,
+                                 struct snd_util_memhdr *hdr,
+                                 const void __user *buf, long count)
+{
+       struct snd_emux *emu = private_data;
+       return emu->ops.sample_new(emu, sp, hdr, buf, count);
+       
+}
+
+static int sf_sample_free(void *private_data, struct snd_sf_sample *sp,
+                                  struct snd_util_memhdr *hdr)
+{
+       struct snd_emux *emu = private_data;
+       return emu->ops.sample_free(emu, sp, hdr);
+       
+}
+
+static void sf_sample_reset(void *private_data)
+{
+       struct snd_emux *emu = private_data;
+       emu->ops.sample_reset(emu);
+}
+
+int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name)
 {
        int err;
-       snd_sf_callback_t sf_cb;
+       struct snd_sf_callback sf_cb;
 
        snd_assert(emu->hw != NULL, return -EINVAL);
        snd_assert(emu->max_voices > 0, return -EINVAL);
@@ -76,17 +101,21 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name)
        snd_assert(name != NULL, return -EINVAL);
 
        emu->card = card;
-       emu->name = snd_kmalloc_strdup(name, GFP_KERNEL);
-       emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
+       emu->name = kstrdup(name, GFP_KERNEL);
+       emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice),
+                             GFP_KERNEL);
        if (emu->voices == NULL)
                return -ENOMEM;
 
        /* create soundfont list */
        memset(&sf_cb, 0, sizeof(sf_cb));
        sf_cb.private_data = emu;
-       sf_cb.sample_new = (snd_sf_sample_new_t)emu->ops.sample_new;
-       sf_cb.sample_free = (snd_sf_sample_free_t)emu->ops.sample_free;
-       sf_cb.sample_reset = (snd_sf_sample_reset_t)emu->ops.sample_reset;
+       if (emu->ops.sample_new)
+               sf_cb.sample_new = sf_sample_new;
+       if (emu->ops.sample_free)
+               sf_cb.sample_free = sf_sample_free;
+       if (emu->ops.sample_reset)
+               sf_cb.sample_reset = sf_sample_reset;
        emu->sflist = snd_sf_new(&sf_cb, emu->memhdr);
        if (emu->sflist == NULL)
                return -ENOMEM;
@@ -108,10 +137,11 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name)
        return 0;
 }
 
+EXPORT_SYMBOL(snd_emux_register);
 
 /*
  */
-int snd_emux_free(snd_emux_t *emu)
+int snd_emux_free(struct snd_emux *emu)
 {
        unsigned long flags;
 
@@ -137,28 +167,14 @@ int snd_emux_free(snd_emux_t *emu)
        if (emu->sflist)
                snd_sf_free(emu->sflist);
 
-       if (emu->voices)
-               kfree(emu->voices);
-
-       if (emu->name)
-               kfree(emu->name);
-
+       kfree(emu->voices);
+       kfree(emu->name);
        kfree(emu);
        return 0;
 }
 
-
-EXPORT_SYMBOL(snd_emux_new);
-EXPORT_SYMBOL(snd_emux_register);
 EXPORT_SYMBOL(snd_emux_free);
 
-EXPORT_SYMBOL(snd_emux_terminate_all);
-EXPORT_SYMBOL(snd_emux_lock_voice);
-EXPORT_SYMBOL(snd_emux_unlock_voice);
-
-/* soundfont.c */
-EXPORT_SYMBOL(snd_sf_linear_to_log);
-
 
 /*
  *  INIT part