]>
Commit | Line | Data |
---|---|---|
2953961c | 1 | /* |
b3f22de0 | 2 | * This file is part of the PulseView project. |
2953961c JH |
3 | * |
4 | * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #include "sigsession.h" | |
22 | ||
dc0867ff | 23 | #include "devicemanager.h" |
1b1ec774 JH |
24 | #include "data/analog.h" |
25 | #include "data/analogsnapshot.h" | |
26 | #include "data/logic.h" | |
27 | #include "data/logicsnapshot.h" | |
82c7f640 | 28 | |
aba1dd16 | 29 | #include "view/analogsignal.h" |
82c7f640 | 30 | #include "view/decodesignal.h" |
8d634081 | 31 | #include "view/logicsignal.h" |
28a4c9c5 | 32 | |
2953961c JH |
33 | #include <assert.h> |
34 | ||
728e5ef7 JH |
35 | #include <sys/stat.h> |
36 | ||
79efbc53 JH |
37 | #include <QDebug> |
38 | ||
28a4c9c5 | 39 | using namespace boost; |
e3f65ace | 40 | using namespace std; |
28a4c9c5 | 41 | |
51e77110 JH |
42 | namespace pv { |
43 | ||
2953961c | 44 | // TODO: This should not be necessary |
04abfae9 | 45 | SigSession* SigSession::_session = NULL; |
2953961c | 46 | |
dc0867ff JH |
47 | SigSession::SigSession(DeviceManager &device_manager) : |
48 | _device_manager(device_manager), | |
d64d1596 | 49 | _sdi(NULL), |
5b7cf66c | 50 | _capture_state(Stopped) |
2953961c JH |
51 | { |
52 | // TODO: This should not be necessary | |
04abfae9 | 53 | _session = this; |
2953961c JH |
54 | } |
55 | ||
56 | SigSession::~SigSession() | |
57 | { | |
5b7cf66c JH |
58 | stop_capture(); |
59 | ||
333d5bbc | 60 | if (_sampling_thread.get()) |
2e2946fe JH |
61 | _sampling_thread->join(); |
62 | _sampling_thread.reset(); | |
63 | ||
0f784939 JH |
64 | if (_sdi) |
65 | _device_manager.release_device(_sdi); | |
66 | _sdi = NULL; | |
67 | ||
2953961c | 68 | // TODO: This should not be necessary |
04abfae9 | 69 | _session = NULL; |
2953961c JH |
70 | } |
71 | ||
dc0867ff JH |
72 | struct sr_dev_inst* SigSession::get_device() const |
73 | { | |
74 | return _sdi; | |
75 | } | |
76 | ||
d64d1596 JH |
77 | void SigSession::set_device(struct sr_dev_inst *sdi) |
78 | { | |
88497156 | 79 | if (_sdi) |
dc0867ff | 80 | _device_manager.release_device(_sdi); |
88497156 | 81 | if (sdi) |
dc0867ff | 82 | _device_manager.use_device(sdi, this); |
d64d1596 | 83 | _sdi = sdi; |
b698553c | 84 | update_signals(sdi); |
d64d1596 JH |
85 | } |
86 | ||
dc0867ff JH |
87 | void SigSession::release_device(struct sr_dev_inst *sdi) |
88 | { | |
89 | (void)sdi; | |
90 | ||
91 | assert(_capture_state == Stopped); | |
92 | _sdi = NULL; | |
b698553c | 93 | update_signals(NULL); |
dc0867ff JH |
94 | } |
95 | ||
f2edb557 JH |
96 | void SigSession::load_file(const string &name, |
97 | function<void (const QString)> error_handler) | |
2953961c | 98 | { |
8a67bd9e | 99 | stop_capture(); |
e8c9f8a5 JH |
100 | |
101 | if (sr_session_load(name.c_str()) == SR_OK) { | |
102 | GSList *devlist = NULL; | |
103 | sr_session_dev_list(&devlist); | |
104 | ||
105 | if (!devlist || !devlist->data || | |
106 | sr_session_start() != SR_OK) { | |
107 | error_handler(tr("Failed to start session.")); | |
108 | return; | |
109 | } | |
110 | ||
deef291c | 111 | sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data; |
e8c9f8a5 JH |
112 | g_slist_free(devlist); |
113 | ||
deef291c JH |
114 | update_signals(sdi); |
115 | read_sample_rate(sdi); | |
116 | ||
e8c9f8a5 JH |
117 | _sampling_thread.reset(new boost::thread( |
118 | &SigSession::load_session_thread_proc, this, | |
119 | error_handler)); | |
120 | ||
121 | } else { | |
122 | sr_input *in = NULL; | |
123 | ||
124 | if (!(in = load_input_file_format(name.c_str(), | |
125 | error_handler))) | |
126 | return; | |
127 | ||
128 | update_signals(in->sdi); | |
deef291c | 129 | read_sample_rate(in->sdi); |
e8c9f8a5 JH |
130 | |
131 | _sampling_thread.reset(new boost::thread( | |
132 | &SigSession::load_input_thread_proc, this, | |
133 | name, in, error_handler)); | |
134 | } | |
135 | ||
2953961c JH |
136 | } |
137 | ||
5b7cf66c JH |
138 | SigSession::capture_state SigSession::get_capture_state() const |
139 | { | |
949f8050 | 140 | lock_guard<mutex> lock(_sampling_mutex); |
5b7cf66c JH |
141 | return _capture_state; |
142 | } | |
143 | ||
d64d1596 | 144 | void SigSession::start_capture(uint64_t record_length, |
f2edb557 | 145 | function<void (const QString)> error_handler) |
2e2946fe | 146 | { |
5b7cf66c JH |
147 | stop_capture(); |
148 | ||
d64d1596 JH |
149 | // Check that a device instance has been selected. |
150 | if (!_sdi) { | |
151 | qDebug() << "No device selected"; | |
152 | return; | |
153 | } | |
154 | ||
9c48fa57 JH |
155 | // Check that at least one probe is enabled |
156 | const GSList *l; | |
d64d1596 | 157 | for (l = _sdi->probes; l; l = l->next) { |
9c48fa57 JH |
158 | sr_probe *const probe = (sr_probe*)l->data; |
159 | assert(probe); | |
160 | if (probe->enabled) | |
161 | break; | |
162 | } | |
163 | ||
164 | if (!l) { | |
165 | error_handler(tr("No probes enabled.")); | |
166 | return; | |
167 | } | |
168 | ||
169 | // Begin the session | |
2e2946fe | 170 | _sampling_thread.reset(new boost::thread( |
d64d1596 | 171 | &SigSession::sample_thread_proc, this, _sdi, |
f2edb557 | 172 | record_length, error_handler)); |
2e2946fe JH |
173 | } |
174 | ||
5b7cf66c JH |
175 | void SigSession::stop_capture() |
176 | { | |
333d5bbc | 177 | if (get_capture_state() == Stopped) |
5b7cf66c JH |
178 | return; |
179 | ||
180 | sr_session_stop(); | |
181 | ||
182 | // Check that sampling stopped | |
333d5bbc | 183 | if (_sampling_thread.get()) |
5b7cf66c JH |
184 | _sampling_thread->join(); |
185 | _sampling_thread.reset(); | |
5b7cf66c JH |
186 | } |
187 | ||
3868e5fa | 188 | vector< shared_ptr<view::Signal> > SigSession::get_signals() |
2e2946fe | 189 | { |
3868e5fa | 190 | lock_guard<mutex> lock(_signals_mutex); |
2e2946fe JH |
191 | return _signals; |
192 | } | |
193 | ||
1b1ec774 | 194 | boost::shared_ptr<data::Logic> SigSession::get_data() |
2e2946fe JH |
195 | { |
196 | return _logic_data; | |
197 | } | |
198 | ||
82c7f640 JH |
199 | void SigSession::add_decoder(srd_decoder *const dec) |
200 | { | |
201 | { | |
202 | shared_ptr<view::DecodeSignal> d(new view::DecodeSignal(*this, dec)); | |
203 | _decode_traces.push_back(d); | |
204 | } | |
205 | signals_changed(); | |
206 | } | |
207 | ||
6ac96c2e JH |
208 | void SigSession::set_capture_state(capture_state state) |
209 | { | |
949f8050 | 210 | lock_guard<mutex> lock(_sampling_mutex); |
2b49eeb0 | 211 | const bool changed = _capture_state != state; |
6ac96c2e | 212 | _capture_state = state; |
2b49eeb0 JH |
213 | if(changed) |
214 | capture_state_changed(state); | |
6ac96c2e JH |
215 | } |
216 | ||
728e5ef7 JH |
217 | /** |
218 | * Attempts to autodetect the format. Failing that | |
219 | * @param filename The filename of the input file. | |
220 | * @return A pointer to the 'struct sr_input_format' that should be used, | |
221 | * or NULL if no input format was selected or auto-detected. | |
222 | */ | |
223 | sr_input_format* SigSession::determine_input_file_format( | |
224 | const string &filename) | |
225 | { | |
226 | int i; | |
227 | ||
228 | /* If there are no input formats, return NULL right away. */ | |
229 | sr_input_format *const *const inputs = sr_input_list(); | |
230 | if (!inputs) { | |
231 | g_critical("No supported input formats available."); | |
232 | return NULL; | |
233 | } | |
234 | ||
235 | /* Otherwise, try to find an input module that can handle this file. */ | |
236 | for (i = 0; inputs[i]; i++) { | |
237 | if (inputs[i]->format_match(filename.c_str())) | |
238 | break; | |
239 | } | |
240 | ||
241 | /* Return NULL if no input module wanted to touch this. */ | |
242 | if (!inputs[i]) { | |
243 | g_critical("Error: no matching input module found."); | |
244 | return NULL; | |
245 | } | |
246 | ||
247 | return inputs[i]; | |
248 | } | |
249 | ||
250 | sr_input* SigSession::load_input_file_format(const string &filename, | |
251 | function<void (const QString)> error_handler, | |
252 | sr_input_format *format) | |
253 | { | |
254 | struct stat st; | |
255 | sr_input *in; | |
256 | ||
257 | if (!format && !(format = | |
258 | determine_input_file_format(filename.c_str()))) { | |
259 | /* The exact cause was already logged. */ | |
260 | return NULL; | |
261 | } | |
262 | ||
263 | if (stat(filename.c_str(), &st) == -1) { | |
264 | error_handler(tr("Failed to load file")); | |
265 | return NULL; | |
266 | } | |
267 | ||
268 | /* Initialize the input module. */ | |
269 | if (!(in = new sr_input)) { | |
270 | qDebug("Failed to allocate input module.\n"); | |
271 | return NULL; | |
272 | } | |
273 | ||
274 | in->format = format; | |
275 | in->param = NULL; | |
276 | if (in->format->init && | |
277 | in->format->init(in, filename.c_str()) != SR_OK) { | |
278 | qDebug("Input format init failed.\n"); | |
279 | return NULL; | |
280 | } | |
281 | ||
282 | sr_session_new(); | |
283 | ||
284 | if (sr_session_dev_add(in->sdi) != SR_OK) { | |
285 | qDebug("Failed to use device.\n"); | |
286 | sr_session_destroy(); | |
287 | return NULL; | |
288 | } | |
289 | ||
290 | return in; | |
291 | } | |
292 | ||
b698553c | 293 | void SigSession::update_signals(const sr_dev_inst *const sdi) |
b087ba7f JH |
294 | { |
295 | assert(_capture_state == Stopped); | |
296 | ||
297 | shared_ptr<view::Signal> signal; | |
298 | unsigned int logic_probe_count = 0; | |
299 | unsigned int analog_probe_count = 0; | |
300 | ||
82c7f640 JH |
301 | // Clear the decode traces |
302 | _decode_traces.clear(); | |
303 | ||
b087ba7f | 304 | // Detect what data types we will receive |
b698553c JH |
305 | if(sdi) { |
306 | for (const GSList *l = sdi->probes; l; l = l->next) { | |
b087ba7f JH |
307 | const sr_probe *const probe = (const sr_probe *)l->data; |
308 | if (!probe->enabled) | |
309 | continue; | |
310 | ||
311 | switch(probe->type) { | |
312 | case SR_PROBE_LOGIC: | |
313 | logic_probe_count++; | |
314 | break; | |
315 | ||
316 | case SR_PROBE_ANALOG: | |
317 | analog_probe_count++; | |
318 | break; | |
319 | } | |
320 | } | |
321 | } | |
322 | ||
323 | // Create data containers for the data snapshots | |
324 | { | |
325 | lock_guard<mutex> data_lock(_data_mutex); | |
326 | ||
327 | _logic_data.reset(); | |
328 | if (logic_probe_count != 0) { | |
329 | _logic_data.reset(new data::Logic( | |
330 | logic_probe_count)); | |
331 | assert(_logic_data); | |
332 | } | |
333 | ||
334 | _analog_data.reset(); | |
335 | if (analog_probe_count != 0) { | |
336 | _analog_data.reset(new data::Analog()); | |
337 | assert(_analog_data); | |
338 | } | |
339 | } | |
340 | ||
341 | // Make the Signals list | |
342 | { | |
343 | lock_guard<mutex> lock(_signals_mutex); | |
344 | ||
345 | _signals.clear(); | |
346 | ||
b698553c JH |
347 | if(sdi) { |
348 | for (const GSList *l = sdi->probes; l; l = l->next) { | |
b087ba7f JH |
349 | const sr_probe *const probe = |
350 | (const sr_probe *)l->data; | |
351 | assert(probe); | |
b087ba7f JH |
352 | |
353 | switch(probe->type) { | |
354 | case SR_PROBE_LOGIC: | |
355 | signal = shared_ptr<view::Signal>( | |
c0f86852 | 356 | new view::LogicSignal(*this, probe, |
cec48d16 | 357 | _logic_data)); |
b087ba7f JH |
358 | break; |
359 | ||
360 | case SR_PROBE_ANALOG: | |
361 | signal = shared_ptr<view::Signal>( | |
c0f86852 | 362 | new view::AnalogSignal(*this, probe, |
cec48d16 | 363 | _analog_data)); |
b087ba7f JH |
364 | break; |
365 | } | |
366 | ||
367 | _signals.push_back(signal); | |
368 | } | |
369 | } | |
370 | } | |
371 | ||
372 | signals_changed(); | |
373 | } | |
374 | ||
2b49eeb0 JH |
375 | bool SigSession::is_trigger_enabled() const |
376 | { | |
377 | assert(_sdi); | |
378 | for (const GSList *l = _sdi->probes; l; l = l->next) { | |
379 | const sr_probe *const p = (const sr_probe *)l->data; | |
380 | assert(p); | |
381 | if (p->trigger && p->trigger[0] != '\0') | |
382 | return true; | |
383 | } | |
384 | ||
385 | return false; | |
386 | } | |
387 | ||
deef291c JH |
388 | void SigSession::read_sample_rate(const sr_dev_inst *const sdi) |
389 | { | |
390 | GVariant *gvar; | |
391 | uint64_t sample_rate = 0; | |
392 | ||
393 | // Read out the sample rate | |
394 | if(sdi->driver) | |
395 | { | |
396 | const int ret = sr_config_get(sdi->driver, | |
397 | SR_CONF_SAMPLERATE, &gvar, sdi); | |
398 | if (ret != SR_OK) { | |
399 | qDebug("Failed to get samplerate\n"); | |
400 | return; | |
401 | } | |
402 | ||
403 | sample_rate = g_variant_get_uint64(gvar); | |
404 | g_variant_unref(gvar); | |
405 | } | |
406 | ||
407 | if(_analog_data) | |
408 | _analog_data->set_samplerate(sample_rate); | |
409 | if(_logic_data) | |
410 | _logic_data->set_samplerate(sample_rate); | |
411 | } | |
412 | ||
e8c9f8a5 | 413 | void SigSession::load_session_thread_proc( |
f2edb557 | 414 | function<void (const QString)> error_handler) |
8a67bd9e | 415 | { |
e8c9f8a5 | 416 | (void)error_handler; |
728e5ef7 | 417 | |
e8c9f8a5 JH |
418 | sr_session_datafeed_callback_add(data_feed_in_proc, NULL); |
419 | ||
420 | set_capture_state(Running); | |
421 | ||
422 | sr_session_run(); | |
423 | ||
424 | sr_session_destroy(); | |
425 | set_capture_state(Stopped); | |
426 | ||
427 | // Confirm that SR_DF_END was received | |
428 | assert(!_cur_logic_snapshot); | |
429 | assert(!_cur_analog_snapshot); | |
430 | } | |
431 | ||
432 | void SigSession::load_input_thread_proc(const string name, | |
433 | sr_input *in, function<void (const QString)> error_handler) | |
434 | { | |
435 | (void)error_handler; | |
436 | ||
437 | assert(in); | |
438 | assert(in->format); | |
8a67bd9e | 439 | |
5045f16d | 440 | sr_session_datafeed_callback_add(data_feed_in_proc, NULL); |
8a67bd9e | 441 | |
8a67bd9e JH |
442 | set_capture_state(Running); |
443 | ||
e8c9f8a5 | 444 | in->format->loadfile(in, name.c_str()); |
8a67bd9e | 445 | |
728e5ef7 | 446 | sr_session_destroy(); |
8a67bd9e | 447 | set_capture_state(Stopped); |
1a2fe44c JH |
448 | |
449 | // Confirm that SR_DF_END was received | |
450 | assert(!_cur_logic_snapshot); | |
451 | assert(!_cur_analog_snapshot); | |
728e5ef7 JH |
452 | |
453 | delete in; | |
8a67bd9e JH |
454 | } |
455 | ||
2e2946fe | 456 | void SigSession::sample_thread_proc(struct sr_dev_inst *sdi, |
f2edb557 JH |
457 | uint64_t record_length, |
458 | function<void (const QString)> error_handler) | |
274d4f13 | 459 | { |
be73bdfa | 460 | assert(sdi); |
f2edb557 | 461 | assert(error_handler); |
be73bdfa | 462 | |
274d4f13 | 463 | sr_session_new(); |
5045f16d | 464 | sr_session_datafeed_callback_add(data_feed_in_proc, NULL); |
274d4f13 JH |
465 | |
466 | if (sr_session_dev_add(sdi) != SR_OK) { | |
f2edb557 | 467 | error_handler(tr("Failed to use device.")); |
274d4f13 JH |
468 | sr_session_destroy(); |
469 | return; | |
470 | } | |
471 | ||
be73bdfa JH |
472 | // Set the sample limit |
473 | if (sr_config_set(sdi, SR_CONF_LIMIT_SAMPLES, | |
8eb9d311 | 474 | g_variant_new_uint64(record_length)) != SR_OK) { |
f2edb557 JH |
475 | error_handler(tr("Failed to configure " |
476 | "time-based sample limit.")); | |
274d4f13 JH |
477 | sr_session_destroy(); |
478 | return; | |
479 | } | |
480 | ||
eec446e1 | 481 | if (sr_session_start() != SR_OK) { |
f2edb557 | 482 | error_handler(tr("Failed to start session.")); |
eec446e1 JH |
483 | return; |
484 | } | |
485 | ||
2b49eeb0 | 486 | set_capture_state(is_trigger_enabled() ? AwaitingTrigger : Running); |
eec446e1 JH |
487 | |
488 | sr_session_run(); | |
489 | sr_session_destroy(); | |
490 | ||
491 | set_capture_state(Stopped); | |
1a2fe44c JH |
492 | |
493 | // Confirm that SR_DF_END was received | |
494 | assert(!_cur_logic_snapshot); | |
495 | assert(!_cur_analog_snapshot); | |
eec446e1 JH |
496 | } |
497 | ||
498 | void SigSession::feed_in_header(const sr_dev_inst *sdi) | |
499 | { | |
deef291c | 500 | read_sample_rate(sdi); |
be73bdfa JH |
501 | } |
502 | ||
503 | void SigSession::feed_in_meta(const sr_dev_inst *sdi, | |
504 | const sr_datafeed_meta &meta) | |
505 | { | |
94fe58ef UH |
506 | (void)sdi; |
507 | ||
be73bdfa JH |
508 | for (const GSList *l = meta.config; l; l = l->next) { |
509 | const sr_config *const src = (const sr_config*)l->data; | |
510 | switch (src->key) { | |
511 | case SR_CONF_SAMPLERATE: | |
512 | /// @todo handle samplerate changes | |
513 | /// samplerate = (uint64_t *)src->value; | |
514 | break; | |
515 | default: | |
516 | // Unknown metadata is not an error. | |
517 | break; | |
518 | } | |
aba1dd16 JH |
519 | } |
520 | } | |
521 | ||
9c112671 JH |
522 | void SigSession::feed_in_logic(const sr_datafeed_logic &logic) |
523 | { | |
524 | lock_guard<mutex> lock(_data_mutex); | |
79efbc53 JH |
525 | |
526 | if (!_logic_data) | |
9c112671 | 527 | { |
79efbc53 JH |
528 | qDebug() << "Unexpected logic packet"; |
529 | return; | |
530 | } | |
be73bdfa | 531 | |
79efbc53 JH |
532 | if (!_cur_logic_snapshot) |
533 | { | |
2b49eeb0 JH |
534 | set_capture_state(Running); |
535 | ||
9c112671 | 536 | // Create a new data snapshot |
1b1ec774 JH |
537 | _cur_logic_snapshot = shared_ptr<data::LogicSnapshot>( |
538 | new data::LogicSnapshot(logic)); | |
9c112671 JH |
539 | _logic_data->push_snapshot(_cur_logic_snapshot); |
540 | } | |
541 | else | |
542 | { | |
543 | // Append to the existing data snapshot | |
544 | _cur_logic_snapshot->append_payload(logic); | |
545 | } | |
546 | ||
547 | data_updated(); | |
548 | } | |
549 | ||
aba1dd16 JH |
550 | void SigSession::feed_in_analog(const sr_datafeed_analog &analog) |
551 | { | |
552 | lock_guard<mutex> lock(_data_mutex); | |
79efbc53 JH |
553 | |
554 | if(!_analog_data) | |
aba1dd16 | 555 | { |
79efbc53 JH |
556 | qDebug() << "Unexpected analog packet"; |
557 | return; // This analog packet was not expected. | |
558 | } | |
be73bdfa | 559 | |
79efbc53 JH |
560 | if (!_cur_analog_snapshot) |
561 | { | |
2b49eeb0 JH |
562 | set_capture_state(Running); |
563 | ||
aba1dd16 | 564 | // Create a new data snapshot |
1b1ec774 JH |
565 | _cur_analog_snapshot = shared_ptr<data::AnalogSnapshot>( |
566 | new data::AnalogSnapshot(analog)); | |
aba1dd16 JH |
567 | _analog_data->push_snapshot(_cur_analog_snapshot); |
568 | } | |
569 | else | |
570 | { | |
571 | // Append to the existing data snapshot | |
572 | _cur_analog_snapshot->append_payload(analog); | |
573 | } | |
574 | ||
575 | data_updated(); | |
576 | } | |
9c112671 | 577 | |
b0e1d01d JH |
578 | void SigSession::data_feed_in(const struct sr_dev_inst *sdi, |
579 | const struct sr_datafeed_packet *packet) | |
580 | { | |
581 | assert(sdi); | |
582 | assert(packet); | |
583 | ||
584 | switch (packet->type) { | |
585 | case SR_DF_HEADER: | |
eec446e1 | 586 | feed_in_header(sdi); |
b0e1d01d JH |
587 | break; |
588 | ||
be73bdfa | 589 | case SR_DF_META: |
aba1dd16 | 590 | assert(packet->payload); |
be73bdfa JH |
591 | feed_in_meta(sdi, |
592 | *(const sr_datafeed_meta*)packet->payload); | |
aba1dd16 JH |
593 | break; |
594 | ||
2e2946fe | 595 | case SR_DF_LOGIC: |
28a4c9c5 | 596 | assert(packet->payload); |
9c112671 | 597 | feed_in_logic(*(const sr_datafeed_logic*)packet->payload); |
2953961c JH |
598 | break; |
599 | ||
aba1dd16 JH |
600 | case SR_DF_ANALOG: |
601 | assert(packet->payload); | |
602 | feed_in_analog(*(const sr_datafeed_analog*)packet->payload); | |
603 | break; | |
604 | ||
2953961c | 605 | case SR_DF_END: |
2e2946fe JH |
606 | { |
607 | { | |
608 | lock_guard<mutex> lock(_data_mutex); | |
609 | _cur_logic_snapshot.reset(); | |
aba1dd16 | 610 | _cur_analog_snapshot.reset(); |
2e2946fe | 611 | } |
04abfae9 | 612 | data_updated(); |
2953961c JH |
613 | break; |
614 | } | |
2e2946fe | 615 | } |
2953961c JH |
616 | } |
617 | ||
04abfae9 | 618 | void SigSession::data_feed_in_proc(const struct sr_dev_inst *sdi, |
5045f16d | 619 | const struct sr_datafeed_packet *packet, void *cb_data) |
2953961c | 620 | { |
5045f16d | 621 | (void) cb_data; |
04abfae9 JH |
622 | assert(_session); |
623 | _session->data_feed_in(sdi, packet); | |
2953961c | 624 | } |
51e77110 JH |
625 | |
626 | } // namespace pv |