Loading hal/audio_hw.c +19 −19 Original line number Original line Diff line number Diff line Loading @@ -3597,6 +3597,20 @@ static int out_set_volume(struct audio_stream_out *stream, float left, return -ENOSYS; return -ENOSYS; } } static void update_frames_written(struct stream_out *out, size_t bytes) { size_t bpf = 0; if (is_offload_usecase(out->usecase) && !out->non_blocking && !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) bpf = 1; else if (!is_offload_usecase(out->usecase)) bpf = audio_bytes_per_sample(out->format) * audio_channel_count_from_out_mask(out->channel_mask); if (bpf != 0) out->written += bytes / bpf; } static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, size_t bytes) size_t bytes) { { Loading @@ -3614,14 +3628,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, pthread_mutex_unlock(&out->lock); pthread_mutex_unlock(&out->lock); return -ENETRESET; return -ENETRESET; } else { } else { /* increase written size during SSR to avoid mismatch * with the written frames count in AF */ // bytes per frame size_t bpf = audio_bytes_per_sample(out->format) * audio_channel_count_from_out_mask(out->channel_mask); if (bpf != 0) out->written += bytes / bpf; ALOGD(" %s: sound card is not active/SSR state", __func__); ALOGD(" %s: sound card is not active/SSR state", __func__); ret= -EIO; ret= -EIO; goto exit; goto exit; Loading @@ -3630,8 +3636,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, if (audio_extn_passthru_should_drop_data(out)) { if (audio_extn_passthru_should_drop_data(out)) { ALOGV(" %s : Drop data as compress passthrough session is going on", __func__); ALOGV(" %s : Drop data as compress passthrough session is going on", __func__); if ((audio_bytes_per_sample(out->format) != 0) && (out->config.channels != 0)) out->written += bytes / (out->config.channels * audio_bytes_per_sample(out->format)); ret = -EIO; ret = -EIO; goto exit; goto exit; } } Loading @@ -3655,10 +3659,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, (audio_extn_a2dp_is_suspended())) { (audio_extn_a2dp_is_suspended())) { if (!(out->devices & AUDIO_DEVICE_OUT_SPEAKER)) { if (!(out->devices & AUDIO_DEVICE_OUT_SPEAKER)) { if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) { if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) { size_t bpf = audio_bytes_per_sample(out->format) * audio_channel_count_from_out_mask(out->channel_mask); if (bpf != 0) out->written += bytes / bpf; ret = -EIO; ret = -EIO; goto exit; goto exit; } } Loading Loading @@ -3736,6 +3736,9 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, } else } else ret = compress_write(out->compr, buffer, bytes); ret = compress_write(out->compr, buffer, bytes); if ((ret < 0 || ret == (ssize_t)bytes) && !out->non_blocking) update_frames_written(out, bytes); if (ret < 0) if (ret < 0) ret = -errno; ret = -errno; ALOGVV("%s: writing buffer (%zu bytes) to compress device returned %zd", __func__, bytes, ret); ALOGVV("%s: writing buffer (%zu bytes) to compress device returned %zd", __func__, bytes, ret); Loading @@ -3750,8 +3753,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, out_on_error(&out->stream.common); out_on_error(&out->stream.common); return ret; return ret; } } if ( ret == (ssize_t)bytes && !out->non_blocking) out->written += bytes; /* Call compr start only when non-zero bytes of data is there to be rendered */ /* Call compr start only when non-zero bytes of data is there to be rendered */ if (!out->playback_started && ret > 0) { if (!out->playback_started && ret > 0) { Loading Loading @@ -3830,14 +3831,13 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, if (ret < 0) if (ret < 0) ret = -errno; ret = -errno; else if (ret == 0 && (audio_bytes_per_sample(out->format) != 0)) else if (ret > 0) out->written += bytes / (out->config.channels * audio_bytes_per_sample(out->format)); else ret = -EINVAL; ret = -EINVAL; } } } } exit: exit: update_frames_written(out, bytes); if (-ENETRESET == ret) { if (-ENETRESET == ret) { out->card_status = CARD_STATUS_OFFLINE; out->card_status = CARD_STATUS_OFFLINE; } } Loading Loading
hal/audio_hw.c +19 −19 Original line number Original line Diff line number Diff line Loading @@ -3597,6 +3597,20 @@ static int out_set_volume(struct audio_stream_out *stream, float left, return -ENOSYS; return -ENOSYS; } } static void update_frames_written(struct stream_out *out, size_t bytes) { size_t bpf = 0; if (is_offload_usecase(out->usecase) && !out->non_blocking && !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) bpf = 1; else if (!is_offload_usecase(out->usecase)) bpf = audio_bytes_per_sample(out->format) * audio_channel_count_from_out_mask(out->channel_mask); if (bpf != 0) out->written += bytes / bpf; } static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, size_t bytes) size_t bytes) { { Loading @@ -3614,14 +3628,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, pthread_mutex_unlock(&out->lock); pthread_mutex_unlock(&out->lock); return -ENETRESET; return -ENETRESET; } else { } else { /* increase written size during SSR to avoid mismatch * with the written frames count in AF */ // bytes per frame size_t bpf = audio_bytes_per_sample(out->format) * audio_channel_count_from_out_mask(out->channel_mask); if (bpf != 0) out->written += bytes / bpf; ALOGD(" %s: sound card is not active/SSR state", __func__); ALOGD(" %s: sound card is not active/SSR state", __func__); ret= -EIO; ret= -EIO; goto exit; goto exit; Loading @@ -3630,8 +3636,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, if (audio_extn_passthru_should_drop_data(out)) { if (audio_extn_passthru_should_drop_data(out)) { ALOGV(" %s : Drop data as compress passthrough session is going on", __func__); ALOGV(" %s : Drop data as compress passthrough session is going on", __func__); if ((audio_bytes_per_sample(out->format) != 0) && (out->config.channels != 0)) out->written += bytes / (out->config.channels * audio_bytes_per_sample(out->format)); ret = -EIO; ret = -EIO; goto exit; goto exit; } } Loading @@ -3655,10 +3659,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, (audio_extn_a2dp_is_suspended())) { (audio_extn_a2dp_is_suspended())) { if (!(out->devices & AUDIO_DEVICE_OUT_SPEAKER)) { if (!(out->devices & AUDIO_DEVICE_OUT_SPEAKER)) { if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) { if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) { size_t bpf = audio_bytes_per_sample(out->format) * audio_channel_count_from_out_mask(out->channel_mask); if (bpf != 0) out->written += bytes / bpf; ret = -EIO; ret = -EIO; goto exit; goto exit; } } Loading Loading @@ -3736,6 +3736,9 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, } else } else ret = compress_write(out->compr, buffer, bytes); ret = compress_write(out->compr, buffer, bytes); if ((ret < 0 || ret == (ssize_t)bytes) && !out->non_blocking) update_frames_written(out, bytes); if (ret < 0) if (ret < 0) ret = -errno; ret = -errno; ALOGVV("%s: writing buffer (%zu bytes) to compress device returned %zd", __func__, bytes, ret); ALOGVV("%s: writing buffer (%zu bytes) to compress device returned %zd", __func__, bytes, ret); Loading @@ -3750,8 +3753,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, out_on_error(&out->stream.common); out_on_error(&out->stream.common); return ret; return ret; } } if ( ret == (ssize_t)bytes && !out->non_blocking) out->written += bytes; /* Call compr start only when non-zero bytes of data is there to be rendered */ /* Call compr start only when non-zero bytes of data is there to be rendered */ if (!out->playback_started && ret > 0) { if (!out->playback_started && ret > 0) { Loading Loading @@ -3830,14 +3831,13 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, if (ret < 0) if (ret < 0) ret = -errno; ret = -errno; else if (ret == 0 && (audio_bytes_per_sample(out->format) != 0)) else if (ret > 0) out->written += bytes / (out->config.channels * audio_bytes_per_sample(out->format)); else ret = -EINVAL; ret = -EINVAL; } } } } exit: exit: update_frames_written(out, bytes); if (-ENETRESET == ret) { if (-ENETRESET == ret) { out->card_status = CARD_STATUS_OFFLINE; out->card_status = CARD_STATUS_OFFLINE; } } Loading