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

Commit 94a5bdc4 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: change dts notifier nodes path to satisfy seandroid policy"

parents 256de84a 79b9859f
Loading
Loading
Loading
Loading

hal/audio_extn/AudioUtil.c

deleted100644 → 0
+0 −130
Original line number Diff line number Diff line
/*Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* This file was modified by DTS, Inc. The portions of the
* code modified by DTS, Inc are copyrighted and
* licensed separately, as follows:
*
*  (C) 2014 DTS, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#define LOG_TAG "AudioUtil"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include <stdlib.h>

#include <cutils/properties.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sound/devdep_params.h>
#include <sound/asound.h>
#include "AudioUtil.h"

#define ROUTE_PATH    "/data/data/dts/route"
#define DEVICE_NODE   "/dev/snd/hwC0D3"

static int32_t mDevices = 0;
static int32_t mCurrDevice = 0;

void create_route_node(void)
{
    char prop[PROPERTY_VALUE_MAX] = "true";
    int fd;
    property_get("use.dts_eagle", prop, "0");
    if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) {
        ALOGV("create_route_node");
        if ((fd=open(ROUTE_PATH, O_RDONLY)) < 0) {
            ALOGV("No File exisit");
        } else {
            ALOGV("A file with the same name exist. Remove it before creating it");
            close(fd);
            remove(ROUTE_PATH);
        }
        if ((fd=creat(ROUTE_PATH, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
            ALOGE("opening route node failed returned");
            return;
        }
        chmod(ROUTE_PATH, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH);
        ALOGV("opening route  node successful");
        close(fd);
    }
}

void notify_route_node(int active_device, int devices)
{
    char prop[PROPERTY_VALUE_MAX] = "true";
    char buf[1024];
    int fd;
    if ((mCurrDevice == active_device) &&
        (mDevices == devices)) {
        ALOGV("nothing to update to route node");
        return;
    }
    mDevices = devices;
    mCurrDevice = active_device;
    property_get("use.dts_eagle", prop, "0");
    if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) {
        ALOGV("notify active device : %d all_devices : %d", active_device, devices);
        if ((fd=open(ROUTE_PATH, O_TRUNC|O_WRONLY)) < 0) {
            ALOGV("Write device to route node failed");
        } else {
            ALOGV("Write device to route node successful");
            snprintf(buf, sizeof(buf), "device=%d;all_devices=%d", active_device, devices);
            int n = write(fd, buf, strlen(buf));
            ALOGV("number of bytes written: %d", n);
            close(fd);
        }
        int eaglefd = open(DEVICE_NODE, O_RDWR);
        int32_t params[2] = {active_device, 1 /*is primary device*/};
        if (eaglefd > 0) {
            if(ioctl(eaglefd, DTS_EAGLE_IOCTL_SET_ACTIVE_DEVICE, &params) < 0) {
                ALOGE("DTS_EAGLE (%s): error sending primary device\n", __func__);
            }
            ALOGD("DTS_EAGLE (%s): sent primary device\n", __func__);
            close(eaglefd);
        } else {
            ALOGE("DTS_EAGLE (%s): error opening eagle\n", __func__);
        }
    }
}

void remove_route_node(void)
{
    char prop[PROPERTY_VALUE_MAX] = "true";
    int fd;
    property_get("use.dts_eagle", prop, "0");
    if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) {
        ALOGV("remove_route_node");
        if ((fd=open(ROUTE_PATH, O_RDONLY)) < 0) {
            ALOGV("open route  node failed");
        } else {
            ALOGV("open route node successful");
            ALOGV("Remove the file");
            close(fd);
            remove(ROUTE_PATH);
        }
    }
}

hal/audio_extn/AudioUtil.h

deleted100644 → 0
+0 −46
Original line number Diff line number Diff line
/*Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* This file was modified by DTS, Inc. The portions of the
* code modified by DTS, Inc are copyrighted and
* licensed separately, as follows:
*
*  (C) 2014 DTS, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef AUDIO_UTIL_H_
#define AUDIO_UTIL_H_

#ifndef DTS_EAGLE
#define create_route_node() (0)
#define notify_route_node(active_device, devices) (0)
#define remove_route_node() (0)
#else
void create_route_node(void);
void notify_route_node(int active_device, int devices);
void remove_route_node(void);
#endif

#endif  //AUDIO_UTIL_H_
+2 −2
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@
#ifdef DTS_EAGLE

#define AUDIO_PARAMETER_KEY_DTS_EAGLE   "DTS_EAGLE"
#define STATE_NOTIFY_FILE               "/data/data/dts/stream"
#define FADE_NOTIFY_FILE                "/data/data/dts/fade"
#define STATE_NOTIFY_FILE               "/data/misc/dts/stream"
#define FADE_NOTIFY_FILE                "/data/misc/dts/fade"
#define DTS_EAGLE_KEY                   "DTS_EAGLE"
#define DEVICE_NODE                     "/dev/snd/hwC0D3"
#define MAX_LENGTH_OF_INTEGER_IN_STRING 13
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ static const char *paramList[10] = {
                              "bassboost_param_strength"
};

#define EFFECT_FILE "/data/data/dts/effect"
#define EFFECT_FILE "/data/misc/dts/effect"
#define MAX_LENGTH_OF_INTEGER_IN_STRING 13

#ifdef DTS_EAGLE