BEAST - Free Software Audio Synthesizer and Tracker  0.10.0
bsedevice.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BSE_DEVICE_H__
3 #define __BSE_DEVICE_H__
4 
5 #include <bse/bseobject.hh>
6 
7 G_BEGIN_DECLS
8 
9 /* --- object type macros --- */
10 #define BSE_TYPE_DEVICE (BSE_TYPE_ID (BseDevice))
11 #define BSE_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_DEVICE, BseDevice))
12 #define BSE_DEVICE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), BSE_TYPE_DEVICE, BseDeviceClass))
13 #define BSE_IS_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_DEVICE))
14 #define BSE_IS_DEVICE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_DEVICE))
15 #define BSE_DEVICE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_DEVICE, BseDeviceClass))
16 /* flag tests */
17 #define BSE_DEVICE_OPEN(pdev) ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_OPEN) != 0)
18 #define BSE_DEVICE_READABLE(pdev) ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_READABLE) != 0)
19 #define BSE_DEVICE_WRITABLE(pdev) ((BSE_OBJECT_FLAGS (pdev) & BSE_DEVICE_FLAG_WRITABLE) != 0)
20 
21 
22 /* --- enums --- */
23 typedef enum /*< skip >*/
24 {
25  BSE_DEVICE_FLAG_OPEN = 1 << (BSE_OBJECT_FLAGS_USHIFT + 0),
26  BSE_DEVICE_FLAG_READABLE = 1 << (BSE_OBJECT_FLAGS_USHIFT + 1),
27  BSE_DEVICE_FLAG_WRITABLE = 1 << (BSE_OBJECT_FLAGS_USHIFT + 2)
28 } BseDeviceFlags;
29 #define BSE_DEVICE_FLAGS_USHIFT (BSE_OBJECT_FLAGS_USHIFT + 3)
30 
31 
32 /* --- BseDevice structs --- */
33 struct BseDevice : BseObject {
34  /* valid while BSE_DEVICE_OPEN() */
35  gchar *open_device_name;
36  gchar *open_device_args;
37 };
39  gint driver_rating;
40  const gchar *driver_name;
41  const gchar *driver_syntax;
42  const gchar *driver_blurb;
43  SfiRing* (*list_devices) (BseDevice *device);
44  Bse::Error (*open) (BseDevice *device,
45  gboolean require_readable,
46  gboolean require_writable,
47  guint n_args,
48  const gchar **args);
49  void (*post_open) (BseDevice *device);
50  void (*pre_close) (BseDevice *device);
51  void (*close) (BseDevice *device);
52 };
54  BseDevice *device;
55  gchar *device_args;
56  gchar *device_blurb;
57  gchar *device_group; /* usually NULL */
58  gchar *device_error; /* if device_name == NULL */
59 };
60 
61 /* --- prototypes --- */
62 void bse_device_class_setup (gpointer klass,
63  gint rating,
64  const gchar *name,
65  const gchar *syntax,
66  const gchar *blurb);
67 SfiRing* bse_device_list (BseDevice *device);
68 Bse::Error bse_device_open (BseDevice *device,
69  gboolean need_readable,
70  gboolean need_writable,
71  const gchar *arg_string);
72 void bse_device_set_opened (BseDevice *device,
73  const gchar *device_name,
74  gboolean readable,
75  gboolean writable);
76 void bse_device_close (BseDevice *device);
77 BseDeviceEntry* bse_device_entry_new (BseDevice *device,
78  gchar *orphan_args,
79  gchar *orphan_blurb);
80 BseDeviceEntry* bse_device_group_entry_new (BseDevice *device,
81  gchar *orphan_args,
82  gchar *orphan_group,
83  gchar *orphan_blurb);
84 BseDeviceEntry* bse_device_error_new (BseDevice *device,
85  gchar *orphan_error);
86 void bse_device_entry_free (BseDeviceEntry *entry);
87 void bse_device_entry_list_free (SfiRing *list);
88 SfiRing* bse_device_class_list (GType type,
89  void (*request_callback) (BseDevice *device,
90  gpointer data),
91  gpointer data);
92 void bse_device_dump_list (GType base_type,
93  const gchar *indent,
94  gboolean with_auto,
95  void (*request_callback) (BseDevice *device,
96  gpointer data),
97  gpointer data);
98 BseDevice* bse_device_open_best (GType base_type,
99  gboolean need_readable,
100  gboolean need_writable,
101  SfiRing *devices,
102  void (*request_callback) (BseDevice *device,
103  gpointer data),
104  gpointer data,
105  Bse::Error *errorp);
106 BseDevice* bse_device_open_auto (GType base_type,
107  gboolean need_readable,
108  gboolean need_writable,
109  void (*request_callback) (BseDevice *device,
110  gpointer data),
111  gpointer data,
112  Bse::Error *errorp);
113 
114 
115 G_END_DECLS
116 
117 #endif /* __BSE_DEVICE_H__ */
Definition: bseobject.hh:61
Definition: bseobject.hh:94
Definition: sfiring.hh:23
Definition: bsedevice.hh:33
Definition: bsedevice.hh:38
Definition: bsedevice.hh:53