Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7aa29e34 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Mikhail Naganov
Browse files

audio: Check for stream state before checking capture position

Check if stream is in standby before calling capture position

Bug: 70527174
Test: make
Change-Id: I3543287a375a337f8b15eb59d9b97eeca9a0a1d8
parent bb07d2b8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -3446,6 +3446,14 @@ static int in_get_capture_position(const struct audio_stream_in *stream,
    int ret = -ENOSYS;

    lock_input_stream(in);
    // note: ST sessions do not close the alsa pcm driver synchronously
    // on standby. Therefore, we may return an error even though the
    // pcm stream is still opened.
    if (in->standby) {
        ALOGE_IF(in->pcm != NULL && !in->is_st_session,
                 "%s stream in standby but pcm not NULL for non ST session", __func__);
        goto exit;
    }
    if (in->pcm) {
        struct timespec timestamp;
        unsigned int avail;
@@ -3455,6 +3463,7 @@ static int in_get_capture_position(const struct audio_stream_in *stream,
            ret = 0;
        }
    }
exit:
    pthread_mutex_unlock(&in->lock);
    return ret;
}