]> git.alsa-project.org Git - alsa-lib.git/commitdiff
64-bit fixes.
authorJaroslav Kysela <perex@perex.cz>
Fri, 4 Aug 2000 10:24:12 +0000 (10:24 +0000)
committerJaroslav Kysela <perex@perex.cz>
Fri, 4 Aug 2000 10:24:12 +0000 (10:24 +0000)
Controls API uses binary tree functions (tsearch ...).

13 files changed:
include/control.h
src/control/control_local.h
src/control/controls.c
src/control/defaults.c
src/instr/iwffff.c
src/mixer/mixer.c
src/mixer/simple.c
src/pcm/pcm.c
src/pcm/pcm_hw.c
src/pcm/pcm_local.h
src/pcm/pcm_mmap.c
src/pcm/pcm_plug.c
src/seq/seq.c

index c30a3ce5f7401ed62d63d8fb91a394d52627a586..a7c99d4c619f6c654fa5f4dba8242865392f1736 100644 (file)
@@ -57,7 +57,7 @@ int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks);
 typedef struct snd_hcontrol_stru snd_hcontrol_t;
 
 struct snd_hcontrol_stru {
-       snd_control_id_t id; 
+       snd_control_id_t id;    /* must be always on top */
        int change: 1,          /* structure change */
            value: 1;           /* value change */
        /* event callbacks */
@@ -68,20 +68,17 @@ struct snd_hcontrol_stru {
        void *private_data;
        void (*private_free)(void *private_data);
        /* links */
-       snd_hcontrol_t *prev;
-       snd_hcontrol_t *next;
+       snd_ctl_t *handle;      /* associated handle */
 };
 
-typedef int (snd_ctl_csort_t)(const snd_hcontrol_t **c1, const snd_hcontrol_t **c2);
+typedef int (snd_ctl_csort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
 typedef int (snd_ctl_ccallback_rebuild_t)(snd_ctl_t *handle, void *private_data);
 typedef int (snd_ctl_ccallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol);
 
 int snd_ctl_cbuild(snd_ctl_t *handle, snd_ctl_csort_t *csort);
 int snd_ctl_cfree(snd_ctl_t *handle);
-snd_hcontrol_t *snd_ctl_cfirst(snd_ctl_t *handle);
-snd_hcontrol_t *snd_ctl_clast(snd_ctl_t *handle);
 snd_hcontrol_t *snd_ctl_cfind(snd_ctl_t *handle, snd_control_id_t *id);
-int snd_ctl_csort(const snd_hcontrol_t **c1, const snd_hcontrol_t **c2);
+int snd_ctl_csort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
 int snd_ctl_cresort(snd_ctl_t *handle, snd_ctl_csort_t *csort);
 int snd_ctl_ccallback_rebuild(snd_ctl_t *handle, snd_ctl_ccallback_rebuild_t *callback, void *private_data);
 int snd_ctl_ccallback_add(snd_ctl_t *handle, snd_ctl_ccallback_add_t *callback, void *private_data);
index 45d0ad6c5cf7c732e3b0caa361816c50d8ab0499..d6e125319e39032a17e63e048cbe074279409c19 100644 (file)
@@ -24,8 +24,8 @@ struct snd_ctl {
        int fd;
        int ccount;
        int cerr;
-       snd_hcontrol_t *cfirst;
-       snd_hcontrol_t *clast;
+       void *croot;            /* root of controls */
+       void *croot_new;        /* new croot */
        snd_ctl_csort_t *csort;
        snd_ctl_ccallback_rebuild_t *callback_rebuild;
        void *callback_rebuild_private_data;
index 1871fffb75c4e63b720597df80a34b14c55b1e67..7b53515bbc092e4d19aac6016dca5ee40381793d 100644 (file)
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <assert.h>
+#define __USE_GNU
+#include <search.h>
 #include "asoundlib.h"
 #include "control_local.h"
 
-static void snd_ctl_link_after(snd_ctl_t *handle, snd_hcontrol_t *point, snd_hcontrol_t *hcontrol);
+static void snd_ctl_cfree1(snd_hcontrol_t *hcontrol);
 
 int snd_ctl_cbuild(snd_ctl_t *handle, snd_ctl_csort_t *csort)
 {
        snd_control_list_t list;
        snd_hcontrol_t *hcontrol, *prev;
-       int err, idx;
+       int err;
+       unsigned int idx;
 
+       printf("cbuild - start\n");
        assert(handle != NULL);
        if ((err = snd_ctl_cfree(handle)) < 0)
                return err;
-      __rebuild:
+       if (csort == NULL)
+               csort = snd_ctl_csort;
        memset(&list, 0, sizeof(list));
        do {
                if (list.pids != NULL)
@@ -68,93 +73,49 @@ int snd_ctl_cbuild(snd_ctl_t *handle, snd_ctl_csort_t *csort)
                        return -ENOMEM;
                }
                hcontrol->id = list.pids[idx];
-               if (prev == NULL) {
-                       handle->cfirst = handle->clast = hcontrol;
-                       handle->ccount = 1;
-               } else {
-                       snd_ctl_link_after(handle, prev, hcontrol);
+               hcontrol->handle = handle;
+               if (tsearch(hcontrol, &handle->croot, (__compar_fn_t)csort) == NULL) {
+                       tdestroy(&handle->croot, (__free_fn_t)snd_ctl_cfree1);
+                       handle->croot = NULL;
                }
-               prev = hcontrol;
+               handle->ccount++;
        }
        if (list.pids != NULL)
                free(list.pids);
-       if (csort != NULL && (err = snd_ctl_cresort(handle, csort)) < 0)
-               return err;
+       handle->csort = csort;
        return 0;
 }
 
-snd_hcontrol_t *snd_ctl_cfirst(snd_ctl_t *handle)
-{
-       assert(handle != NULL);
-       return handle->cfirst;
-}
-
-snd_hcontrol_t *snd_ctl_clast(snd_ctl_t *handle)
+static void snd_ctl_cfree1(snd_hcontrol_t *hcontrol)
 {
+       snd_ctl_t *handle;
+       
+       assert(hcontrol != NULL);
+       handle = hcontrol->handle;
        assert(handle != NULL);
-       return handle->clast;
-}
-
-static void snd_ctl_unlink(snd_ctl_t *handle, snd_hcontrol_t *hcontrol)
-{
-       if (handle->cfirst == hcontrol)
-               handle->cfirst = hcontrol->next;
-       if (handle->clast == hcontrol)
-               handle->clast = hcontrol->prev;
-       if (hcontrol->prev != NULL)
-               hcontrol->prev->next = hcontrol->next;
-       if (hcontrol->next != NULL)
-               hcontrol->next->prev = hcontrol->prev;
-       hcontrol->prev = hcontrol->next = NULL;
-       handle->ccount--;
-}
-
-static void snd_ctl_link_before(snd_ctl_t *handle, snd_hcontrol_t *point, snd_hcontrol_t *hcontrol)
-{
-       if (point == handle->cfirst)
-               handle->cfirst = hcontrol;
-       hcontrol->next = point;
-       hcontrol->prev = point->prev;
-       if (point->prev != NULL)
-               point->prev->next = hcontrol;
-       point->prev = hcontrol;
-       handle->ccount++;
-}
-
-static void snd_ctl_link_after(snd_ctl_t *handle, snd_hcontrol_t *point, snd_hcontrol_t *hcontrol)
-{
-       if (point == handle->clast)
-               handle->clast = hcontrol;
-       hcontrol->prev = point;
-       hcontrol->next = point->next;
-       if (point->next != NULL)
-               point->next->prev = hcontrol;
-       point->next = hcontrol;
-       handle->ccount++;
-}
-
-static void snd_ctl_cfree1(snd_ctl_t *handle, snd_hcontrol_t *hcontrol)
-{
-       snd_ctl_unlink(handle, hcontrol);
+       assert(handle->ccount > 0);
        if (hcontrol->event_remove)
                hcontrol->event_remove(handle, hcontrol);
        if (hcontrol->private_free)
                hcontrol->private_free(hcontrol->private_data);
        free(hcontrol);
+       handle->ccount--;
 }
 
 int snd_ctl_cfree(snd_ctl_t *handle)
 {
        handle->csort = NULL;
-       while (handle->cfirst)
-               snd_ctl_cfree1(handle, handle->cfirst);
+       handle->cerr = 0;
+       if (handle->croot != NULL) {
+               tdestroy(handle->croot, (__free_fn_t)snd_ctl_cfree1);
+               handle->croot = NULL;
+       }
        assert(handle->ccount == 0);
+       return 0;
 }
 
-int snd_ctl_csort(const snd_hcontrol_t **_c1, const snd_hcontrol_t **_c2)
+int snd_ctl_csort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2)
 {
-       const snd_hcontrol_t *c1 = *_c1;
-       const snd_hcontrol_t *c2 = *_c2;
        int res;
 
        res = strcmp(c1->id.name, c2->id.name);
@@ -165,54 +126,70 @@ int snd_ctl_csort(const snd_hcontrol_t **_c1, const snd_hcontrol_t **_c2)
                        return 1;
                return 0;
        }
+       return res;
+}
+
+static void snd_ctl_cresort_action(snd_hcontrol_t *hcontrol, VISIT which, int level)
+{
+       snd_ctl_t *handle;
+
+       level = 0;                      /* to keep GCC happy */
+       assert(hcontrol != NULL);
+       handle = hcontrol->handle;
+       assert(handle != NULL);
+       if (handle->cerr < 0)
+               return;
+       switch (which) {
+       case preorder: break;
+       case postorder: break;
+       case endorder:
+       case leaf:
+               if (tsearch(hcontrol, &handle->croot, (__compar_fn_t)handle->csort) == NULL)
+                       handle->cerr = -ENOMEM;
+               break;
+       }
+}
+
+static void snd_ctl_cresort_free(snd_hcontrol_t *hcontrol)
+{
+       hcontrol = NULL;                /* to keep GCC happy */
+       /* nothing */
 }
 
 int snd_ctl_cresort(snd_ctl_t *handle, snd_ctl_csort_t *csort)
 {
-       int idx, count;
-       snd_hcontrol_t **pmap, *hcontrol;
+       int result;
+       snd_ctl_csort_t *csort_old;
 
        assert(handle != NULL && csort != NULL);
        if (handle->ccount == 0)
                return 0;
-       pmap = (snd_hcontrol_t **)calloc(handle->ccount, sizeof(snd_hcontrol_t *));
-       if (pmap == NULL)
-               return -ENOMEM;
-       for (hcontrol = handle->cfirst, idx = 0; hcontrol != NULL; hcontrol = hcontrol->next, idx++) {
-               printf("idx = %i, hcontrol = 0x%x (0x%x), '%s'\n", idx, (int)hcontrol, (int)&pmap[idx], hcontrol->id.name);
-               pmap[idx] = hcontrol;
-       }
-       assert(idx == handle->ccount);
+       if (handle->cerr < 0)
+               return handle->cerr;
+       assert(handle->croot_new == NULL);
+       csort_old = handle->csort;
        handle->csort = csort;
-       qsort(pmap, count = handle->ccount, sizeof(snd_hcontrol_t *), (int (*)(const void *, const void *))csort);
-       while (handle->cfirst)
-               snd_ctl_unlink(handle, handle->cfirst);
-       handle->cfirst = handle->clast = pmap[0]; handle->ccount = 1;
-       for (idx = 1; idx < count; idx++)
-               snd_ctl_link_after(handle, pmap[idx-1], pmap[idx]);
-       free(pmap);
+       twalk(handle->croot, (__action_fn_t)snd_ctl_cresort_action);
+       if (handle->cerr < 0) {
+               result = handle->cerr;
+               handle->cerr = 0;
+               handle->csort = csort_old;
+               tdestroy(handle->croot_new, (__free_fn_t)snd_ctl_cresort_free);
+               handle->croot_new = NULL;
+               return result;
+       }
+       tdestroy(handle->croot, (__free_fn_t)snd_ctl_cresort_free);
+       handle->croot = handle->croot_new;
+       handle->croot_new = NULL;
        return 0;
 }
 
 snd_hcontrol_t *snd_ctl_cfind(snd_ctl_t *handle, snd_control_id_t *id)
 {
-       snd_hcontrol_t *hcontrol;
-       
        assert(handle != NULL);
-       for (hcontrol = handle->cfirst; hcontrol != NULL; hcontrol = hcontrol->next) {
-               if (hcontrol->id.iface != id->iface)
-                       continue;
-               if (hcontrol->id.device != id->device)
-                       continue;
-               if (hcontrol->id.subdevice != id->subdevice)
-                       continue;
-               if (strncmp(hcontrol->id.name, id->name, sizeof(hcontrol->id.name)))
-                       continue;
-               if (hcontrol->id.index != id->index)
-                       continue;
-               return hcontrol;
-       }
-       return NULL;
+       if (handle->croot == NULL)
+               return NULL;
+       return (snd_hcontrol_t *)tfind(id, &handle->croot, (__compar_fn_t)handle->csort);
 }
 
 int snd_ctl_ccallback_rebuild(snd_ctl_t *handle, snd_ctl_ccallback_rebuild_t *callback, void *private_data)
@@ -220,6 +197,7 @@ int snd_ctl_ccallback_rebuild(snd_ctl_t *handle, snd_ctl_ccallback_rebuild_t *ca
        assert(handle != NULL);
        handle->callback_rebuild = callback;
        handle->callback_rebuild_private_data = private_data;
+       return 0;
 }
 
 int snd_ctl_ccallback_add(snd_ctl_t *handle, snd_ctl_ccallback_add_t *callback, void *private_data)
@@ -227,10 +205,12 @@ int snd_ctl_ccallback_add(snd_ctl_t *handle, snd_ctl_ccallback_add_t *callback,
        assert(handle != NULL);
        handle->callback_add = callback;
        handle->callback_add_private_data = private_data;
+       return 0;
 }
 
 static void callback_rebuild(snd_ctl_t *handle, void *private_data)
 {
+       private_data = NULL;    /* to keep GCC happy */
        handle->cerr = snd_ctl_cbuild(handle, handle->csort);
        if (handle->cerr >= 0 && handle->callback_rebuild)
                handle->callback_rebuild(handle, handle->callback_rebuild_private_data);
@@ -240,6 +220,7 @@ static void callback_change(snd_ctl_t *handle, void *private_data, snd_control_i
 {
        snd_hcontrol_t *hcontrol;
 
+       private_data = NULL;    /* to keep GCC happy */
        if (handle->cerr < 0)
                return;
        hcontrol = snd_ctl_cfind(handle, id);
@@ -254,6 +235,7 @@ static void callback_value(snd_ctl_t *handle, void *private_data, snd_control_id
 {
        snd_hcontrol_t *hcontrol;
 
+       private_data = NULL;    /* to keep GCC happy */
        if (handle->cerr < 0)
                return;
        hcontrol = snd_ctl_cfind(handle, id);
@@ -268,6 +250,7 @@ static void callback_add(snd_ctl_t *handle, void *private_data, snd_control_id_t
 {
        snd_hcontrol_t *hcontrol, *icontrol;
 
+       private_data = NULL;    /* to keep GCC happy */
        if (handle->cerr < 0)
                return;
        hcontrol = (snd_hcontrol_t *)calloc(1, sizeof(snd_hcontrol_t));
@@ -276,17 +259,16 @@ static void callback_add(snd_ctl_t *handle, void *private_data, snd_control_id_t
                return;
        }
        hcontrol->id = *id;
-       if (handle->csort != NULL) {
-               for (icontrol = handle->cfirst; icontrol != NULL; icontrol = icontrol->next) {
-                       if (handle->csort((const snd_hcontrol_t **)&icontrol, (const snd_hcontrol_t **)&hcontrol) > 0) {
-                               snd_ctl_link_before(handle, icontrol, hcontrol);
-                               break;
-                       }
-               }
-               if (icontrol == NULL)
-                       snd_ctl_link_after(handle, handle->clast, hcontrol);
-       } else {
-               snd_ctl_link_after(handle, handle->clast, hcontrol);
+       hcontrol->handle = handle;
+       icontrol = tsearch(hcontrol, &handle->croot, (__compar_fn_t)handle->csort);
+       if (icontrol == NULL) {
+               free(hcontrol);
+               handle->cerr = -ENOMEM;
+               return;
+       }
+       if (icontrol != hcontrol) {     /* double hit */
+               free(hcontrol);
+               return;
        }
        if (handle->callback_add)
                handle->callback_add(handle, handle->callback_add_private_data, hcontrol);
@@ -296,6 +278,7 @@ static void callback_remove(snd_ctl_t *handle, void *private_data, snd_control_i
 {
        snd_hcontrol_t *hcontrol;
 
+       private_data = NULL;    /* to keep GCC happy */
        if (handle->cerr < 0)
                return;
        hcontrol = snd_ctl_cfind(handle, id);
@@ -303,19 +286,42 @@ static void callback_remove(snd_ctl_t *handle, void *private_data, snd_control_i
                handle->cerr = -ENOENT;
                return;
        }
-       snd_ctl_cfree1(handle, hcontrol);
+       if (tdelete(hcontrol, &handle->croot, (__compar_fn_t)handle->csort) != NULL)
+               snd_ctl_cfree1(hcontrol);
+}
+
+static void snd_ctl_cevent_walk1(snd_hcontrol_t *hcontrol, VISIT which, int level)
+{
+       level = 0;      /* to keep GCC happy */
+       assert(hcontrol != NULL);
+       switch (which) {
+       case preorder: break;
+       case postorder: break;
+       case endorder:
+       case leaf:
+               if (hcontrol->change && hcontrol->event_change) {
+                       hcontrol->event_change(hcontrol->handle, hcontrol);
+                       hcontrol->change = 0;
+               }
+               if (hcontrol->value && hcontrol->event_value) {
+                       hcontrol->event_value(hcontrol->handle, hcontrol);
+                       hcontrol->value = 0;
+               }                       
+               break;
+       }
 }
 
 int snd_ctl_cevent(snd_ctl_t *handle)
 {
-       snd_ctl_callbacks_t callbacks = {
+       static snd_ctl_callbacks_t callbacks = {
                rebuild: callback_rebuild,
                value: callback_value,
                change: callback_change,
                add: callback_add,
-               remove: callback_remove
+               remove: callback_remove,
+               private_data: NULL,
+               reserved: { NULL, }
        };
-       snd_hcontrol_t *hcontrol;
        int res;
 
        assert(handle != NULL);
@@ -325,15 +331,6 @@ int snd_ctl_cevent(snd_ctl_t *handle)
                return res;
        if (handle->cerr < 0)
                return handle->cerr;
-       for (hcontrol = handle->cfirst; hcontrol != NULL; hcontrol = hcontrol->next) {
-               if (hcontrol->change && hcontrol->event_change) {
-                       hcontrol->event_change(handle, hcontrol);
-                       hcontrol->change = 0;
-               }
-               if (hcontrol->value && hcontrol->event_value) {
-                       hcontrol->event_value(handle, hcontrol);
-                       hcontrol->value = 0;
-               }                       
-       }
+       twalk(handle->croot, (__action_fn_t)snd_ctl_cevent_walk1);
        return res;
 }
index 5e6a27eb44c8d2610698e190857ed64d0284ba79..a2cd56031a26d074434df037abb7e559cc071e12 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <errno.h>
 #include "asoundlib.h"
 
index dafcebac88f4010738fe4d05a1d83db506f27359..5c09cb824609c30fce8178646ecd7f5a7ce686c1 100644 (file)
@@ -245,7 +245,7 @@ int snd_instr_iwffff_open(snd_iwffff_handle_t **handle, const char *name_fff, co
        }
        iwf->share_id1 = IWFFFF_SHARE_FILE;
 #ifdef __alpha__
-       iwf->share_id2 = (info.st_dev << 16) | ((info.st_ino >> 32) & 0xffff);
+       iwf->share_id2 = (info.st_dev << 16) /* | ((info.st_ino >> 32) & 0xffff) */;
 #else
        iwf->share_id2 = info.st_dev << 16;
 #endif
index d28f9cf431887a331312f3583d47729e7efe7bfb..1c9f27c1e6d491fb3997676b4743a4e19a0d31b9 100644 (file)
@@ -206,7 +206,6 @@ static void snd_mixer_simple_read_remove(snd_ctl_t *ctl_handle, void *private_da
 
 int snd_mixer_simple_read(snd_mixer_t *handle, snd_mixer_simple_callbacks_t *callbacks)
 {
-       snd_ctl_callbacks_t xcallbacks;
        int err;
 
        if (handle == NULL)
index c0e554eb0e27508d80e4d196b4060f450fc16de0..f9e4bfc75c0859e78d296f70a1fc7b09340c98a6 100644 (file)
@@ -38,8 +38,9 @@ static int test_mixer_id(snd_mixer_t *handle, const char *name, int index)
        id.iface = SND_CONTROL_IFACE_MIXER;
        strcpy(id.name, name);
        id.index = index;
+       printf("look\n");
        hcontrol = snd_ctl_cfind(handle->ctl_handle, &id);
-       // fprintf(stderr, "Looking for control: '%s', %i (0x%lx)\n", name, index, (long)hcontrol);
+       fprintf(stderr, "Looking for control: '%s', %i (0x%lx)\n", name, index, (long)hcontrol);
        return hcontrol != NULL;
 }
 
@@ -130,6 +131,7 @@ static int input_get_volume(snd_mixer_t *handle, mixer_simple_t *simple, snd_mix
                return err;
        for (idx = 0; idx < simple->voices && idx < 32; idx++)
                control->volume.values[idx] = ctl.value.integer.value[voices == 1 ? 0 : idx];
+       return 0;
 }
 
 static int input_get_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
@@ -144,6 +146,7 @@ static int input_get_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, sn
        for (idx = 0; idx < simple->voices && idx < 32; idx++)
                if (ctl.value.integer.value[voices == 1 ? 0 : idx] == 0)
                        control->mute |= 1 << idx;
+       return 0;
 }
 
 static int input_get_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
@@ -158,6 +161,7 @@ static int input_get_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple,
        for (idx = 0; idx < simple->voices && idx < 32; idx++)
                if (ctl.value.integer.value[voices == 1 ? 0 : idx])
                        control->capture |= 1 << idx;
+       return 0;
 }
 
 static int input_get(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control)
@@ -197,7 +201,6 @@ static int input_get(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simp
                if (simple->present & MIXER_PRESENT_CAPTURE_SWITCH) {
                        input_get_capture_switch(handle, simple, control, "Capture ", simple->cswitch_values);
                } else if (simple->present & MIXER_PRESENT_CAPTURE_SOURCE) {
-                       char str[128];
                        snd_control_t ctl;
                        if ((err = get_mixer_read(handle, "Capture Source", 0, &ctl)) < 0)
                                return err;
@@ -224,6 +227,7 @@ static int input_put_volume(snd_mixer_t *handle, mixer_simple_t *simple, snd_mix
        }
        if ((err = put_mixer_write(handle, str, simple->sid.index, &ctl)) < 0)
                return err;
+       return 0;
 }
 
 static int input_put_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
@@ -242,6 +246,7 @@ static int input_put_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, sn
        err = put_mixer_write(handle, str, simple->sid.index, &ctl);
        if ((err = put_mixer_write(handle, str, simple->sid.index, &ctl)) < 0)
                return err;
+       return 0;
 }
 
 static int input_put_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
@@ -257,6 +262,7 @@ static int input_put_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple,
                ctl.value.integer.value[idx] = (control->capture & (1 << idx)) ? 1 : 0;
        if ((err = put_mixer_write(handle, str, simple->sid.index, &ctl)) < 0)
                return err;
+       return 0;
 }
 
 static int input_put(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control)
@@ -285,7 +291,6 @@ static int input_put(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simp
                if (simple->present & MIXER_PRESENT_CAPTURE_SWITCH) {
                        input_put_capture_switch(handle, simple, control, "Capture ", simple->cswitch_values);
                } else if (simple->present & MIXER_PRESENT_CAPTURE_SOURCE) {
-                       char str[128];
                        snd_control_t ctl;
                        if ((err = get_mixer_read(handle, "Capture Source", 0, &ctl)) < 0)
                                return err;
@@ -320,8 +325,8 @@ static mixer_simple_t *build_input_scontrol(snd_mixer_t *handle, const char *sna
 static int build_input(snd_mixer_t *handle, const char *sname)
 {
        char str[128];
-       unsigned int present, caps, capture_item;
-       int index = -1, voices, err;
+       unsigned int present, caps, capture_item, voices;
+       int index = -1, err;
        snd_control_info_t gswitch_info, pswitch_info, cswitch_info;
        snd_control_info_t gvolume_info, pvolume_info, cvolume_info;
        snd_control_info_t csource_info;
@@ -334,15 +339,19 @@ static int build_input(snd_mixer_t *handle, const char *sname)
        memset(&gvolume_info, 0, sizeof(gvolume_info));
        memset(&pvolume_info, 0, sizeof(pvolume_info));
        memset(&cvolume_info, 0, sizeof(cvolume_info));
+       printf("b (1)\n");
        do {
                index++;
                voices = 0;
                present = caps = capture_item = 0;
                min = max = 0;
                sprintf(str, "%s Switch", sname);
+               printf("b (2)\n");
                if (test_mixer_id(handle, str, index)) {
+                       printf("b (3)\n");
                        if ((err = get_mixer_info(handle, str, index, &gswitch_info)) < 0)
                                return err;
+                       printf("b (4)\n");
                        if (gswitch_info.type == SND_CONTROL_TYPE_BOOLEAN) {
                                if (voices < gswitch_info.values_count)
                                        voices = gswitch_info.values_count;
@@ -350,6 +359,7 @@ static int build_input(snd_mixer_t *handle, const char *sname)
                                present |= MIXER_PRESENT_GLOBAL_SWITCH;
                        }
                }
+               printf("b (3)\n");
                sprintf(str, "%s Volume", sname);
                if (test_mixer_id(handle, str, index)) {
                        if ((err = get_mixer_info(handle, str, index, &gvolume_info)) < 0)
@@ -473,6 +483,7 @@ static int build_input(snd_mixer_t *handle, const char *sname)
                                        caps &= ~SND_MIXER_SCTCAP_JOINTLY_VOLUME;
                        }
                }
+               printf("b (4)\n");
                simple = build_input_scontrol(handle, sname, index);
                if (simple == NULL)
                        return -ENOMEM;
@@ -489,7 +500,7 @@ static int build_input(snd_mixer_t *handle, const char *sname)
                simple->voices = voices;
                simple->min = min;
                simple->max = max;
-               // fprintf(stderr, "sname = '%s', index = %i, present = 0x%x, voices = %i\n", sname, index, present, voices);
+               fprintf(stderr, "sname = '%s', index = %i, present = 0x%x, voices = %i\n", sname, index, present, voices);
        } while (present != 0);
        return 0;
 }
@@ -516,9 +527,11 @@ int snd_mixer_simple_build(snd_mixer_t *handle)
        char **input = inputs;
        int err;
 
+       printf("simple build - start\n");
        if ((err = snd_ctl_cbuild(handle->ctl_handle, snd_ctl_csort)) < 0)
                return err;
        while (*input) {
+               printf("simple build - input '%s'\n", *input);
                if ((err = build_input(handle, *input)) < 0) {
                        snd_mixer_simple_destroy(handle);
                        return err;
@@ -526,6 +539,7 @@ int snd_mixer_simple_build(snd_mixer_t *handle)
                input++;
        }
        handle->simple_valid = 1;
+       printf("simple build - end\n");
        return 0;
 }
 
index 1b990fad4efccf7f6eddda4da4199f39356b4086..658f0f031e84d35eb9b2ef99ea9efaf2bd82437b 100644 (file)
@@ -139,7 +139,7 @@ int snd_pcm_state(snd_pcm_t *handle)
        return handle->fast_ops->state(handle->fast_op_arg);
 }
 
-int snd_pcm_frame_io(snd_pcm_t *handle, int update)
+ssize_t snd_pcm_frame_io(snd_pcm_t *handle, int update)
 {
        assert(handle);
        assert(handle->valid_setup);
@@ -428,16 +428,16 @@ int snd_pcm_dump_setup(snd_pcm_t *handle, FILE *fp)
        fprintf(fp, "xrun_mode: %s\n", assoc(setup->xrun_mode, xruns));
        fprintf(fp, "time: %s\n", assoc(setup->time, onoff));
        // ust_time
-       fprintf(fp, "buffer_size: %d\n", setup->buffer_size);
-       fprintf(fp, "frag_size: %d\n", setup->frag_size);
-       fprintf(fp, "frags: %d\n", setup->frags);
-       fprintf(fp, "frame_boundary: %d\n", setup->frame_boundary);
+       fprintf(fp, "buffer_size: %ld\n", (long)setup->buffer_size);
+       fprintf(fp, "frag_size: %ld\n", (long)setup->frag_size);
+       fprintf(fp, "frags: %ld\n", (long)setup->frags);
+       fprintf(fp, "frame_boundary: %ld\n", (long)setup->frame_boundary);
        fprintf(fp, "msbits_per_sample: %d\n", setup->msbits_per_sample);
-       fprintf(fp, "frames_min: %d\n", setup->frames_min);
-       fprintf(fp, "frames_align: %d\n", setup->frames_align);
-       fprintf(fp, "frames_xrun_max: %d\n", setup->frames_xrun_max);
+       fprintf(fp, "frames_min: %ld\n", (long)setup->frames_min);
+       fprintf(fp, "frames_align: %ld\n", (long)setup->frames_align);
+       fprintf(fp, "frames_xrun_max: %ld\n", (long)setup->frames_xrun_max);
        fprintf(fp, "fill_mode: %s\n", assoc(setup->fill_mode, fills));
-       fprintf(fp, "frames_fill_max: %d\n", setup->frames_fill_max);
+       fprintf(fp, "frames_fill_max: %ld\n", (long)setup->frames_fill_max);
        return 0;
 }
 
@@ -473,28 +473,28 @@ int snd_pcm_format_value(const char* name)
        return -1;
 }
 
-ssize_t snd_pcm_bytes_to_frames(snd_pcm_t *handle, int bytes)
+ssize_t snd_pcm_bytes_to_frames(snd_pcm_t *handle, ssize_t bytes)
 {
        assert(handle);
        assert(handle->valid_setup);
        return bytes * 8 / handle->bits_per_frame;
 }
 
-ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *handle, int frames)
+ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *handle, ssize_t frames)
 {
        assert(handle);
        assert(handle->valid_setup);
        return frames * handle->bits_per_frame / 8;
 }
 
-ssize_t snd_pcm_bytes_to_samples(snd_pcm_t *handle, int bytes)
+ssize_t snd_pcm_bytes_to_samples(snd_pcm_t *handle, ssize_t bytes)
 {
        assert(handle);
        assert(handle->valid_setup);
        return bytes * 8 / handle->bits_per_sample;
 }
 
-ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *handle, int samples)
+ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *handle, ssize_t samples)
 {
        assert(handle);
        assert(handle->valid_setup);
index e67072261fef3fabf3f4dcfd4d0423b217a443fb..ed2cc8de65ef871e7f084a0ef789f5597305621f 100644 (file)
@@ -121,7 +121,7 @@ static int snd_pcm_hw_status(void *private, snd_pcm_status_t * status)
        return 0;
 }
 
-static ssize_t snd_pcm_hw_state(void *private)
+static int snd_pcm_hw_state(void *private)
 {
        snd_pcm_hw_t *hw = (snd_pcm_hw_t*) private;
        int fd = hw->fd;
index e7fba8addda77753332984a43485f0996d6b558a..e43276497f0ce550ea00e8f88f854b33bbeedca4 100644 (file)
@@ -111,9 +111,9 @@ int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug,
                                        bitset_t *client_vmask);
 int snd_pcm_plug_capture_channels_mask(snd_pcm_plug_t *plug,
                                       bitset_t *client_vmask);
-int snd_pcm_plugin_client_channels(snd_pcm_plugin_t *plugin,
-                                  size_t frames,
-                                  snd_pcm_plugin_channel_t **channels);
+ssize_t snd_pcm_plugin_client_channels(snd_pcm_plugin_t *plugin,
+                                      size_t frames,
+                                      snd_pcm_plugin_channel_t **channels);
 
 void *snd_pcm_plug_buf_alloc(snd_pcm_plug_t *plug, size_t size);
 void snd_pcm_plug_buf_unlock(snd_pcm_plug_t *pcm, void *ptr);
index 8d03bb38aad248bd0a9e0d7a3621d2f2e93349d1..441becf65d2a0edbcced3a1b4e12f50c196e0dc8 100644 (file)
@@ -20,6 +20,7 @@
   
 #include <stdio.h>
 #include <malloc.h>
+#include <string.h>
 #include <errno.h>
 #include <sys/poll.h>
 #include <sys/uio.h>
@@ -118,7 +119,7 @@ int snd_pcm_mmap_state(snd_pcm_t *handle)
        return handle->mmap_status->state;
 }
 
-int snd_pcm_mmap_frame_io(snd_pcm_t *handle)
+ssize_t snd_pcm_mmap_frame_io(snd_pcm_t *handle)
 {
        assert(handle);
        assert(handle->mmap_status);
index 2874e0f649b1a9feec069143a6a3a45aa3fb98b4..c1b45e7f681a4e84cc2e83b0b7f80365d01239c4 100644 (file)
@@ -68,7 +68,7 @@ int snd_pcm_plugin_append(snd_pcm_plugin_t *plugin)
 void snd_pcm_plugin_dump(snd_pcm_plugin_t *plugin, FILE *fp)
 {
        fprintf(fp, "----------- %s\n", plugin->name);
-       fprintf(fp, "Buffer: %d frames\n", plugin->buf_frames);
+       fprintf(fp, "Buffer: %ld frames\n", (long)plugin->buf_frames);
        if (plugin->src_format.interleave != plugin->dst_format.interleave) {
                if (plugin->src_format.interleave)
                        fprintf(fp, "Interleaved -> Non interleaved\n");
@@ -314,7 +314,7 @@ static int snd_pcm_plug_state(void *private)
        return snd_pcm_state(plug->slave);
 }
 
-static int snd_pcm_plug_frame_io(void *private, int update)
+static ssize_t snd_pcm_plug_frame_io(void *private, int update)
 {
        snd_pcm_plug_t *plug = (snd_pcm_plug_t*) private;
        ssize_t frame_io = snd_pcm_frame_io(plug->slave, update);
index 7f552dbe52ee53656294afd2522362b0646a5387..e150d337a753db52a550dc998dea217e35d31ec9 100644 (file)
@@ -733,7 +733,8 @@ int snd_seq_flush_output(snd_seq_t *seq)
  */
 int snd_seq_extract_output(snd_seq_t *seq, snd_seq_event_t **ev_res)
 {
-       int len, olen, err;
+       size_t len, olen;
+       int err;
        snd_seq_event_t *ev;
 
        if (!seq)
@@ -890,7 +891,7 @@ static int snd_seq_decode_event(char **buf, size_t *len, snd_seq_event_t *ev)
 static int snd_seq_event_read_buffer(snd_seq_t *seq)
 {
        char *buf;
-       int count;
+       ssize_t count;
 
        count = read(seq->fd, seq->ibuf, seq->ibufsize);
        if (count < 0)