summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.mk47
-rw-r--r--Android_bp (renamed from Android.bp)24
-rw-r--r--CleanSpec.mk4
-rw-r--r--compress.c22
-rw-r--r--compress_plugin.c5
-rw-r--r--include/tinycompress/tinycompress.h25
6 files changed, 125 insertions, 2 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..55bd87e
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,47 @@
+ifneq ($(AUDIO_USE_STUB_HAL), true)
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS := -Wno-macro-redefined -Wno-unused-function
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTENDED_COMPRESS_FORMAT)), true)
+LOCAL_CFLAGS += -DENABLE_EXTENDED_COMPRESS_FORMAT
+endif
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+LOCAL_SRC_FILES := compress.c utils.c compress_hw.c compress_plugin.c snd_utils.c
+LOCAL_MODULE := libtinycompress
+LOCAL_SHARED_LIBRARIES := libcutils libutils
+LOCAL_MODULE_TAGS := optional
+LOCAL_VENDOR_MODULE := true
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS := -Wno-macro-redefined -Wno-unused-function
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+LOCAL_SRC_FILES := cplay.c
+LOCAL_MODULE := cplay
+LOCAL_VENDOR_MODULE := true
+LOCAL_SHARED_LIBRARIES := libcutils libutils libtinycompress
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS := -Wno-macro-redefined -Wno-unused-function
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+LOCAL_SRC_FILES := compress.c utils.c
+LOCAL_CFLAGS += -DUSE_VENDOR_EXTN
+LOCAL_CFLAGS += -DENABLE_EXTENDED_COMPRESS_FORMAT
+LOCAL_MODULE := libtinycompress_vendor
+LOCAL_SHARED_LIBRARIES := libcutils libutils
+LOCAL_MODULE_TAGS := optional
+LOCAL_VENDOR_MODULE := true
+include $(BUILD_SHARED_LIBRARY)
+endif
diff --git a/Android.bp b/Android_bp
index a4f8d6d..9255d37 100644
--- a/Android.bp
+++ b/Android_bp
@@ -46,6 +46,30 @@ cc_library_shared {
],
}
+cc_library_shared {
+ name: "libtinycompress_vendor",
+ vendor: true,
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-macro-redefined",
+ "-Wno-unused-function",
+ ],
+ export_include_dirs: ["include"],
+ srcs: [
+ "compress.c",
+ "utils.c",
+ ],
+ shared_libs: [
+ "libcutils",
+ "libutils",
+ ],
+ header_libs: [
+ "device_kernel_headers",
+ ],
+}
+
cc_binary {
name: "cplay",
vendor: true,
diff --git a/CleanSpec.mk b/CleanSpec.mk
index f7dec23..9eab8b3 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -44,7 +44,9 @@
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/cplay)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/cplay)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib64/libtinycompress.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib/libtinycompress.so)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/compress.c b/compress.c
index 7422c4b..f1947b0 100644
--- a/compress.c
+++ b/compress.c
@@ -552,8 +552,13 @@ int compress_set_next_track_param(struct compress *compress,
if (!is_compress_running(compress))
return oops(compress, ENODEV, "device not ready");
+ if (codec_options == NULL)
+ return oops(compress, ENODEV, "codec_option NULL");
+
+#ifdef SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM
if (ioctl(compress->fd, SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM, codec_options))
return oops(compress, errno, "cannot set next track params\n");
+#endif
return 0;
}
#endif
@@ -617,6 +622,23 @@ int compress_wait(struct compress *compress, int timeout_ms)
return oops(compress, EIO, "poll signalled unhandled event");
}
+int compress_set_codec_params(struct compress *compress,
+ struct snd_codec *codec) {
+ struct snd_compr_params params;
+
+ if (!is_compress_running(compress))
+ return oops(compress, ENODEV, "device not ready");
+
+ params.buffer.fragment_size = compress->config->fragment_size;
+ params.buffer.fragments = compress->config->fragments;
+ memcpy(&params.codec, codec, sizeof(params.codec));
+
+ if (compress->ops->ioctl(compress->data, SNDRV_COMPRESS_SET_PARAMS, &params))
+ return oops(compress, errno, "cannot set device");
+
+ return 0;
+}
+
#ifdef ENABLE_EXTENDED_COMPRESS_FORMAT
int compress_get_metadata(struct compress *compress,
struct snd_compr_metadata *mdata) {
diff --git a/compress_plugin.c b/compress_plugin.c
index 7a5538d..0e536cc 100644
--- a/compress_plugin.c
+++ b/compress_plugin.c
@@ -84,7 +84,10 @@ static int compress_plug_set_params(struct compress_plug_data *plug_data,
struct compress_plugin *plugin = plug_data->plugin;
int rc;
- if (plugin->state != COMPRESS_PLUG_STATE_OPEN)
+ if (plugin->state == COMPRESS_PLUG_STATE_RUNNING)
+ return plugin->ops->set_params(plugin, params);
+ else if (plugin->state != COMPRESS_PLUG_STATE_OPEN &&
+ plugin->state != COMPRESS_PLUG_STATE_SETUP)
return -EBADFD;
if (params->buffer.fragment_size == 0 ||
diff --git a/include/tinycompress/tinycompress.h b/include/tinycompress/tinycompress.h
index 0ab7134..97b305f 100644
--- a/include/tinycompress/tinycompress.h
+++ b/include/tinycompress/tinycompress.h
@@ -81,6 +81,8 @@ struct compr_gapless_mdata {
struct compress;
struct snd_compr_tstamp;
+union snd_codec_options;
+struct snd_compr_metadata;
#ifdef ENABLE_EXTENDED_COMPRESS_FORMAT
union snd_codec_options;
@@ -254,6 +256,18 @@ int compress_set_next_track_param(struct compress *compress,
#endif
/*
+ * 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
*
@@ -309,6 +323,17 @@ const char *compress_get_error(struct compress *compress);
/* utility functions */
unsigned int compress_get_alsa_rate(unsigned int rate);
+ /*
+ * compress_set_codec_params: set codec config intended for next track
+ * if DSP has support to switch CODEC config during gapless playback
+ * This API is expected to be called after compress_next_track is called
+ * return 0 on success, negative on error
+ *
+ * @compress: compress stream for which metadata has to set
+ * @codec: codec configuration for next track
+ */
+int compress_set_codec_params(struct compress *compress, struct snd_codec *codec);
+
#ifdef ENABLE_EXTENDED_COMPRESS_FORMAT
/* set metadata */
int compress_set_metadata(struct compress *compress,