/* Returns a human readable reason for the last error */
const char *compress_get_error(struct compress *compress);
+/*
+ * compress_set_param: set codec config intended for next track
+ * if DSP has support to switch CODEC config during gapless playback
+ *
+ * return 0 on success, negative on error
+ *
+ * @compress: compress stream for which metadata has to set
+ * @config: stream config for next track
+ */
+int compress_set_codec_params(struct compress *compress, struct snd_codec *codec);
+
#if defined(__cplusplus)
} // extern "C"
#endif
return oops(compress, EIO, "poll signalled unhandled event");
}
+static int compress_hw_set_codec_params(void *data, struct snd_codec *codec)
+{
+ struct compress_hw_data *compress = (struct compress_hw_data *)data;
+ struct snd_compr_params params;
+
+ if (!is_compress_hw_ready(compress))
+ return oops(compress, ENODEV, "device not ready\n");
+
+ if (!codec)
+ return oops(compress, EINVAL, "passed bad config\n");
+
+ if (!compress->next_track)
+ return oops(compress, EPERM,
+ "set CODEC params while next track not signalled is not allowed");
+
+ params.buffer.fragment_size = compress->config->fragment_size;
+ params.buffer.fragments = compress->config->fragments;
+ memcpy(¶ms.codec, codec, sizeof(params.codec));
+
+ if (ioctl(compress->fd, SNDRV_COMPRESS_SET_PARAMS, ¶ms))
+ return oops(compress, errno, "cannot set param for next track\n");
+
+ return 0;
+}
+
struct compress_ops compress_hw_ops = {
.open_by_name = compress_hw_open_by_name,
.close = compress_hw_close,
.is_compress_running = is_compress_hw_running,
.is_compress_ready = is_compress_hw_ready,
.get_error = compress_hw_get_error,
+ .set_codec_params = compress_hw_set_codec_params,
};