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

Commit 3163a3f5 authored by Dhanalakshmi Siddani's avatar Dhanalakshmi Siddani Committed by Gerrit - the friendly Code Review server
Browse files

audio: Support for compress offload recovery

- Add support to return error for compress time stamp query
  during SSR

 CRs-Fixed: 683288

Change-Id: Ie6849bbd3de9474fa556bfe4b183a10a44e4b3e8
parent 397d6369
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -2027,6 +2027,7 @@ static int out_get_render_position(const struct audio_stream_out *stream,
                                   uint32_t *dsp_frames)
{
    struct stream_out *out = (struct stream_out *)stream;
    struct audio_device *adev = out->dev;
    if (is_offload_usecase(out->usecase) && (dsp_frames != NULL)) {
        ssize_t ret = 0;
        *dsp_frames = 0;
@@ -2047,6 +2048,13 @@ static int out_get_render_position(const struct audio_stream_out *stream,
        } else if(ret < 0) {
            ALOGE(" ERROR: Unable to get time stamp from compress driver");
            return -EINVAL;
        } else if (get_snd_card_state(adev) == SND_CARD_STATE_OFFLINE){
            /*
             * Handle corner case where compress session is closed during SSR
             * and timestamp is queried
             */
            ALOGE(" ERROR: sound card not active, return error");
            return -EINVAL;
        } else {
            return 0;
        }
@@ -2083,12 +2091,20 @@ static int out_get_presentation_position(const struct audio_stream_out *stream,

    if (is_offload_usecase(out->usecase)) {
        if (out->compr != NULL) {
            compress_get_tstamp(out->compr, &dsp_frames,
            ret = compress_get_tstamp(out->compr, &dsp_frames,
                    &out->sample_rate);
            ALOGVV("%s rendered frames %ld sample_rate %d",
                   __func__, dsp_frames, out->sample_rate);
            *frames = dsp_frames;
            if (ret < 0)
                ret = -errno;
            if (-ENETRESET == ret) {
                ALOGE(" ERROR: sound card not active Unable to get time stamp from compress driver");
                set_snd_card_state(adev,SND_CARD_STATE_OFFLINE);
                ret = -EINVAL;
            } else
                ret = 0;

            /* this is the best we can do */
            clock_gettime(CLOCK_MONOTONIC, timestamp);
        }