struct sr_dev_driver **driver_list;
#ifdef HAVE_LIBUSB_1_0
libusb_context *libusb_ctx;
- gboolean usb_source_present;
#endif
};
/*--- log.c -----------------------------------------------------------------*/
-SR_PRIV int sr_log(int loglevel, const char *format, ...);
-SR_PRIV int sr_spew(const char *format, ...);
-SR_PRIV int sr_dbg(const char *format, ...);
-SR_PRIV int sr_info(const char *format, ...);
-SR_PRIV int sr_warn(const char *format, ...);
-SR_PRIV int sr_err(const char *format, ...);
+#if defined(G_OS_WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+/*
+ * On MinGW, we need to specify the gnu_printf format flavor or GCC
+ * will assume non-standard Microsoft printf syntax.
+ */
+SR_PRIV int sr_log(int loglevel, const char *format, ...)
+ __attribute__((__format__ (__gnu_printf__, 2, 3)));
+#else
+SR_PRIV int sr_log(int loglevel, const char *format, ...) G_GNUC_PRINTF(2, 3);
+#endif
/* Message logging helpers with subsystem-specific prefix string. */
-#ifndef NO_LOG_WRAPPERS
-#define sr_log(l, s, args...) sr_log(l, "%s: " s, LOG_PREFIX, ## args)
-#define sr_spew(s, args...) sr_spew("%s: " s, LOG_PREFIX, ## args)
-#define sr_dbg(s, args...) sr_dbg("%s: " s, LOG_PREFIX, ## args)
-#define sr_info(s, args...) sr_info("%s: " s, LOG_PREFIX, ## args)
-#define sr_warn(s, args...) sr_warn("%s: " s, LOG_PREFIX, ## args)
-#define sr_err(s, args...) sr_err("%s: " s, LOG_PREFIX, ## args)
-#endif
+#define sr_spew(...) sr_log(SR_LOG_SPEW, LOG_PREFIX ": " __VA_ARGS__)
+#define sr_dbg(...) sr_log(SR_LOG_DBG, LOG_PREFIX ": " __VA_ARGS__)
+#define sr_info(...) sr_log(SR_LOG_INFO, LOG_PREFIX ": " __VA_ARGS__)
+#define sr_warn(...) sr_log(SR_LOG_WARN, LOG_PREFIX ": " __VA_ARGS__)
+#define sr_err(...) sr_log(SR_LOG_ERR, LOG_PREFIX ": " __VA_ARGS__)
/*--- device.c --------------------------------------------------------------*/
GSList *transforms;
struct sr_trigger *trigger;
- gboolean running;
+ /** Mutex protecting the main context pointer and ownership flag. */
+ GMutex main_mutex;
+ /** Context of the session main loop. */
+ GMainContext *main_context;
+ /** Whether we are using the thread's default context. */
+ gboolean main_context_is_default;
- /*
- * Event sources and poll FDs are stored in the same order in the
- * the sources and pollfds arrays. However, each source may cover
- * any number of associated poll FDs, so the indices do not match.
- *
- * We cannot embed the GPollFD into the source struct since we want
- * to be able to pass the array of all poll descriptors to g_poll().
- */
- GArray *sources;
- GArray *pollfds;
+ /** Whether the session has been started. */
+ gboolean running;
- /*
- * These are our synchronization primitives for stopping the session in
- * an async fashion. We need to make sure the session is stopped from
- * within the session thread itself.
- */
- /** Mutex protecting access to abort_session. */
- GMutex stop_mutex;
- /** Abort current session. See sr_session_stop(). */
- gboolean abort_session;
+ /** Registered event sources for this session. */
+ GHashTable *event_sources;
+ /** Session main loop. */
+ GMainLoop *main_loop;
};
SR_PRIV int sr_session_source_add_internal(struct sr_session *session,
- const GPollFD *pollfds, int num_fds, int timeout,
- sr_receive_data_callback cb, void *cb_data,
- gintptr poll_object);
+ void *key, GSource *source);
SR_PRIV int sr_session_source_remove_internal(struct sr_session *session,
- gintptr poll_object);
+ void *key);
+SR_PRIV int sr_session_source_destroyed(struct sr_session *session,
+ void *key, GSource *source);
SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi,
const struct sr_datafeed_packet *packet);
-SR_PRIV int sr_session_stop_sync(struct sr_session *session);
SR_PRIV int sr_sessionfile_check(const char *filename);
SR_PRIV int sr_packet_copy(const struct sr_datafeed_packet *packet,
struct sr_datafeed_packet **copy);