<commit_before>/*
 * Copyright (C) 2013-2018 Jolla Ltd.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * These PulseAudio Modules are free software; you can redistribute
 * it and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 * USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "version.h"
#include "droid-config.h"

#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>

#ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h>
#endif

#include <pulse/rtclock.h>
#include <pulse/timeval.h>
#include <pulse/volume.h>
#include <pulse/xmalloc.h>

#include <pulsecore/core.h>
#include <pulsecore/core-error.h>
#include <pulsecore/i18n.h>
#include <pulsecore/module.h>
#include <pulsecore/memchunk.h>
#include <pulsecore/sink.h>
#include <pulsecore/modargs.h>
#include <pulsecore/core-rtclock.h>
#include <pulsecore/core-util.h>
#include <pulsecore/sample-util.h>
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
#include <pulsecore/thread.h>
#include <pulsecore/thread-mq.h>
#include <pulsecore/rtpoll.h>
#include <pulsecore/time-smoother.h>
#include <pulsecore/refcnt.h>
#include <pulsecore/shared.h>
#include <pulsecore/mutex.h>
#include <pulsecore/strlist.h>
#include <pulsecore/atomic.h>

#include <hardware/audio.h>
#include <hardware_legacy/audio_policy_conf.h>

#define VENDOR_AUDIO_POLICY_CONFIG_XML_FILE "/vendor/etc/audio_policy_configuration.xml"
#define SYSTEM_AUDIO_POLICY_CONFIG_XML_FILE "/system/etc/audio_policy_configuration.xml"


pa_droid_config_audio *pa_droid_config_load(pa_modargs *ma) {
    pa_droid_config_audio *config = NULL;
    const char *manual_config;
    const char *config_location[5] = {
        VENDOR_AUDIO_POLICY_CONFIG_XML_FILE,
        SYSTEM_AUDIO_POLICY_CONFIG_XML_FILE,
        AUDIO_POLICY_VENDOR_CONFIG_FILE,
        AUDIO_POLICY_CONFIG_FILE,
        NULL};

    pa_assert(ma);

    if ((manual_config = pa_modargs_get_value(ma, "config", NULL))) {
        if (!(config = pa_parse_droid_audio_config(manual_config)))
            pa_log("Failed to parse configuration from %s", manual_config);
    } else {
        int i;
        for (i = 0; config_location[i]; i++) {
            if ((config = pa_parse_droid_audio_config(config_location[i])))
                break;
            else
                pa_log_debug("Failed to parse configuration from %s", config_location[i]);
        }

    }

    if (!config)
        pa_log("Failed to parse any configuration.");

    return config;
}<commit_msg>[config] Reorder configuration file search locations. JB#42564<commit_after>/*
 * Copyright (C) 2013-2018 Jolla Ltd.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * These PulseAudio Modules are free software; you can redistribute
 * it and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 * USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "version.h"
#include "droid-config.h"

#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>

#ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h>
#endif

#include <pulse/rtclock.h>
#include <pulse/timeval.h>
#include <pulse/volume.h>
#include <pulse/xmalloc.h>

#include <pulsecore/core.h>
#include <pulsecore/core-error.h>
#include <pulsecore/i18n.h>
#include <pulsecore/module.h>
#include <pulsecore/memchunk.h>
#include <pulsecore/sink.h>
#include <pulsecore/modargs.h>
#include <pulsecore/core-rtclock.h>
#include <pulsecore/core-util.h>
#include <pulsecore/sample-util.h>
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
#include <pulsecore/thread.h>
#include <pulsecore/thread-mq.h>
#include <pulsecore/rtpoll.h>
#include <pulsecore/time-smoother.h>
#include <pulsecore/refcnt.h>
#include <pulsecore/shared.h>
#include <pulsecore/mutex.h>
#include <pulsecore/strlist.h>
#include <pulsecore/atomic.h>

#include <hardware/audio.h>
#include <hardware_legacy/audio_policy_conf.h>

#define VENDOR_AUDIO_POLICY_CONFIG_XML_FILE "/vendor/etc/audio_policy_configuration.xml"
#define SYSTEM_AUDIO_POLICY_CONFIG_XML_FILE "/system/etc/audio_policy_configuration.xml"


pa_droid_config_audio *pa_droid_config_load(pa_modargs *ma) {
    pa_droid_config_audio *config = NULL;
    const char *manual_config;
    const char *config_location[] = {
        VENDOR_AUDIO_POLICY_CONFIG_XML_FILE,
        AUDIO_POLICY_VENDOR_CONFIG_FILE,
        SYSTEM_AUDIO_POLICY_CONFIG_XML_FILE,
        AUDIO_POLICY_CONFIG_FILE,
        NULL};

    pa_assert(ma);

    if ((manual_config = pa_modargs_get_value(ma, "config", NULL))) {
        if (!(config = pa_parse_droid_audio_config(manual_config)))
            pa_log("Failed to parse configuration from %s", manual_config);
    } else {
        int i;
        for (i = 0; config_location[i]; i++) {
            if ((config = pa_parse_droid_audio_config(config_location[i])))
                break;
            else
                pa_log_debug("Failed to parse configuration from %s", config_location[i]);
        }

    }

    if (!config)
        pa_log("Failed to parse any configuration.");

    return config;
}
{'fraction_non_alphanumeric': 0.1117952041477641, 'fraction_numerical': 0.008749189889825017, 'mean_word_length': 4.076480263157895, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4594049', 'n_tokens_mistral': 2156, 'n_tokens_neox': 2120, 'n_words': 530}