tinycompress: Add support to send codec specific data

Codec specific  metadata is sent only for first stream in gapless
playback.
This causes incorrect configuration to be set for second
stream and distortions are observed due to framedrops in adsp.
Add support to send codec specific format data of next stream
during gapless playback.

Change-Id: If6f2a0d75140614c283ae444fc51b9b505d200f0
diff --git a/compress.c b/compress.c
index 6a03e3b..83b041b 100644
--- a/compress.c
+++ b/compress.c
@@ -569,19 +569,21 @@
 	if (ioctl(compress->fd, SNDRV_COMPRESS_SET_METADATA, &metadata))
 		return oops(compress, errno, "can't set metadata for stream\n");
 
-	metadata.key = SNDRV_COMPRESS_MIN_BLK_SIZE;
-	metadata.value[0] = mdata->min_blk_size;
-	if (ioctl(compress->fd, SNDRV_COMPRESS_SET_METADATA, &metadata))
-		return oops(compress, errno, "can't set metadata for stream\n");
-
-	metadata.key = SNDRV_COMPRESS_MAX_BLK_SIZE;
-	metadata.value[0] = mdata->max_blk_size;
-	if (ioctl(compress->fd, SNDRV_COMPRESS_SET_METADATA, &metadata))
-		return oops(compress, errno, "can't set metadata for stream\n");
 	compress->gapless_metadata = 1;
 	return 0;
 }
 
+int compress_set_next_track_param(struct compress *compress,
+	union snd_codec_options *codec_options)
+{
+	if (!is_compress_running(compress))
+		return oops(compress, ENODEV, "device not ready");
+
+	if (ioctl(compress->fd, SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM, codec_options))
+		return oops(compress, errno, "cannot set next track params\n");
+	return 0;
+}
+
 bool is_codec_supported(unsigned int card, unsigned int device,
 		unsigned int flags, struct snd_codec *codec)
 {
diff --git a/include/tinycompress/tinycompress.h b/include/tinycompress/tinycompress.h
index 3cf5b82..9820d10 100644
--- a/include/tinycompress/tinycompress.h
+++ b/include/tinycompress/tinycompress.h
@@ -74,8 +74,6 @@
 struct compr_gapless_mdata {
 	__u32 encoder_delay;
 	__u32 encoder_padding;
-	__u32 min_blk_size;
-	__u32 max_blk_size;
 };
 
 #define COMPRESS_OUT        0x20000000
@@ -83,6 +81,7 @@
 
 struct compress;
 struct snd_compr_tstamp;
+union snd_codec_options;
 
 /*
  * compress_open: open a new compress stream
@@ -238,6 +237,18 @@
 			struct compr_gapless_mdata *mdata);
 
 /*
+ * compress_set_next_track_param: set params of next compress stream in gapless
+ *
+ * return 0 on success, negative on error
+ *
+ * @compress: compress stream for which codec options has to be set
+ * @codec_options: codec options of compress stream based on codec type
+ */
+
+int compress_set_next_track_param(struct compress *compress,
+			union snd_codec_options *codec_options);
+
+/*
  * is_codec_supported:check if the given codec is supported
  * returns true when supported, false if not
  *