Add sr_ prefix to session related API functions.

This commit is contained in:
Uwe Hermann 2011-02-08 18:00:49 +01:00
parent 2872d21ebc
commit 8a2efef2d5
13 changed files with 81 additions and 85 deletions

View File

@ -244,14 +244,14 @@ static int receive_data(int fd, int revents, void *user_data)
packet.length = count * sample_size;
packet.unitsize = sample_size;
packet.payload = outb;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
free(outb);
alsa->limit_samples -= count;
} while (alsa->limit_samples > 0);
packet.type = SR_DF_END;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
return TRUE;
}
@ -342,7 +342,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
header.num_analog_probes = NUM_PROBES;
header.num_logic_probes = 0;
header.protocol_id = SR_PROTO_RAW;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
free(ufds);
return SR_OK;

View File

@ -877,7 +877,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent;
session_bus(sigma->session_id, &packet);
sr_session_bus(sigma->session_id, &packet);
sent += tosend;
}
@ -921,7 +921,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples;
session_bus(sigma->session_id, &packet);
sr_session_bus(sigma->session_id, &packet);
sent += tosend;
}
@ -931,7 +931,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
packet.type = SR_DF_TRIGGER;
packet.length = 0;
packet.payload = 0;
session_bus(sigma->session_id, &packet);
sr_session_bus(sigma->session_id, &packet);
}
}
@ -943,7 +943,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent;
session_bus(sigma->session_id, &packet);
sr_session_bus(sigma->session_id, &packet);
}
*lastsample = samples[n - 1];
@ -990,7 +990,7 @@ static int receive_data(int fd, int revents, void *user_data)
/* End of samples. */
packet.type = SR_DF_END;
packet.length = 0;
session_bus(sigma->session_id, &packet);
sr_session_bus(sigma->session_id, &packet);
sigma->state.state = SIGMA_IDLE;
@ -1306,7 +1306,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
header.protocol_id = SR_PROTO_RAW;
header.num_logic_probes = sigma->num_probes;
header.num_analog_probes = 0;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
/* Add capture source. */
source_add(0, G_IO_IN, 10, receive_data, sdi);

View File

@ -303,7 +303,7 @@ static int receive_data(int fd, int revents, void *user_data)
packet.length = z;
packet.unitsize = 1;
packet.payload = c;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
}
} while (z > 0);
@ -314,7 +314,7 @@ static int receive_data(int fd, int revents, void *user_data)
/* Send last packet. */
packet.type = SR_DF_END;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
return FALSE;
}
@ -378,7 +378,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
header->protocol_id = SR_PROTO_RAW;
header->num_logic_probes = NUM_PROBES;
header->num_analog_probes = 0;
session_bus(session_device_id, packet);
sr_session_bus(session_device_id, packet);
free(header);
free(packet);

View File

@ -649,17 +649,17 @@ static int receive_data(int fd, int revents, void *user_data)
packet.length = 1024;
packet.unitsize = 1;
packet.payload = logic_out;
session_bus(mso->session_id, &packet);
sr_session_bus(mso->session_id, &packet);
packet.type = SR_DF_ANALOG;
packet.length = 1024;
packet.unitsize = sizeof(double);
packet.payload = analog_out;
session_bus(mso->session_id, &packet);
sr_session_bus(mso->session_id, &packet);
packet.type = SR_DF_END;
session_bus(mso->session_id, &packet);
sr_session_bus(mso->session_id, &packet);
return TRUE;
}
@ -734,7 +734,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
header.num_analog_probes = 1;
header.num_logic_probes = 8;
header.protocol_id = SR_PROTO_RAW;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
return ret;
}
@ -747,7 +747,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
device_index = device_index;
packet.type = SR_DF_END;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
}
struct sr_device_plugin link_mso19_plugin_info = {

View File

@ -618,24 +618,24 @@ static int receive_data(int fd, int revents, void *user_data)
packet.length = trigger_at * 4;
packet.unitsize = 4;
packet.payload = raw_sample_buf;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
}
packet.type = SR_DF_TRIGGER;
packet.length = 0;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
packet.type = SR_DF_LOGIC;
packet.length = (limit_samples * 4) - (trigger_at * 4);
packet.unitsize = 4;
packet.payload = raw_sample_buf + trigger_at * 4;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
} else {
packet.type = SR_DF_LOGIC;
packet.length = limit_samples * 4;
packet.unitsize = 4;
packet.payload = raw_sample_buf;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
}
free(raw_sample_buf);
@ -643,7 +643,7 @@ static int receive_data(int fd, int revents, void *user_data)
serial_close(fd);
packet.type = SR_DF_END;
packet.length = 0;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
}
return TRUE;
@ -772,7 +772,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
header->protocol_id = SR_PROTO_RAW;
header->num_logic_probes = NUM_PROBES;
header->num_analog_probes = 0;
session_bus(session_device_id, packet);
sr_session_bus(session_device_id, packet);
g_free(header);
g_free(packet);
@ -788,7 +788,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
packet.type = SR_DF_END;
packet.length = 0;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
}
struct sr_device_plugin ols_plugin_info = {

View File

@ -609,7 +609,7 @@ void receive_transfer(struct libusb_transfer *transfer)
*/
packet.type = SR_DF_TRIGGER;
packet.length = 0;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
/*
* Send the samples that triggered it, since we're
@ -619,7 +619,7 @@ void receive_transfer(struct libusb_transfer *transfer)
packet.length = trigger_stage;
packet.unitsize = 1;
packet.payload = trigger_buffer;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
trigger_stage = TRIGGER_FIRED;
break;
@ -652,7 +652,7 @@ void receive_transfer(struct libusb_transfer *transfer)
packet.length = cur_buflen - trigger_offset;
packet.unitsize = 1;
packet.payload = cur_buf + trigger_offset;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
g_free(cur_buf);
num_samples += cur_buflen;
@ -717,7 +717,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
header->protocol_id = SR_PROTO_RAW;
header->num_logic_probes = NUM_PROBES;
header->num_analog_probes = 0;
session_bus(session_device_id, packet);
sr_session_bus(session_device_id, packet);
g_free(header);
g_free(packet);
@ -733,7 +733,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
device_index = device_index;
packet.type = SR_DF_END;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
receive_transfer(NULL);

View File

@ -514,7 +514,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
header.protocol_id = SR_PROTO_RAW;
header.num_logic_probes = num_channels;
header.num_analog_probes = 0;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
buf = g_malloc(PACKET_SIZE);
if (!buf)
@ -533,13 +533,13 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
packet.length = PACKET_SIZE;
packet.unitsize = 4;
packet.payload = buf;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
}
analyzer_read_stop(sdi->usb->devhdl);
g_free(buf);
packet.type = SR_DF_END;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
return SR_OK;
}
@ -551,7 +551,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
struct sr_device_instance *sdi;
packet.type = SR_DF_END;
session_bus(session_device_id, &packet);
sr_session_bus(session_device_id, &packet);
if (!(sdi = sr_get_device_instance(device_instances, device_index)))
return; /* TODO: Cry? */

View File

@ -231,15 +231,11 @@ struct hwcap_option *find_hwcap_option(int hwcap)
void source_remove(int fd)
{
session_source_remove(fd);
sr_session_source_remove(fd);
}
void source_add(int fd, int events, int timeout, receive_data_callback rcv_cb,
void *user_data)
{
session_source_add(fd, events, timeout, rcv_cb, user_data);
sr_session_source_add(fd, events, timeout, rcv_cb, user_data);
}

View File

@ -78,7 +78,7 @@ static int loadfile(struct sr_input *in, const char *filename)
packet.type = SR_DF_HEADER;
packet.length = sizeof(struct sr_datafeed_header);
packet.payload = &header;
session_bus(in->vdevice, &packet);
sr_session_bus(in->vdevice, &packet);
/* chop up the input file into chunks and feed it into the session bus */
packet.type = SR_DF_LOGIC;
@ -86,14 +86,14 @@ static int loadfile(struct sr_input *in, const char *filename)
packet.payload = buffer;
while ((size = read(fd, buffer, CHUNKSIZE)) > 0) {
packet.length = size;
session_bus(in->vdevice, &packet);
sr_session_bus(in->vdevice, &packet);
}
close(fd);
/* end of stream */
packet.type = SR_DF_END;
packet.length = 0;
session_bus(in->vdevice, &packet);
sr_session_bus(in->vdevice, &packet);
return SR_OK;
}

View File

@ -44,14 +44,14 @@ struct source *sources = NULL;
int source_timeout = -1;
struct sr_session *session_new(void)
struct sr_session *sr_session_new(void)
{
session = calloc(1, sizeof(struct sr_session));
return session;
}
void session_destroy(void)
void sr_session_destroy(void)
{
g_slist_free(session->devices);
@ -60,13 +60,13 @@ void session_destroy(void)
g_free(session);
}
void session_device_clear(void)
void sr_session_device_clear(void)
{
g_slist_free(session->devices);
session->devices = NULL;
}
int session_device_add(struct sr_device *device)
int sr_session_device_add(struct sr_device *device)
{
int ret;
@ -81,7 +81,7 @@ int session_device_add(struct sr_device *device)
return SR_OK;
}
void session_pa_clear(void)
void sr_session_pa_clear(void)
{
/*
* The protocols are pointers to the global set of PA plugins,
@ -91,24 +91,24 @@ void session_pa_clear(void)
session->analyzers = NULL;
}
void session_pa_add(struct analyzer *an)
void sr_session_pa_add(struct analyzer *an)
{
session->analyzers = g_slist_append(session->analyzers, an);
}
void session_datafeed_callback_clear(void)
void sr_session_datafeed_callback_clear(void)
{
g_slist_free(session->datafeed_callbacks);
session->datafeed_callbacks = NULL;
}
void session_datafeed_callback_add(datafeed_callback callback)
void sr_session_datafeed_callback_add(datafeed_callback callback)
{
session->datafeed_callbacks =
g_slist_append(session->datafeed_callbacks, callback);
}
static void session_run_poll()
static void sr_session_run_poll()
{
GPollFD *fds, my_gpollfd;
int ret, i;
@ -150,7 +150,7 @@ static void session_run_poll()
}
int session_start(void)
int sr_session_start(void)
{
struct sr_device *device;
GSList *l;
@ -167,7 +167,7 @@ int session_start(void)
return ret;
}
void session_run(void)
void sr_session_run(void)
{
g_message("session: running");
@ -180,11 +180,11 @@ void session_run(void)
sources[0].cb(-1, 0, sources[0].user_data);
else
/* real sources, use g_poll() main loop */
session_run_poll();
sr_session_run_poll();
}
void session_halt(void)
void sr_session_halt(void)
{
g_message("session: halting");
@ -192,7 +192,7 @@ void session_halt(void)
}
void session_stop(void)
void sr_session_stop(void)
{
struct sr_device *device;
GSList *l;
@ -207,7 +207,7 @@ void session_stop(void)
}
void session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
void sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
{
GSList *l;
datafeed_callback cb;
@ -222,7 +222,7 @@ void session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
}
}
void session_source_add(int fd, int events, int timeout,
void sr_session_source_add(int fd, int events, int timeout,
receive_data_callback callback, void *user_data)
{
struct source *new_sources, *s;
@ -248,7 +248,7 @@ void session_source_add(int fd, int events, int timeout,
source_timeout = timeout;
}
void session_source_remove(int fd)
void sr_session_source_remove(int fd)
{
struct source *new_sources;
int old, new;

View File

@ -90,7 +90,7 @@ static int feed_chunk(int fd, int revents, void *user_data)
packet.length = ret;
packet.unitsize = vdevice->unitsize;
packet.payload = buf;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
} else {
/* done with this capture file */
zip_fclose(vdevice->capfile);
@ -103,7 +103,7 @@ static int feed_chunk(int fd, int revents, void *user_data)
if (!got_data) {
packet.type = SR_DF_END;
packet.length = 0;
session_bus(user_data, &packet);
sr_session_bus(user_data, &packet);
}
return TRUE;
@ -247,7 +247,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
}
/* freewheeling source */
session_source_add(-1, 0, 0, feed_chunk, session_device_id);
sr_session_source_add(-1, 0, 0, feed_chunk, session_device_id);
/* Send header packet to the session bus. */
packet = g_malloc(sizeof(struct sr_datafeed_packet));
@ -263,7 +263,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
header->protocol_id = SR_PROTO_RAW;
header->num_logic_probes = vdevice->num_probes;
header->num_analog_probes = 0;
session_bus(session_device_id, packet);
sr_session_bus(session_device_id, packet);
g_free(header);
g_free(packet);
@ -284,5 +284,5 @@ struct sr_device_plugin session_driver = {
hw_get_capabilities,
hw_set_configuration,
hw_start_acquisition,
NULL
NULL,
};

View File

@ -30,7 +30,7 @@ extern struct sr_session *session;
extern struct sr_device_plugin session_driver;
int session_load(const char *filename)
int sr_session_load(const char *filename)
{
GKeyFile *kf;
GPtrArray *capturefiles;
@ -77,7 +77,7 @@ int session_load(const char *filename)
return SR_ERR;
}
session = session_new();
session = sr_session_new();
devcnt = 0;
capturefiles = g_ptr_array_new_with_free_func(g_free);
@ -98,7 +98,7 @@ int session_load(const char *filename)
if (devcnt == 0)
/* first device, init the plugin */
device->plugin->init((char *)filename);
session_device_add(device);
sr_session_device_add(device);
device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTUREFILE, val);
g_ptr_array_add(capturefiles, val);
} else if (!strcmp(keys[j], "samplerate")) {
@ -136,7 +136,7 @@ int session_load(const char *filename)
return SR_OK;
}
int session_save(char *filename)
int sr_session_save(char *filename)
{
GSList *l, *p, *d;
FILE *meta;

View File

@ -97,31 +97,31 @@ typedef void (*datafeed_callback) (struct sr_device *device,
struct sr_datafeed_packet *packet);
/* Session setup */
int session_load(const char *filename);
struct sr_session *session_new(void);
void session_destroy(void);
void session_device_clear(void);
int session_device_add(struct sr_device *device);
int sr_session_load(const char *filename);
struct sr_session *sr_session_new(void);
void sr_session_destroy(void);
void sr_session_device_clear(void);
int sr_session_device_add(struct sr_device *device);
/* Protocol analyzers setup */
void session_pa_clear(void);
void session_pa_add(struct analyzer *pa);
void sr_session_pa_clear(void);
void sr_session_pa_add(struct analyzer *pa);
/* Datafeed setup */
void session_datafeed_callback_clear(void);
void session_datafeed_callback_add(datafeed_callback callback);
void sr_session_datafeed_callback_clear(void);
void sr_session_datafeed_callback_add(datafeed_callback callback);
/* Session control */
int session_start(void);
void session_run(void);
void session_halt(void);
void session_stop(void);
void session_bus(struct sr_device *device, struct sr_datafeed_packet *packet);
int sr_session_start(void);
void sr_session_run(void);
void sr_session_halt(void);
void sr_session_stop(void);
void sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet);
void make_metadata(char *filename);
int session_save(char *filename);
void session_source_add(int fd, int events, int timeout,
int sr_session_save(char *filename);
void sr_session_source_add(int fd, int events, int timeout,
receive_data_callback callback, void *user_data);
void session_source_remove(int fd);
void sr_session_source_remove(int fd);
/*--- input/input.c ---------------------------------------------------------*/