sr: Name all callback data 'cb_data'.
This commit is contained in:
parent
31ccebc492
commit
1f9813eb6c
|
@ -235,9 +235,9 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
}
|
||||
}
|
||||
|
||||
static int receive_data(int fd, int revents, void *user_data)
|
||||
static int receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi = user_data;
|
||||
struct sr_dev_inst *sdi = cb_data;
|
||||
struct context *ctx = sdi->priv;
|
||||
struct sr_datafeed_packet packet;
|
||||
struct sr_analog_sample *sample;
|
||||
|
@ -281,19 +281,19 @@ static int receive_data(int fd, int revents, void *user_data)
|
|||
packet.length = count * sample_size;
|
||||
packet.unitsize = sample_size;
|
||||
packet.payload = outb;
|
||||
sr_session_send(user_data, &packet);
|
||||
sr_session_send(sdi, &packet);
|
||||
g_free(outb);
|
||||
ctx->limit_samples -= count;
|
||||
|
||||
} while (ctx->limit_samples > 0);
|
||||
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(user_data, &packet);
|
||||
sr_session_send(sdi, &packet);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
@ -386,7 +386,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
||||
{
|
||||
/* Avoid compiler warnings. */
|
||||
dev_index = dev_index;
|
||||
|
|
|
@ -123,7 +123,7 @@ static const char *firmware_files[] = {
|
|||
"asix-sigma-phasor.fw", /* Frequency counter */
|
||||
};
|
||||
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_data);
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data);
|
||||
|
||||
static int sigma_read(void *buf, size_t size, struct context *ctx)
|
||||
{
|
||||
|
@ -1008,9 +1008,9 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int receive_data(int fd, int revents, void *session_data)
|
||||
static int receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi = session_data;
|
||||
struct sr_dev_inst *sdi = cb_data;
|
||||
struct context *ctx = sdi->priv;
|
||||
struct sr_datafeed_packet packet;
|
||||
const int chunks_per_read = 32;
|
||||
|
@ -1037,7 +1037,7 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
if (running_msec < ctx->limit_msec && numchunks < 32767)
|
||||
return FALSE;
|
||||
|
||||
hw_dev_acquisition_stop(sdi->index, session_data);
|
||||
hw_dev_acquisition_stop(sdi->index, sdi);
|
||||
|
||||
return FALSE;
|
||||
} else if (ctx->state.state == SIGMA_DOWNLOAD) {
|
||||
|
@ -1083,12 +1083,12 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
&ctx->state.lastts,
|
||||
&ctx->state.lastsample,
|
||||
ctx->state.triggerpos & 0x1ff,
|
||||
limit_chunk, session_data);
|
||||
limit_chunk, sdi);
|
||||
else
|
||||
decode_chunk_ts(buf + (i * CHUNK_SIZE),
|
||||
&ctx->state.lastts,
|
||||
&ctx->state.lastsample,
|
||||
-1, limit_chunk, session_data);
|
||||
-1, limit_chunk, sdi);
|
||||
|
||||
++ctx->state.chunks_downloaded;
|
||||
}
|
||||
|
@ -1254,7 +1254,7 @@ static int build_basic_trigger(struct triggerlut *lut, struct context *ctx)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
@ -1266,9 +1266,6 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
|||
struct triggerinout triggerinout_conf;
|
||||
struct triggerlut lut;
|
||||
|
||||
/* Avoid compiler warnings. */
|
||||
(void)session_data;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
|
||||
return SR_ERR;
|
||||
|
||||
|
@ -1371,7 +1368,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
|
|
@ -138,7 +138,7 @@ static int hwcaps[] = {
|
|||
|
||||
/* Function prototypes. */
|
||||
static int la8_close_usb_reset_sequencer(struct context *ctx);
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_data);
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data);
|
||||
static int la8_reset(struct context *ctx);
|
||||
|
||||
static void fill_supported_samplerates_if_needed(void)
|
||||
|
@ -960,7 +960,7 @@ static void send_block_to_session_bus(struct context *ctx, int block)
|
|||
}
|
||||
}
|
||||
|
||||
static int receive_data(int fd, int revents, void *session_data)
|
||||
static int receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
int i, ret;
|
||||
struct sr_dev_inst *sdi;
|
||||
|
@ -970,8 +970,8 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
(void)fd;
|
||||
(void)revents;
|
||||
|
||||
if (!(sdi = session_data)) {
|
||||
sr_err("la8: %s: session_data was NULL", __func__);
|
||||
if (!(sdi = cb_data)) {
|
||||
sr_err("la8: %s: cb_data was NULL", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -988,7 +988,7 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
/* Get one block of data. */
|
||||
if ((ret = la8_read_block(ctx)) < 0) {
|
||||
sr_err("la8: %s: la8_read_block error: %d", __func__, ret);
|
||||
hw_dev_acquisition_stop(sdi->index, session_data);
|
||||
hw_dev_acquisition_stop(sdi->index, sdi);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1004,13 +1004,13 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
for (i = 0; i < NUM_BLOCKS; i++)
|
||||
send_block_to_session_bus(ctx, i);
|
||||
|
||||
hw_dev_acquisition_stop(sdi->index, session_data);
|
||||
hw_dev_acquisition_stop(sdi->index, sdi);
|
||||
|
||||
// return FALSE; /* FIXME? */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
@ -1085,7 +1085,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
|
|
@ -138,7 +138,7 @@ static int default_pattern = PATTERN_SIGROK;
|
|||
static GThread *my_thread;
|
||||
static int thread_running;
|
||||
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_data);
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data);
|
||||
|
||||
static int hw_init(const char *devinfo)
|
||||
{
|
||||
|
@ -368,7 +368,7 @@ static void thread_func(void *data)
|
|||
}
|
||||
|
||||
/* Callback handling data */
|
||||
static int receive_data(int fd, int revents, void *session_data)
|
||||
static int receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
struct sr_datafeed_logic logic;
|
||||
|
@ -390,7 +390,7 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
logic.length = z;
|
||||
logic.unitsize = 1;
|
||||
logic.data = c;
|
||||
sr_session_send(session_data, &packet);
|
||||
sr_session_send(cb_data, &packet);
|
||||
samples_received += z;
|
||||
}
|
||||
} while (z > 0);
|
||||
|
@ -401,7 +401,7 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
|
||||
/* Send last packet. */
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(session_data, &packet);
|
||||
sr_session_send(cb_data, &packet);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_datafeed_packet *packet;
|
||||
struct sr_datafeed_header *header;
|
||||
|
@ -481,7 +481,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
||||
{
|
||||
/* Avoid compiler warnings. */
|
||||
(void)dev_index;
|
||||
|
|
|
@ -77,7 +77,7 @@ static struct sr_samplerates fx2lafw_samplerates = {
|
|||
static GSList *dev_insts = NULL;
|
||||
static libusb_context *usb_context = NULL;
|
||||
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id);
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id);
|
||||
|
||||
/**
|
||||
* Check the USB configuration to determine if this is an fx2lafw device.
|
||||
|
@ -483,14 +483,14 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int receive_data(int fd, int revents, void *user_data)
|
||||
static int receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
/* Avoid compiler warnings. */
|
||||
(void)fd;
|
||||
(void)revents;
|
||||
(void)user_data;
|
||||
(void)cb_data;
|
||||
|
||||
tv.tv_sec = tv.tv_usec = 0;
|
||||
libusb_handle_events_timeout(usb_context, &tv);
|
||||
|
@ -575,7 +575,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
|||
}
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct sr_datafeed_packet *packet;
|
||||
|
@ -641,7 +641,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
|||
}
|
||||
|
||||
/* This stops acquisition on ALL devices, ignoring dev_index. */
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
|
||||
|
|
|
@ -681,9 +681,9 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
#define MSO_TRIGGER_DATAREADY '6'
|
||||
|
||||
/* FIXME: Pass errors? */
|
||||
static int receive_data(int fd, int revents, void *user_data)
|
||||
static int receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi = user_data;
|
||||
struct sr_dev_inst *sdi = cb_data;
|
||||
struct context *ctx = sdi->priv;
|
||||
struct sr_datafeed_packet packet;
|
||||
struct sr_datafeed_logic logic;
|
||||
|
@ -748,7 +748,7 @@ static int receive_data(int fd, int revents, void *user_data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct context *ctx;
|
||||
|
@ -822,7 +822,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
|
|||
}
|
||||
|
||||
/* FIXME */
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
|
||||
|
|
|
@ -691,7 +691,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int receive_data(int fd, int revents, void *session_data)
|
||||
static int receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
struct sr_datafeed_logic logic;
|
||||
|
@ -722,7 +722,7 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
* finished. We'll double that to 30ms to be sure...
|
||||
*/
|
||||
sr_source_remove(fd);
|
||||
sr_source_add(fd, G_IO_IN, 30, receive_data, session_data);
|
||||
sr_source_add(fd, G_IO_IN, 30, receive_data, cb_data);
|
||||
ctx->raw_sample_buf = g_try_malloc(ctx->limit_samples * 4);
|
||||
if (!ctx->raw_sample_buf) {
|
||||
sr_err("ols: %s: ctx->raw_sample_buf malloc failed",
|
||||
|
@ -834,12 +834,12 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
logic.unitsize = 4;
|
||||
logic.data = ctx->raw_sample_buf +
|
||||
(ctx->limit_samples - ctx->num_samples) * 4;
|
||||
sr_session_send(session_data, &packet);
|
||||
sr_session_send(cb_data, &packet);
|
||||
}
|
||||
|
||||
/* send the trigger */
|
||||
packet.type = SR_DF_TRIGGER;
|
||||
sr_session_send(session_data, &packet);
|
||||
sr_session_send(cb_data, &packet);
|
||||
|
||||
/* send post-trigger samples */
|
||||
packet.type = SR_DF_LOGIC;
|
||||
|
@ -848,7 +848,7 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
logic.unitsize = 4;
|
||||
logic.data = ctx->raw_sample_buf + ctx->trigger_at * 4 +
|
||||
(ctx->limit_samples - ctx->num_samples) * 4;
|
||||
sr_session_send(session_data, &packet);
|
||||
sr_session_send(cb_data, &packet);
|
||||
} else {
|
||||
/* no trigger was used */
|
||||
packet.type = SR_DF_LOGIC;
|
||||
|
@ -857,20 +857,20 @@ static int receive_data(int fd, int revents, void *session_data)
|
|||
logic.unitsize = 4;
|
||||
logic.data = ctx->raw_sample_buf +
|
||||
(ctx->limit_samples - ctx->num_samples) * 4;
|
||||
sr_session_send(session_data, &packet);
|
||||
sr_session_send(cb_data, &packet);
|
||||
}
|
||||
g_free(ctx->raw_sample_buf);
|
||||
|
||||
serial_flush(fd);
|
||||
serial_close(fd);
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(session_data, &packet);
|
||||
sr_session_send(cb_data, &packet);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_datafeed_packet *packet;
|
||||
struct sr_datafeed_header *header;
|
||||
|
@ -1023,7 +1023,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ static libusb_context *usb_context = NULL;
|
|||
static int new_saleae_logic_firmware = 0;
|
||||
|
||||
static int hw_dev_config_set(int dev_index, int hwcap, void *value);
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id);
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id);
|
||||
|
||||
/**
|
||||
* Check the USB configuration to determine if this is a Saleae Logic.
|
||||
|
@ -657,14 +657,14 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int receive_data(int fd, int revents, void *user_data)
|
||||
static int receive_data(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
/* Avoid compiler warnings. */
|
||||
(void)fd;
|
||||
(void)revents;
|
||||
(void)user_data;
|
||||
(void)cb_data;
|
||||
|
||||
tv.tv_sec = tv.tv_usec = 0;
|
||||
libusb_handle_events_timeout(usb_context, &tv);
|
||||
|
@ -810,7 +810,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
|||
}
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct sr_datafeed_packet *packet;
|
||||
|
@ -876,7 +876,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
|||
}
|
||||
|
||||
/* This stops acquisition on ALL devices, ignoring dev_index. */
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
|
||||
|
|
|
@ -613,7 +613,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
}
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_data)
|
||||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct sr_datafeed_packet packet;
|
||||
|
@ -689,7 +689,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
|
|||
}
|
||||
|
||||
/* This stops acquisition on ALL devices, ignoring dev_index. */
|
||||
static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
|
||||
static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
struct sr_dev_inst *sdi;
|
||||
|
|
|
@ -315,7 +315,7 @@ SR_PRIV void sr_source_remove(int fd)
|
|||
}
|
||||
|
||||
SR_PRIV void sr_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback_t cb, void *user_data)
|
||||
sr_receive_data_callback_t cb, void *cb_data)
|
||||
{
|
||||
sr_session_source_add(fd, events, timeout, cb, user_data);
|
||||
sr_session_source_add(fd, events, timeout, cb, cb_data);
|
||||
}
|
||||
|
|
23
log.c
23
log.c
|
@ -27,7 +27,8 @@
|
|||
static int sr_loglevel = SR_LOG_WARN; /* Show errors+warnings per default. */
|
||||
|
||||
/* Function prototype. */
|
||||
static int sr_logv(void *data, int loglevel, const char *format, va_list args);
|
||||
static int sr_logv(void *cb_data, int loglevel, const char *format,
|
||||
va_list args);
|
||||
|
||||
/* Pointer to the currently selected log handler. Default: sr_logv(). */
|
||||
static sr_log_handler_t sr_log_handler = sr_logv;
|
||||
|
@ -128,25 +129,25 @@ SR_API char *sr_log_logdomain_get(void)
|
|||
*
|
||||
* @param handler Function pointer to the log handler function to use.
|
||||
* Must not be NULL.
|
||||
* @param data Pointer to private data to be passed on. This can be used by
|
||||
* the caller to pass arbitrary data to the log functions. This
|
||||
* pointer is only stored or passed on by libsigrok, and
|
||||
* is never used or interpreted in any way. The pointer is allowed
|
||||
* to be NULL if the caller doesn't need/want to pass any data.
|
||||
* @param cb_data Pointer to private data to be passed on. This can be used by
|
||||
* the caller to pass arbitrary data to the log functions. This
|
||||
* pointer is only stored or passed on by libsigrok, and is
|
||||
* never used or interpreted in any way. The pointer is allowed
|
||||
* to be NULL if the caller doesn't need/want to pass any data.
|
||||
*
|
||||
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
|
||||
*/
|
||||
SR_API int sr_log_handler_set(sr_log_handler_t handler, void *data)
|
||||
SR_API int sr_log_handler_set(sr_log_handler_t handler, void *cb_data)
|
||||
{
|
||||
if (!handler) {
|
||||
sr_err("log: %s: handler was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
/* Note: 'data' is allowed to be NULL. */
|
||||
/* Note: 'cb_data' is allowed to be NULL. */
|
||||
|
||||
sr_log_handler = handler;
|
||||
sr_log_handler_data = data;
|
||||
sr_log_handler_data = cb_data;
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
@ -170,12 +171,12 @@ SR_API int sr_log_handler_set_default(void)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int sr_logv(void *data, int loglevel, const char *format, va_list args)
|
||||
static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* This specific log handler doesn't need the void pointer data. */
|
||||
(void)data;
|
||||
(void)cb_data;
|
||||
|
||||
/* Only output messages of at least the selected loglevel(s). */
|
||||
if (loglevel > sr_loglevel)
|
||||
|
|
14
session.c
14
session.c
|
@ -33,7 +33,7 @@ struct source {
|
|||
int events;
|
||||
int timeout;
|
||||
sr_receive_data_callback_t cb;
|
||||
void *user_data;
|
||||
void *cb_data;
|
||||
};
|
||||
|
||||
/* There can only be one session at a time. */
|
||||
|
@ -233,7 +233,7 @@ static int sr_session_run_poll(void)
|
|||
* asked for that timeout.
|
||||
*/
|
||||
if (!sources[i].cb(fds[i].fd, fds[i].revents,
|
||||
sources[i].user_data))
|
||||
sources[i].cb_data))
|
||||
sr_session_source_remove(sources[i].fd);
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ SR_API int sr_session_run(void)
|
|||
if (num_sources == 1 && sources[0].fd == -1) {
|
||||
/* Dummy source, freewheel over it. */
|
||||
while (session->running)
|
||||
sources[0].cb(-1, 0, sources[0].user_data);
|
||||
sources[0].cb(-1, 0, sources[0].cb_data);
|
||||
} else {
|
||||
/* Real sources, use g_poll() main loop. */
|
||||
sr_session_run_poll();
|
||||
|
@ -464,13 +464,13 @@ SR_PRIV int sr_session_send(struct sr_dev *dev,
|
|||
* @param events TODO.
|
||||
* @param timeout TODO.
|
||||
* @param cb TODO.
|
||||
* @param user_data TODO.
|
||||
* @param cb_data TODO.
|
||||
*
|
||||
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
|
||||
* SR_ERR_MALLOC upon memory allocation errors.
|
||||
*/
|
||||
SR_API int sr_session_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback_t cb, void *user_data)
|
||||
sr_receive_data_callback_t cb, void *cb_data)
|
||||
{
|
||||
struct source *new_sources, *s;
|
||||
|
||||
|
@ -479,7 +479,7 @@ SR_API int sr_session_source_add(int fd, int events, int timeout,
|
|||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
/* Note: user_data can be NULL, that's not a bug. */
|
||||
/* Note: cb_data can be NULL, that's not a bug. */
|
||||
|
||||
new_sources = g_try_malloc0(sizeof(struct source) * (num_sources + 1));
|
||||
if (!new_sources) {
|
||||
|
@ -498,7 +498,7 @@ SR_API int sr_session_source_add(int fd, int events, int timeout,
|
|||
s->events = events;
|
||||
s->timeout = timeout;
|
||||
s->cb = cb;
|
||||
s->user_data = user_data;
|
||||
s->cb_data = cb_data;
|
||||
sources = new_sources;
|
||||
|
||||
if (timeout != source_timeout && timeout > 0
|
||||
|
|
|
@ -269,7 +269,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
|
||||
static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
|
||||
{
|
||||
struct zip_stat zs;
|
||||
struct session_vdev *vdev;
|
||||
|
|
|
@ -93,7 +93,7 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
|
|||
|
||||
SR_PRIV void sr_source_remove(int fd);
|
||||
SR_PRIV void sr_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback_t cb, void *user_data);
|
||||
sr_receive_data_callback_t cb, void *cb_data);
|
||||
|
||||
/*--- hardware/common/serial.c ----------------------------------------------*/
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ SR_API int sr_exit(void);
|
|||
|
||||
/*--- log.c -----------------------------------------------------------------*/
|
||||
|
||||
typedef int (*sr_log_handler_t)(void *data, int loglevel, const char *format,
|
||||
typedef int (*sr_log_handler_t)(void *cb_data, int loglevel, const char *format,
|
||||
va_list args);
|
||||
|
||||
SR_API int sr_log_loglevel_set(int loglevel);
|
||||
SR_API int sr_log_loglevel_get(void);
|
||||
SR_API int sr_log_handler_set(sr_log_handler_t handler, void *data);
|
||||
SR_API int sr_log_handler_set(sr_log_handler_t handler, void *cb_data);
|
||||
SR_API int sr_log_handler_set_default(void);
|
||||
SR_API int sr_log_logdomain_set(const char *logdomain);
|
||||
SR_API char *sr_log_logdomain_get(void);
|
||||
|
@ -99,7 +99,7 @@ SR_API int sr_session_halt(void);
|
|||
SR_API int sr_session_stop(void);
|
||||
SR_API int sr_session_save(const char *filename);
|
||||
SR_API int sr_session_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback_t cb, void *user_data);
|
||||
sr_receive_data_callback_t cb, void *cb_data);
|
||||
SR_API int sr_session_source_remove(int fd);
|
||||
|
||||
/*--- input/input.c ---------------------------------------------------------*/
|
||||
|
|
6
sigrok.h
6
sigrok.h
|
@ -92,7 +92,7 @@ extern "C" {
|
|||
/* Marks private, non-public libsigrok symbols (not part of the API). */
|
||||
#define SR_PRIV __attribute__((visibility("hidden")))
|
||||
|
||||
typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *user_data);
|
||||
typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *cb_data);
|
||||
|
||||
/* Data types used by hardware drivers for dev_config_set() */
|
||||
enum {
|
||||
|
@ -353,8 +353,8 @@ struct sr_dev_driver {
|
|||
int (*dev_status_get) (int dev_index);
|
||||
int *(*hwcap_get_all) (void);
|
||||
int (*dev_config_set) (int dev_index, int hwcap, void *value);
|
||||
int (*dev_acquisition_start) (int dev_index, gpointer session_dev_id);
|
||||
int (*dev_acquisition_stop) (int dev_index, gpointer session_dev_id);
|
||||
int (*dev_acquisition_start) (int dev_index, void *session_dev_id);
|
||||
int (*dev_acquisition_stop) (int dev_index, void *session_dev_id);
|
||||
};
|
||||
|
||||
struct sr_session {
|
||||
|
|
Loading…
Reference in New Issue