"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "usb_stream/pcm_usb_stream.c" between
alsa-plugins-1.2.2.tar.bz2 and alsa-plugins-1.2.5.tar.bz2

About: ALSA (Advanced Linux Sound Architecture) - Additional plugins for various audio libraries and sound servers.

pcm_usb_stream.c  (alsa-plugins-1.2.2.tar.bz2):pcm_usb_stream.c  (alsa-plugins-1.2.5.tar.bz2)
skipping to change at line 53 skipping to change at line 53
#ifdef VDEBUG #ifdef VDEBUG
#define VDBG(f, ...) \ #define VDBG(f, ...) \
fprintf(stderr, "%s:%i %i "f"\n", __FUNCTION__, __LINE__, getpid(), ## __ VA_ARGS__); fprintf(stderr, "%s:%i %i "f"\n", __FUNCTION__, __LINE__, getpid(), ## __ VA_ARGS__);
#else #else
#define VDBG(f, ...) #define VDBG(f, ...)
#endif #endif
#define FRAME_SIZE 6 #define FRAME_SIZE 6
#define LCARD 32
struct user_usb_stream { struct user_usb_stream {
char card[LCARD]; int card;
unsigned use; unsigned use;
struct usb_stream *s; struct usb_stream *s;
void *write_area; void *write_area;
struct user_usb_stream *next; struct user_usb_stream *next;
}; };
typedef struct { typedef struct {
snd_pcm_ioplug_t io; snd_pcm_ioplug_t io;
snd_hwdep_t *hwdep; snd_hwdep_t *hwdep;
skipping to change at line 82 skipping to change at line 81
unsigned periods_done; unsigned periods_done;
unsigned channels; unsigned channels;
snd_pcm_uframes_t period_size; snd_pcm_uframes_t period_size;
unsigned int rate; unsigned int rate;
} snd_pcm_us_t; } snd_pcm_us_t;
static struct user_usb_stream *uus; static struct user_usb_stream *uus;
static pthread_mutex_t uus_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t uus_mutex = PTHREAD_MUTEX_INITIALIZER;
static struct user_usb_stream *get_uus(const char *card) static struct user_usb_stream *get_uus(int card)
{ {
pthread_mutex_lock(&uus_mutex); pthread_mutex_lock(&uus_mutex);
struct user_usb_stream **l_uus = &uus, struct user_usb_stream **l_uus = &uus,
*r_uus = NULL; *r_uus = NULL;
while (*l_uus) { while (*l_uus) {
if (strcmp((*l_uus)->card, card) == 0) { if ((*l_uus)->card == card) {
r_uus = *l_uus; r_uus = *l_uus;
r_uus->use++; r_uus->use++;
goto unlock; goto unlock;
} }
l_uus = &(*l_uus)->next; l_uus = &(*l_uus)->next;
} }
r_uus = calloc(1, sizeof(*r_uus)); r_uus = calloc(1, sizeof(*r_uus));
if (r_uus) { if (r_uus) {
r_uus->use = 1; r_uus->use = 1;
strcpy(r_uus->card, card); r_uus->card = card;
*l_uus = r_uus; *l_uus = r_uus;
} }
unlock: unlock:
pthread_mutex_unlock(&uus_mutex); pthread_mutex_unlock(&uus_mutex);
return r_uus; return r_uus;
} }
static void uus_free(snd_pcm_us_t *us) static void uus_free(snd_pcm_us_t *us)
{ {
skipping to change at line 401 skipping to change at line 400
(err = snd_pcm_ioplug_set_param_minmax(&us->io, SND_PCM_IOPLUG_HW_PER IOD_BYTES, (err = snd_pcm_ioplug_set_param_minmax(&us->io, SND_PCM_IOPLUG_HW_PER IOD_BYTES,
period_bytes_min, period_bytes _max)) < 0 || period_bytes_min, period_bytes _max)) < 0 ||
(err = snd_pcm_ioplug_set_param_minmax(&us->io, SND_PCM_IOPLUG_HW_PER IODS, (err = snd_pcm_ioplug_set_param_minmax(&us->io, SND_PCM_IOPLUG_HW_PER IODS,
2, 2)) < 0) 2, 2)) < 0)
return err; return err;
return 0; return 0;
} }
static int snd_pcm_us_open(snd_pcm_t **pcmp, const char *name, static int snd_pcm_us_open(snd_pcm_t **pcmp, const char *name,
const char *card, int card,
snd_pcm_stream_t stream, int mode, snd_pcm_stream_t stream, int mode,
snd_pcm_uframes_t period_size, snd_pcm_uframes_t period_size,
unsigned int rate) unsigned int rate)
{ {
snd_pcm_us_t *us; snd_pcm_us_t *us;
int err; int err;
char us_name[32]; char us_name[32];
if (strlen(card) >= LCARD)
return -EINVAL;
assert(pcmp); assert(pcmp);
us = calloc(1, sizeof(*us)); us = calloc(1, sizeof(*us));
if (!us) if (!us)
return -ENOMEM; return -ENOMEM;
if (snprintf(us_name, sizeof(us_name), "hw:%s", card) if (snprintf(us_name, sizeof(us_name), "hw:%d", card)
>= (int)sizeof(us_name)) { >= (int)sizeof(us_name)) {
fprintf(stderr, "%s: WARNING: USB_STREAM client name '%s' truncat ed to %d characters, might not be unique\n", fprintf(stderr, "%s: WARNING: USB_STREAM client name '%s' truncat ed to %d characters, might not be unique\n",
__func__, us_name, (int)strlen(us_name)); __func__, us_name, (int)strlen(us_name));
} }
VDBG("%i %s", stream, us_name); VDBG("%i %s", stream, us_name);
us->uus = get_uus(card); us->uus = get_uus(card);
if (!us->uus) { if (!us->uus) {
free(us); free(us);
return -ENOMEM; return -ENOMEM;
} }
skipping to change at line 470 skipping to change at line 466
VDBG(""); VDBG("");
*pcmp = us->io.pcm; *pcmp = us->io.pcm;
return 0; return 0;
} }
SND_PCM_PLUGIN_DEFINE_FUNC(usb_stream) SND_PCM_PLUGIN_DEFINE_FUNC(usb_stream)
{ {
snd_config_iterator_t i, next; snd_config_iterator_t i, next;
const char *card; int err, card = -1;
int err;
long period_size = 0, rate = 0; long period_size = 0, rate = 0;
snd_config_for_each(i, next, conf) { snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i); snd_config_t *n = snd_config_iterator_entry(i);
const char *id; const char *id;
if (snd_config_get_id(n, &id) < 0) if (snd_config_get_id(n, &id) < 0)
continue; continue;
if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0) if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0)
continue; continue;
if (strcmp(id, "card") == 0) { if (strcmp(id, "card") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) { card = snd_config_get_card(n);
SNDERR("Invalid type for %s", id); if (card < 0) {
SNDERR("Invalid card '%s'", id);
return -EINVAL; return -EINVAL;
} }
snd_config_get_string(n, &card);
continue; continue;
} }
if (strcmp(id, "period_size") == 0) { if (strcmp(id, "period_size") == 0) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) {
SNDERR("Invalid type for %s", id); SNDERR("Invalid type for %s", id);
return -EINVAL; return -EINVAL;
} }
snd_config_get_integer(n, &period_size); snd_config_get_integer(n, &period_size);
continue; continue;
} }
 End of changes. 11 change blocks. 
15 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)