diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-07-05 23:38:41 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-07-05 23:38:41 +0000 |
commit | 317a54ec28fe13fa5ba850486dcb922d146e4be3 (patch) | |
tree | 7fabe6e57d054a2871eee385eb75c366c7cc6292 /mixlib | |
parent | 551ec2bb5fb690a9bfa7db1691b54946163473b6 (diff) | |
download | mdk-317a54ec28fe13fa5ba850486dcb922d146e4be3.tar.gz mdk-317a54ec28fe13fa5ba850486dcb922d146e4be3.tar.bz2 |
externally provided device files directory
Diffstat (limited to 'mixlib')
-rw-r--r-- | mixlib/mix_device.c | 19 | ||||
-rw-r--r-- | mixlib/mix_device.h | 7 | ||||
-rw-r--r-- | mixlib/xmix_device.c | 15 | ||||
-rw-r--r-- | mixlib/xmix_device.h | 3 |
4 files changed, 35 insertions, 9 deletions
diff --git a/mixlib/mix_device.c b/mixlib/mix_device.c index 2f3f702..d40ea98 100644 --- a/mixlib/mix_device.c +++ b/mixlib/mix_device.c @@ -19,10 +19,27 @@ * */ - #include "mix_file.h" #include "xmix_device.h" +/* + Set the directory for mix device files (by default, it's ".") + If the dir does not exist, it is created. +*/ +gboolean +mix_device_set_dir (const gchar *dirname) +{ + if (mix_stat_dir (dirname, "devices")) + { + if (DEV_DIR_) g_free (DEV_DIR_); + DEV_DIR_ = g_strdup (dirname); + return TRUE; + } + else + return FALSE; +} + + mix_device_t * mix_device_new (mix_device_type_t type) { diff --git a/mixlib/mix_device.h b/mixlib/mix_device.h index 7248d72..9f37092 100644 --- a/mixlib/mix_device.h +++ b/mixlib/mix_device.h @@ -70,6 +70,13 @@ typedef enum { } mix_device_mode_t; /* + Set the directory for mix device files (by default, it's ".") + If the dir does not exist, it is created. +*/ +extern gboolean +mix_device_set_dir (const gchar *dirname); + +/* Create a new device with default name and given type. */ extern mix_device_t * diff --git a/mixlib/xmix_device.c b/mixlib/xmix_device.c index b0ec547..47b6397 100644 --- a/mixlib/xmix_device.c +++ b/mixlib/xmix_device.c @@ -24,6 +24,8 @@ #include "xmix_device.h" +gchar *DEV_DIR_ = NULL; + const char *DEV_EXT_ = ".dev"; const char *DEF_NAMES_[] = { @@ -58,14 +60,11 @@ const mix_fmode_t FMODES_[] = { void construct_device_ (mix_device_t *result, mix_device_type_t type) { - result->type = type; - if (type != mix_dev_CONSOLE) { - result->file = MIX_IOCHANNEL(mix_file_new_with_def_ext (DEF_NAMES_[type], - FMODES_[type], - DEV_EXT_)); - } else - result->file = mix_io_new (stdout); - result->vtable = DEF_DEV_VTABLE_; + gchar *name; + name = DEV_DIR_ ? g_strdup_printf ("%s/%s", DEV_DIR_, DEF_NAMES_[type]) + : g_strdup (DEF_NAMES_[type]); + construct_device_with_name_ (result, type, name); + g_free (name); } diff --git a/mixlib/xmix_device.h b/mixlib/xmix_device.h index f44409f..faa8334 100644 --- a/mixlib/xmix_device.h +++ b/mixlib/xmix_device.h @@ -28,6 +28,9 @@ #include "mix_file.h" #include "mix_device.h" +/* device file directory */ +extern gchar *DEV_DIR_; + /* table of overridable device operations */ typedef gboolean (*mix_dev_write_func_t) (mix_device_t *, const mix_word_t *); typedef gboolean (*mix_dev_read_func_t) (mix_device_t *, mix_word_t *); |