G_BEGIN_DECLS
/**
- *ALSAHwdepIfaceType:
+ * ALSAHwdepIfaceType:
* @ALSAHWDEP_IFACE_TYPE_OPL2: For OPL2 sound chip.
* @ALSAHWDEP_IFACE_TYPE_OPL3: For OPL3 sound chip.
* @ALSAHWDEP_IFACE_TYPE_OPL4: For OPL4 sound chip.
ALSAHWDEP_IFACE_TYPE_FW_FIREFACE,
} ALSAHwdepIfaceType;
+/**
+ * ALSAHwdepDeviceCommonError:
+ * @ALSAHWDEP_DEVICE_COMMON_ERROR_FAILED: The operation failed due to unspecified reason.
+ * @ALSAHWDEP_DEVICE_COMMON_ERROR_IS_OPENED: The instance is already associated to character device.
+ * @ALSAHWDEP_DEVICE_COMMON_ERROR_IS_NOT_OPENED: The instance is not associated to character device yet.
+ * @ALSAHWDEP_DEVICE_COMMON_ERROR_IS_USED: The character device is already used.
+ * @ALSAHWDEP_DEVICE_COMMON_ERROR_IS_NOT_SUPPORTED: The HwDep device associated to the character device is not supported.
+ * @ALSAHWDEP_DEVICE_COMMON_ERROR_IS_DISCONNECTED: The sound card is under disconnected state.
+ *
+ * A set of enumerations for code of ALSAHwDep.DeviceCommonError error domain.
+ */
+typedef enum {
+ ALSAHWDEP_DEVICE_COMMON_ERROR_FAILED = 1,
+ ALSAHWDEP_DEVICE_COMMON_ERROR_IS_OPENED,
+ ALSAHWDEP_DEVICE_COMMON_ERROR_IS_NOT_OPENED,
+ ALSAHWDEP_DEVICE_COMMON_ERROR_IS_USED,
+ ALSAHWDEP_DEVICE_COMMON_ERROR_IS_NOT_SUPPORTED,
+ ALSAHWDEP_DEVICE_COMMON_ERROR_IS_DISCONNECTED,
+} ALSAHwdepDeviceCommonError;
+
G_END_DECLS
#endif
"alsahwdep_device_common_get_protocol_version";
"alsahwdep_device_common_get_device_info";
"alsahwdep_device_common_create_source";
+
+ "alsahwdep_device_common_error_quark";
+ "alsahwdep_device_common_error_get_type";
+ "alsahwdep_device_common_error_to_label";
} ALSA_GOBJECT_0_0_0;
G_DEFINE_INTERFACE(ALSAHwdepDeviceCommon, alsahwdep_device_common, G_TYPE_OBJECT)
+/**
+ * alsahwdep_device_common_error_quark:
+ *
+ * Return the [alias@GLib.Quark] for [struct@GLib.Error] with code in ALSAHwdep.DeviceCommonError
+ * enumerations.
+ *
+ * Returns: A [alias@GLib.Quark].
+ */
+G_DEFINE_QUARK(alsahwdep-device-common-error-quark, alsahwdep_device_common_error)
+
+/**
+ * alsahwdep_device_common_error_to_label:
+ * @code: A ALSAHwdep.DeviceCommonError.
+ * @label: (out) (transfer none): The string label of error.
+ *
+ * Retrieve the string label of error from code.
+ */
+void alsahwdep_device_common_error_to_label(ALSAHwdepDeviceCommonError code, const char **label)
+{
+ static const char *const labels[] = {
+ [ALSAHWDEP_DEVICE_COMMON_ERROR_FAILED] =
+ "The operation failed due to unspecified reason.",
+ [ALSAHWDEP_DEVICE_COMMON_ERROR_IS_OPENED] =
+ "The instance is already associated to character device.",
+ [ALSAHWDEP_DEVICE_COMMON_ERROR_IS_NOT_OPENED] =
+ "The instance is not associated to character device yet.",
+ [ALSAHWDEP_DEVICE_COMMON_ERROR_IS_USED] =
+ "The character device is already used.",
+ [ALSAHWDEP_DEVICE_COMMON_ERROR_IS_NOT_SUPPORTED] =
+ "The HwDep device associated to the character device is not supported.",
+ [ALSAHWDEP_DEVICE_COMMON_ERROR_IS_DISCONNECTED] =
+ "The sound card is under disconnected state.",
+ };
+
+ switch (code) {
+ case ALSAHWDEP_DEVICE_COMMON_ERROR_FAILED:
+ case ALSAHWDEP_DEVICE_COMMON_ERROR_IS_OPENED:
+ case ALSAHWDEP_DEVICE_COMMON_ERROR_IS_NOT_OPENED:
+ case ALSAHWDEP_DEVICE_COMMON_ERROR_IS_USED:
+ case ALSAHWDEP_DEVICE_COMMON_ERROR_IS_NOT_SUPPORTED:
+ case ALSAHWDEP_DEVICE_COMMON_ERROR_IS_DISCONNECTED:
+ break;
+ default:
+ code = ALSAHWDEP_DEVICE_COMMON_ERROR_FAILED;
+ break;
+ }
+
+ *label = labels[code];
+}
+
static void alsahwdep_device_common_default_init(ALSAHwdepDeviceCommonInterface *iface)
{
/**
G_DECLARE_INTERFACE(ALSAHwdepDeviceCommon, alsahwdep_device_common, ALSAHWDEP, DEVICE_COMMON, GObject)
+GQuark alsahwdep_device_common_error_quark();
+
+void alsahwdep_device_common_error_to_label(ALSAHwdepDeviceCommonError code, const char **label);
+
struct _ALSAHwdepDeviceCommonInterface {
GTypeInterface parent_iface;
'FW_FIREFACE',
)
+device_common_error_types = (
+ 'FAILED',
+ 'IS_OPENED',
+ 'IS_NOT_OPENED',
+ 'IS_USED',
+ 'IS_NOT_SUPPORTED',
+ 'IS_DISCONNECTED',
+)
+
types = {
ALSAHwdep.IfaceType: iface_types,
+ ALSAHwdep.DeviceCommonError: device_common_error_types,
}
for obj, types in types.items():