Exemple #1
0
void PannerBankNode::strategyChanged() {
	int newStrategy = getProperty(Lav_PANNER_STRATEGY).getIntValue();
	int newChannels =0;
	switch(newStrategy) {
		case Lav_PANNING_STRATEGY_STEREO:
		newChannels=2;
		break;
		case Lav_PANNING_STRATEGY_HRTF:
		newChannels =2;
		break;
		case Lav_PANNING_STRATEGY_SURROUND51:
		newChannels=6;
		break;
		case Lav_PANNING_STRATEGY_SURROUND71:
		newChannels=8;
		break;
		default:
		newChannels=2;
		break;
	}
	output_gain->resize(newChannels, newChannels);
	output_gain->getInputConnection(0)->reconfigure(0, newChannels);
	output_gain->getOutputConnection(0)->reconfigure(0, newChannels);
	getOutputConnection(0)->reconfigure(0, newChannels);
}
bool IntelHWComposerDrm::detectMDSModeChange()
{

#ifdef TARGET_HAS_MULTIPLE_DISPLAY

    drmModeConnection hdmi = getOutputConnection(OUTPUT_HDMI);
    int mdsMode = 0;
    if (mMonitor != 0) {
        mdsMode = mMonitor->getDisplayMode();
        ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: get MDS Mode %d", __func__, mdsMode);
        //TODO: overlay only support OVERLAY_EXTEND and OVERLAY_MIPI0
        if (mdsMode == OVERLAY_EXTEND && hdmi == DRM_MODE_CONNECTED)
            setDisplayMode(OVERLAY_EXTEND);
        else if (mdsMode == OVERLAY_CLONE_MIPI0)
            setDisplayMode(OVERLAY_CLONE_MIPI0);
        else
            setDisplayMode(OVERLAY_MIPI0);
    } else
#endif
    {
        setDisplayMode(OVERLAY_MIPI0);
    }

    return true;
}
Exemple #3
0
void Node::connect(int output, std::shared_ptr<Node> toNode, int input) {
	if(doesEdgePreserveAcyclicity(std::static_pointer_cast<Node>(this->shared_from_this()), toNode) == false) ERROR(Lav_ERROR_CAUSES_CYCLE, "Connection would cause infinite loop.");
	auto outputConnection =getOutputConnection(output);
	auto inputConnection = toNode->getInputConnection(input);
	makeConnection(outputConnection, inputConnection);
	simulation->invalidatePlan();
}
Exemple #4
0
void BufferNode::bufferChanged() {
	auto buff = getProperty(Lav_BUFFER_BUFFER).getBufferValue();
	double maxPosition = 0.0;
	int newChannels= 0;
	if(buff==nullptr) {
		resize(0, 1);
		getOutputConnection(0)->reconfigure(0, 1);
	}
	else {
		newChannels = buff->getChannels() > 0 ? buff->getChannels() : 1;
		resize(0, newChannels);
		getOutputConnection(0)->reconfigure(0, newChannels);
		maxPosition =buff->getDuration();
	}
	player.setBuffer(buff);
	getProperty(Lav_BUFFER_POSITION).setDoubleValue(0.0); //the callback handles changing everything else.
	getProperty(Lav_BUFFER_POSITION).setDoubleRange(0.0, maxPosition);
}
void EnvironmentNode::willTick() {
	if(werePropertiesModified(this, Lav_ENVIRONMENT_OUTPUT_CHANNELS)) {
		int channels = getProperty(Lav_ENVIRONMENT_OUTPUT_CHANNELS).getIntValue();
		output->resize(channels, channels);
		getOutputConnection(0)->reconfigure(0, channels);
		output->getOutputConnection(0)->reconfigure(0, channels);
		output->getInputConnection(0)->reconfigure(0, channels);
	}
}
Exemple #6
0
void Node::connectProperty(int output, std::shared_ptr<Node> node, int slot) {
	if(doesEdgePreserveAcyclicity(std::static_pointer_cast<Node>(this->shared_from_this()), node) == false) ERROR(Lav_ERROR_CAUSES_CYCLE, "Connection would cause infinite loop.");
	auto &prop = node->getProperty(slot);
	auto conn = prop.getInputConnection();
	if(conn ==nullptr) ERROR(Lav_ERROR_CANNOT_CONNECT_TO_PROPERTY, "Property does not support connections.");
	auto outputConn =getOutputConnection(output);
	makeConnection(outputConn, conn);
	simulation->invalidatePlan();
}
Exemple #7
0
void MultipannerNode::strategyChanged() {
	int newStrategy = getProperty(Lav_PANNER_STRATEGY).getIntValue();
	int newOutputSize=2;
	bool hookHrtf = false, hookAmplitude = false;
	switch(newStrategy) {
		case Lav_PANNING_STRATEGY_HRTF:
		hookHrtf = true;
		break;
		case Lav_PANNING_STRATEGY_STEREO:
		std::dynamic_pointer_cast<AmplitudePannerNode>(amplitude_panner)->configureStandardChannelMap(2);
		hookAmplitude = true;
		break;
		case Lav_PANNING_STRATEGY_SURROUND40:
		std::dynamic_pointer_cast<AmplitudePannerNode>(amplitude_panner)->configureStandardChannelMap(4);
		hookAmplitude = true;
		newOutputSize = 4;
		break;
		case Lav_PANNING_STRATEGY_SURROUND51:
		std::dynamic_pointer_cast<AmplitudePannerNode>(amplitude_panner)->configureStandardChannelMap(6);
		hookAmplitude = true;
		newOutputSize=6;
		break;
		case Lav_PANNING_STRATEGY_SURROUND71:
		std::dynamic_pointer_cast<AmplitudePannerNode>(amplitude_panner)->configureStandardChannelMap(8);
		hookAmplitude=true;
		newOutputSize=8;
		break;
	}
	if(hookAmplitude) {
		getOutputConnection(0)->reconfigure(0, newOutputSize);
		setOutputNode(amplitude_panner);
		current_panner = amplitude_panner;
	}
	if(hookHrtf) {
		getOutputConnection(0)->reconfigure(0, 2);
		setOutputNode(hrtf_panner);
		current_panner = hrtf_panner;
	}
}
Exemple #8
0
void CsvSourceComponent::gaussPropagation(double z)
{
    int resolution = 0;
    QFile intensityFile(intensityDataPath);
    if (!intensityFile.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        qDebug() << "Could not open file " + intensityDataPath;
        resolution = 256;
    }
    else
    {
        while (!intensityFile.atEnd())
        {
            intensityFile.readLine();
            resolution++;
        }
    }
    intensityFile.close();
    double w = stepSize * resolution  / std::sqrt(M_PI * resolution);
    getOutputConnection()->setData(
                PipelineSpectrumData::createGaussSpectrumData(spectrum, w, 0.0, 1.0, resolution));
}
bool IntelHWComposerDrm::detectDrmModeInfo()
{
    ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: detecting drm mode info...\n", __func__);

    if (mDrmFd < 0) {
        ALOGE("%s: invalid drm FD\n", __func__);
        return false;
    }

    /*try to get drm resources*/
    drmModeResPtr resources = drmModeGetResources(mDrmFd);
    if (!resources || !resources->connectors) {
        ALOGE("%s: fail to get drm resources. %s\n", __func__, strerror(errno));
        return false;
    }

    /*get mipi0 info*/
    drmModeConnectorPtr connector = NULL;
    drmModeEncoderPtr encoder = NULL;
    drmModeCrtcPtr crtc = NULL;
    drmModeConnectorPtr connectors[OUTPUT_MAX];
    drmModeModeInfoPtr mode = NULL;
    drmModeFBPtr fbInfo = NULL;

    for (int i = 0; i < resources->count_connectors; i++) {
        connector = drmModeGetConnector(mDrmFd, resources->connectors[i]);
        if (!connector) {
            ALOGW("%s: fail to get drm connector\n", __func__);
            continue;
        }

        int outputIndex = -1;
        if (connector->connector_type == DRM_MODE_CONNECTOR_MIPI ||
            connector->connector_type == DRM_MODE_CONNECTOR_LVDS) {
            ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: got MIPI/LVDS connector\n", __func__);
            if (connector->connector_type_id == 1)
                outputIndex = OUTPUT_MIPI0;
            else if (connector->connector_type_id == 2)
                outputIndex = OUTPUT_MIPI1;
            else {
                ALOGW("%s: unknown connector type\n", __func__);
                outputIndex = OUTPUT_MIPI0;
            }
        } else if (connector->connector_type == DRM_MODE_CONNECTOR_DVID) {
            ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: got HDMI connector\n", __func__);
            outputIndex = OUTPUT_HDMI;
        }

        /*update connection status*/
        setOutputConnection(outputIndex, connector->connection);

        /*get related encoder*/
        encoder = drmModeGetEncoder(mDrmFd, connector->encoder_id);
        if (!encoder) {
            ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: fail to get drm encoder\n", __func__);
            drmModeFreeConnector(connector);
            setOutputConnection(outputIndex, DRM_MODE_DISCONNECTED);
            continue;
        }

        /*get related crtc*/
        crtc = drmModeGetCrtc(mDrmFd, encoder->crtc_id);
        if (!crtc) {
            ALOGD_IF(ALLOW_MONITOR_PRINT, "%s: fail to get drm crtc\n", __func__);
            drmModeFreeEncoder(encoder);
            drmModeFreeConnector(connector);
            setOutputConnection(outputIndex, DRM_MODE_DISCONNECTED);
            continue;
        }
        /*set crtc mode*/
        setOutputMode(outputIndex, &crtc->mode, crtc->mode_valid);

        // get fb info
        fbInfo = drmModeGetFB(mDrmFd, crtc->buffer_id);
        if (!fbInfo) {
            ALOGD("%s: fail to get fb info\n", __func__);
            drmModeFreeCrtc(crtc);
            drmModeFreeEncoder(encoder);
            drmModeFreeConnector(connector);
            setOutputConnection(outputIndex, DRM_MODE_DISCONNECTED);
            continue;
        }

        setOutputFBInfo(outputIndex, fbInfo);

        /*free all crtc/connector/encoder*/
        drmModeFreeFB(fbInfo);
        drmModeFreeCrtc(crtc);
        drmModeFreeEncoder(encoder);
        drmModeFreeConnector(connector);
    }

    drmModeFreeResources(resources);

    drmModeConnection mipi0 = getOutputConnection(OUTPUT_MIPI0);
    drmModeConnection mipi1 = getOutputConnection(OUTPUT_MIPI1);
    drmModeConnection hdmi = getOutputConnection(OUTPUT_HDMI);

    detectMDSModeChange();

    ALOGD_IF(ALLOW_MONITOR_PRINT,
           "%s: mipi/lvds %s, mipi1 %s, hdmi %s, displayMode %d\n",
        __func__,
        ((mipi0 == DRM_MODE_CONNECTED) ? "connected" : "disconnected"),
        ((mipi1 == DRM_MODE_CONNECTED) ? "connected" : "disconnected"),
        ((hdmi == DRM_MODE_CONNECTED) ? "connected" : "disconnected"),
        getDisplayMode());

    return true;
}
Exemple #10
0
void CsvSourceComponent::fourierPropagation(double z)
{
    int resolution = 256;
    QFile intensityFile(intensityDataPath);
    if (intensityDataPath.isNull() || intensityDataPath.isEmpty() ||
            !intensityFile.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        qDebug() << "Could not open file " + intensityDataPath;
        getOutputConnection()->setData(
                    PipelineSpectrumData::createFourierSpectrumData(spectrum, resolution, stepSize));
        return;
    }
    QList<QString> intensityLines;
    int rows = 0;
    while (!intensityFile.atEnd())
    {
        intensityLines << intensityFile.readLine();
        rows++;
    }
    intensityFile.close();

    QFile phaseFile(phaseDataPath);
    QList<QString> phaseLines;
    if (phaseDataPath.isNull() || phaseDataPath.isEmpty() ||
            phaseFile.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        while (!phaseFile.atEnd())
        {
            phaseLines << phaseFile.readLine();
        }
    }
    phaseFile.close();

    int cols = intensityLines.first().split(",").size();
    resolution = qMin(rows, cols);
    PipelineSpectrumData* spectrumData =
            PipelineSpectrumData::createFourierSpectrumData(spectrum, resolution, stepSize);
    for(int k = 0; k < spectrum.size(); k++)
    {
        FourierPipelineData* data = spectrumData->getData<FourierPipelineData>(k);
        for(int i = 0; i < resolution; i++)
        {
            QStringList intVals = intensityLines[i].split(",");
            QStringList phaseVals;
            if(i < phaseLines.size())
                phaseVals = phaseLines[i].split(csvSeparator);
            for(int j = 0; j < resolution; j++)
            {
                double intensity = 0;
                if(j < intVals.size())
                    intensity = intVals.at(j).toDouble();
                double phase = 0;
                if(j < phaseVals.size())
                    phase = phaseVals.at(j).toDouble();
                double abs = std::sqrt(intensity);
                data->ComplexAmplitude->set(i, j, std::complex<double>(abs*std::cos(phase), abs*std::sin(phase)));
            }
        }
    }
    getOutputConnection()->setData(spectrumData);
}
Exemple #11
0
void Node::disconnect(int which) {
	auto o =getOutputConnection(which);
	o->clear();
	simulation->invalidatePlan();
}
Exemple #12
0
void Node::connectSimulation(int which) {
	auto outputConnection=getOutputConnection(which);
	auto inputConnection = simulation->getFinalOutputConnection();
	makeConnection(outputConnection, inputConnection);
	simulation->invalidatePlan();
}