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 | 74342aaaa7bf55eddd07f19453f8b75902c07aa1 (patch) | |
| tree | e3e9b680244cbbd1cc7f2a451028c602e08d79d4 | |
| parent | 6ea6bdd894fd0c00e781360d6dfc6dea1a36f5c6 (diff) | |
| download | mdk-74342aaaa7bf55eddd07f19453f8b75902c07aa1.tar.gz mdk-74342aaaa7bf55eddd07f19453f8b75902c07aa1.tar.bz2  | |
externally provided device files directory
| -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 *);  | 
