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

Commit f750b213 authored by Eric Laurent's avatar Eric Laurent
Browse files

Revert "audio: low latency playback optimizations"

This reverts commit b7804685.

Change-Id: Ie5735dae556dcef62cdfd955da2817244d45f099
parent b7804685
Loading
Loading
Loading
Loading
+34 −253
Original line number Original line Diff line number Diff line
@@ -15,7 +15,6 @@
 */
 */


#define LOG_TAG "audio_hw_primary"
#define LOG_TAG "audio_hw_primary"
#define ATRACE_TAG ATRACE_TAG_AUDIO
/*#define LOG_NDEBUG 0*/
/*#define LOG_NDEBUG 0*/
/*#define VERY_VERY_VERBOSE_LOGGING*/
/*#define VERY_VERY_VERBOSE_LOGGING*/
#ifdef VERY_VERY_VERBOSE_LOGGING
#ifdef VERY_VERY_VERBOSE_LOGGING
@@ -35,7 +34,6 @@
#include <sys/prctl.h>
#include <sys/prctl.h>


#include <cutils/log.h>
#include <cutils/log.h>
#include <cutils/trace.h>
#include <cutils/str_parms.h>
#include <cutils/str_parms.h>
#include <cutils/properties.h>
#include <cutils/properties.h>
#include <cutils/atomic.h>
#include <cutils/atomic.h>
@@ -75,8 +73,6 @@
#define STR(x) #x
#define STR(x) #x
#endif
#endif


#define ULL_PERIOD_SIZE (DEFAULT_OUTPUT_SAMPLING_RATE/1000)

static unsigned int configured_low_latency_capture_period_size =
static unsigned int configured_low_latency_capture_period_size =
        LOW_LATENCY_CAPTURE_PERIOD_SIZE;
        LOW_LATENCY_CAPTURE_PERIOD_SIZE;


@@ -107,20 +103,6 @@ struct pcm_config pcm_config_low_latency = {
    .avail_min = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
    .avail_min = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
};
};


static int af_period_multiplier = 4;
struct pcm_config pcm_config_rt = {
    .channels = DEFAULT_CHANNEL_COUNT,
    .rate = DEFAULT_OUTPUT_SAMPLING_RATE,
    .period_size = ULL_PERIOD_SIZE, //1 ms
    .period_count = 512, //=> buffer size is 512ms
    .format = PCM_FORMAT_S16_LE,
    .start_threshold = ULL_PERIOD_SIZE*8, //8ms
    .stop_threshold = INT_MAX,
    .silence_threshold = 0,
    .silence_size = 0,
    .avail_min = ULL_PERIOD_SIZE, //1 ms
};

struct pcm_config pcm_config_hdmi_multi = {
struct pcm_config pcm_config_hdmi_multi = {
    .channels = HDMI_MULTI_DEFAULT_CHANNEL_COUNT, /* changed when the stream is opened */
    .channels = HDMI_MULTI_DEFAULT_CHANNEL_COUNT, /* changed when the stream is opened */
    .rate = DEFAULT_OUTPUT_SAMPLING_RATE, /* changed when the stream is opened */
    .rate = DEFAULT_OUTPUT_SAMPLING_RATE, /* changed when the stream is opened */
@@ -140,19 +122,6 @@ struct pcm_config pcm_config_audio_capture = {
    .avail_min = 0,
    .avail_min = 0,
};
};


struct pcm_config pcm_config_audio_capture_rt = {
    .channels = DEFAULT_CHANNEL_COUNT,
    .rate = DEFAULT_OUTPUT_SAMPLING_RATE,
    .period_size = ULL_PERIOD_SIZE,
    .period_count = 512,
    .format = PCM_FORMAT_S16_LE,
    .start_threshold = 0,
    .stop_threshold = INT_MAX,
    .silence_threshold = 0,
    .silence_size = 0,
    .avail_min = ULL_PERIOD_SIZE, //1 ms
};

#define AFE_PROXY_CHANNEL_COUNT 2
#define AFE_PROXY_CHANNEL_COUNT 2
#define AFE_PROXY_SAMPLING_RATE 48000
#define AFE_PROXY_SAMPLING_RATE 48000


@@ -232,120 +201,6 @@ static struct audio_device *adev = NULL;
static pthread_mutex_t adev_init_lock;
static pthread_mutex_t adev_init_lock;
static unsigned int audio_device_ref_count;
static unsigned int audio_device_ref_count;


static bool may_use_noirq_mode(struct audio_device *adev, audio_usecase_t uc_id,
                               int flags __unused)
{
    int dir = 0;
    switch (uc_id) {
    case USECASE_AUDIO_RECORD_LOW_LATENCY:
        dir = 1;
    case USECASE_AUDIO_PLAYBACK_ULL:
        break;
    default:
        return false;
    }

    int dev_id = platform_get_pcm_device_id(uc_id, dir == 0 ?
                                            PCM_PLAYBACK : PCM_CAPTURE);
    if (adev->adm_is_noirq_avail)
        return adev->adm_is_noirq_avail(adev->adm_data,
                                        adev->snd_card, dev_id, dir);
    return false;
}

static void register_out_stream(struct stream_out *out)
{
    struct audio_device *adev = out->dev;
    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD)
        return;

    if (!adev->adm_register_output_stream)
        return;

    adev->adm_register_output_stream(adev->adm_data,
                                     out->handle,
                                     out->flags);

    if (!adev->adm_set_config)
        return;

    if (out->realtime) {
        adev->adm_set_config(adev->adm_data,
                             out->handle,
                             out->pcm, &out->config);
    }
}

static void register_in_stream(struct stream_in *in)
{
    struct audio_device *adev = in->dev;
    if (!adev->adm_register_input_stream)
        return;

    adev->adm_register_input_stream(adev->adm_data,
                                    in->capture_handle,
                                    in->flags);

    if (!adev->adm_set_config)
        return;

    if (in->realtime) {
        adev->adm_set_config(adev->adm_data,
                             in->capture_handle,
                             in->pcm,
                             &in->config);
    }
}

static void request_out_focus(struct stream_out *out, long ns)
{
    struct audio_device *adev = out->dev;

    if (out->routing_change) {
        out->routing_change = false;
        if (adev->adm_on_routing_change)
            adev->adm_on_routing_change(adev->adm_data, out->handle);
    }

    if (adev->adm_request_focus_v2) {
        adev->adm_request_focus_v2(adev->adm_data, out->handle, ns);
    } else if (adev->adm_request_focus) {
        adev->adm_request_focus(adev->adm_data, out->handle);
    }
}

static void request_in_focus(struct stream_in *in, long ns)
{
    struct audio_device *adev = in->dev;

    if (in->routing_change) {
        in->routing_change = false;
        if (adev->adm_on_routing_change)
            adev->adm_on_routing_change(adev->adm_data, in->capture_handle);
    }

    if (adev->adm_request_focus_v2) {
        adev->adm_request_focus_v2(adev->adm_data, in->capture_handle, ns);
    } else if (adev->adm_request_focus) {
        adev->adm_request_focus(adev->adm_data, in->capture_handle);
    }
}

static void release_out_focus(struct stream_out *out, long ns __unused)
{
    struct audio_device *adev = out->dev;

    if (adev->adm_abandon_focus)
        adev->adm_abandon_focus(adev->adm_data, out->handle);
}

static void release_in_focus(struct stream_in *in, long ns __unused)
{
    struct audio_device *adev = in->dev;
    if (adev->adm_abandon_focus)
        adev->adm_abandon_focus(adev->adm_data, in->capture_handle);
}

__attribute__ ((visibility ("default")))
__attribute__ ((visibility ("default")))
bool audio_hw_send_gain_dep_calibration(int level) {
bool audio_hw_send_gain_dep_calibration(int level) {
    bool ret_val = false;
    bool ret_val = false;
@@ -381,12 +236,6 @@ static bool is_supported_format(audio_format_t format)
    return false;
    return false;
}
}


static inline bool is_mmap_usecase(audio_usecase_t uc_id)
{
    return (uc_id == USECASE_AUDIO_RECORD_AFE_PROXY) ||
           (uc_id == USECASE_AUDIO_PLAYBACK_AFE_PROXY);
}

static int get_snd_codec_id(audio_format_t format)
static int get_snd_codec_id(audio_format_t format)
{
{
    int id = 0;
    int id = 0;
@@ -1013,8 +862,6 @@ int start_input_stream(struct stream_in *in)
    if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) {
    if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) {
        flags |= PCM_MMAP | PCM_NOIRQ;
        flags |= PCM_MMAP | PCM_NOIRQ;
        pcm_open_retry_count = PROXY_OPEN_RETRY_COUNT;
        pcm_open_retry_count = PROXY_OPEN_RETRY_COUNT;
    } else if (in->realtime) {
        flags |= PCM_MMAP | PCM_NOIRQ;
    }
    }


    while (1) {
    while (1) {
@@ -1044,10 +891,7 @@ int start_input_stream(struct stream_in *in)
        in->pcm = NULL;
        in->pcm = NULL;
        goto error_open;
        goto error_open;
    }
    }
    register_in_stream(in);

    if (in->realtime) {
        ret = pcm_start(in->pcm);
    }
    audio_extn_perf_lock_release();
    audio_extn_perf_lock_release();


    ALOGV("%s: exit", __func__);
    ALOGV("%s: exit", __func__);
@@ -1381,12 +1225,9 @@ int start_output_stream(struct stream_out *out)
    if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD) {
    if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD) {
        unsigned int flags = PCM_OUT;
        unsigned int flags = PCM_OUT;
        unsigned int pcm_open_retry_count = 0;
        unsigned int pcm_open_retry_count = 0;

        if (out->usecase == USECASE_AUDIO_PLAYBACK_AFE_PROXY) {
        if (out->usecase == USECASE_AUDIO_PLAYBACK_AFE_PROXY) {
            flags |= PCM_MMAP | PCM_NOIRQ;
            flags |= PCM_MMAP | PCM_NOIRQ;
            pcm_open_retry_count = PROXY_OPEN_RETRY_COUNT;
            pcm_open_retry_count = PROXY_OPEN_RETRY_COUNT;
        } else if (out->realtime) {
            flags |= PCM_MMAP | PCM_NOIRQ;
        } else
        } else
            flags |= PCM_MONOTONIC;
            flags |= PCM_MONOTONIC;


@@ -1437,14 +1278,9 @@ int start_output_stream(struct stream_out *out)
        if (adev->offload_effects_start_output != NULL)
        if (adev->offload_effects_start_output != NULL)
            adev->offload_effects_start_output(out->handle, out->pcm_device_id);
            adev->offload_effects_start_output(out->handle, out->pcm_device_id);
    }
    }
    ret = 0;
    register_out_stream(out);
    if (out->realtime) {
        ret = pcm_start(out->pcm);
    }
    audio_extn_perf_lock_release();
    audio_extn_perf_lock_release();
    ALOGV("%s: exit", __func__);
    ALOGV("%s: exit", __func__);
    return ret;
    return 0;
error_open:
error_open:
    audio_extn_perf_lock_release();
    audio_extn_perf_lock_release();
    stop_output_stream(out);
    stop_output_stream(out);
@@ -1533,7 +1369,7 @@ static size_t out_get_buffer_size(const struct audio_stream *stream)
    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
        return out->compr_config.fragment_size;
        return out->compr_config.fragment_size;
    }
    }
    return out->config.period_size * out->af_period_multiplier *
    return out->config.period_size *
                audio_stream_out_frame_size((const struct audio_stream_out *)stream);
                audio_stream_out_frame_size((const struct audio_stream_out *)stream);
}
}


@@ -1686,18 +1522,11 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
         *       Because select_devices() must be called to switch back the music
         *       Because select_devices() must be called to switch back the music
         *       playback to headset.
         *       playback to headset.
         */
         */
        audio_devices_t new_dev = val;
        if (val != 0) {
        if (new_dev != AUDIO_DEVICE_NONE) {
            out->devices = val;
            bool same_dev = out->devices == new_dev;
            out->devices = new_dev;


            if (!out->standby) {
            if (!out->standby)
                if (!same_dev) {
                    ALOGV("update routing change");
                    out->routing_change = true;
                }
                select_devices(adev, out->usecase);
                select_devices(adev, out->usecase);
            }


            if (output_drives_call(adev, out)) {
            if (output_drives_call(adev, out)) {
                if (!voice_is_in_call(adev)) {
                if (!voice_is_in_call(adev)) {
@@ -1769,19 +1598,10 @@ static char* out_get_parameters(const struct audio_stream *stream, const char *k


static uint32_t out_get_latency(const struct audio_stream_out *stream)
static uint32_t out_get_latency(const struct audio_stream_out *stream)
{
{
    uint32_t hw_delay, period_ms;
    struct stream_out *out = (struct stream_out *)stream;
    struct stream_out *out = (struct stream_out *)stream;


    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD)
    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD)
        return COMPRESS_OFFLOAD_PLAYBACK_LATENCY;
        return COMPRESS_OFFLOAD_PLAYBACK_LATENCY;
    else if (out->realtime) {
        // since the buffer won't be filled up faster than realtime,
        // return a smaller number
        period_ms = (out->af_period_multiplier * out->config.period_size *
                     1000) / (out->config.rate);
        hw_delay = platform_render_latency(out->usecase)/1000;
        return period_ms + hw_delay;
    }


    return (out->config.period_count * out->config.period_size * 1000) /
    return (out->config.period_count * out->config.period_size * 1000) /
           (out->config.rate);
           (out->config.rate);
@@ -1859,6 +1679,8 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
            out->standby = true;
            out->standby = true;
            goto exit;
            goto exit;
        }
        }
        if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD && adev->adm_register_output_stream)
            adev->adm_register_output_stream(adev->adm_data, out->handle, out->flags);
    }
    }


    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
@@ -1902,21 +1724,20 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
                memset((void *)buffer, 0, bytes);
                memset((void *)buffer, 0, bytes);


            ALOGVV("%s: writing buffer (%d bytes) to pcm device", __func__, bytes);
            ALOGVV("%s: writing buffer (%d bytes) to pcm device", __func__, bytes);
            if (adev->adm_request_focus)
                adev->adm_request_focus(adev->adm_data, out->handle);


            long ns = pcm_bytes_to_frames(out->pcm, bytes)*1000000000LL/
            if (out->usecase == USECASE_AUDIO_PLAYBACK_AFE_PROXY) {
                                                out->config.rate;
            request_out_focus(out, ns);

            bool use_mmap = is_mmap_usecase(out->usecase) || out->realtime;
            if (use_mmap)
                ret = pcm_mmap_write(out->pcm, (void *)buffer, bytes);
                ret = pcm_mmap_write(out->pcm, (void *)buffer, bytes);
            }
            else
            else
                ret = pcm_write(out->pcm, (void *)buffer, bytes);
                ret = pcm_write(out->pcm, (void *)buffer, bytes);


            if (ret == 0)
            if (ret == 0)
                out->written += bytes / (out->config.channels * sizeof(short));
                out->written += bytes / (out->config.channels * sizeof(short));


            release_out_focus(out, ns);
            if (adev->adm_abandon_focus)
                adev->adm_abandon_focus(adev->adm_data, out->handle);
        }
        }
    }
    }


@@ -2110,7 +1931,7 @@ static size_t in_get_buffer_size(const struct audio_stream *stream)
{
{
    struct stream_in *in = (struct stream_in *)stream;
    struct stream_in *in = (struct stream_in *)stream;


    return in->config.period_size * in->af_period_multiplier *
    return in->config.period_size *
                audio_stream_in_frame_size((const struct audio_stream_in *)stream);
                audio_stream_in_frame_size((const struct audio_stream_in *)stream);
}
}


@@ -2204,11 +2025,8 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
        if (((int)in->device != val) && (val != 0)) {
        if (((int)in->device != val) && (val != 0)) {
            in->device = val;
            in->device = val;
            /* If recording is in progress, change the tx device to new device */
            /* If recording is in progress, change the tx device to new device */
            if (!in->standby) {
            if (!in->standby)
                ALOGV("update input routing change");
                status = select_devices(adev, in->usecase);
                in->routing_change = true;
                ret = select_devices(adev, in->usecase);
            }
        }
        }
    }
    }


@@ -2256,27 +2074,22 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
            goto exit;
            goto exit;
        }
        }
        in->standby = 0;
        in->standby = 0;
        if (adev->adm_register_input_stream)
            adev->adm_register_input_stream(adev->adm_data, in->capture_handle, in->flags);
    }
    }


    //what's the duration requested by the client?
    if (adev->adm_request_focus)
    long ns = pcm_bytes_to_frames(in->pcm, bytes)*1000000000LL/
        adev->adm_request_focus(adev->adm_data, in->capture_handle);
                                                in->config.rate;
    request_in_focus(in, ns);


    bool use_mmap = is_mmap_usecase(in->usecase) || in->realtime;
    if (in->pcm) {
    if (in->pcm) {
        if (use_mmap) {
        if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) {
            ret = pcm_mmap_read(in->pcm, buffer, bytes);
            ret = pcm_mmap_read(in->pcm, buffer, bytes);
        } else
        } else
            ret = pcm_read(in->pcm, buffer, bytes);
            ret = pcm_read(in->pcm, buffer, bytes);

        if (ret < 0) {
            ALOGE("Failed to read w/err %s", strerror(errno));
            ret = -errno;
        }
    }
    }


    release_in_focus(in, ns);
    if (adev->adm_abandon_focus)
        adev->adm_abandon_focus(adev->adm_data, in->capture_handle);


    /*
    /*
     * Instead of writing zeroes here, we could trust the hardware
     * Instead of writing zeroes here, we could trust the hardware
@@ -2529,9 +2342,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
            out->config = pcm_config_deep_buffer;
            out->config = pcm_config_deep_buffer;
        } else if (out->flags & AUDIO_OUTPUT_FLAG_RAW) {
        } else if (out->flags & AUDIO_OUTPUT_FLAG_RAW) {
            out->usecase = USECASE_AUDIO_PLAYBACK_ULL;
            out->usecase = USECASE_AUDIO_PLAYBACK_ULL;
            out->realtime = may_use_noirq_mode(adev, USECASE_AUDIO_PLAYBACK_ULL, out->flags);
            out->config = pcm_config_low_latency;
            out->usecase = USECASE_AUDIO_PLAYBACK_ULL;
            out->config = out->realtime ? pcm_config_rt : pcm_config_low_latency;
        } else {
        } else {
            out->usecase = USECASE_AUDIO_PLAYBACK_LOW_LATENCY;
            out->usecase = USECASE_AUDIO_PLAYBACK_LOW_LATENCY;
            out->config = pcm_config_low_latency;
            out->config = pcm_config_low_latency;
@@ -2599,7 +2410,6 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
    out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
    out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
    out->stream.get_presentation_position = out_get_presentation_position;
    out->stream.get_presentation_position = out_get_presentation_position;


    out->af_period_multiplier  = out->realtime ? af_period_multiplier : 1;
    out->standby = 1;
    out->standby = 1;
    /* out->muted = false; by calloc() */
    /* out->muted = false; by calloc() */
    /* out->written = 0; by calloc() */
    /* out->written = 0; by calloc() */
@@ -2909,28 +2719,18 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
#if LOW_LATENCY_CAPTURE_USE_CASE
#if LOW_LATENCY_CAPTURE_USE_CASE
            in->usecase = USECASE_AUDIO_RECORD_LOW_LATENCY;
            in->usecase = USECASE_AUDIO_RECORD_LOW_LATENCY;
#endif
#endif
            in->realtime = may_use_noirq_mode(adev, in->usecase, in->flags);
            in->config = in->realtime ? pcm_config_audio_capture_rt :
                                  pcm_config_audio_capture;
        }
        }
        in->config = pcm_config_audio_capture;


        if (!in->realtime) {
        frame_size = audio_stream_in_frame_size(&in->stream);
        frame_size = audio_stream_in_frame_size(&in->stream);
        buffer_size = get_input_buffer_size(config->sample_rate,
        buffer_size = get_input_buffer_size(config->sample_rate,
                                            config->format,
                                            config->format,
                                            channel_count,
                                            channel_count,
                                            is_low_latency);
                                            is_low_latency);
        in->config.period_size = buffer_size / frame_size;
        in->config.period_size = buffer_size / frame_size;
        } // period size is left untouched for rt mode playback
    }
    }

    in->config.channels = channel_count;
    in->config.channels = channel_count;
    if (in->realtime) {
        in->af_period_multiplier = af_period_multiplier;
    } else {
    in->config.rate = config->sample_rate;
    in->config.rate = config->sample_rate;
        in->af_period_multiplier = 1;
    }


    /* This stream could be for sound trigger lab,
    /* This stream could be for sound trigger lab,
       get sound trigger pcm if present */
       get sound trigger pcm if present */
@@ -3262,14 +3062,6 @@ static int adev_open(const hw_module_t *module, const char *name,
                                dlsym(adev->adm_lib, "adm_request_focus");
                                dlsym(adev->adm_lib, "adm_request_focus");
        adev->adm_abandon_focus = (adm_abandon_focus_t)
        adev->adm_abandon_focus = (adm_abandon_focus_t)
                                dlsym(adev->adm_lib, "adm_abandon_focus");
                                dlsym(adev->adm_lib, "adm_abandon_focus");
        adev->adm_set_config = (adm_set_config_t)
                                    dlsym(adev->adm_lib, "adm_set_config");
        adev->adm_request_focus_v2 = (adm_request_focus_v2_t)
                                    dlsym(adev->adm_lib, "adm_request_focus_v2");
        adev->adm_is_noirq_avail = (adm_is_noirq_avail_t)
                                    dlsym(adev->adm_lib, "adm_is_noirq_avail");
        adev->adm_on_routing_change = (adm_on_routing_change_t)
                                    dlsym(adev->adm_lib, "adm_on_routing_change");
    }
    }


    adev->bt_wb_speech_enabled = false;
    adev->bt_wb_speech_enabled = false;
@@ -3299,17 +3091,6 @@ static int adev_open(const hw_module_t *module, const char *name,
    }
    }


    audio_device_ref_count++;
    audio_device_ref_count++;

    if (property_get("audio_hal.period_multiplier", value, NULL) > 0) {
        af_period_multiplier = atoi(value);
        if (af_period_multiplier < 0) {
            af_period_multiplier = 2;
        } else if (af_period_multiplier > 4) {
            af_period_multiplier = 4;
        }
        ALOGV("new period_multiplier = %d", af_period_multiplier);
    }

    pthread_mutex_unlock(&adev_init_lock);
    pthread_mutex_unlock(&adev_init_lock);


    if (adev->adm_init)
    if (adev->adm_init)
+3 −16
Original line number Original line Diff line number Diff line
@@ -177,9 +177,7 @@ struct stream_out {
    void *offload_cookie;
    void *offload_cookie;
    struct compr_gapless_mdata gapless_mdata;
    struct compr_gapless_mdata gapless_mdata;
    int send_new_metadata;
    int send_new_metadata;
    bool realtime;

    int af_period_multiplier;
    bool routing_change;
    struct audio_device *dev;
    struct audio_device *dev;
};
};


@@ -203,9 +201,7 @@ struct stream_in {
    audio_input_flags_t flags;
    audio_input_flags_t flags;
    bool is_st_session;
    bool is_st_session;
    bool is_st_session_active;
    bool is_st_session_active;
    bool realtime;

    int af_period_multiplier;
    bool routing_change;
    struct audio_device *dev;
    struct audio_device *dev;
};
};


@@ -238,12 +234,6 @@ typedef void (*adm_register_input_stream_t)(void *, audio_io_handle_t, audio_inp
typedef void (*adm_deregister_stream_t)(void *, audio_io_handle_t);
typedef void (*adm_deregister_stream_t)(void *, audio_io_handle_t);
typedef void (*adm_request_focus_t)(void *, audio_io_handle_t);
typedef void (*adm_request_focus_t)(void *, audio_io_handle_t);
typedef void (*adm_abandon_focus_t)(void *, audio_io_handle_t);
typedef void (*adm_abandon_focus_t)(void *, audio_io_handle_t);
typedef void (*adm_set_config_t)(void *, audio_io_handle_t,
                                         struct pcm *,
                                         struct pcm_config *);
typedef void (*adm_request_focus_v2_t)(void *, audio_io_handle_t, long);
typedef bool (*adm_is_noirq_avail_t)(void *, int, int, int);
typedef void (*adm_on_routing_change_t)(void *, audio_io_handle_t);


struct audio_device {
struct audio_device {
    struct audio_hw_device device;
    struct audio_hw_device device;
@@ -295,13 +285,10 @@ struct audio_device {
    adm_deregister_stream_t adm_deregister_stream;
    adm_deregister_stream_t adm_deregister_stream;
    adm_request_focus_t adm_request_focus;
    adm_request_focus_t adm_request_focus;
    adm_abandon_focus_t adm_abandon_focus;
    adm_abandon_focus_t adm_abandon_focus;
    adm_set_config_t adm_set_config;
    adm_request_focus_v2_t adm_request_focus_v2;
    adm_is_noirq_avail_t adm_is_noirq_avail;
    adm_on_routing_change_t adm_on_routing_change;


    /* logging */
    /* logging */
    snd_device_t last_logged_snd_device[AUDIO_USECASE_MAX][2]; /* [out, in] */
    snd_device_t last_logged_snd_device[AUDIO_USECASE_MAX][2]; /* [out, in] */

};
};


int select_devices(struct audio_device *adev,
int select_devices(struct audio_device *adev,
+0 −3
Original line number Original line Diff line number Diff line
@@ -491,7 +491,6 @@ static const struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = {


#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
#define ULL_PLATFORM_DELAY         (7*1000LL)


static pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT;
static pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT;
static bool is_tmus = false;
static bool is_tmus = false;
@@ -2525,8 +2524,6 @@ int64_t platform_render_latency(audio_usecase_t usecase)
            return DEEP_BUFFER_PLATFORM_DELAY;
            return DEEP_BUFFER_PLATFORM_DELAY;
        case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
        case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
            return LOW_LATENCY_PLATFORM_DELAY;
            return LOW_LATENCY_PLATFORM_DELAY;
        case USECASE_AUDIO_PLAYBACK_ULL:
            return ULL_PLATFORM_DELAY;
        default:
        default:
            return 0;
            return 0;
    }
    }