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

Commit 949a0891 authored by Eric Laurent's avatar Eric Laurent
Browse files

implement get_presentation_position() for offloaded outputs

Bug: 9587132.
Change-Id: Idf40259b59552c29671830f30ccca3bef6ef0edd
parent 957b4382
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -1422,9 +1422,22 @@ static int out_get_presentation_position(const struct audio_stream_out *stream,
{
    struct stream_out *out = (struct stream_out *)stream;
    int ret = -1;
    unsigned long dsp_frames;

    pthread_mutex_lock(&out->lock);

    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
        if (out->compr != NULL) {
            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;
            ret = 0;
            /* this is the best we can do */
            clock_gettime(CLOCK_MONOTONIC, timestamp);
        }
    } else {
        if (out->pcm) {
            size_t avail;
            if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
@@ -1438,6 +1451,7 @@ static int out_get_presentation_position(const struct audio_stream_out *stream,
                }
            }
        }
    }

    pthread_mutex_unlock(&out->lock);