Skip to content

Commit e7eed98

Browse files
committed
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 <[email protected]>
1 parent e04ba7f commit e7eed98

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/libfreenect.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,16 @@ FREENECTAPI int freenect_list_device_attributes(freenect_context *ctx, struct fr
272272
*/
273273
FREENECTAPI void freenect_free_device_attributes(struct freenect_device_attributes* attribute_list);
274274

275+
/**
276+
* Answer which subdevices this library supports. This is most useful for
277+
* wrappers trying to determine whether the underlying library was built with
278+
* audio support or not, so the wrapper can avoid calling functions that do not
279+
* exist.
280+
*
281+
* @return Flags representing the subdevices that the library supports opening (see freenect_device_flags)
282+
*/
283+
FREENECTAPI int freenect_supported_subdevices(void);
284+
275285
/**
276286
* Set which subdevices any subsequent calls to freenect_open_device()
277287
* should open. This will not affect devices which have already been

src/core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ FREENECTAPI void freenect_free_device_attributes(struct freenect_device_attribut
103103
return;
104104
}
105105

106+
FREENECTAPI int freenect_supported_subdevices(void) {
107+
#ifdef BUILD_AUDIO
108+
return FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA | FREENECT_DEVICE_AUDIO;
109+
#else
110+
return FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA;
111+
#endif
112+
}
113+
106114
FREENECTAPI void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs) {
107115
ctx->enabled_subdevices = (freenect_device_flags)(subdevs & (FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA
108116
#ifdef BUILD_AUDIO

0 commit comments

Comments
 (0)