Use new SR_DF_META packet.

Since input modules determine a samplerate by reading from their
file format (or having it overridden with an option), they need
to pass this up to the frontend.
This commit is contained in:
Bert Vermeulen 2013-01-20 15:45:09 +01:00
parent d8e3685c47
commit 2df1e81970
3 changed files with 21 additions and 15 deletions

View File

@ -100,8 +100,9 @@ static int loadfile(struct sr_input *in, const char *filename)
{
struct sr_datafeed_header header;
struct sr_datafeed_packet packet;
struct sr_datafeed_meta_logic meta;
struct sr_datafeed_meta meta;
struct sr_datafeed_logic logic;
struct sr_config *src;
unsigned char buffer[CHUNKSIZE];
int fd, size, num_probes;
struct context *ctx;
@ -120,12 +121,13 @@ static int loadfile(struct sr_input *in, const char *filename)
packet.payload = &header;
sr_session_send(in->sdi, &packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.payload = &meta;
meta.samplerate = ctx->samplerate;
meta.num_probes = num_probes;
sr_session_send(in->sdi, &packet);
if (ctx->samplerate) {
packet.type = SR_DF_META;
packet.payload = &meta;
src = sr_config_make(SR_HWCAP_SAMPLERATE, (const void *)&ctx->samplerate);
meta.config = g_slist_append(NULL, src);
sr_session_send(in->sdi, &packet);
}
/* Chop up the input file into chunks & send it to the session bus. */
packet.type = SR_DF_LOGIC;

View File

@ -139,8 +139,9 @@ static int loadfile(struct sr_input *in, const char *filename)
{
struct sr_datafeed_header header;
struct sr_datafeed_packet packet;
struct sr_datafeed_meta_logic meta;
struct sr_datafeed_meta meta;
struct sr_datafeed_logic logic;
struct sr_config *src;
uint8_t buf[PACKET_SIZE], divcount;
int i, fd, size, num_probes;
uint64_t samplerate;
@ -173,10 +174,10 @@ static int loadfile(struct sr_input *in, const char *filename)
sr_session_send(in->sdi, &packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.type = SR_DF_META;
packet.payload = &meta;
meta.samplerate = samplerate;
meta.num_probes = num_probes;
src = sr_config_make(SR_HWCAP_SAMPLERATE, (const void *)&samplerate);
meta.config = g_slist_append(NULL, src);
sr_session_send(in->sdi, &packet);
/* TODO: Handle trigger point. */

View File

@ -545,9 +545,11 @@ static int loadfile(struct sr_input *in, const char *filename)
{
struct sr_datafeed_header header;
struct sr_datafeed_packet packet;
struct sr_datafeed_meta_logic meta;
struct sr_datafeed_meta meta;
struct sr_config *src;
FILE *file;
struct context *ctx;
uint64_t samplerate;
ctx = in->internal;
@ -569,10 +571,11 @@ static int loadfile(struct sr_input *in, const char *filename)
sr_session_send(in->sdi, &packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.type = SR_DF_META;
packet.payload = &meta;
meta.samplerate = ctx->samplerate / ctx->downsample;
meta.num_probes = ctx->probecount;
samplerate = ctx->samplerate / ctx->downsample;
src = sr_config_make(SR_HWCAP_SAMPLERATE, (const void *)&samplerate);
meta.config = g_slist_append(NULL, src);
sr_session_send(in->sdi, &packet);
/* Parse the contents of the VCD file */