]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added name support
authorAbramo Bagnara <abramo@alsa-project.org>
Tue, 10 Oct 2000 09:11:07 +0000 (09:11 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Tue, 10 Oct 2000 09:11:07 +0000 (09:11 +0000)
13 files changed:
src/pcm/pcm.c
src/pcm/pcm_adpcm.c
src/pcm/pcm_alaw.c
src/pcm/pcm_file.c
src/pcm/pcm_hw.c
src/pcm/pcm_linear.c
src/pcm/pcm_local.h
src/pcm/pcm_mulaw.c
src/pcm/pcm_multi.c
src/pcm/pcm_plug.c
src/pcm/pcm_plugin.h
src/pcm/pcm_rate.c
src/pcm/pcm_route.c

index 109776762652602a4d6c965bad532c529525533e..6bcf50c22e00d04c28676628785700739205d711 100644 (file)
@@ -73,6 +73,8 @@ int snd_pcm_close(snd_pcm_t *pcm)
        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;
 }      
index ee6580ceeab51a5c12f8d6f8e840deaec8568a08..4c916ab3f0644177c5177fab288e1ae658abe3f6 100644 (file)
@@ -552,7 +552,7 @@ struct snd_pcm_ops snd_pcm_adpcm_ops = {
        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;
@@ -577,6 +577,8 @@ int snd_pcm_adpcm_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int c
                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;
@@ -643,7 +645,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
        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;
index 2646de9e2915ffea2cff727d0d2b005c0a1f38c6..27f616e675113f3ae9cf14e79628628d99fe4002 100644 (file)
@@ -420,7 +420,7 @@ struct snd_pcm_ops snd_pcm_alaw_ops = {
        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;
@@ -444,6 +444,8 @@ int snd_pcm_alaw_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int cl
                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;
@@ -510,7 +512,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
        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;
index acb09a57c99fd14fb9e33d32ba75f67929eb1944..3e7ea2a7f9e59708a34a451635eed3f5f4dc0fde 100644 (file)
@@ -370,7 +370,7 @@ struct snd_pcm_fast_ops snd_pcm_file_fast_ops = {
        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;
@@ -395,6 +395,8 @@ int snd_pcm_file_open(snd_pcm_t **handlep, char *fname, int fd, snd_pcm_t *slave
                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;
@@ -463,7 +465,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name,
        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;
index 795b05948d8f7ae3d93f53d14c9fbd252a4133cc..9a056d7910932261f6dfdb0468a21477c90ce788 100644 (file)
@@ -576,6 +576,16 @@ int snd_pcm_hw_open_device(snd_pcm_t **handlep, int card, int device, int stream
        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)
 {
@@ -619,6 +629,6 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
        }
        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);
 }
                                
index b3cea851f1eec3c9162186b24e6ee15adf753eed..b335445e391b7aa4b7b1c79be3ffd8ea6602a872 100644 (file)
@@ -263,7 +263,7 @@ struct snd_pcm_ops snd_pcm_linear_ops = {
        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;
@@ -286,6 +286,8 @@ int snd_pcm_linear_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int
                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;
@@ -351,7 +353,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
        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;
index c6fb580819154ac474480d18730a36f78d5109fa..7772af60c1d4feb181a7f719d6814689c7996f5f 100644 (file)
@@ -66,6 +66,7 @@ struct snd_pcm_fast_ops {
 };
 
 struct snd_pcm {
+       char *name;
        snd_pcm_type_t type;
        int stream;
        int mode;
@@ -143,7 +144,6 @@ static inline size_t snd_pcm_mmap_avail(snd_pcm_t *pcm)
                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)
@@ -170,7 +170,6 @@ static inline ssize_t snd_pcm_mmap_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
@@ -182,7 +181,6 @@ static inline ssize_t snd_pcm_mmap_delay(snd_pcm_t *pcm)
                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)
index 1139717d1012b1a2e6bd31e4e4ff5fbde43c0d4c..65448586b040663a5a97e95fe68aa8cecb9a292e 100644 (file)
@@ -437,7 +437,7 @@ struct snd_pcm_ops snd_pcm_mulaw_ops = {
        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;
@@ -461,6 +461,8 @@ int snd_pcm_mulaw_open(snd_pcm_t **handlep, int sformat, snd_pcm_t *slave, int c
                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;
@@ -527,7 +529,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
        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;
index b97e1d1b4605bd7e5585276f4fa374fede5b9416..a2ead720d671f315e2f5060df8939854f291aaec 100644 (file)
@@ -49,17 +49,17 @@ typedef struct {
 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);
@@ -532,11 +532,12 @@ struct snd_pcm_fast_ops snd_pcm_multi_fast_ops = {
        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;
@@ -587,6 +588,8 @@ int snd_pcm_multi_create(snd_pcm_t **handlep, size_t slaves_count,
                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;
@@ -761,11 +764,11 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
                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) {
index b46ef67327b54d4fbaf5ec052d9fe85ab48745db..af47c679dadf348da08958022f539f6667a476f5 100644 (file)
@@ -314,7 +314,7 @@ static int snd_pcm_plug_change_rate(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_for
        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;
@@ -378,7 +378,7 @@ static int snd_pcm_plug_change_channels(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm
                                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;
@@ -391,7 +391,7 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_f
 {
        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 ||
@@ -442,7 +442,7 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_f
                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;
@@ -667,6 +667,7 @@ struct snd_pcm_ops snd_pcm_plug_ops = {
 };
 
 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,
@@ -691,6 +692,8 @@ int snd_pcm_plug_open(snd_pcm_t **handlep,
                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;
@@ -716,10 +719,10 @@ int snd_pcm_plug_open_subdevice(snd_pcm_t **handlep, int card, int device, int s
        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);
 }
@@ -777,7 +780,7 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, char *name,
        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;
index fe216d1b00b7409b7d957d4020480c4b0e4cfba9..25de6d2a5959b1d666553ff5f2323b701be085e9 100644 (file)
@@ -87,19 +87,19 @@ typedef int ttable_entry_t;
 #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);
 
index c2ef1796c252b70063c0eba0cfea05f8d9abef7a..9606c2747846303525573995483198269af93a64 100644 (file)
@@ -584,7 +584,7 @@ struct snd_pcm_ops snd_pcm_rate_ops = {
        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;
@@ -610,6 +610,8 @@ int snd_pcm_rate_open(snd_pcm_t **handlep, int sformat, int srate, snd_pcm_t *sl
                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;
@@ -682,7 +684,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
        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;
index 08f9d43dbd47c992e97e2cdfb5d948a810d3cbd1..341e3be64e9e7c59da1beb0fa355a40942eb4b75 100644 (file)
@@ -775,7 +775,7 @@ int route_load_ttable(route_params_t *params, int stream,
 }
 
 
-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,
@@ -804,6 +804,8 @@ int snd_pcm_route_open(snd_pcm_t **handlep,
                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;
@@ -952,7 +954,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
        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);