Loading hal/audio_hw.c +11 −9 Original line number Diff line number Diff line Loading @@ -2518,7 +2518,8 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, lock_output_stream(out); // this is always nonzero const int frame_size = audio_stream_out_frame_size(stream); const size_t frame_size = audio_stream_out_frame_size(stream); const size_t frames = bytes / frame_size; if (out->usecase == USECASE_AUDIO_PLAYBACK_MMAP) { error_code = ERROR_CODE_WRITE; Loading Loading @@ -2609,7 +2610,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, exit: // For PCM we always consume the buffer and return #bytes regardless of ret. if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD) { out->written += bytes / (out->config.channels * sizeof(short)); out->written += frames; } long long sleeptime_us = 0; Loading @@ -2623,8 +2624,7 @@ exit: if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD) { ALOGE_IF(out->pcm != NULL, "%s: error %zd - %s", __func__, ret, pcm_get_error(out->pcm)); sleeptime_us = bytes * 1000000LL / frame_size / out_get_sample_rate(&out->stream.common); sleeptime_us = frames * 1000000LL / out_get_sample_rate(&out->stream.common); // usleep not guaranteed for values over 1 second but we don't limit here. } } Loading @@ -2637,7 +2637,7 @@ exit: usleep(sleeptime_us); } else { // only log if the data is properly written (out->power_log may be null) power_log_log(out->power_log, buffer, bytes / frame_size, now_ns); power_log_log(out->power_log, buffer, frames, now_ns); } return bytes; } Loading Loading @@ -3198,6 +3198,8 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer, int *int_buf_stream = NULL; lock_input_stream(in); const size_t frame_size = audio_stream_in_frame_size(stream); const size_t frames = bytes / frame_size; if (in->is_st_session) { ALOGVV(" %s: reading on st session bytes=%zu", __func__, bytes); Loading Loading @@ -3269,12 +3271,11 @@ exit: if (ret != 0) { in_standby(&in->stream.common); ALOGV("%s: read failed - sleeping for buffer duration", __func__); usleep(bytes * 1000000 / audio_stream_in_frame_size(stream) / in_get_sample_rate(&in->stream.common)); usleep(frames * 1000000LL / in_get_sample_rate(&in->stream.common)); memset(buffer, 0, bytes); // clear return data } if (bytes > 0) { in->frames_read += bytes / audio_stream_in_frame_size(stream); in->frames_read += frames; } return bytes; } Loading Loading @@ -3608,7 +3609,8 @@ static int adev_open_output_stream(struct audio_hw_device *dev, out->config = is_hdmi ? pcm_config_hdmi_multi : pcm_config_hifi; out->config.rate = config->sample_rate; out->config.channels = audio_channel_count_from_out_mask(out->channel_mask); out->config.period_size = HDMI_MULTI_PERIOD_BYTES / (out->config.channels * 2); out->config.period_size = HDMI_MULTI_PERIOD_BYTES / (out->config.channels * audio_bytes_per_sample(config->format)); out->config.format = pcm_format_from_audio_format(out->format); } else if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { pthread_mutex_lock(&adev->lock); Loading Loading
hal/audio_hw.c +11 −9 Original line number Diff line number Diff line Loading @@ -2518,7 +2518,8 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, lock_output_stream(out); // this is always nonzero const int frame_size = audio_stream_out_frame_size(stream); const size_t frame_size = audio_stream_out_frame_size(stream); const size_t frames = bytes / frame_size; if (out->usecase == USECASE_AUDIO_PLAYBACK_MMAP) { error_code = ERROR_CODE_WRITE; Loading Loading @@ -2609,7 +2610,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, exit: // For PCM we always consume the buffer and return #bytes regardless of ret. if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD) { out->written += bytes / (out->config.channels * sizeof(short)); out->written += frames; } long long sleeptime_us = 0; Loading @@ -2623,8 +2624,7 @@ exit: if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD) { ALOGE_IF(out->pcm != NULL, "%s: error %zd - %s", __func__, ret, pcm_get_error(out->pcm)); sleeptime_us = bytes * 1000000LL / frame_size / out_get_sample_rate(&out->stream.common); sleeptime_us = frames * 1000000LL / out_get_sample_rate(&out->stream.common); // usleep not guaranteed for values over 1 second but we don't limit here. } } Loading @@ -2637,7 +2637,7 @@ exit: usleep(sleeptime_us); } else { // only log if the data is properly written (out->power_log may be null) power_log_log(out->power_log, buffer, bytes / frame_size, now_ns); power_log_log(out->power_log, buffer, frames, now_ns); } return bytes; } Loading Loading @@ -3198,6 +3198,8 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer, int *int_buf_stream = NULL; lock_input_stream(in); const size_t frame_size = audio_stream_in_frame_size(stream); const size_t frames = bytes / frame_size; if (in->is_st_session) { ALOGVV(" %s: reading on st session bytes=%zu", __func__, bytes); Loading Loading @@ -3269,12 +3271,11 @@ exit: if (ret != 0) { in_standby(&in->stream.common); ALOGV("%s: read failed - sleeping for buffer duration", __func__); usleep(bytes * 1000000 / audio_stream_in_frame_size(stream) / in_get_sample_rate(&in->stream.common)); usleep(frames * 1000000LL / in_get_sample_rate(&in->stream.common)); memset(buffer, 0, bytes); // clear return data } if (bytes > 0) { in->frames_read += bytes / audio_stream_in_frame_size(stream); in->frames_read += frames; } return bytes; } Loading Loading @@ -3608,7 +3609,8 @@ static int adev_open_output_stream(struct audio_hw_device *dev, out->config = is_hdmi ? pcm_config_hdmi_multi : pcm_config_hifi; out->config.rate = config->sample_rate; out->config.channels = audio_channel_count_from_out_mask(out->channel_mask); out->config.period_size = HDMI_MULTI_PERIOD_BYTES / (out->config.channels * 2); out->config.period_size = HDMI_MULTI_PERIOD_BYTES / (out->config.channels * audio_bytes_per_sample(config->format)); out->config.format = pcm_format_from_audio_format(out->format); } else if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { pthread_mutex_lock(&adev->lock); Loading