BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
bsedevice.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __BSE_DEVICE_H__
00003 #define __BSE_DEVICE_H__
00004 
00005 #include        <bse/bseobject.hh>
00006 
00007 G_BEGIN_DECLS
00008 
00009 /* --- object type macros --- */
00010 #define BSE_TYPE_DEVICE              (BSE_TYPE_ID (BseDevice))
00011 #define BSE_DEVICE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_DEVICE, BseDevice))
00012 #define BSE_DEVICE_CLASS(class)      (G_TYPE_CHECK_CLASS_CAST ((class), BSE_TYPE_DEVICE, BseDeviceClass))
00013 #define BSE_IS_DEVICE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_DEVICE))
00014 #define BSE_IS_DEVICE_CLASS(class)   (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_DEVICE))
00015 #define BSE_DEVICE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_DEVICE, BseDeviceClass))
00016 /* flag tests */
00017 #define BSE_DEVICE_OPEN(pdev)        ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_OPEN) != 0)
00018 #define BSE_DEVICE_READABLE(pdev)    ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_READABLE) != 0)
00019 #define BSE_DEVICE_WRITABLE(pdev)    ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_WRITABLE) != 0)
00020 
00021 
00022 /* --- enums --- */
00023 typedef enum    /*< skip >*/
00024 {
00025   BSE_DEVICE_FLAG_OPEN          = 1 << (BSE_OBJECT_FLAGS_USHIFT + 0),
00026   BSE_DEVICE_FLAG_READABLE      = 1 << (BSE_OBJECT_FLAGS_USHIFT + 1),
00027   BSE_DEVICE_FLAG_WRITABLE      = 1 << (BSE_OBJECT_FLAGS_USHIFT + 2)
00028 } BseDeviceFlags;
00029 #define BSE_DEVICE_FLAGS_USHIFT (BSE_OBJECT_FLAGS_USHIFT + 3)
00030 
00031 
00032 /* --- BseDevice structs --- */
00033 struct BseDevice : BseObject {
00034   /* valid while BSE_DEVICE_OPEN() */
00035   gchar                 *open_device_name;
00036   gchar                 *open_device_args;
00037 };
00038 struct BseDeviceClass : BseObjectClass {
00039   gint                  driver_rating;
00040   const gchar          *driver_name;
00041   const gchar          *driver_syntax;
00042   const gchar          *driver_blurb;
00043   SfiRing*            (*list_devices)  (BseDevice    *device);
00044   BseErrorType        (*open)          (BseDevice    *device,
00045                                         gboolean        require_readable,
00046                                         gboolean        require_writable,
00047                                         guint           n_args,
00048                                         const gchar   **args);
00049   void                (*post_open)     (BseDevice    *device);
00050   void                (*pre_close)     (BseDevice    *device);
00051   void                (*close)         (BseDevice    *device);
00052 };
00053 struct BseDeviceEntry {
00054   BseDevice      *device;
00055   gchar          *device_args;
00056   gchar          *device_blurb;
00057   gchar          *device_group; /* usually NULL */
00058   gchar          *device_error; /* if device_name == NULL */
00059 };
00060 
00061 /* --- prototypes --- */
00062 void            bse_device_class_setup     (gpointer        klass,
00063                                             gint            rating,
00064                                             const gchar    *name,
00065                                             const gchar    *syntax,
00066                                             const gchar    *blurb);
00067 SfiRing*        bse_device_list            (BseDevice      *device);
00068 BseErrorType    bse_device_open            (BseDevice      *device,
00069                                             gboolean        need_readable,
00070                                             gboolean        need_writable,
00071                                             const gchar    *arg_string);
00072 void            bse_device_set_opened      (BseDevice      *device,
00073                                             const gchar    *device_name,
00074                                             gboolean        readable,
00075                                             gboolean        writable);
00076 void            bse_device_close           (BseDevice      *device);
00077 BseDeviceEntry* bse_device_entry_new       (BseDevice      *device,
00078                                             gchar          *orphan_args,
00079                                             gchar          *orphan_blurb);
00080 BseDeviceEntry* bse_device_group_entry_new (BseDevice      *device,
00081                                             gchar          *orphan_args,
00082                                             gchar          *orphan_group,
00083                                             gchar          *orphan_blurb);
00084 BseDeviceEntry* bse_device_error_new       (BseDevice      *device,
00085                                             gchar          *orphan_error);
00086 void            bse_device_entry_free      (BseDeviceEntry *entry);
00087 void            bse_device_entry_list_free (SfiRing        *list);
00088 SfiRing*        bse_device_class_list      (GType           type,
00089                                             void          (*request_callback) (BseDevice *device,
00090                                                                                gpointer   data),
00091                                             gpointer        data);
00092 void            bse_device_dump_list       (GType           base_type,
00093                                             const gchar    *indent,
00094                                             gboolean        with_auto,
00095                                             void          (*request_callback) (BseDevice *device,
00096                                                                                gpointer   data),
00097                                             gpointer        data);
00098 BseDevice*      bse_device_open_best       (GType           base_type,
00099                                             gboolean        need_readable,
00100                                             gboolean        need_writable,
00101                                             SfiRing        *devices,
00102                                             void          (*request_callback) (BseDevice *device,
00103                                                                                gpointer   data),
00104                                             gpointer        data,
00105                                             BseErrorType   *errorp);
00106 BseDevice*      bse_device_open_auto       (GType           base_type,
00107                                             gboolean        need_readable,
00108                                             gboolean        need_writable,
00109                                             void          (*request_callback) (BseDevice *device,
00110                                                                                gpointer   data),
00111                                             gpointer        data,
00112                                             BseErrorType   *errorp);
00113 
00114 
00115 G_END_DECLS
00116 
00117 #endif /* __BSE_DEVICE_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines