Loading hal/audio_hw.c +28 −1 Original line number Diff line number Diff line Loading @@ -1128,7 +1128,7 @@ int start_input_stream(struct stream_in *in) ALOGV("%s: Opening PCM device card_id(%d) device_id(%d), channels %d", __func__, adev->snd_card, in->pcm_device_id, in->config.channels); unsigned int flags = PCM_IN; unsigned int flags = PCM_IN | PCM_MONOTONIC; unsigned int pcm_open_retry_entry_count = 0; if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) { Loading Loading @@ -2628,6 +2628,8 @@ exit: 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)); } else { in->frames_read += bytes / audio_stream_in_frame_size(stream); } return bytes; } Loading @@ -2637,6 +2639,29 @@ static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream __unused return 0; } static int in_get_capture_position(const struct audio_stream_in *stream, int64_t *frames, int64_t *time) { if (stream == NULL || frames == NULL || time == NULL) { return -EINVAL; } struct stream_in *in = (struct stream_in *)stream; int ret = -ENOSYS; lock_input_stream(in); if (in->pcm) { struct timespec timestamp; unsigned int avail; if (pcm_get_htimestamp(in->pcm, &avail, ×tamp) == 0) { *frames = in->frames_read + avail; *time = timestamp.tv_sec * 1000000000LL + timestamp.tv_nsec; ret = 0; } } pthread_mutex_unlock(&in->lock); return ret; } static int add_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect, bool enable) Loading Loading @@ -3375,12 +3400,14 @@ static int adev_open_input_stream(struct audio_hw_device *dev, in->stream.set_gain = in_set_gain; in->stream.read = in_read; in->stream.get_input_frames_lost = in_get_input_frames_lost; in->stream.get_capture_position = in_get_capture_position; in->device = devices; in->source = source; in->dev = adev; in->standby = 1; in->channel_mask = config->channel_mask; // in->frames_read = 0; /* Update config params with the requested sample rate and channels */ in->usecase = USECASE_AUDIO_RECORD; Loading hal/audio_hw.h +1 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,7 @@ struct stream_in { bool enable_aec; bool enable_ns; audio_format_t format; int64_t frames_read; /* total frames read, not cleared when entering standby */ struct audio_device *dev; }; Loading Loading
hal/audio_hw.c +28 −1 Original line number Diff line number Diff line Loading @@ -1128,7 +1128,7 @@ int start_input_stream(struct stream_in *in) ALOGV("%s: Opening PCM device card_id(%d) device_id(%d), channels %d", __func__, adev->snd_card, in->pcm_device_id, in->config.channels); unsigned int flags = PCM_IN; unsigned int flags = PCM_IN | PCM_MONOTONIC; unsigned int pcm_open_retry_entry_count = 0; if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) { Loading Loading @@ -2628,6 +2628,8 @@ exit: 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)); } else { in->frames_read += bytes / audio_stream_in_frame_size(stream); } return bytes; } Loading @@ -2637,6 +2639,29 @@ static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream __unused return 0; } static int in_get_capture_position(const struct audio_stream_in *stream, int64_t *frames, int64_t *time) { if (stream == NULL || frames == NULL || time == NULL) { return -EINVAL; } struct stream_in *in = (struct stream_in *)stream; int ret = -ENOSYS; lock_input_stream(in); if (in->pcm) { struct timespec timestamp; unsigned int avail; if (pcm_get_htimestamp(in->pcm, &avail, ×tamp) == 0) { *frames = in->frames_read + avail; *time = timestamp.tv_sec * 1000000000LL + timestamp.tv_nsec; ret = 0; } } pthread_mutex_unlock(&in->lock); return ret; } static int add_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect, bool enable) Loading Loading @@ -3375,12 +3400,14 @@ static int adev_open_input_stream(struct audio_hw_device *dev, in->stream.set_gain = in_set_gain; in->stream.read = in_read; in->stream.get_input_frames_lost = in_get_input_frames_lost; in->stream.get_capture_position = in_get_capture_position; in->device = devices; in->source = source; in->dev = adev; in->standby = 1; in->channel_mask = config->channel_mask; // in->frames_read = 0; /* Update config params with the requested sample rate and channels */ in->usecase = USECASE_AUDIO_RECORD; Loading
hal/audio_hw.h +1 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,7 @@ struct stream_in { bool enable_aec; bool enable_ns; audio_format_t format; int64_t frames_read; /* total frames read, not cleared when entering standby */ struct audio_device *dev; }; Loading