aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2019-07-01 20:59:38 +0000
committerXin Li <delphij@google.com>2019-07-01 20:59:38 +0000
commit9206e293121930cc3b1e04706a75e467ef698e86 (patch)
tree60eb05f2e88de4fce5c0d1574244d042b1357998
parentb48936b8eb31518652013230e8eb1eca9b9af218 (diff)
parent4c77b6dd5f07c87b32a89b67e013fc4825d93685 (diff)
downloadtinycompress-9206e293121930cc3b1e04706a75e467ef698e86.tar.gz
DO NOT MERGE - Merge qt-dev-plus-aosp-without-vendor (5699924) into stage-aosp-mastertemp_140451723
Bug: 134405016 Change-Id: I0757be296eead566bb474a2567e3d21d8203de23
-rw-r--r--compress.c47
-rw-r--r--include/tinycompress/tinycompress.h27
2 files changed, 74 insertions, 0 deletions
diff --git a/compress.c b/compress.c
index d1a2283..5845cae 100644
--- a/compress.c
+++ b/compress.c
@@ -572,6 +572,19 @@ int compress_set_gapless_metadata(struct compress *compress,
return 0;
}
+#ifdef ENABLE_EXTENDED_COMPRESS_FORMAT
+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;
+}
+#endif
+
bool is_codec_supported(unsigned int card, unsigned int device,
unsigned int flags, struct snd_codec *codec)
{
@@ -630,3 +643,37 @@ int compress_wait(struct compress *compress, int timeout_ms)
return oops(compress, EIO, "poll signalled unhandled event");
}
+#ifdef ENABLE_EXTENDED_COMPRESS_FORMAT
+int compress_get_metadata(struct compress *compress,
+ struct snd_compr_metadata *mdata) {
+ int version;
+ if (!is_compress_ready(compress))
+ return oops(compress, ENODEV, "device not ready");
+
+ version = get_compress_version(compress);
+ if (version <= 0)
+ return -1;
+
+ if (ioctl(compress->fd, SNDRV_COMPRESS_GET_METADATA, mdata)) {
+ return oops(compress, errno, "can't get metadata for stream\n");
+ }
+ return 0;
+}
+
+int compress_set_metadata(struct compress *compress,
+ struct snd_compr_metadata *mdata) {
+
+ int version;
+ if (!is_compress_ready(compress))
+ return oops(compress, ENODEV, "device not ready");
+
+ version = get_compress_version(compress);
+ if (version <= 0)
+ return -1;
+
+ if (ioctl(compress->fd, SNDRV_COMPRESS_SET_METADATA, mdata)) {
+ return oops(compress, errno, "can't set metadata for stream\n");
+ }
+ return 0;
+}
+#endif
diff --git a/include/tinycompress/tinycompress.h b/include/tinycompress/tinycompress.h
index 9f95b87..0ab7134 100644
--- a/include/tinycompress/tinycompress.h
+++ b/include/tinycompress/tinycompress.h
@@ -82,6 +82,10 @@ struct compr_gapless_mdata {
struct compress;
struct snd_compr_tstamp;
+#ifdef ENABLE_EXTENDED_COMPRESS_FORMAT
+union snd_codec_options;
+struct snd_compr_metadata;
+#endif
/*
* compress_open: open a new compress stream
* returns the valid struct compress on success, NULL on failure
@@ -235,6 +239,20 @@ int compress_partial_drain(struct compress *compress);
int compress_set_gapless_metadata(struct compress *compress,
struct compr_gapless_mdata *mdata);
+#ifdef ENABLE_EXTENDED_COMPRESS_FORMAT
+/*
+ * 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);
+#endif
+
/*
* is_codec_supported:check if the given codec is supported
* returns true when supported, false if not
@@ -291,6 +309,15 @@ const char *compress_get_error(struct compress *compress);
/* utility functions */
unsigned int compress_get_alsa_rate(unsigned int rate);
+#ifdef ENABLE_EXTENDED_COMPRESS_FORMAT
+/* set metadata */
+int compress_set_metadata(struct compress *compress,
+ struct snd_compr_metadata *mdata);
+
+/* get metadata */
+int compress_get_metadata(struct compress *compress,
+ struct snd_compr_metadata *mdata);
+#endif
#if defined(__cplusplus)
}