File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,13 +28,23 @@ namespace EasyPTP {
2828
2929int PTPUSB::inst_count = 0 ;
3030
31- PTPUSB::PTPUSB () {
32- this ->init ();
33- }
31+ PTPUSB::PTPUSB () : PTPUSB(NULL ) { }
3432
35- PTPUSB::PTPUSB (libusb_device * dev) {
36- this ->init ();
37- this ->open (dev);
33+ PTPUSB::PTPUSB (libusb_device * dev) : handle(NULL ), usb_error(0 ), intf(NULL ),
34+ ep_in (0 ), ep_out(0 )
35+ {
36+ // Increment our instance count, and initialize libusb if this is our first
37+ // instance
38+ if (PTPUSB::inst_count++ == 0 )
39+ {
40+ libusb_init (NULL );
41+ }
42+
43+ // If we were passsed a device, open it!
44+ if (dev != NULL )
45+ {
46+ this ->open (dev);
47+ }
3848}
3949
4050PTPUSB::~PTPUSB () {
@@ -47,19 +57,6 @@ PTPUSB::~PTPUSB() {
4757 }
4858}
4959
50- void PTPUSB::init () {
51- if (PTPUSB::inst_count == 0 ) {
52- libusb_init (NULL ); // Make sure to initialize libusb first!
53- }
54-
55- PTPUSB::inst_count++;
56- this ->handle = NULL ;
57- this ->usb_error = 0 ;
58- this ->intf = NULL ;
59- this ->ep_in = 0 ;
60- this ->ep_out = 0 ;
61- }
62-
6360void PTPUSB::connect_to_first () {
6461 // Find the first camera
6562 libusb_device * dev = this ->find_first_camera ();
You can’t perform that action at this time.
0 commit comments