Loading hal/audio_extn/audio_extn.h +6 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,11 @@ int audio_extn_parse_compress_metadata(struct stream_out *out, #define compress_set_next_track_param(compress, codec_options) (0) #endif #ifndef AUDIO_HW_EXTN_API_ENABLED #define compress_set_metadata(compress, metadata) (0) #define compress_get_metadata(compress, metadata) (0) #endif #define MAX_LENGTH_MIXER_CONTROL_IN_INT (128) void audio_extn_set_parameters(struct audio_device *adev, Loading Loading @@ -823,4 +828,5 @@ int audio_extn_set_aptx_dec_params(struct aptx_dec_param *payload); int audio_extn_utils_get_avt_device_drift( struct audio_usecase *usecase, struct audio_avt_device_drift_param *drift_param); int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out); #endif /* AUDIO_EXTN_H */ hal/audio_extn/utils.c +50 −2 Original line number Diff line number Diff line Loading @@ -29,13 +29,15 @@ #include <cutils/log.h> #include <cutils/misc.h> #include "audio_hw.h" #include "platform.h" #include "platform_api.h" #include "audio_extn.h" #include "voice.h" #include "sound/compress_params.h" #include <sound/compress_params.h> #include <sound/compress_offload.h> #include <tinycompress/tinycompress.h> #ifdef AUDIO_EXTERNAL_HDMI_ENABLED #ifdef HDMI_PASSTHROUGH_ENABLED #include "audio_parsers.h" Loading Loading @@ -82,6 +84,10 @@ #define SR_192000 (14<<0) /* 192kHz */ #endif /* ToDo: Check and update a proper value in msec */ #define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 50 struct string_to_enum { const char *name; uint32_t value; Loading Loading @@ -1646,3 +1652,45 @@ int audio_extn_utils_get_avt_device_drift( done: return ret; } #ifdef SNDRV_COMPRESS_PATH_DELAY int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out) { int ret = -EINVAL; struct snd_compr_metadata metadata; int delay_ms = COMPRESS_OFFLOAD_PLAYBACK_LATENCY; if (property_get_bool("audio.playback.dsp.pathdelay", false)) { ALOGD("%s:: Quering DSP delay %d",__func__, __LINE__); if (!(is_offload_usecase(out->usecase))) { ALOGE("%s:: not supported for non offload session", __func__); goto exit; } if (!out->compr) { ALOGD("%s:: Invalid compress handle,returning default dsp latency", __func__); goto exit; } metadata.key = SNDRV_COMPRESS_PATH_DELAY; ret = compress_get_metadata(out->compr, &metadata); if(ret) { ALOGE("%s::error %s", __func__, compress_get_error(out->compr)); goto exit; } delay_ms = metadata.value[0] / 1000; /*convert to ms*/ } else { ALOGD("%s:: Using Fix DSP delay",__func__); } exit: ALOGD("%s:: delay in ms is %d",__func__, delay_ms); return delay_ms; } #else int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out __unused) { return COMPRESS_OFFLOAD_PLAYBACK_LATENCY; } #endif hal/audio_hw.c +3 −3 Original line number Diff line number Diff line Loading @@ -79,8 +79,6 @@ #define COMPRESS_OFFLOAD_NUM_FRAGMENTS 4 /*DIRECT PCM has same buffer sizes as DEEP Buffer*/ #define DIRECT_PCM_NUM_FRAGMENTS 2 /* ToDo: Check and update a proper value in msec */ #define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 50 #define COMPRESS_PLAYBACK_VOLUME_MAX 0x2000 #define DSD_VOLUME_MIN_DB (-110) Loading Loading @@ -2928,7 +2926,9 @@ static uint32_t out_get_latency(const struct audio_stream_out *stream) uint32_t latency = 0; if (is_offload_usecase(out->usecase)) { latency = COMPRESS_OFFLOAD_PLAYBACK_LATENCY; lock_output_stream(out); latency = audio_extn_utils_compress_get_dsp_latency(out); pthread_mutex_unlock(&out->lock); } else if (out->realtime) { // since the buffer won't be filled up faster than realtime, // return a smaller number Loading qahw_api/test/qahw_playback_test.c +8 −2 Original line number Diff line number Diff line Loading @@ -494,6 +494,7 @@ void *start_stream_playback (void* stream_data) size_t bytes_read = 0; char *data_ptr = NULL; bool exit = false; int32_t latency; if (is_offload) { fprintf(log_file, "stream %d: set callback for offload stream for playback usecase\n", params->stream_index); Loading Loading @@ -583,6 +584,9 @@ void *start_stream_playback (void* stream_data) pthread_exit(0); } latency = qahw_out_get_latency(params->out_handle); fprintf(log_file, "playback latency before starting a session %dms!!\n", latency); while (!exit && !stop_playback) { if (!bytes_remaining) { bytes_read = fread(data_ptr, 1, bytes_wanted, params->file_stream); Loading Loading @@ -613,8 +617,10 @@ void *start_stream_playback (void* stream_data) params->stream_index, bytes_remaining, offset, write_length); bytes_written = write_to_hal(params->out_handle, data_ptr+offset, bytes_remaining, params); bytes_remaining -= bytes_written; fprintf(log_file, "stream %d: bytes_written %zd, bytes_remaining %zd\n", params->stream_index, bytes_written, bytes_remaining); latency = qahw_out_get_latency(params->out_handle); fprintf(log_file, "stream %d: bytes_written %zd, bytes_remaining %zd latency %d\n", params->stream_index, bytes_written, bytes_remaining, latency); } if (params->ethread_data != nullptr) { Loading Loading
hal/audio_extn/audio_extn.h +6 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,11 @@ int audio_extn_parse_compress_metadata(struct stream_out *out, #define compress_set_next_track_param(compress, codec_options) (0) #endif #ifndef AUDIO_HW_EXTN_API_ENABLED #define compress_set_metadata(compress, metadata) (0) #define compress_get_metadata(compress, metadata) (0) #endif #define MAX_LENGTH_MIXER_CONTROL_IN_INT (128) void audio_extn_set_parameters(struct audio_device *adev, Loading Loading @@ -823,4 +828,5 @@ int audio_extn_set_aptx_dec_params(struct aptx_dec_param *payload); int audio_extn_utils_get_avt_device_drift( struct audio_usecase *usecase, struct audio_avt_device_drift_param *drift_param); int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out); #endif /* AUDIO_EXTN_H */
hal/audio_extn/utils.c +50 −2 Original line number Diff line number Diff line Loading @@ -29,13 +29,15 @@ #include <cutils/log.h> #include <cutils/misc.h> #include "audio_hw.h" #include "platform.h" #include "platform_api.h" #include "audio_extn.h" #include "voice.h" #include "sound/compress_params.h" #include <sound/compress_params.h> #include <sound/compress_offload.h> #include <tinycompress/tinycompress.h> #ifdef AUDIO_EXTERNAL_HDMI_ENABLED #ifdef HDMI_PASSTHROUGH_ENABLED #include "audio_parsers.h" Loading Loading @@ -82,6 +84,10 @@ #define SR_192000 (14<<0) /* 192kHz */ #endif /* ToDo: Check and update a proper value in msec */ #define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 50 struct string_to_enum { const char *name; uint32_t value; Loading Loading @@ -1646,3 +1652,45 @@ int audio_extn_utils_get_avt_device_drift( done: return ret; } #ifdef SNDRV_COMPRESS_PATH_DELAY int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out) { int ret = -EINVAL; struct snd_compr_metadata metadata; int delay_ms = COMPRESS_OFFLOAD_PLAYBACK_LATENCY; if (property_get_bool("audio.playback.dsp.pathdelay", false)) { ALOGD("%s:: Quering DSP delay %d",__func__, __LINE__); if (!(is_offload_usecase(out->usecase))) { ALOGE("%s:: not supported for non offload session", __func__); goto exit; } if (!out->compr) { ALOGD("%s:: Invalid compress handle,returning default dsp latency", __func__); goto exit; } metadata.key = SNDRV_COMPRESS_PATH_DELAY; ret = compress_get_metadata(out->compr, &metadata); if(ret) { ALOGE("%s::error %s", __func__, compress_get_error(out->compr)); goto exit; } delay_ms = metadata.value[0] / 1000; /*convert to ms*/ } else { ALOGD("%s:: Using Fix DSP delay",__func__); } exit: ALOGD("%s:: delay in ms is %d",__func__, delay_ms); return delay_ms; } #else int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out __unused) { return COMPRESS_OFFLOAD_PLAYBACK_LATENCY; } #endif
hal/audio_hw.c +3 −3 Original line number Diff line number Diff line Loading @@ -79,8 +79,6 @@ #define COMPRESS_OFFLOAD_NUM_FRAGMENTS 4 /*DIRECT PCM has same buffer sizes as DEEP Buffer*/ #define DIRECT_PCM_NUM_FRAGMENTS 2 /* ToDo: Check and update a proper value in msec */ #define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 50 #define COMPRESS_PLAYBACK_VOLUME_MAX 0x2000 #define DSD_VOLUME_MIN_DB (-110) Loading Loading @@ -2928,7 +2926,9 @@ static uint32_t out_get_latency(const struct audio_stream_out *stream) uint32_t latency = 0; if (is_offload_usecase(out->usecase)) { latency = COMPRESS_OFFLOAD_PLAYBACK_LATENCY; lock_output_stream(out); latency = audio_extn_utils_compress_get_dsp_latency(out); pthread_mutex_unlock(&out->lock); } else if (out->realtime) { // since the buffer won't be filled up faster than realtime, // return a smaller number Loading
qahw_api/test/qahw_playback_test.c +8 −2 Original line number Diff line number Diff line Loading @@ -494,6 +494,7 @@ void *start_stream_playback (void* stream_data) size_t bytes_read = 0; char *data_ptr = NULL; bool exit = false; int32_t latency; if (is_offload) { fprintf(log_file, "stream %d: set callback for offload stream for playback usecase\n", params->stream_index); Loading Loading @@ -583,6 +584,9 @@ void *start_stream_playback (void* stream_data) pthread_exit(0); } latency = qahw_out_get_latency(params->out_handle); fprintf(log_file, "playback latency before starting a session %dms!!\n", latency); while (!exit && !stop_playback) { if (!bytes_remaining) { bytes_read = fread(data_ptr, 1, bytes_wanted, params->file_stream); Loading Loading @@ -613,8 +617,10 @@ void *start_stream_playback (void* stream_data) params->stream_index, bytes_remaining, offset, write_length); bytes_written = write_to_hal(params->out_handle, data_ptr+offset, bytes_remaining, params); bytes_remaining -= bytes_written; fprintf(log_file, "stream %d: bytes_written %zd, bytes_remaining %zd\n", params->stream_index, bytes_written, bytes_remaining); latency = qahw_out_get_latency(params->out_handle); fprintf(log_file, "stream %d: bytes_written %zd, bytes_remaining %zd latency %d\n", params->stream_index, bytes_written, bytes_remaining, latency); } if (params->ethread_data != nullptr) { Loading