make time/duration work, at least when loading from a session file

PD decode() call now takes 3 arguments: timeoffset, duration, data
as per the current API specification.
This commit is contained in:
Bert Vermeulen 2011-12-15 03:31:31 +01:00 committed by Uwe Hermann
parent 15278f3e9c
commit cb1e389c72
1 changed files with 6 additions and 2 deletions

View File

@ -33,6 +33,7 @@ struct session_vdevice {
char *capturefile; char *capturefile;
struct zip *archive; struct zip *archive;
struct zip_file *capfile; struct zip_file *capfile;
int bytes_read;
uint64_t samplerate; uint64_t samplerate;
int unitsize; int unitsize;
int num_probes; int num_probes;
@ -66,6 +67,7 @@ static int feed_chunk(int fd, int revents, void *session_data)
struct session_vdevice *vdevice; struct session_vdevice *vdevice;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic; struct sr_datafeed_logic logic;
uint64_t sample_period_ps;
GSList *l; GSList *l;
void *buf; void *buf;
int ret, got_data; int ret, got_data;
@ -94,12 +96,14 @@ static int feed_chunk(int fd, int revents, void *session_data)
if (ret > 0) { if (ret > 0) {
got_data = TRUE; got_data = TRUE;
packet.type = SR_DF_LOGIC; packet.type = SR_DF_LOGIC;
packet.timeoffset = 0; sample_period_ps = 1000000000000 / vdevice->samplerate;
packet.duration = 0; packet.timeoffset = sample_period_ps * (vdevice->bytes_read / vdevice->unitsize);
packet.duration = sample_period_ps * (ret / vdevice->unitsize);
packet.payload = &logic; packet.payload = &logic;
logic.length = ret; logic.length = ret;
logic.unitsize = vdevice->unitsize; logic.unitsize = vdevice->unitsize;
logic.data = buf; logic.data = buf;
vdevice->bytes_read += ret;
sr_session_bus(session_data, &packet); sr_session_bus(session_data, &packet);
} else { } else {
/* done with this capture file */ /* done with this capture file */