@@ -45,7 +45,6 @@ + (instancetype)sharedInstance {
45
45
- (instancetype )init {
46
46
self = [super init ];
47
47
if (self) {
48
- // start alerts loop
49
48
[self uvcInit ];
50
49
}
51
50
return self;
@@ -69,13 +68,21 @@ - (void)reload {
69
68
if (ctx) {
70
69
[self uvcDeinit ];
71
70
}
71
+
72
+ // clear-out the vars
73
+ ctx = NULL ;
74
+ dev = NULL ;
75
+ devh = NULL ;
76
+
72
77
[self uvcInit ];
73
78
[self start ];
74
79
}
75
80
76
81
- (void )changeFrameDesc : (LVFrameDesc)frameDesc {
77
- [self uvcStopStreaming ];
78
- [self uvcStartStreamingWithFrameDesc: frameDesc];
82
+ if (devh) {
83
+ [self uvcStopStreaming ];
84
+ [self uvcStartStreamingWithFrameDesc: frameDesc];
85
+ }
79
86
}
80
87
81
88
- (int )uvcInit {
@@ -120,13 +127,24 @@ - (int)uvcOpenDevice {
120
127
return 0 ;
121
128
}
122
129
123
- - (int )uvcGetFrameDescriptors {
124
- // Select uncompressed format
130
+ - (const uvc_format_desc_t *)uvcGetUncompressedFormatDesc {
125
131
const uvc_format_desc_t *format_desc = uvc_get_format_descs (devh);
126
132
while (format_desc && format_desc->bDescriptorSubtype != UVC_VS_FORMAT_UNCOMPRESSED) {
127
133
format_desc = format_desc->next ;
128
134
}
129
135
136
+ if (format_desc == NULL ) {
137
+ printf (" Can't find uncompressed format\n " );
138
+ return NULL ;
139
+ }
140
+
141
+ return format_desc;
142
+ }
143
+
144
+ - (int )uvcGetFrameDescriptors {
145
+ // Select uncompressed format
146
+ const uvc_format_desc_t *format_desc = [self uvcGetUncompressedFormatDesc ];
147
+
130
148
// format_desc->bNumFrameDescriptors returns 0
131
149
uint8_t bNumFrameDescriptors = 0 ;
132
150
const uvc_frame_desc_t *frame_desc = format_desc->frame_descs ;
@@ -151,20 +169,6 @@ - (int)uvcGetFrameDescriptors {
151
169
return 0 ;
152
170
}
153
171
154
- - (const uvc_format_desc_t *)uvcGetUncompressedFormatDesc {
155
- const uvc_format_desc_t *format_desc = uvc_get_format_descs (devh);
156
- while (format_desc && format_desc->bDescriptorSubtype != UVC_VS_FORMAT_UNCOMPRESSED) {
157
- format_desc = format_desc->next ;
158
- }
159
-
160
- if (format_desc == NULL ) {
161
- printf (" Can't find uncompressed format\n " );
162
- return NULL ;
163
- }
164
-
165
- return format_desc;
166
- }
167
-
168
172
- (int )uvcStartStreaming {
169
173
const uvc_format_desc_t *format_desc = [self uvcGetUncompressedFormatDesc ];
170
174
0 commit comments