2 * This file is part of the sigrok-cli project.
4 * Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
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 3 of the License, or
9 * (at your option) any later version.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <glib/gstdio.h>
25 #include "sigrok-cli.h"
27 static uint64_t limit_samples
= 0;
28 static uint64_t limit_frames
= 0;
31 extern struct srd_session
*srd_sess
;
34 static int set_limit_time(const struct sr_dev_inst
*sdi
)
39 struct sr_dev_driver
*driver
;
41 driver
= sr_dev_inst_driver_get(sdi
);
43 if (!(time_msec
= sr_parse_timestring(opt_time
))) {
44 g_critical("Invalid time '%s'", opt_time
);
48 if (sr_dev_config_capabilities_list(sdi
, NULL
, SR_CONF_LIMIT_MSEC
)
50 gvar
= g_variant_new_uint64(time_msec
);
51 if (sr_config_set(sdi
, NULL
, SR_CONF_LIMIT_MSEC
, gvar
) != SR_OK
) {
52 g_critical("Failed to configure time limit.");
55 } else if (sr_dev_config_capabilities_list(sdi
, NULL
, SR_CONF_SAMPLERATE
)
56 & (SR_CONF_GET
| SR_CONF_SET
)) {
57 /* Convert to samples based on the samplerate. */
58 sr_config_get(driver
, sdi
, NULL
, SR_CONF_SAMPLERATE
, &gvar
);
59 samplerate
= g_variant_get_uint64(gvar
);
60 g_variant_unref(gvar
);
61 limit_samples
= (samplerate
) * time_msec
/ (uint64_t)1000;
62 if (limit_samples
== 0) {
63 g_critical("Not enough time at this samplerate.");
66 gvar
= g_variant_new_uint64(limit_samples
);
67 if (sr_config_set(sdi
, NULL
, SR_CONF_LIMIT_SAMPLES
, gvar
) != SR_OK
) {
68 g_critical("Failed to configure time-based sample limit.");
72 g_critical("This device does not support time limits.");
79 const struct sr_output
*setup_output_format(const struct sr_dev_inst
*sdi
, FILE **outfile
)
81 const struct sr_output_module
*omod
;
82 const struct sr_option
**options
;
83 const struct sr_output
*o
;
84 GHashTable
*fmtargs
, *fmtopts
;
87 if (!opt_output_format
) {
88 if (opt_output_file
) {
89 opt_output_format
= DEFAULT_OUTPUT_FORMAT_FILE
;
91 opt_output_format
= DEFAULT_OUTPUT_FORMAT_NOFILE
;
95 fmtargs
= parse_generic_arg(opt_output_format
, TRUE
, NULL
);
96 fmtspec
= g_hash_table_lookup(fmtargs
, "sigrok_key");
98 g_critical("Invalid output format.");
99 if (!(omod
= sr_output_find(fmtspec
)))
100 g_critical("Unknown output module '%s'.", fmtspec
);
101 g_hash_table_remove(fmtargs
, "sigrok_key");
102 if ((options
= sr_output_options_get(omod
))) {
103 fmtopts
= generic_arg_to_opt(options
, fmtargs
);
104 (void)warn_unknown_keys(options
, fmtargs
, NULL
);
105 sr_output_options_free(options
);
109 o
= sr_output_new(omod
, fmtopts
, sdi
, opt_output_file
);
111 if (opt_output_file
) {
112 if (!sr_output_test_flag(omod
, SR_OUTPUT_INTERNAL_IO_HANDLING
)) {
113 *outfile
= g_fopen(opt_output_file
, "wb");
115 g_critical("Cannot write to output file '%s'.",
122 setup_binary_stdout();
127 g_hash_table_destroy(fmtopts
);
128 g_hash_table_destroy(fmtargs
);
133 const struct sr_transform
*setup_transform_module(const struct sr_dev_inst
*sdi
)
135 const struct sr_transform_module
*tmod
;
136 const struct sr_option
**options
;
137 const struct sr_transform
*t
;
138 GHashTable
*fmtargs
, *fmtopts
;
141 fmtargs
= parse_generic_arg(opt_transform_module
, TRUE
, NULL
);
142 fmtspec
= g_hash_table_lookup(fmtargs
, "sigrok_key");
144 g_critical("Invalid transform module.");
145 if (!(tmod
= sr_transform_find(fmtspec
)))
146 g_critical("Unknown transform module '%s'.", fmtspec
);
147 g_hash_table_remove(fmtargs
, "sigrok_key");
148 if ((options
= sr_transform_options_get(tmod
))) {
149 fmtopts
= generic_arg_to_opt(options
, fmtargs
);
150 (void)warn_unknown_keys(options
, fmtargs
, NULL
);
151 sr_transform_options_free(options
);
155 t
= sr_transform_new(tmod
, fmtopts
, sdi
);
157 g_hash_table_destroy(fmtopts
);
158 g_hash_table_destroy(fmtargs
);
163 /* Get the input stream's list of channels and their types, once. */
164 static void props_get_channels(struct df_arg_desc
*args
,
165 const struct sr_dev_inst
*sdi
)
167 struct input_stream_props
*props
;
169 const struct sr_channel
*ch
;
173 props
= &args
->props
;
177 props
->channels
= g_slist_copy(sr_dev_inst_channels_get(sdi
));
178 if (!props
->channels
)
180 for (l
= props
->channels
; l
; l
= l
->next
) {
184 if (ch
->type
!= SR_CHANNEL_ANALOG
)
186 props
->first_analog_channel
= ch
;
191 static gboolean
props_chk_1st_channel(struct df_arg_desc
*args
,
192 const struct sr_datafeed_analog
*analog
)
194 struct sr_channel
*ch
;
196 if (!args
|| !analog
|| !analog
->meaning
)
198 ch
= g_slist_nth_data(analog
->meaning
->channels
, 0);
201 return ch
== args
->props
.first_analog_channel
;
204 static void props_dump_details(struct df_arg_desc
*args
)
206 struct input_stream_props
*props
;
209 const struct sr_channel
*ch
;
214 props
= &args
->props
;
215 if (props
->samplerate
)
216 printf("Samplerate: %" PRIu64
"\n", props
->samplerate
);
217 if (props
->channels
) {
218 ch_count
= g_slist_length(props
->channels
);
219 printf("Channels: %zu\n", ch_count
);
220 for (l
= props
->channels
; l
; l
= l
->next
) {
222 if (ch
->type
== SR_CHANNEL_ANALOG
)
226 printf("- %s: %s\n", ch
->name
, type
);
230 printf("Logic unitsize: %zu\n", props
->unitsize
);
231 if (props
->sample_count_logic
)
232 printf("Logic sample count: %" PRIu64
"\n", props
->sample_count_logic
);
233 if (props
->sample_count_analog
)
234 printf("Analog sample count: %" PRIu64
"\n", props
->sample_count_analog
);
235 if (props
->frame_count
)
236 printf("Frame count: %" PRIu64
"\n", props
->frame_count
);
237 if (props
->triggered
)
238 printf("Trigger count: %" PRIu64
"\n", props
->triggered
);
241 static void props_cleanup(struct df_arg_desc
*args
)
243 struct input_stream_props
*props
;
247 props
= &args
->props
;
248 g_slist_free(props
->channels
);
249 props
->channels
= NULL
;
250 props
->first_analog_channel
= NULL
;
253 void datafeed_in(const struct sr_dev_inst
*sdi
,
254 const struct sr_datafeed_packet
*packet
, void *cb_data
)
256 static const struct sr_output
*o
= NULL
;
257 static const struct sr_output
*oa
= NULL
;
258 static uint64_t rcvd_samples_logic
= 0;
259 static uint64_t rcvd_samples_analog
= 0;
260 static uint64_t samplerate
= 0;
261 static int triggered
= 0;
262 static FILE *outfile
= NULL
;
264 const struct sr_datafeed_meta
*meta
;
265 const struct sr_datafeed_logic
*logic
;
266 const struct sr_datafeed_analog
*analog
;
267 struct df_arg_desc
*df_arg
;
269 struct input_stream_props
*props
;
270 struct sr_session
*session
;
271 struct sr_config
*src
;
277 struct sr_dev_driver
*driver
;
279 /* Avoid warnings when building without decoder support. */
283 driver
= sr_dev_inst_driver_get(sdi
);
285 /* Skip all packets before the first header. */
286 if (packet
->type
!= SR_DF_HEADER
&& !o
)
289 /* Prepare to either process data, or "just" gather properties. */
291 session
= df_arg
->session
;
292 do_props
= df_arg
->do_props
;
293 props
= &df_arg
->props
;
295 switch (packet
->type
) {
297 g_debug("cli: Received SR_DF_HEADER.");
298 if (maybe_config_get(driver
, sdi
, NULL
, SR_CONF_SAMPLERATE
,
300 samplerate
= g_variant_get_uint64(gvar
);
301 g_variant_unref(gvar
);
304 /* Setup variables for maximum code path re-use. */
307 /* Start collecting input stream properties. */
308 memset(props
, 0, sizeof(*props
));
309 props
->samplerate
= samplerate
;
310 props_get_channels(df_arg
, sdi
);
313 if (!(o
= setup_output_format(sdi
, &outfile
)))
314 g_critical("Failed to initialize output module.");
316 /* Set up backup analog output module. */
318 oa
= sr_output_new(sr_output_find("analog"), NULL
,
321 rcvd_samples_logic
= rcvd_samples_analog
= 0;
326 if (srd_session_metadata_set(srd_sess
, SRD_CONF_SAMPLERATE
,
327 g_variant_new_uint64(samplerate
)) != SRD_OK
) {
328 g_critical("Failed to configure decode session.");
331 pd_samplerate
= samplerate
;
333 if (srd_session_start(srd_sess
) != SRD_OK
) {
334 g_critical("Failed to start decode session.");
342 g_debug("cli: Received SR_DF_META.");
343 meta
= packet
->payload
;
344 for (l
= meta
->config
; l
; l
= l
->next
) {
347 case SR_CONF_SAMPLERATE
:
348 samplerate
= g_variant_get_uint64(src
->data
);
349 g_debug("cli: Got samplerate %"PRIu64
" Hz.", samplerate
);
351 props
->samplerate
= samplerate
;
356 if (srd_session_metadata_set(srd_sess
, SRD_CONF_SAMPLERATE
,
357 g_variant_new_uint64(samplerate
)) != SRD_OK
) {
358 g_critical("Failed to pass samplerate to decoder.");
360 pd_samplerate
= samplerate
;
364 case SR_CONF_SAMPLE_INTERVAL
:
365 samplerate
= g_variant_get_uint64(src
->data
);
366 g_debug("cli: Got sample interval %"PRIu64
" ms.", samplerate
);
368 props
->samplerate
= samplerate
;
373 /* Unknown metadata is not an error. */
380 g_debug("cli: Received SR_DF_TRIGGER.");
389 logic
= packet
->payload
;
390 g_message("cli: Received SR_DF_LOGIC (%"PRIu64
" bytes, unitsize = %d).",
391 logic
->length
, logic
->unitsize
);
392 if (logic
->length
== 0)
396 props_get_channels(df_arg
, sdi
);
397 props
->unitsize
= logic
->unitsize
;
398 props
->sample_count_logic
+= logic
->length
/ logic
->unitsize
;
402 /* Don't store any samples until triggered. */
403 if (opt_wait_trigger
&& !triggered
)
406 if (limit_samples
&& rcvd_samples_logic
>= limit_samples
)
409 end_sample
= rcvd_samples_logic
+ logic
->length
/ logic
->unitsize
;
410 /* Cut off last packet according to the sample limit. */
411 if (limit_samples
&& end_sample
> limit_samples
)
412 end_sample
= limit_samples
;
413 input_len
= (end_sample
- rcvd_samples_logic
) * logic
->unitsize
;
417 if (srd_session_send(srd_sess
, rcvd_samples_logic
, end_sample
,
418 logic
->data
, input_len
, logic
->unitsize
) != SRD_OK
)
419 sr_session_stop(session
);
423 rcvd_samples_logic
= end_sample
;
427 analog
= packet
->payload
;
428 g_message("cli: Received SR_DF_ANALOG (%d samples).", analog
->num_samples
);
429 if (analog
->num_samples
== 0)
433 /* Only count the first analog channel. */
434 props_get_channels(df_arg
, sdi
);
435 if (!props_chk_1st_channel(df_arg
, analog
))
437 props
->sample_count_analog
+= analog
->num_samples
;
441 if (limit_samples
&& rcvd_samples_analog
>= limit_samples
)
444 rcvd_samples_analog
+= analog
->num_samples
;
447 case SR_DF_FRAME_BEGIN
:
448 g_debug("cli: Received SR_DF_FRAME_BEGIN.");
451 case SR_DF_FRAME_END
:
452 g_debug("cli: Received SR_DF_FRAME_END.");
454 props
->frame_count
++;
463 if (!do_props
&& o
&& !opt_pds
) {
464 if (sr_output_send(o
, packet
, &out
) == SR_OK
) {
467 * The user didn't specify an output module,
468 * but needs to see this analog data.
470 sr_output_send(oa
, packet
, &out
);
472 if (outfile
&& out
&& out
->len
> 0) {
473 fwrite(out
->str
, 1, out
->len
, outfile
);
477 g_string_free(out
, TRUE
);
482 * SR_DF_END needs to be handled after the output module's receive()
483 * is called, so it can properly clean up that module.
485 if (packet
->type
== SR_DF_END
) {
486 g_debug("cli: Received SR_DF_END.");
488 #if defined HAVE_SRD_SESSION_SEND_EOF && HAVE_SRD_SESSION_SEND_EOF
489 (void)srd_session_send_eof(srd_sess
);
493 props_dump_details(df_arg
);
494 props_cleanup(df_arg
);
506 if (outfile
&& outfile
!= stdout
)
510 if (rcvd_samples_logic
> 0 && rcvd_samples_logic
< limit_samples
)
511 g_warning("Device only sent %" PRIu64
" samples.",
513 else if (rcvd_samples_analog
> 0 && rcvd_samples_analog
< limit_samples
)
514 g_warning("Device only sent %" PRIu64
" samples.",
515 rcvd_samples_analog
);
521 int opt_to_gvar(char *key
, char *value
, struct sr_config
*src
)
523 const struct sr_key_info
*srci
, *srmqi
;
524 double tmp_double
, dlow
, dhigh
;
525 uint64_t tmp_u64
, p
, q
, low
, high
, mqflags
;
527 GVariant
*rational
[2], *range
[2], *gtup
[2];
528 GVariantBuilder
*vbl
;
533 if (!(srci
= sr_key_info_name_get(SR_KEY_CONFIG
, key
))) {
534 g_critical("Unknown device option '%s'.", (char *) key
);
537 src
->key
= srci
->key
;
539 if ((!value
|| strlen(value
) == 0) &&
540 (srci
->datatype
!= SR_T_BOOL
)) {
541 g_critical("Option '%s' needs a value.", (char *)key
);
546 switch (srci
->datatype
) {
548 ret
= sr_parse_sizestring(value
, &tmp_u64
);
551 src
->data
= g_variant_new_uint64(tmp_u64
);
554 ret
= sr_parse_sizestring(value
, &tmp_u64
);
557 src
->data
= g_variant_new_int32(tmp_u64
);
560 src
->data
= g_variant_new_string(value
);
566 tmp_bool
= sr_parse_boolstring(value
);
567 src
->data
= g_variant_new_boolean(tmp_bool
);
570 tmp_double
= strtof(value
, NULL
);
571 src
->data
= g_variant_new_double(tmp_double
);
573 case SR_T_RATIONAL_PERIOD
:
574 if ((ret
= sr_parse_period(value
, &p
, &q
)) != SR_OK
)
576 rational
[0] = g_variant_new_uint64(p
);
577 rational
[1] = g_variant_new_uint64(q
);
578 src
->data
= g_variant_new_tuple(rational
, 2);
580 case SR_T_RATIONAL_VOLT
:
581 if ((ret
= sr_parse_voltage(value
, &p
, &q
)) != SR_OK
)
583 rational
[0] = g_variant_new_uint64(p
);
584 rational
[1] = g_variant_new_uint64(q
);
585 src
->data
= g_variant_new_tuple(rational
, 2);
587 case SR_T_UINT64_RANGE
:
588 if (sscanf(value
, "%"PRIu64
"-%"PRIu64
, &low
, &high
) != 2) {
592 range
[0] = g_variant_new_uint64(low
);
593 range
[1] = g_variant_new_uint64(high
);
594 src
->data
= g_variant_new_tuple(range
, 2);
597 case SR_T_DOUBLE_RANGE
:
598 if (sscanf(value
, "%lf-%lf", &dlow
, &dhigh
) != 2) {
602 range
[0] = g_variant_new_double(dlow
);
603 range
[1] = g_variant_new_double(dhigh
);
604 src
->data
= g_variant_new_tuple(range
, 2);
608 /* Expects the argument to be in the form of key=value. */
609 keyval
= g_strsplit(value
, "=", 2);
610 if (!keyval
[0] || !keyval
[1]) {
615 vbl
= g_variant_builder_new(G_VARIANT_TYPE_DICTIONARY
);
616 g_variant_builder_add(vbl
, "{ss}",
617 keyval
[0], keyval
[1]);
618 src
->data
= g_variant_builder_end(vbl
);
624 Argument is MQ id e.g. ("voltage") optionally followed by one
625 or more /<mqflag> e.g. "/ac".
627 keyval
= g_strsplit(value
, "/", 0);
628 if (!keyval
[0] || !(srmqi
= sr_key_info_name_get(SR_KEY_MQ
, keyval
[0]))) {
635 for (i
= 1; keyval
[i
]; i
++) {
636 if (!(srmqi
= sr_key_info_name_get(SR_KEY_MQFLAGS
, keyval
[i
]))) {
640 mqflags
|= srmqi
->key
;
644 gtup
[0] = g_variant_new_uint32(mq
);
645 gtup
[1] = g_variant_new_uint64(mqflags
);
646 src
->data
= g_variant_new_tuple(gtup
, 2);
650 g_critical("Unknown data type specified for option '%s' "
651 "(driver implementation bug?).", key
);
656 g_critical("Invalid value: '%s' for option '%s'", value
, key
);
661 int set_dev_options_array(struct sr_dev_inst
*sdi
, char **opts
)
664 const char *opt_text
;
668 for (opt_idx
= 0; opts
&& opts
[opt_idx
]; opt_idx
++) {
669 opt_text
= opts
[opt_idx
];
670 args
= parse_generic_arg(opt_text
, FALSE
, "channel_group");
673 ret
= set_dev_options(sdi
, args
);
674 g_hash_table_destroy(args
);
682 int set_dev_options(struct sr_dev_inst
*sdi
, GHashTable
*args
)
684 struct sr_config src
;
686 struct sr_channel_group
*cg
;
692 * Not finding the 'sigrok_key' key (optional user specified
693 * channel group name) in the current options group's hash table
694 * is perfectly fine. In that case the -g selection is used,
695 * which defaults to "the device" (global parameters).
697 cg_name
= g_hash_table_lookup(args
, "sigrok_key");
698 cg
= lookup_channel_group(sdi
, cg_name
);
700 g_hash_table_iter_init(&iter
, args
);
701 while (g_hash_table_iter_next(&iter
, &key
, &value
)) {
702 if (g_ascii_strcasecmp(key
, "sigrok_key") == 0)
704 if ((ret
= opt_to_gvar(key
, value
, &src
)) != 0)
706 if ((ret
= maybe_config_set(sr_dev_inst_driver_get(sdi
), sdi
, cg
,
707 src
.key
, src
.data
)) != SR_OK
) {
708 g_critical("Failed to set device option '%s': %s.",
709 (char *)key
, sr_strerror(ret
));
717 void run_session(void)
719 struct df_arg_desc df_arg
;
720 GSList
*devices
, *real_devices
, *sd
;
722 struct sr_session
*session
;
723 struct sr_trigger
*trigger
;
724 struct sr_dev_inst
*sdi
;
725 uint64_t min_samples
, max_samples
;
729 struct sr_dev_driver
*driver
;
730 const struct sr_transform
*t
;
731 GMainLoop
*main_loop
;
733 memset(&df_arg
, 0, sizeof(df_arg
));
734 df_arg
.do_props
= FALSE
;
736 devices
= device_scan();
738 g_critical("No devices found.");
743 for (sd
= devices
; sd
; sd
= sd
->next
) {
746 driver
= sr_dev_inst_driver_get(sdi
);
748 if (!(drv_opts
= sr_dev_options(driver
, NULL
, NULL
))) {
749 g_critical("Failed to query list of driver options.");
754 for (i
= 0; i
< drv_opts
->len
; i
++) {
755 if (g_array_index(drv_opts
, uint32_t, i
) == SR_CONF_DEMO_DEV
)
759 g_array_free(drv_opts
, TRUE
);
762 real_devices
= g_slist_append(real_devices
, sdi
);
765 if (g_slist_length(devices
) > 1) {
766 if (g_slist_length(real_devices
) != 1) {
767 g_critical("sigrok-cli only supports one device for capturing.");
770 /* We only have one non-demo device. */
771 g_slist_free(devices
);
772 devices
= real_devices
;
777 /* This is unlikely to happen but it makes static analyzers stop complaining. */
779 g_critical("No real devices found.");
784 g_slist_free(devices
);
785 g_slist_free(real_devices
);
787 sr_session_new(sr_ctx
, &session
);
788 df_arg
.session
= session
;
789 sr_session_datafeed_callback_add(session
, datafeed_in
, &df_arg
);
790 df_arg
.session
= NULL
;
792 if (sr_dev_open(sdi
) != SR_OK
) {
793 g_critical("Failed to open device.");
797 if (sr_session_dev_add(session
, sdi
) != SR_OK
) {
798 g_critical("Failed to add device to session.");
799 sr_session_destroy(session
);
804 if (set_dev_options_array(sdi
, opt_configs
) != SR_OK
)
808 if (select_channels(sdi
) != SR_OK
) {
809 g_critical("Failed to set channels.");
810 sr_session_destroy(session
);
816 if (!parse_triggerstring(sdi
, opt_triggers
, &trigger
)) {
817 sr_session_destroy(session
);
820 if (sr_session_trigger_set(session
, trigger
) != SR_OK
) {
821 sr_session_destroy(session
);
826 if (opt_continuous
) {
827 if (!sr_dev_has_option(sdi
, SR_CONF_CONTINUOUS
)) {
828 g_critical("This device does not support continuous sampling.");
829 sr_session_destroy(session
);
835 if (set_limit_time(sdi
) != SR_OK
) {
836 sr_session_destroy(session
);
842 if ((sr_parse_sizestring(opt_samples
, &limit_samples
) != SR_OK
)) {
843 g_critical("Invalid sample limit '%s'.", opt_samples
);
844 sr_session_destroy(session
);
847 if (maybe_config_list(driver
, sdi
, NULL
, SR_CONF_LIMIT_SAMPLES
,
850 * The device has no compression, or compression is turned
851 * off, and publishes its sample memory size.
853 g_variant_get(gvar
, "(tt)", &min_samples
, &max_samples
);
854 g_variant_unref(gvar
);
855 if (limit_samples
< min_samples
) {
856 g_critical("The device stores at least %"PRIu64
857 " samples with the current settings.", min_samples
);
859 if (limit_samples
> max_samples
) {
860 g_critical("The device can store only %"PRIu64
861 " samples with the current settings.", max_samples
);
864 gvar
= g_variant_new_uint64(limit_samples
);
865 if (maybe_config_set(sr_dev_inst_driver_get(sdi
), sdi
, NULL
, SR_CONF_LIMIT_SAMPLES
, gvar
) != SR_OK
) {
866 g_critical("Failed to configure sample limit.");
867 sr_session_destroy(session
);
873 if ((sr_parse_sizestring(opt_frames
, &limit_frames
) != SR_OK
)) {
874 g_critical("Invalid frame limit '%s'.", opt_frames
);
875 sr_session_destroy(session
);
878 gvar
= g_variant_new_uint64(limit_frames
);
879 if (maybe_config_set(sr_dev_inst_driver_get(sdi
), sdi
, NULL
, SR_CONF_LIMIT_FRAMES
, gvar
) != SR_OK
) {
880 g_critical("Failed to configure frame limit.");
881 sr_session_destroy(session
);
886 if (opt_transform_module
) {
887 if (!(t
= setup_transform_module(sdi
)))
888 g_critical("Failed to initialize transform module.");
891 main_loop
= g_main_loop_new(NULL
, FALSE
);
893 sr_session_stopped_callback_set(session
,
894 (sr_session_stopped_callback
)g_main_loop_quit
, main_loop
);
896 if (sr_session_start(session
) != SR_OK
) {
897 g_critical("Failed to start session.");
898 g_main_loop_unref(main_loop
);
899 sr_session_destroy(session
);
906 g_main_loop_run(main_loop
);
912 sr_trigger_free(trigger
);
914 sr_session_datafeed_callback_remove_all(session
);
915 g_main_loop_unref(main_loop
);
916 sr_session_destroy(session
);