Skip to content

Commit

Permalink
Add function to query what subdevices the library supports.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
zarvox committed Nov 13, 2011
1 parent e04ba7f commit e7eed98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/libfreenect.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,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
Expand Down
8 changes: 8 additions & 0 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7eed98

Please sign in to comment.