Skip to content
Browse files

Add function to query what subdevices the library supports.

This is essential for making wrappers that can work properly with
both versions of libfreenect with audio support and versions of
libfreenect without audio support.

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
  • Loading branch information...
1 parent e04ba7f commit e7eed98b0c6442540c05755eeb2d91ad31dafbbe @zarvox zarvox committed
Showing with 18 additions and 0 deletions.
  1. +10 −0 include/libfreenect.h
  2. +8 −0 src/core.c
View
10 include/libfreenect.h
@@ -273,6 +273,16 @@ FREENECTAPI int freenect_list_device_attributes(freenect_context *ctx, struct fr
FREENECTAPI void freenect_free_device_attributes(struct freenect_device_attributes* attribute_list);
/**
+ * Answer which subdevices this library supports. This is most useful for
+ * wrappers trying to determine whether the underlying library was built with
+ * audio support or not, so the wrapper can avoid calling functions that do not
+ * exist.
+ *
+ * @return Flags representing the subdevices that the library supports opening (see freenect_device_flags)
+ */
+FREENECTAPI int freenect_supported_subdevices(void);
+
+/**
* Set which subdevices any subsequent calls to freenect_open_device()
* should open. This will not affect devices which have already been
* opened. The default behavior, should you choose not to call this
View
8 src/core.c
@@ -103,6 +103,14 @@ FREENECTAPI void freenect_free_device_attributes(struct freenect_device_attribut
return;
}
+FREENECTAPI int freenect_supported_subdevices(void) {
+#ifdef BUILD_AUDIO
+ return FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA | FREENECT_DEVICE_AUDIO;
+#else
+ return FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA;
+#endif
+}
+
FREENECTAPI void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs) {
ctx->enabled_subdevices = (freenect_device_flags)(subdevs & (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA
#ifdef BUILD_AUDIO

0 comments on commit e7eed98

Please sign in to comment.
Something went wrong with that request. Please try again.