Skip to content

Commit 1c0eef2

Browse files
committed
api: Add return values to Freenect2Device methods
1 parent 045e12b commit 1c0eef2

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

include/libfreenect2/libfreenect2.hpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,22 @@ class LIBFREENECT2_API Freenect2Device
355355
* All above configuration must only be called before start() or after stop().
356356
*
357357
* FrameListener will receive frames when the device is running.
358+
*
359+
* @return Undefined. To be defined in 0.2.
358360
*/
359-
virtual void start() = 0;
361+
virtual bool start() = 0;
360362

361-
/** Stop data processing. */
362-
virtual void stop() = 0;
363+
/** Stop data processing.
364+
*
365+
* @return Undefined. To be defined in 0.2.
366+
*/
367+
virtual bool stop() = 0;
363368

364-
/** Shut down the device. */
365-
virtual void close() = 0;
369+
/** Shut down the device.
370+
*
371+
* @return Undefined. To be defined in 0.2.
372+
*/
373+
virtual bool close() = 0;
366374
};
367375

368376
class Freenect2Impl;

src/libfreenect2.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ class Freenect2DeviceImpl : public Freenect2Device
259259

260260
virtual void setColorFrameListener(libfreenect2::FrameListener* rgb_frame_listener);
261261
virtual void setIrAndDepthFrameListener(libfreenect2::FrameListener* ir_frame_listener);
262-
virtual void start();
263-
virtual void stop();
264-
virtual void close();
262+
virtual bool start();
263+
virtual bool stop();
264+
virtual bool close();
265265
};
266266

267267
struct PrintBusAndDevice
@@ -671,10 +671,10 @@ bool Freenect2DeviceImpl::open()
671671
return true;
672672
}
673673

674-
void Freenect2DeviceImpl::start()
674+
bool Freenect2DeviceImpl::start()
675675
{
676676
LOG_INFO << "starting...";
677-
if(state_ != Open) return;
677+
if(state_ != Open) return false;
678678

679679
CommandTransaction::Result serial_result, firmware_result, result;
680680

@@ -790,16 +790,17 @@ void Freenect2DeviceImpl::start()
790790

791791
state_ = Streaming;
792792
LOG_INFO << "started";
793+
return true;
793794
}
794795

795-
void Freenect2DeviceImpl::stop()
796+
bool Freenect2DeviceImpl::stop()
796797
{
797798
LOG_INFO << "stopping...";
798799

799800
if(state_ != Streaming)
800801
{
801802
LOG_INFO << "already stopped, doing nothing";
802-
return;
803+
return false;
803804
}
804805

805806
LOG_INFO << "disabling usb transfer submission...";
@@ -820,16 +821,17 @@ void Freenect2DeviceImpl::stop()
820821

821822
state_ = Open;
822823
LOG_INFO << "stopped";
824+
return true;
823825
}
824826

825-
void Freenect2DeviceImpl::close()
827+
bool Freenect2DeviceImpl::close()
826828
{
827829
LOG_INFO << "closing...";
828830

829831
if(state_ == Closed)
830832
{
831833
LOG_INFO << "already closed, doing nothing";
832-
return;
834+
return true;
833835
}
834836

835837
if(state_ == Streaming)
@@ -863,6 +865,7 @@ void Freenect2DeviceImpl::close()
863865

864866
state_ = Closed;
865867
LOG_INFO << "closed";
868+
return true;
866869
}
867870

868871
PacketPipeline *createDefaultPacketPipeline()

0 commit comments

Comments
 (0)