if ((err = pcm->ops->close(pcm->op_arg)) < 0)
ret = err;
pcm->valid_setup = 0;
+ if (pcm->name)
+ free(pcm->name);
free(pcm);
return ret;
}
munmap_data: snd_pcm_plugin_munmap_data,
};
-int snd_pcm_adpcm_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int close_slave)
+int snd_pcm_adpcm_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *handle;
snd_pcm_adpcm_t *adpcm;
free(adpcm);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_ADPCM;
handle->stream = slave->stream;
handle->ops = &snd_pcm_adpcm_ops;
free(sname);
if (err < 0)
return err;
- err = snd_pcm_adpcm_open(pcmp, sformat, spcm, 1);
+ err = snd_pcm_adpcm_open(pcmp, name, sformat, spcm, 1);
if (err < 0)
snd_pcm_close(spcm);
return err;
munmap_data: snd_pcm_plugin_munmap_data,
};
-int snd_pcm_alaw_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int close_slave)
+int snd_pcm_alaw_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *handle;
snd_pcm_alaw_t *alaw;
free(alaw);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_ALAW;
handle->stream = slave->stream;
handle->ops = &snd_pcm_alaw_ops;
free(sname);
if (err < 0)
return err;
- err = snd_pcm_alaw_open(pcmp, sformat, spcm, 1);
+ err = snd_pcm_alaw_open(pcmp, name, sformat, spcm, 1);
if (err < 0)
snd_pcm_close(spcm);
return err;
mmap_forward: snd_pcm_file_mmap_forward,
};
-int snd_pcm_file_open(snd_pcm_t **handlep, char *fname, int fd, snd_pcm_t *slave, int close_slave)
+int snd_pcm_file_open(snd_pcm_t **handlep, char *name, char *fname, int fd, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *handle;
snd_pcm_file_t *file;
free(file);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_FILE;
handle->stream = slave->stream;
handle->ops = &snd_pcm_file_ops;
free(sname);
if (err < 0)
return err;
- err = snd_pcm_file_open(pcmp, fname, fd, spcm, 1);
+ err = snd_pcm_file_open(pcmp, name, fname, fd, spcm, 1);
if (err < 0)
snd_pcm_close(spcm);
return err;
return snd_pcm_hw_open_subdevice(handlep, card, device, -1, stream, mode);
}
+int snd_pcm_hw_open(snd_pcm_t **handlep, char *name, int card, int device, int subdevice, int stream, int mode)
+{
+ int err = snd_pcm_hw_open_subdevice(handlep, card, device, subdevice, stream, mode);
+ if (err < 0)
+ return err;
+ if (name)
+ (*handlep)->name = strdup(name);
+ return 0;
+}
+
int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
int stream, int mode)
{
}
if (card < 0)
return -EINVAL;
- return snd_pcm_hw_open_subdevice(pcmp, card, device, subdevice, stream, mode);
+ return snd_pcm_hw_open(pcmp, name, card, device, subdevice, stream, mode);
}
munmap_data: snd_pcm_plugin_munmap_data,
};
-int snd_pcm_linear_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int close_slave)
+int snd_pcm_linear_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *handle;
snd_pcm_linear_t *linear;
free(linear);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_LINEAR;
handle->stream = slave->stream;
handle->ops = &snd_pcm_linear_ops;
free(sname);
if (err < 0)
return err;
- err = snd_pcm_linear_open(pcmp, sformat, spcm, 1);
+ err = snd_pcm_linear_open(pcmp, name, sformat, spcm, 1);
if (err < 0)
snd_pcm_close(spcm);
return err;
};
struct snd_pcm {
+ char *name;
snd_pcm_type_t type;
int stream;
int mode;
return snd_pcm_mmap_playback_avail(pcm);
else
return snd_pcm_mmap_capture_avail(pcm);
- return 0;
}
static inline ssize_t snd_pcm_mmap_playback_hw_avail(snd_pcm_t *pcm)
return snd_pcm_mmap_playback_hw_avail(pcm);
else
return snd_pcm_mmap_capture_hw_avail(pcm);
- return 0;
}
#define snd_pcm_mmap_playback_delay snd_pcm_mmap_playback_hw_avail
return snd_pcm_mmap_playback_delay(pcm);
else
return snd_pcm_mmap_capture_delay(pcm);
- return 0;
}
static inline void *snd_pcm_channel_area_addr(snd_pcm_channel_area_t *area, size_t offset)
munmap_data: snd_pcm_plugin_munmap_data,
};
-int snd_pcm_mulaw_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int close_slave)
+int snd_pcm_mulaw_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *handle;
snd_pcm_mulaw_t *mulaw;
free(mulaw);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_MULAW;
handle->stream = slave->stream;
handle->ops = &snd_pcm_mulaw_ops;
free(sname);
if (err < 0)
return err;
- err = snd_pcm_mulaw_open(pcmp, sformat, spcm, 1);
+ err = snd_pcm_mulaw_open(pcmp, name, sformat, spcm, 1);
if (err < 0)
snd_pcm_close(spcm);
return err;
static int snd_pcm_multi_close(snd_pcm_t *pcm)
{
snd_pcm_multi_t *multi = pcm->private;
- unsigned int i;
+ size_t i;
int ret = 0;
for (i = 0; i < multi->slaves_count; ++i) {
int err;
snd_pcm_multi_slave_t *slave = &multi->slaves[i];
- if (slave->close_slave) {
+ if (slave->close_slave)
err = snd_pcm_close(slave->pcm);
- if (err < 0)
- ret = err;
- } else
- snd_pcm_unlink(slave->pcm);
+ else
+ err = snd_pcm_unlink(slave->pcm);
+ if (err < 0)
+ ret = err;
}
free(multi->slaves);
free(multi->channels);
mmap_forward: snd_pcm_multi_mmap_forward,
};
-int snd_pcm_multi_create(snd_pcm_t **handlep, size_t slaves_count,
- snd_pcm_t **slaves_handle, size_t *schannels_count,
- size_t channels_count,
- int *sidxs, unsigned int *schannels,
- int close_slaves)
+int snd_pcm_multi_open(snd_pcm_t **handlep, char *name,
+ size_t slaves_count,
+ snd_pcm_t **slaves_handle, size_t *schannels_count,
+ size_t channels_count,
+ int *sidxs, unsigned int *schannels,
+ int close_slaves)
{
snd_pcm_t *handle;
snd_pcm_multi_t *multi;
free(multi);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_MULTI;
handle->stream = stream;
handle->mode = multi->slaves[0].pcm->mode;
if (err < 0)
goto _free;
}
- err = snd_pcm_multi_create(pcmp, slaves_count, slaves_pcm,
- slaves_channels,
- channels_count,
- channels_sidx, channels_schannel,
- 1);
+ err = snd_pcm_multi_open(pcmp, name, slaves_count, slaves_pcm,
+ slaves_channels,
+ channels_count,
+ channels_sidx, channels_schannel,
+ 1);
_free:
if (err < 0) {
for (idx = 0; idx < slaves_count; ++idx) {
assert(snd_pcm_format_linear(slv->sfmt));
if (clt->rate == slv->rate)
return 0;
- err = snd_pcm_rate_open(new, slv->sfmt, slv->rate, plug->slave, plug->slave != plug->req_slave);
+ err = snd_pcm_rate_open(new, NULL, slv->sfmt, slv->rate, plug->slave, plug->slave != plug->req_slave);
if (err < 0)
return err;
slv->rate = clt->rate;
s = 0;
}
}
- err = snd_pcm_route_open(new, slv->sfmt, slv->channels, ttable, tt_ssize, tt_cused, tt_sused, plug->slave, plug->slave != plug->req_slave);
+ err = snd_pcm_route_open(new, NULL, slv->sfmt, slv->channels, ttable, tt_ssize, tt_cused, tt_sused, plug->slave, plug->slave != plug->req_slave);
if (err < 0)
return err;
slv->channels = clt->channels;
{
snd_pcm_plug_t *plug = pcm->private;
int err, cfmt;
- int (*f)(snd_pcm_t **handle, int sformat, snd_pcm_t *slave, int close_slave);
+ int (*f)(snd_pcm_t **handle, char *name, int sformat, snd_pcm_t *slave, int close_slave);
if (snd_pcm_format_linear(slv->sfmt)) {
/* Conversion is done in another plugin */
if (clt->sfmt == slv->sfmt ||
else
cfmt = SND_PCM_SFMT_S16;
}
- err = f(new, slv->sfmt, plug->slave, plug->slave != plug->req_slave);
+ err = f(new, NULL, slv->sfmt, plug->slave, plug->slave != plug->req_slave);
if (err < 0)
return err;
slv->sfmt = cfmt;
};
int snd_pcm_plug_open(snd_pcm_t **handlep,
+ char *name,
ttable_entry_t *ttable,
unsigned int tt_ssize,
unsigned int tt_cused, unsigned int tt_sused,
free(plug);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_PLUG;
handle->stream = slave->stream;
handle->ops = &snd_pcm_plug_ops;
err = snd_pcm_hw_open_subdevice(&slave, card, device, subdevice, stream, mode);
if (err < 0)
return err;
- return snd_pcm_plug_open(handlep, 0, 0, 0, 0, slave, 1);
+ return snd_pcm_plug_open(handlep, NULL, 0, 0, 0, 0, slave, 1);
}
-int snd_pcm_plug_open_card(snd_pcm_t **handlep, int card, int device, int stream, int mode)
+int snd_pcm_plug_open_device(snd_pcm_t **handlep, int card, int device, int stream, int mode)
{
return snd_pcm_plug_open_subdevice(handlep, card, device, -1, stream, mode);
}
free(sname);
if (err < 0)
return err;
- err = snd_pcm_plug_open(pcmp, ttable, MAX_CHANNELS, cused, sused, spcm, 1);
+ err = snd_pcm_plug_open(pcmp, name, ttable, MAX_CHANNELS, cused, sused, spcm, 1);
if (err < 0)
snd_pcm_close(spcm);
return err;
#define FULL ROUTE_PLUGIN_RESOLUTION
#endif
-int snd_pcm_linear_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int close_slave);
-int snd_pcm_mulaw_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int close_slave);
-int snd_pcm_alaw_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int close_slave);
-int snd_pcm_adpcm_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int close_slave);
+int snd_pcm_linear_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *slave, int close_slave);
+int snd_pcm_mulaw_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *slave, int close_slave);
+int snd_pcm_alaw_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *slave, int close_slave);
+int snd_pcm_adpcm_open(snd_pcm_t **handlep, char *name, int sformat, snd_pcm_t *slave, int close_slave);
int snd_pcm_route_load_ttable(snd_config_t *tt, ttable_entry_t *ttable,
unsigned int tt_csize, unsigned int tt_ssize,
unsigned int *tt_cused, unsigned int *tt_sused,
int schannels);
-int snd_pcm_route_open(snd_pcm_t **handlep,
+int snd_pcm_route_open(snd_pcm_t **handlep, char *name,
int sformat, unsigned int schannels,
ttable_entry_t *ttable,
unsigned int tt_ssize,
unsigned int tt_cused, unsigned int tt_sused,
snd_pcm_t *slave, int close_slave);
-int snd_pcm_rate_open(snd_pcm_t **handlep, int sformat, int srate, snd_pcm_t *slave, int close_slave);
+int snd_pcm_rate_open(snd_pcm_t **handlep, char *name, int sformat, int srate, snd_pcm_t *slave, int close_slave);
munmap_data: snd_pcm_plugin_munmap_data,
};
-int snd_pcm_rate_open(snd_pcm_t **handlep, int sformat, int srate, snd_pcm_t *slave, int close_slave)
+int snd_pcm_rate_open(snd_pcm_t **handlep, char *name, int sformat, int srate, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *handle;
snd_pcm_rate_t *rate;
free(rate);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_RATE;
handle->stream = slave->stream;
handle->ops = &snd_pcm_rate_ops;
free(sname);
if (err < 0)
return err;
- err = snd_pcm_rate_open(pcmp, sformat, srate, spcm, 1);
+ err = snd_pcm_rate_open(pcmp, name, sformat, srate, spcm, 1);
if (err < 0)
snd_pcm_close(spcm);
return err;
}
-int snd_pcm_route_open(snd_pcm_t **handlep,
+int snd_pcm_route_open(snd_pcm_t **handlep, char *name,
int sformat, unsigned int schannels,
ttable_entry_t *ttable,
unsigned int tt_ssize,
free(route);
return -ENOMEM;
}
+ if (name)
+ handle->name = strdup(name);
handle->type = SND_PCM_TYPE_ROUTE;
handle->stream = slave->stream;
handle->ops = &snd_pcm_route_ops;
free(sname);
if (err < 0)
return err;
- err = snd_pcm_route_open(pcmp, sformat, schannels,
+ err = snd_pcm_route_open(pcmp, name, sformat, schannels,
ttable, MAX_CHANNELS,
cused, sused,
spcm, 1);