/** @endcond */
SR_PRIV struct sr_dev_driver session_driver_info;
-static struct sr_dev_driver *di = &session_driver_info;
struct session_vdev {
char *sessionfile;
};
static const uint32_t devopts[] = {
- SR_CONF_CAPTUREFILE,
- SR_CONF_CAPTURE_UNITSIZE,
- SR_CONF_SAMPLERATE,
+ SR_CONF_CAPTUREFILE | SR_CONF_SET,
+ SR_CONF_CAPTURE_UNITSIZE | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET,
};
static int receive_data(int fd, int revents, void *cb_data)
}
}
- if (!(buf = g_try_malloc(CHUNKSIZE))) {
- sr_err("%s: buf malloc failed", __func__);
- return FALSE;
- }
+ buf = g_malloc(CHUNKSIZE);
ret = zip_fread(vdev->capfile, buf,
CHUNKSIZE / vdev->unitsize * vdev->unitsize);
/* driver callbacks */
-static int init(struct sr_context *sr_ctx)
+static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{
return std_init(sr_ctx, di, LOG_PREFIX);
}
-static int dev_clear(void)
+static int dev_clear(const struct sr_dev_driver *di)
{
struct drv_context *drvc;
GSList *l;
static int dev_open(struct sr_dev_inst *sdi)
{
+ struct sr_dev_driver *di;
struct drv_context *drvc;
struct session_vdev *vdev;
+ di = sdi->driver;
drvc = di->priv;
vdev = g_malloc0(sizeof(struct session_vdev));
sdi->priv = vdev;
(void)cg;
+ if (!sdi)
+ return SR_ERR;
+
+ vdev = sdi->priv;
+
switch (key) {
case SR_CONF_SAMPLERATE:
- if (sdi) {
- vdev = sdi->priv;
- *data = g_variant_new_uint64(vdev->samplerate);
- } else
- return SR_ERR;
+ *data = g_variant_new_uint64(vdev->samplerate);
+ break;
+ case SR_CONF_CAPTURE_UNITSIZE:
+ *data = g_variant_new_uint64(vdev->unitsize);
break;
default:
return SR_ERR_NA;