Loading hal/audio_hw.c +23 −3 Original line number Diff line number Diff line Loading @@ -53,8 +53,10 @@ #include "voice_extn.h" #include "sound/compress_params.h" #define MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE (256 * 1024) #define MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE (8 * 1024) #define MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE (2 * 1024) #define COMPRESS_OFFLOAD_FRAGMENT_SIZE_FOR_AV_STREAMING (2 * 1024) #define COMPRESS_OFFLOAD_FRAGMENT_SIZE (32 * 1024) #define COMPRESS_OFFLOAD_NUM_FRAGMENTS 4 /* ToDo: Check and update a proper value in msec */ Loading Loading @@ -157,7 +159,7 @@ static int set_voice_volume_l(struct audio_device *adev, float volume); * If value is not power of 2 round it to * power of 2. */ static uint32_t get_offload_buffer_size() static uint32_t get_offload_buffer_size(audio_offload_info_t* info) { char value[PROPERTY_VALUE_MAX] = {0}; uint32_t fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE; Loading @@ -167,6 +169,13 @@ static uint32_t get_offload_buffer_size() //ring buffer size needs to be 4k aligned. CHECK(!(fragment_size * COMPRESS_OFFLOAD_NUM_FRAGMENTS % 4096)); } if (info != NULL && info->has_video && info->is_streaming) { fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE_FOR_AV_STREAMING; ALOGV("%s: offload fragment size reduced for AV streaming to %d", __func__, out->compr_config.fragment_size); } if(fragment_size < MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE) fragment_size = MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE; else if(fragment_size > MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE) Loading Loading @@ -1347,11 +1356,21 @@ static int parse_compress_metadata(struct stream_out *out, struct str_parms *par struct compr_gapless_mdata tmp_mdata; tmp_mdata.encoder_delay = 0; tmp_mdata.encoder_padding = 0; if (!out || !parms) { ALOGE("%s: return invalid ",__func__); return -EINVAL; } ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FORMAT, value, sizeof(value)); if (ret >= 0) { if (atoi(value) == SND_AUDIOSTREAMFORMAT_MP4ADTS) { out->compr_config.codec->format = SND_AUDIOSTREAMFORMAT_MP4ADTS; ALOGV("ADTS format is set in offload mode"); } out->send_new_metadata = 1; } ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_SAMPLE_RATE, value, sizeof(value)); if(ret >= 0) is_meta_data_params = true; Loading Loading @@ -2159,7 +2178,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, else out->compr_config.codec->id = get_snd_codec_id(config->offload_info.format); out->compr_config.fragment_size = get_offload_buffer_size(); out->compr_config.fragment_size = get_offload_buffer_size(&config->offload_info); out->compr_config.fragments = COMPRESS_OFFLOAD_NUM_FRAGMENTS; out->compr_config.codec->sample_rate = compress_get_alsa_rate(config->offload_info.sample_rate); Loading @@ -2168,6 +2187,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, out->compr_config.codec->ch_in = popcount(config->channel_mask); out->compr_config.codec->ch_out = out->compr_config.codec->ch_in; out->compr_config.codec->format = SND_AUDIOSTREAMFORMAT_RAW; if (flags & AUDIO_OUTPUT_FLAG_NON_BLOCKING) out->non_blocking = 1; Loading Loading
hal/audio_hw.c +23 −3 Original line number Diff line number Diff line Loading @@ -53,8 +53,10 @@ #include "voice_extn.h" #include "sound/compress_params.h" #define MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE (256 * 1024) #define MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE (8 * 1024) #define MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE (2 * 1024) #define COMPRESS_OFFLOAD_FRAGMENT_SIZE_FOR_AV_STREAMING (2 * 1024) #define COMPRESS_OFFLOAD_FRAGMENT_SIZE (32 * 1024) #define COMPRESS_OFFLOAD_NUM_FRAGMENTS 4 /* ToDo: Check and update a proper value in msec */ Loading Loading @@ -157,7 +159,7 @@ static int set_voice_volume_l(struct audio_device *adev, float volume); * If value is not power of 2 round it to * power of 2. */ static uint32_t get_offload_buffer_size() static uint32_t get_offload_buffer_size(audio_offload_info_t* info) { char value[PROPERTY_VALUE_MAX] = {0}; uint32_t fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE; Loading @@ -167,6 +169,13 @@ static uint32_t get_offload_buffer_size() //ring buffer size needs to be 4k aligned. CHECK(!(fragment_size * COMPRESS_OFFLOAD_NUM_FRAGMENTS % 4096)); } if (info != NULL && info->has_video && info->is_streaming) { fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE_FOR_AV_STREAMING; ALOGV("%s: offload fragment size reduced for AV streaming to %d", __func__, out->compr_config.fragment_size); } if(fragment_size < MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE) fragment_size = MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE; else if(fragment_size > MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE) Loading Loading @@ -1347,11 +1356,21 @@ static int parse_compress_metadata(struct stream_out *out, struct str_parms *par struct compr_gapless_mdata tmp_mdata; tmp_mdata.encoder_delay = 0; tmp_mdata.encoder_padding = 0; if (!out || !parms) { ALOGE("%s: return invalid ",__func__); return -EINVAL; } ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FORMAT, value, sizeof(value)); if (ret >= 0) { if (atoi(value) == SND_AUDIOSTREAMFORMAT_MP4ADTS) { out->compr_config.codec->format = SND_AUDIOSTREAMFORMAT_MP4ADTS; ALOGV("ADTS format is set in offload mode"); } out->send_new_metadata = 1; } ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_SAMPLE_RATE, value, sizeof(value)); if(ret >= 0) is_meta_data_params = true; Loading Loading @@ -2159,7 +2178,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, else out->compr_config.codec->id = get_snd_codec_id(config->offload_info.format); out->compr_config.fragment_size = get_offload_buffer_size(); out->compr_config.fragment_size = get_offload_buffer_size(&config->offload_info); out->compr_config.fragments = COMPRESS_OFFLOAD_NUM_FRAGMENTS; out->compr_config.codec->sample_rate = compress_get_alsa_rate(config->offload_info.sample_rate); Loading @@ -2168,6 +2187,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, out->compr_config.codec->ch_in = popcount(config->channel_mask); out->compr_config.codec->ch_out = out->compr_config.codec->ch_in; out->compr_config.codec->format = SND_AUDIOSTREAMFORMAT_RAW; if (flags & AUDIO_OUTPUT_FLAG_NON_BLOCKING) out->non_blocking = 1; Loading