@@ -221,7 +221,7 @@ static void init_thread(void)
221221 pthread_create (& thread , NULL , init , NULL );
222222}
223223
224- static int change_video_format (sync_kinect_t * kinect , freenect_resolution res , freenect_video_format fmt )
224+ static int change_video_format_with_res (sync_kinect_t * kinect , freenect_resolution res , freenect_video_format fmt )
225225{
226226 freenect_stop_video (kinect -> dev );
227227 free_buffer_ring (& kinect -> video );
@@ -233,7 +233,12 @@ static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, f
233233 return 0 ;
234234}
235235
236- static int change_depth_format (sync_kinect_t * kinect , freenect_resolution res , freenect_depth_format fmt )
236+ static int change_video_format (sync_kinect_t * kinect , freenect_resolution res , freenect_video_format fmt )
237+ {
238+ return change_video_format_with_res (kinect , FREENECT_RESOLUTION_MEDIUM , fmt );
239+ }
240+
241+ static int change_depth_format_with_res (sync_kinect_t * kinect , freenect_resolution res , freenect_depth_format fmt )
237242{
238243 freenect_stop_depth (kinect -> dev );
239244 free_buffer_ring (& kinect -> depth );
@@ -245,6 +250,11 @@ static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, f
245250 return 0 ;
246251}
247252
253+ static int change_depth_format (sync_kinect_t * kinect , freenect_resolution res , freenect_depth_format fmt )
254+ {
255+ return change_depth_format_with_res (kinect , FREENECT_RESOLUTION_MEDIUM , fmt );
256+ }
257+
248258static sync_kinect_t * alloc_kinect (int index )
249259{
250260 sync_kinect_t * kinect = (sync_kinect_t * )malloc (sizeof (sync_kinect_t ));
@@ -270,7 +280,7 @@ static sync_kinect_t *alloc_kinect(int index)
270280 return kinect ;
271281}
272282
273- static int setup_kinect (int index , int res , int fmt , int is_depth )
283+ static int setup_kinect_with_res (int index , int res , int fmt , int is_depth )
274284{
275285 pending_runloop_tasks_inc ();
276286 pthread_mutex_lock (& runloop_lock );
@@ -303,16 +313,20 @@ static int setup_kinect(int index, int res, int fmt, int is_depth)
303313 pthread_mutex_lock (& buf -> lock );
304314 if ((buf -> fmt != fmt ) || (buf -> res != res )) {
305315 if (is_depth )
306- change_depth_format (kinects [index ], (freenect_resolution )res , (freenect_depth_format )fmt );
316+ change_depth_format_with_res (kinects [index ], (freenect_resolution )res , (freenect_depth_format )fmt );
307317 else
308- change_video_format (kinects [index ], (freenect_resolution )res , (freenect_video_format )fmt );
318+ change_video_format_with_res (kinects [index ], (freenect_resolution )res , (freenect_video_format )fmt );
309319 }
310320 pthread_mutex_unlock (& buf -> lock );
311321 pthread_mutex_unlock (& runloop_lock );
312322 pending_runloop_tasks_dec ();
313323 return 0 ;
314324}
315325
326+ static int setup_kinect (int index , int fmt , int is_depth ) {
327+ return setup_kinect_with_res (index , FREENECT_RESOLUTION_MEDIUM , fmt , is_depth );
328+ }
329+
316330static int sync_get (void * * data , uint32_t * timestamp , buffer_ring_t * buf )
317331{
318332 pthread_mutex_lock (& buf -> lock );
@@ -345,7 +359,7 @@ static int runloop_enter(int index)
345359 return -1 ;
346360 }
347361 if (!thread_running || !kinects [index ])
348- if (setup_kinect (index , FREENECT_RESOLUTION_MEDIUM , FREENECT_DEPTH_11BIT , 1 ))
362+ if (setup_kinect_with_res (index , FREENECT_RESOLUTION_MEDIUM , FREENECT_DEPTH_11BIT , 1 ))
349363 return -1 ;
350364
351365 pending_runloop_tasks_inc ();
@@ -359,7 +373,7 @@ static void runloop_exit()
359373 pending_runloop_tasks_dec ();
360374}
361375
362- int freenect_sync_get_video (void * * video , uint32_t * timestamp , int index ,
376+ int freenect_sync_get_video_with_res (void * * video , uint32_t * timestamp , int index ,
363377 freenect_resolution res , freenect_video_format fmt )
364378{
365379 if (index < 0 || index >= MAX_KINECTS ) {
@@ -368,13 +382,18 @@ int freenect_sync_get_video(void **video, uint32_t *timestamp, int index,
368382 }
369383 if (!thread_running || !kinects [index ] || kinects [index ]-> video .fmt != fmt
370384 || kinects [index ]-> video .res != res )
371- if (setup_kinect (index , res , fmt , 0 ))
385+ if (setup_kinect_with_res (index , res , fmt , 0 ))
372386 return -1 ;
373387 sync_get (video , timestamp , & kinects [index ]-> video );
374388 return 0 ;
375389}
376390
377- int freenect_sync_get_depth (void * * depth , uint32_t * timestamp , int index ,
391+ int freenect_sync_get_video (void * * video , uint32_t * timestamp , int index , freenect_video_format fmt )
392+ {
393+ return freenect_sync_get_video_with_res (video , timestamp , index , FREENECT_RESOLUTION_MEDIUM , fmt );
394+ }
395+
396+ int freenect_sync_get_depth_with_res (void * * depth , uint32_t * timestamp , int index ,
378397 freenect_resolution res , freenect_depth_format fmt )
379398{
380399 if (index < 0 || index >= MAX_KINECTS ) {
@@ -383,12 +402,17 @@ int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index,
383402 }
384403 if (!thread_running || !kinects [index ] || kinects [index ]-> depth .fmt != fmt
385404 || kinects [index ]-> depth .res != res )
386- if (setup_kinect (index , res , fmt , 1 ))
405+ if (setup_kinect_with_res (index , res , fmt , 1 ))
387406 return -1 ;
388407 sync_get (depth , timestamp , & kinects [index ]-> depth );
389408 return 0 ;
390409}
391410
411+ int freenect_sync_get_depth (void * * depth , uint32_t * timestamp , int index , freenect_depth_format fmt )
412+ {
413+ return freenect_sync_get_depth_with_res (depth , timestamp , index , FREENECT_RESOLUTION_MEDIUM , fmt );
414+ }
415+
392416int freenect_sync_get_tilt_state (freenect_raw_tilt_state * * state , int index )
393417{
394418 if (runloop_enter (index )) return -1 ;
0 commit comments