@@ -204,9 +204,39 @@ FN_INTERNAL char* usb_get_serial(freenect_context* ctx, libusb_device* device, l
204204 return NULL ;
205205 }
206206
207+ const char * const K4W_1473_SERIAL = "0000000000000000" ;
208+ if (strncmp ((const char * )serial , K4W_1473_SERIAL , 16 ) == 0 ) {
209+ return NULL ; // K4W and 1473 provide an empty serial; more easily handled as NULL.
210+ }
211+
207212 return strndup ((const char * )serial , sizeof (serial ));
208213}
209214
215+ FN_INTERNAL int fnusb_get_device_attributes (freenect_device * dev , struct freenect_device_attributes * attributes )
216+ {
217+ freenect_context * ctx = dev -> parent ;
218+
219+ int res = 0 ;
220+
221+ char * serial = usb_get_serial (ctx , NULL , dev -> usb_cam .dev , NULL );
222+ if (serial == NULL )
223+ {
224+ char * audio_serial = usb_get_serial (ctx , NULL , dev -> usb_audio .dev , NULL );
225+ if (audio_serial ) {
226+ free (serial );
227+ serial = audio_serial ;
228+ }
229+ }
230+
231+ if (serial == NULL ) {
232+ return -1 ;
233+ }
234+
235+ attributes -> next = NULL ;
236+ attributes -> camera_serial = serial ;
237+ return res ;
238+ }
239+
210240FN_INTERNAL int fnusb_list_device_attributes (freenect_context * ctx , struct freenect_device_attributes * * attribute_list )
211241{
212242 * attribute_list = NULL ; // initialize some return value in case the user is careless.
@@ -240,10 +270,7 @@ FN_INTERNAL int fnusb_list_device_attributes(freenect_context *ctx, struct freen
240270 }
241271
242272 char * serial = usb_get_serial (ctx , camera_device , NULL , & desc );
243-
244- // K4W and 1473 don't provide a camera serial; use audio serial instead.
245- const char * const K4W_1473_SERIAL = "0000000000000000" ;
246- if (serial == NULL || strncmp ((const char * )serial , K4W_1473_SERIAL , 16 ) == 0 )
273+ if (serial == NULL )
247274 {
248275 libusb_device * audio_device = fnusb_find_sibling_device (ctx , camera_device , devs , count , & fnusb_is_audio );
249276 if (audio_device != NULL )
0 commit comments