* SR_ERR_MALLOC upon memory allocation errors, or SR_ERR upon
* other errors.
*/
-SR_API int sr_session_load(const char *filename)
+SR_API int sr_session_load(const char *filename, struct sr_session **session)
{
GKeyFile *kf;
GPtrArray *capturefiles;
return SR_ERR;
}
- sr_session_new();
+ if ((ret = sr_session_new(session)) != SR_OK)
+ return ret;
devcnt = 0;
capturefiles = g_ptr_array_new_with_free_func(g_free);
/* first device, init the driver */
sdi->driver->init(NULL);
sr_dev_open(sdi);
- sr_session_dev_add(sdi);
+ sr_session_dev_add(*session, sdi);
sdi->driver->config_set(SR_CONF_SESSIONFILE,
g_variant_new_string(filename), sdi, NULL);
sdi->driver->config_set(SR_CONF_CAPTUREFILE,
}
/**
- * Save the current session to the specified file.
+ * Save a session to the specified file.
*
- * @param filename The name of the filename to save the current session as.
+ * @param filename The name of the filename to save the session as.
* Must not be NULL.
* @param sdi The device instance from which the data was captured.
* @param buf The data to be saved.
*
* @since 0.2.0
*/
-SR_API int sr_session_save(const char *filename, const struct sr_dev_inst *sdi,
- unsigned char *buf, int unitsize, int units)
+SR_API int sr_session_save(struct sr_session *session, const char *filename,
+ const struct sr_dev_inst *sdi, unsigned char *buf, int unitsize,
+ int units)
{
struct sr_channel *ch;
GSList *l;
channel_names[cnt++] = ch->name;
}
- if ((ret = sr_session_save_init(filename, samplerate, channel_names)) != SR_OK)
+ if ((ret = sr_session_save_init(session, filename, samplerate,
+ channel_names)) != SR_OK)
return ret;
- ret = sr_session_append(filename, buf, unitsize, units);
+ ret = sr_session_append(session, filename, buf, unitsize, units);
return ret;
}
/**
* Initialize a saved session file.
*
- * @param filename The name of the filename to save the current session as.
+ * @param filename The name of the filename to save the session as.
* Must not be NULL.
* @param samplerate The samplerate to store for this session.
* @param channels A NULL-terminated array of strings containing the names
*
* @since 0.3.0
*/
-SR_API int sr_session_save_init(const char *filename, uint64_t samplerate,
- char **channels)
+SR_API int sr_session_save_init(struct sr_session *session,
+ const char *filename, uint64_t samplerate, char **channels)
{
FILE *meta;
struct zip *zipfile;
int tmpfile, cnt, ret, i;
char version[1], metafile[32], *s;
+ (void) session;
+
if (!filename) {
sr_err("%s: filename was NULL", __func__);
return SR_ERR_ARG;
*
* @since 0.3.0
*/
-SR_API int sr_session_append(const char *filename, unsigned char *buf,
- int unitsize, int units)
+SR_API int sr_session_append(struct sr_session *session, const char *filename,
+ unsigned char *buf, int unitsize, int units)
{
struct zip *archive;
struct zip_source *logicsrc;
const char *entry_name;
char *metafile, tmpname[32], chunkname[16];
+ (void) session;
+
if ((ret = sr_sessionfile_check(filename)) != SR_OK)
return ret;