Controls API uses binary tree functions (tsearch ...).
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 */
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);
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;
#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)
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);
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)
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)
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);
{
snd_hcontrol_t *hcontrol;
+ private_data = NULL; /* to keep GCC happy */
if (handle->cerr < 0)
return;
hcontrol = snd_ctl_cfind(handle, id);
{
snd_hcontrol_t *hcontrol;
+ private_data = NULL; /* to keep GCC happy */
if (handle->cerr < 0)
return;
hcontrol = snd_ctl_cfind(handle, id);
{
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));
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);
{
snd_hcontrol_t *hcontrol;
+ private_data = NULL; /* to keep GCC happy */
if (handle->cerr < 0)
return;
hcontrol = snd_ctl_cfind(handle, id);
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);
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;
}
*/
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include "asoundlib.h"
}
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
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)
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;
}
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)
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)
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)
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;
}
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)
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)
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)
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;
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;
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;
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)
caps &= ~SND_MIXER_SCTCAP_JOINTLY_VOLUME;
}
}
+ printf("b (4)\n");
simple = build_input_scontrol(handle, sname, index);
if (simple == NULL)
return -ENOMEM;
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;
}
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;
input++;
}
handle->simple_valid = 1;
+ printf("simple build - end\n");
return 0;
}
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);
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;
}
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);
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;
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);
#include <stdio.h>
#include <malloc.h>
+#include <string.h>
#include <errno.h>
#include <sys/poll.h>
#include <sys/uio.h>
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);
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");
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);
*/
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)
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)