TInt COpenMAXALTestModule::al_audioiodevcapitf_QuerySampleFormatsSupported( CStifItemParser& aItem )
    {
    TInt status(KErrNone);
    XAresult res;
    TInt sizeArr(0);
    TUint deviceId(0);
    TInt samplerate(0);
    XAuint32 devId(0);
    XAmilliHertz samplingrate;
    XAint32 deviceIdArr[20];
    XAint32 numSampleRates(0);
    
    status = aItem.GetNextInt(deviceId);
    if(!status)
        {
        devId = deviceId;
        status = aItem.GetNextInt(samplerate);
        if(!status)
            {
            samplingrate = samplerate;
            status = aItem.GetNextInt(sizeArr);
            if(!status)
                {
                numSampleRates = sizeArr;
                if(m_AIODevCapItf)
                    {
                    res = (*m_AIODevCapItf)->QuerySampleFormatsSupported(
                            m_AIODevCapItf, devId, samplingrate, deviceIdArr, &numSampleRates);
                    status = res;
                    }
                else
                    {
                    status = KErrNotFound;
                    }        
                }
            else
                {
                if(m_AIODevCapItf)
                    {
                    res = (*m_AIODevCapItf)->QuerySampleFormatsSupported(
                            m_AIODevCapItf, devId, samplingrate, NULL, &numSampleRates);
                    status = res;
                    }
                else
                    {
                    status = KErrNotFound;
                    }        
                }
            }
        else
            {
            status = KErrGeneral;
            }
        }
    else
        {
        status = KErrGeneral;
        }
    return status;
    }
예제 #2
0
void IosRunner::start()
{
    if (m_toolHandler) {
        m_toolHandler->stop();
        emit finished(m_cleanExit);
    }
    m_cleanExit = false;
    IosToolHandler::DeviceType devType = IosToolHandler::IosDeviceType;
    if (m_device->type() != Ios::Constants::IOS_DEVICE_TYPE) {
        IosSimulator::ConstPtr sim = m_device.dynamicCast<const IosSimulator>();
        if (sim.isNull()) {
            emit finished(m_cleanExit);
            return;
        }
        devType = IosToolHandler::IosSimulatedIphoneRetina4InchType; // store type in sim?
    }
    m_toolHandler = new IosToolHandler(devType, this);
    connect(m_toolHandler, SIGNAL(appOutput(Ios::IosToolHandler*,QString)),
            SLOT(handleAppOutput(Ios::IosToolHandler*,QString)));
    connect(m_toolHandler,
            SIGNAL(didStartApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)),
            SLOT(handleDidStartApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)));
    connect(m_toolHandler, SIGNAL(errorMsg(Ios::IosToolHandler*,QString)),
            SLOT(handleErrorMsg(Ios::IosToolHandler*,QString)));
    connect(m_toolHandler, SIGNAL(gotGdbserverPort(Ios::IosToolHandler*,QString,QString,int)),
            SLOT(handleGotGdbserverPort(Ios::IosToolHandler*,QString,QString,int)));
    connect(m_toolHandler, SIGNAL(gotInferiorPid(Ios::IosToolHandler*,QString,QString,Q_PID)),
            SLOT(handleGotInferiorPid(Ios::IosToolHandler*,QString,QString,Q_PID)));
    connect(m_toolHandler, SIGNAL(toolExited(Ios::IosToolHandler*,int)),
            SLOT(handleToolExited(Ios::IosToolHandler*,int)));
    connect(m_toolHandler, SIGNAL(finished(Ios::IosToolHandler*)),
            SLOT(handleFinished(Ios::IosToolHandler*)));
    m_toolHandler->requestRunApp(bundlePath(), extraArgs(), runType(), deviceId());
}
예제 #3
0
void IosDeployStep::run(QFutureInterface<bool> &fi)
{
    m_futureInterface = fi;
    QTC_CHECK(m_transferStatus == NoTransfer);
    if (iosdevice().isNull()) {
        m_futureInterface.reportResult(!iossimulator().isNull());
        cleanup();
        m_futureInterface.reportFinished();
        return;
    }
    m_transferStatus = TransferInProgress;
    IosToolHandler *toolHandler = new IosToolHandler(IosToolHandler::IosDeviceType, this);
    m_futureInterface.setProgressRange(0, 200);
    m_futureInterface.setProgressValueAndText(0, QLatin1String("Transferring application"));
    m_futureInterface.reportStarted();
    connect(toolHandler, SIGNAL(isTransferringApp(Ios::IosToolHandler*,QString,QString,int,int,QString)),
            SLOT(handleIsTransferringApp(Ios::IosToolHandler*,QString,QString,int,int,QString)));
    connect(toolHandler, SIGNAL(didTransferApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)),
            SLOT(handleDidTransferApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)));
    connect(toolHandler, SIGNAL(finished(Ios::IosToolHandler*)),
            SLOT(handleFinished(Ios::IosToolHandler*)));
    connect(toolHandler, SIGNAL(errorMsg(Ios::IosToolHandler*,QString)),
            SLOT(handleErrorMsg(Ios::IosToolHandler*,QString)));
    toolHandler->requestTransferApp(appBundle(), deviceId());
}
예제 #4
0
void IosDeployStep::run(QFutureInterface<bool> &fi)
{
    m_futureInterface = fi;
    QTC_CHECK(m_transferStatus == NoTransfer);
    if (iosdevice().isNull()) {
        if (iossimulator().isNull())
            TaskHub::addTask(Task::Error, tr("Deployment failed. No iOS device found."),
                             ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
        m_futureInterface.reportResult(!iossimulator().isNull());
        cleanup();
        emit finished();
        return;
    }
    m_transferStatus = TransferInProgress;
    QTC_CHECK(m_toolHandler == 0);
    m_toolHandler = new IosToolHandler(IosDeviceType::IosDevice, this);
    m_futureInterface.setProgressRange(0, 200);
    m_futureInterface.setProgressValueAndText(0, QLatin1String("Transferring application"));
    m_futureInterface.reportStarted();
    connect(m_toolHandler, SIGNAL(isTransferringApp(Ios::IosToolHandler*,QString,QString,int,int,QString)),
            SLOT(handleIsTransferringApp(Ios::IosToolHandler*,QString,QString,int,int,QString)));
    connect(m_toolHandler, SIGNAL(didTransferApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)),
            SLOT(handleDidTransferApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)));
    connect(m_toolHandler, SIGNAL(finished(Ios::IosToolHandler*)),
            SLOT(handleFinished(Ios::IosToolHandler*)));
    connect(m_toolHandler, SIGNAL(errorMsg(Ios::IosToolHandler*,QString)),
            SLOT(handleErrorMsg(Ios::IosToolHandler*,QString)));
    m_toolHandler->requestTransferApp(appBundle(), deviceId());
}
TInt COpenMAXALTestModule::al_audioiodevcapitf_QueryAudioOutputCapabilities( CStifItemParser& aItem )
    {
    TInt status(KErrNone);
    XAAudioOutputDescriptor outputDesc;
    XAresult res;
    TUint deviceId(0);
    XAuint32 devId(0);
    
    status = aItem.GetNextInt(deviceId);
    if(!status)
        {
        devId = deviceId;
        if(m_AIODevCapItf)
            {
            res = (*m_AIODevCapItf)->QueryAudioOutputCapabilities(
                    m_AIODevCapItf, devId, &outputDesc);
            status = res;
            }
        else
            {
            status = KErrNotFound;
            } 
        }
    return status;
    }
예제 #6
0
/**
 * Updates the current list of active devices
 */
void DeviceManager::updateDeviceList()
{
    //fetch list of current devices
    GstElement *audioSink= createAudioSink();

    QList<QByteArray> list;

    if (audioSink) {
        if (!PulseSupport::getInstance()->isActive()) {
            // If we're using pulse, the PulseSupport class takes care of things for us.
            list = GstHelper::extractProperties(audioSink, "device");
            list.prepend("default");
        }

        for (int i = 0 ; i < list.size() ; ++i) {
            QByteArray gstId = list.at(i);
            if (deviceId(gstId) == -1) {
                // This is a new device, add it
                m_audioDeviceList.append(AudioDevice(this, gstId));
                emit deviceAdded(deviceId(gstId));
                m_backend->logMessage(QString("Found new audio device %0").arg(QString::fromUtf8(gstId)), Backend::Debug, this);
            }
        }

        if (list.size() < m_audioDeviceList.size()) {
            //a device was removed
            for (int i = m_audioDeviceList.size() -1 ; i >= 0 ; --i) {
                QByteArray currId = m_audioDeviceList[i].gstId;
                bool found = false;
                for (int k = list.size() -1  ; k >= 0 ; --k) {
                    if (currId == list[k]) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    m_backend->logMessage(QString("Audio device lost %0").arg(QString::fromUtf8(currId)), Backend::Debug, this);
                    emit deviceRemoved(deviceId(currId));
                    m_audioDeviceList.removeAt(i);
                }
            }
        }
    }

    gst_element_set_state (audioSink, GST_STATE_NULL);
    gst_object_unref (audioSink);
}
예제 #7
0
ScriptValue MediaDeviceInfo::toJSONForBinding(ScriptState* scriptState)
{
    V8ObjectBuilder result(scriptState);
    result.addString("deviceId", deviceId());
    result.addString("kind", kind());
    result.addString("label", label());
    result.addString("groupId", groupId());
    return result.scriptValue();
}
예제 #8
0
void IosRunner::start()
{
    if (m_toolHandler) {
        m_toolHandler->stop();
        emit finished(m_cleanExit);
    }
    m_cleanExit = false;
    m_qmlPort = 0;
    if (!QFileInfo(m_bundleDir).exists()) {
        TaskHub::addTask(Task::Warning,
                         tr("Could not find %1.").arg(m_bundleDir),
                         ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
        emit finished(m_cleanExit);
        return;
    }
    if (m_device->type() == Ios::Constants::IOS_DEVICE_TYPE) {
        IosDevice::ConstPtr iosDevice = m_device.dynamicCast<const IosDevice>();
        if (m_device.isNull()) {
            emit finished(m_cleanExit);
            return;
        }
        if (m_qmlDebug)
            m_qmlPort = iosDevice->nextPort();
    } else {
        IosSimulator::ConstPtr sim = m_device.dynamicCast<const IosSimulator>();
        if (sim.isNull()) {
            emit finished(m_cleanExit);
            return;
        }
        if (m_qmlDebug)
            m_qmlPort = sim->nextPort();
    }

    m_toolHandler = new IosToolHandler(m_deviceType, this);
    connect(m_toolHandler, SIGNAL(appOutput(Ios::IosToolHandler*,QString)),
            SLOT(handleAppOutput(Ios::IosToolHandler*,QString)));
    connect(m_toolHandler,
            SIGNAL(didStartApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)),
            SLOT(handleDidStartApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)));
    connect(m_toolHandler, SIGNAL(errorMsg(Ios::IosToolHandler*,QString)),
            SLOT(handleErrorMsg(Ios::IosToolHandler*,QString)));
    connect(m_toolHandler, SIGNAL(gotServerPorts(Ios::IosToolHandler*,QString,QString,int,int)),
            SLOT(handleGotServerPorts(Ios::IosToolHandler*,QString,QString,int,int)));
    connect(m_toolHandler, SIGNAL(gotInferiorPid(Ios::IosToolHandler*,QString,QString,Q_PID)),
            SLOT(handleGotInferiorPid(Ios::IosToolHandler*,QString,QString,Q_PID)));
    connect(m_toolHandler, SIGNAL(toolExited(Ios::IosToolHandler*,int)),
            SLOT(handleToolExited(Ios::IosToolHandler*,int)));
    connect(m_toolHandler, SIGNAL(finished(Ios::IosToolHandler*)),
            SLOT(handleFinished(Ios::IosToolHandler*)));
    m_toolHandler->requestRunApp(bundlePath(), extraArgs(), runType(), deviceId());
}
예제 #9
0
void IosRunner::start()
{
    if (m_toolHandler) {
        m_toolHandler->stop();
        emit finished(m_cleanExit);
    }
    m_cleanExit = false;
    m_qmlPort = 0;
    if (!QFileInfo::exists(m_bundleDir)) {
        TaskHub::addTask(Task::Warning,
                         tr("Could not find %1.").arg(m_bundleDir),
                         ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
        emit finished(m_cleanExit);
        return;
    }
    if (m_device->type() == Ios::Constants::IOS_DEVICE_TYPE) {
        IosDevice::ConstPtr iosDevice = m_device.dynamicCast<const IosDevice>();
        if (m_device.isNull()) {
            emit finished(m_cleanExit);
            return;
        }
        if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices)
            m_qmlPort = iosDevice->nextPort();
    } else {
        IosSimulator::ConstPtr sim = m_device.dynamicCast<const IosSimulator>();
        if (sim.isNull()) {
            emit finished(m_cleanExit);
            return;
        }
        if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices)
            m_qmlPort = sim->nextPort();
    }

    m_toolHandler = new IosToolHandler(m_deviceType, this);
    connect(m_toolHandler, &IosToolHandler::appOutput,
            this, &IosRunner::handleAppOutput);
    connect(m_toolHandler, &IosToolHandler::didStartApp,
            this, &IosRunner::handleDidStartApp);
    connect(m_toolHandler, &IosToolHandler::errorMsg,
            this, &IosRunner::handleErrorMsg);
    connect(m_toolHandler, &IosToolHandler::gotServerPorts,
            this, &IosRunner::handleGotServerPorts);
    connect(m_toolHandler, &IosToolHandler::gotInferiorPid,
            this, &IosRunner::handleGotInferiorPid);
    connect(m_toolHandler, &IosToolHandler::toolExited,
            this, &IosRunner::handleToolExited);
    connect(m_toolHandler, &IosToolHandler::finished,
            this, &IosRunner::handleFinished);
    m_toolHandler->requestRunApp(bundlePath(), extraArgs(), runType(), deviceId());
}
TInt COpenMAXALTestModule::al_audioiodevcapitf_GetDefaultAudioDevices( CStifItemParser& aItem )
    {
    TInt status(KErrNone);
    XAresult res;
    
    TUint deviceId(0);
    TInt sizeArr(0);
    XAuint32 devId(0);
    XAint32 numOutputs(0);
    XAuint32 deviceIdArr[2];
    
    status = aItem.GetNextInt(deviceId, EHex);
    if(!status)
        {
        devId = deviceId;
        status = aItem.GetNextInt(sizeArr);
        if(!status)
            {
            numOutputs = sizeArr;
            if(m_AIODevCapItf)
                {
                res = (*m_AIODevCapItf)->GetDefaultAudioDevices(
                        m_AIODevCapItf, devId, &numOutputs, deviceIdArr);
                status = res;
                }
            else
                {
                status = KErrNotFound;
                }        
            }
        else
            {
            if(m_AIODevCapItf)
                {
                res = (*m_AIODevCapItf)->GetDefaultAudioDevices(
                        m_AIODevCapItf, devId,&numOutputs, NULL);
                status = res;
                }
            else
                {
                status = KErrNotFound;
                }                
            }
        }
    else
        {
        status = KErrGeneral;
        }
    return status;
    }
예제 #11
0
PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(MediaStream* mediaStream, ExceptionCode& ec)
{
    ASSERT(mediaStream);
    if (!mediaStream) {
        ec = INVALID_STATE_ERR;
        return nullptr;
    }

    ASSERT(isMainThread());
    lazyInitialize();

    AudioSourceProvider* provider = 0;

    Vector<RefPtr<MediaStreamTrack>> audioTracks = mediaStream->getAudioTracks();
    RefPtr<MediaStreamTrack> audioTrack;

    // FIXME: get a provider for non-local MediaStreams (like from a remote peer).
    for (size_t i = 0; i < audioTracks.size(); ++i) {
        audioTrack = audioTracks[i];
        if (audioTrack->source()->isAudioStreamSource()) {
            auto source = static_cast<MediaStreamAudioSource*>(audioTrack->source());
            ASSERT(!source->deviceId().isEmpty());
            destination()->enableInput(source->deviceId());
            provider = destination()->localAudioInputProvider();
            break;
        }
    }

    RefPtr<MediaStreamAudioSourceNode> node = MediaStreamAudioSourceNode::create(this, mediaStream, audioTrack.get(), provider);

    // FIXME: Only stereo streams are supported right now. We should be able to accept multi-channel streams.
    node->setFormat(2, sampleRate());

    refNode(node.get()); // context keeps reference until node is disconnected
    return node;
}
예제 #12
0
/* readonly attribute DOMString DisplayChipset; */
NS_IMETHODIMP nsSystemInfo::GetDisplayChipset(nsAString & aDisplayChipset)
{
  nsCString deviceId(mDeviceID);
  ToUpperCase(deviceId);
  PRInt32 pos = deviceId.Find(NS_LITERAL_CSTRING("&DEV_"));
  if (pos != -1) {
    deviceId.Cut(0, pos + 5);
  }
  pos = deviceId.Find(NS_LITERAL_CSTRING("&"));
  if (pos != -1) {
    deviceId.Cut(pos, deviceId.Length());
  }
  aDisplayChipset.AssignLiteral("0x");
  aDisplayChipset.AppendLiteral(deviceId.BeginReading());
  return NS_OK;
}
    std::string OCSecureResource::getDeviceID()
    {
        char base64Buff[B64ENCODE_OUT_SAFESIZE(sizeof(((OicUuid_t*)0)->id)) + 1] = {0,};
        uint32_t outLen = 0;
        B64Result b64Ret = B64_OK;
        std::ostringstream deviceId("");

        validateSecureResource();
        b64Ret = b64Encode(devPtr->doxm->deviceID.id, sizeof(devPtr->doxm->deviceID.id), base64Buff,
                sizeof(base64Buff), &outLen);

        if (B64_OK == b64Ret)
        {
            deviceId << base64Buff;
        }
        return deviceId.str();
    }
TInt COpenMAXALTestModule::al_audioiodevcapitf_GetAvailableAudioInputs( CStifItemParser& aItem )
    {
    TInt status(KErrNone);
    XAresult res;
    
    TInt deviceId(0);
    XAint32 devId;
    XAuint32* deviceIdArr(NULL);
    
    status = aItem.GetNextInt(deviceId);
    if(!status)
        {
        devId = deviceId;
        if(m_AIODevCapItf)
            {
            res = (*m_AIODevCapItf)->GetAvailableAudioInputs(
                    m_AIODevCapItf, &devId, deviceIdArr);
            status = res;
            }
        else
            {
            status = KErrNotFound;
            }        
        }
    else
        {
        if(m_AIODevCapItf)
            {
            res = (*m_AIODevCapItf)->GetAvailableAudioInputs(
                    m_AIODevCapItf, &devId, NULL);
            status = res;
            }
        else
            {
            status = KErrNotFound;
            }        
        }
    return status;
    }
예제 #15
0
void RHD2000Thread::scanPorts()
{
	if (!deviceFound) //Safety to avoid crashes if board not present
	{
		return;
	}
    // Scan SPI ports

    int delay, stream, id;
    //int numChannelsOnPort[4] = {0, 0, 0, 0};
    Array<int> chipId;
    chipId.insertMultiple(0,-1,8);

    setSampleRate(16, true); // set to 30 kHz temporarily

    // Enable all data streams, and set sources to cover one or two chips
    // on Ports A-D.
    evalBoard->setDataSource(0, Rhd2000EvalBoard::PortA1);
    evalBoard->setDataSource(1, Rhd2000EvalBoard::PortA2);
    evalBoard->setDataSource(2, Rhd2000EvalBoard::PortB1);
    evalBoard->setDataSource(3, Rhd2000EvalBoard::PortB2);
    evalBoard->setDataSource(4, Rhd2000EvalBoard::PortC1);
    evalBoard->setDataSource(5, Rhd2000EvalBoard::PortC2);
    evalBoard->setDataSource(6, Rhd2000EvalBoard::PortD1);
    evalBoard->setDataSource(7, Rhd2000EvalBoard::PortD2);

    evalBoard->enableDataStream(0, true);
    evalBoard->enableDataStream(1, true);
    evalBoard->enableDataStream(2, true);
    evalBoard->enableDataStream(3, true);
    evalBoard->enableDataStream(4, true);
    evalBoard->enableDataStream(5, true);
    evalBoard->enableDataStream(6, true);
    evalBoard->enableDataStream(7, true);

    std::cout << "Number of enabled data streams: " << evalBoard->getNumEnabledDataStreams() << std::endl;


    evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortA,
                                    Rhd2000EvalBoard::AuxCmd3, 0);
    evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortB,
                                    Rhd2000EvalBoard::AuxCmd3, 0);
    evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortC,
                                    Rhd2000EvalBoard::AuxCmd3, 0);
    evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortD,
                                    Rhd2000EvalBoard::AuxCmd3, 0);

    // Since our longest command sequence is 60 commands, we run the SPI
    // interface for 60 samples.
    evalBoard->setMaxTimeStep(60);
    evalBoard->setContinuousRunMode(false);

    Rhd2000DataBlock* dataBlock =
        new Rhd2000DataBlock(evalBoard->getNumEnabledDataStreams());

    Array<int> sumGoodDelays;
    sumGoodDelays.insertMultiple(0,0,8);

    Array<int> indexFirstGoodDelay;
    indexFirstGoodDelay.insertMultiple(0,-1,8);

    Array<int> indexSecondGoodDelay;
    indexSecondGoodDelay.insertMultiple(0,-1,8);


    // Run SPI command sequence at all 16 possible FPGA MISO delay settings
    // to find optimum delay for each SPI interface cable.

    std::cout << "Checking for connected amplifier chips..." << std::endl;

    for (delay = 0; delay < 16; delay++)//(delay = 0; delay < 16; ++delay)
    {
        evalBoard->setCableDelay(Rhd2000EvalBoard::PortA, delay);
        evalBoard->setCableDelay(Rhd2000EvalBoard::PortB, delay);
        evalBoard->setCableDelay(Rhd2000EvalBoard::PortC, delay);
        evalBoard->setCableDelay(Rhd2000EvalBoard::PortD, delay);

        // Start SPI interface.
        evalBoard->run();

        // Wait for the 60-sample run to complete.
        while (evalBoard->isRunning())
        {
            ;
        }

        // Read the resulting single data block from the USB interface.
        evalBoard->readDataBlock(dataBlock);

        // Read the Intan chip ID number from each RHD2000 chip found.
        // Record delay settings that yield good communication with the chip.
        for (stream = 0; stream < MAX_NUM_DATA_STREAMS; ++stream)//MAX_NUM_DATA_STREAMS; ++stream)
        {
            // std::cout << "Stream number " << stream << ", delay = " << delay << std::endl;

            id = deviceId(dataBlock, stream);

            if (id > 0) // 1 = RHD2132, 2 = RHD2216
            {
                //  std::cout << "Device ID found: " << id << std::endl;

                sumGoodDelays.set(stream,sumGoodDelays[stream] + 1);

                if (indexFirstGoodDelay[stream] == -1)
                {
                    indexFirstGoodDelay.set(stream, delay);
                    chipId.set(stream,id);
                }
                else if (indexSecondGoodDelay[stream] == -1)
                {
                    indexSecondGoodDelay.set(stream,delay);
                    chipId.set(stream,id);
                }
            }
        }
    }

    // std::cout << "Chip IDs found: ";
    // for (int i = 0; i < MAX_NUM_DATA_STREAMS; ++i)
    // {
    //     std::cout << chipId[i] << " ";
    // }
    //std::cout << std::endl;

    // Now, disable data streams where we did not find chips present.
    for (stream = 0; stream < MAX_NUM_DATA_STREAMS; ++stream)
    {
        if (chipId[stream] > 0)
        {
            //std::cout << "Enabling headstage on stream " << stream << std::endl;
            enableHeadstage(stream, true);
        }
        else
        {
            enableHeadstage(stream, false);
        }
    }

    std::cout << "Number of enabled data streams: " << evalBoard->getNumEnabledDataStreams() << std::endl;


    // Set cable delay settings that yield good communication with each
    // RHD2000 chip.
    Array<int> optimumDelay;
    optimumDelay.insertMultiple(0,0,8);

    for (stream = 0; stream < MAX_NUM_DATA_STREAMS; ++stream)
    {
        if (sumGoodDelays[stream] == 1 || sumGoodDelays[stream] == 2)
        {
            optimumDelay.set(stream,indexFirstGoodDelay[stream]);
        }
        else if (sumGoodDelays[stream] > 2)
        {
            optimumDelay.set(stream,indexSecondGoodDelay[stream]);
        }
    }

    evalBoard->setCableDelay(Rhd2000EvalBoard::PortA,
                             optimumDelay[0]);
    evalBoard->setCableDelay(Rhd2000EvalBoard::PortB,
                             optimumDelay[1]);
    evalBoard->setCableDelay(Rhd2000EvalBoard::PortC,
                             optimumDelay[2]);
    evalBoard->setCableDelay(Rhd2000EvalBoard::PortD,
                             optimumDelay[3]);

    cableLengthPortA =
        evalBoard->estimateCableLengthMeters(optimumDelay[0]);
    cableLengthPortB =
        evalBoard->estimateCableLengthMeters(optimumDelay[1]);
    cableLengthPortC =
        evalBoard->estimateCableLengthMeters(optimumDelay[2]);
    cableLengthPortD =
        evalBoard->estimateCableLengthMeters(optimumDelay[3]);

    setSampleRate(savedSampleRateIndex); // restore saved sample rate

    updateRegisters();
}
예제 #16
0
void HMDDeviceFactory::EnumerateDevices(EnumerateVisitor& visitor)
{
    MonitorSet monitors;
    monitors.MonitorCount = 0;
    // Get all the monitor handles 
    EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&monitors);

    bool foundHMD = false;
    
   // DeviceManager* manager = getManager();
    DISPLAY_DEVICE dd, ddm;
    UINT           i, j;    

    for (i = 0; 
        (ZeroMemory(&dd, sizeof(dd)), dd.cb = sizeof(dd),
        EnumDisplayDevices(0, i, &dd, 0)) != 0;  i++)
    {
        
        /*
        wchar_t buff[500], flagsBuff[200];
        
        swprintf_s(buff, 500, L"\nDEV: \"%s\" \"%s\" 0x%08x=%s\n     \"%s\" \"%s\"\n",
            dd.DeviceName, dd.DeviceString,
            dd.StateFlags, FormatDisplayStateFlags(flagsBuff, 200, dd.StateFlags),
            dd.DeviceID, dd.DeviceKey);
        ::OutputDebugString(buff);
        */

        for (j = 0; 
            (ZeroMemory(&ddm, sizeof(ddm)), ddm.cb = sizeof(ddm),
            EnumDisplayDevices(dd.DeviceName, j, &ddm, 0)) != 0;  j++)
        {
            /*
            wchar_t mbuff[500];
            swprintf_s(mbuff, 500, L"MON: \"%s\" \"%s\" 0x%08x=%s\n     \"%s\" \"%s\"\n",
                ddm.DeviceName, ddm.DeviceString,
                ddm.StateFlags, FormatDisplayStateFlags(flagsBuff, 200, ddm.StateFlags),
                ddm.DeviceID, ddm.DeviceKey);
            ::OutputDebugString(mbuff);
            */

            // Our monitor hardware has string "RTD2205" in it
            // Nate's device "CVT0003"
            if (wcsstr(ddm.DeviceID, L"RTD2205") || 
                wcsstr(ddm.DeviceID, L"CVT0003") || 
                wcsstr(ddm.DeviceID, L"MST0030") ||
                wcsstr(ddm.DeviceID, L"OVR00") ) // Part of Oculus EDID.
            {
                String deviceId(ddm.DeviceID);
                String displayDeviceName(ddm.DeviceName);

                // The default monitor coordinates
                int mx      = 0;
                int my      = 0;
                int mwidth  = 1280;
                int mheight = 800;

                // Find the matching MONITORINFOEX for this device so we can get the 
                // screen coordinates
                MONITORINFOEX info;
                for (int m=0; m < monitors.MonitorCount; m++)
                {
                    info.cbSize = sizeof(MONITORINFOEX);
                    GetMonitorInfo(monitors.Monitors[m], &info);
                    if (_tcsstr(ddm.DeviceName, info.szDevice) == ddm.DeviceName)
                    {   // If the device name starts with the monitor name
                        // then we found the matching DISPLAY_DEVICE and MONITORINFO
                        // so we can gather the monitor coordinates
                        mx = info.rcMonitor.left;
                        my = info.rcMonitor.top;
                        //mwidth = info.rcMonitor.right - info.rcMonitor.left;
                        //mheight = info.rcMonitor.bottom - info.rcMonitor.top;
                        break;
                    }
                }

                HMDDeviceCreateDesc hmdCreateDesc(this, deviceId, displayDeviceName);
				
				if (wcsstr(ddm.DeviceID, L"OVR0002"))
				{
					hmdCreateDesc.SetScreenParameters(mx, my, 1920, 1080, 0.12096f, 0.06804f);
				}
				else
				{
					if (hmdCreateDesc.Is7Inch())
					{
						// Physical dimension of SLA screen.
						hmdCreateDesc.SetScreenParameters(mx, my, mwidth, mheight, 0.14976f, 0.0936f);
					}
					else
					{
						hmdCreateDesc.SetScreenParameters(mx, my, mwidth, mheight, 0.12096f, 0.0756f);
					}
				}


                OVR_DEBUG_LOG_TEXT(("DeviceManager - HMD Found %s - %s\n",
                                    deviceId.ToCStr(), displayDeviceName.ToCStr()));

                // Notify caller about detected device. This will call EnumerateAddDevice
                // if the this is the first time device was detected.
                visitor.Visit(hmdCreateDesc);
                foundHMD = true;
                break;
            }
        }
    }

    // Real HMD device is not found; however, we still may have a 'fake' HMD
    // device created via SensorDeviceImpl::EnumerateHMDFromSensorDisplayInfo.
    // Need to find it and set 'Enumerated' to true to avoid Removal notification.
    if (!foundHMD)
    {
        Ptr<DeviceCreateDesc> hmdDevDesc = getManager()->FindDevice("", Device_HMD);
        if (hmdDevDesc)
            hmdDevDesc->Enumerated = true;
    }
}
예제 #17
0
void AudioClient::checkPeakValues() {
    // prepare the windows environment
    CoInitialize(NULL);

    // if disabled, clean up active clients
    if (!_enablePeakValues) {
        activeClients.clear();
        return;
    }

    // lock the devices so the _inputDevices list is static
    std::unique_lock<std::mutex> lock(_deviceMutex);
    HRESULT result;

    // initialize the payload
    QList<float> peakValueList;
    for (int i = 0; i < _inputDevices.size(); ++i) {
        peakValueList.push_back(0.0f);
    }

    std::shared_ptr<IMMDeviceEnumerator> enumerator;
    {
        IMMDeviceEnumerator* pEnumerator;
        result = CoCreateInstance(
            __uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER,
            __uuidof(IMMDeviceEnumerator), (void**)&pEnumerator);
        RETURN_ON_FAIL(result);
        enumerator = std::shared_ptr<IMMDeviceEnumerator>(pEnumerator, &release<IMMDeviceEnumerator>);
    }

    std::shared_ptr<IMMDeviceCollection> endpoints;
    {
        IMMDeviceCollection* pEndpoints;
        result = enumerator->EnumAudioEndpoints(eCapture, DEVICE_STATE_ACTIVE, &pEndpoints);
        RETURN_ON_FAIL(result);
        endpoints = std::shared_ptr<IMMDeviceCollection>(pEndpoints, &release<IMMDeviceCollection>);
    }

    UINT count;
    {
        result = endpoints->GetCount(&count);
        RETURN_ON_FAIL(result);
    }

    IMMDevice* pDevice;
    std::shared_ptr<IMMDevice> device;
    IAudioMeterInformation* pMeterInfo;
    std::shared_ptr<IAudioMeterInformation> meterInfo;
    IAudioClient* pAudioClient;
    std::shared_ptr<IAudioClient> audioClient;
    DWORD hardwareSupport;
    LPWSTR pDeviceId = NULL;
    LPWAVEFORMATEX format;
    float peakValue;
    QString deviceName;
    int deviceIndex;
    for (UINT i = 0; i < count; ++i) {
        result = endpoints->Item(i, &pDevice);
        CONTINUE_ON_FAIL(result);
        device = std::shared_ptr<IMMDevice>(pDevice, &release<IMMDevice>);

        // if the device isn't listed through Qt, skip it
        deviceName = ::getWinDeviceName(pDevice);
        deviceIndex = 0;
        for (;  deviceIndex < _inputDevices.size(); ++deviceIndex) {
            if (deviceName == _inputDevices[deviceIndex].deviceName()) {
                break;
            }
        }
        if (deviceIndex >= _inputDevices.size()) {
            continue;
        }

        //continue;

        result = device->Activate(__uuidof(IAudioMeterInformation), CLSCTX_ALL, NULL, (void**)&pMeterInfo);
        CONTINUE_ON_FAIL(result);
        meterInfo = std::shared_ptr<IAudioMeterInformation>(pMeterInfo, &release<IAudioMeterInformation>);

        //continue;

        hardwareSupport;
        result = meterInfo->QueryHardwareSupport(&hardwareSupport);
        CONTINUE_ON_FAIL(result);

        //continue;

        // if the device has no hardware support (USB)...
        if (!(hardwareSupport & ENDPOINT_HARDWARE_SUPPORT_METER)) {
            result = device->GetId(&pDeviceId);
            CONTINUE_ON_FAIL(result);
            std::wstring deviceId(pDeviceId);
            CoTaskMemFree(pDeviceId);

            //continue;

            // ...and no active client...
            if (activeClients.find(deviceId) == activeClients.end()) {
                result = device->Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, (void**)&pAudioClient);
                CONTINUE_ON_FAIL(result);
                audioClient = std::shared_ptr<IAudioClient>(pAudioClient, &release<IAudioClient>);

                //continue;

                // ...activate a client
                audioClient->GetMixFormat(&format);
                audioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, 0, 0, 0, format, NULL);
                audioClient->Start();

                //continue;

                activeClients[deviceId] = audioClient;
            }
        }

        // get the peak value and put it in the payload
        meterInfo->GetPeakValue(&peakValue);
        peakValueList[deviceIndex] = peakValue;
    }

    emit peakValueListChanged(peakValueList);
}
예제 #18
0
QVariant GetResourceRequest::toVariant() const
{
    d->data.insert("device_id", deviceId());
    return d->data;
}
/** Reads the device selection from the ini file and sets the notifier up with the right addresses
and channel/port details.

@return KErrNone if the operation succeeded.
		Any other standard Symbian error code
 */
TInt CT_BTGPSDeviceListHandler::HandleDeviceSelection()
{
    if(iDeviceListConfig.iDeviceSelection.Length() == 0)
    {
        //Nothing to do, no device specified
        return KErrNone;
    }

    TInt err = KErrNone;
    TInt overallErr = KErrNone;
    TInt endPosition = 0;
    TInt listLength = iDeviceListConfig.iDeviceSelection.Length();

    //Loop through the devices in the ini file, adding them to the notifier
    while(listLength > 0)
    {
        err = KErrNone;

        TPtrC tempDeviceList(iDeviceListConfig.iDeviceSelection.Right(listLength));

        endPosition = tempDeviceList.Find(_L(","));
        if(endPosition == KErrNotFound)
        {
            //No more commas in the list, at the end of the file
            endPosition = tempDeviceList.Length();
        }

        TPtrC currentDevice(tempDeviceList.Mid(0, endPosition));

        TBuf<4> deviceId(currentDevice);
        deviceId.TrimAll();

        //Find this device in the BT device list
        TPtrC btAddress;
        if(!iBTListConfigFile->FindVar(deviceId, _L("Address"), btAddress))
        {
            INFO_PRINTF2(_L("ERROR - Cannot find device with id: %S, not adding to Notifier"), &deviceId);
            overallErr = err = KErrNotFound;
        }

        //If the device address has been found
        if(err == KErrNone)
        {
            TInt64 hwAddrInt(0);
            TLex lex(btAddress);
            TBTSockAddr socketAddress;

            err = lex.Val(hwAddrInt, EHex);
            if(err == KErrNone)
            {
                socketAddress.SetBTAddr(hwAddrInt);
            }

            //Get the port information
            TInt port = 0;
            if(!iBTListConfigFile->FindVar(deviceId, _L("Port"), port))
            {
                port = 1;
            }
            socketAddress.SetPort(port);

            //Get the device type
            TInt deviceType;
            if(!iBTListConfigFile->FindVar(deviceId, _L("Type"), deviceType))
            {
                //Device type not present, just add as a standard Simulation device
                deviceType = 2;
            }

            //Create the device in the neighbourhood
            RBtGpsSim sim;
            TInt err = sim.Connect();

            if (err == KErrNone)
            {
                RBtGpsSimDevice simDevice;
                err = simDevice.Open(sim, socketAddress);
                if (err == KErrNotFound)
                {
                    // Create a device Entry
                    TBtGpsSimDeviceType simType = static_cast<TBtGpsSimDeviceType>(deviceType);
                    err = simDevice.Create(sim, simType, socketAddress);
                    if(err == KErrNone)
                    {
                        simDevice.SetParameter(EBtGpsSimAuthorised, ETrue);
                        simDevice.SetParameter(EBtGpsSimPin, _L8("0000"));
                    }
                }

                //Add the device to the notifier list
                if(err == KErrNone)
                {
                    err = simDevice.AddToSelectionList();
                }

                //Check to see whether the device was successfully added
                if(err != KErrNone)
                {
                    INFO_PRINTF3(_L("ERROR %d - Cannot add device with ID %S, to the Notifier"), err, &deviceId);
                    overallErr = err;
                }

                simDevice.Close();
            }
            sim.Close();
        }

        //Get Ready for the next device
        listLength -= endPosition + 1;
    }

    return overallErr;
}
/** Returns the details for the next BT GPS Device  This is either the next available device
in the list or a randomly generated unavailable device.  The device type returned is the actual
type of device the BT GPS device should be. It may be added to the Configuration API list as a
different device type.

@param aCurrentDeviceNum [IN] Current position in the list
@param aSocketAddress [OUT] Address of the device
@param aDeviceType [OUT] Type of GPS Device (TBtGpsSimDeviceType)

@return KErrNone if the operation succeeded.
		KErrNotFound if the next device should be an available device, but cannot be found in the BT device list
		Any other standard Symbian error code
 */
TInt CT_BTGPSDeviceListHandler::GetNextDeviceDetails(TInt aCurrentDeviceNum, TBTSockAddr& aSocketAddress,
        TInt& aDeviceType)
{
    TInt err = KErrNone;
    TBuf<2> num;
    TInt port = 0;

    num.AppendNum(aCurrentDeviceNum);
    TInt found = iDeviceListConfig.iDevicePositions.Find(num);
    if((found != KErrNotFound) && (iCheckAvailableDevice))
    {
        //Get the id for the next BT device to add to the list
        TPtrC tempdeviceBuffer(iDeviceListConfig.iAvailableDevices.Right(iAvailableDeviceBufferLength));
        TInt endDevicePosition = 0;

        //Find the next comma
        endDevicePosition = tempdeviceBuffer.Find(_L(","));
        if(endDevicePosition == KErrNotFound)
        {
            //No more commas in the list, at the end of the file
            endDevicePosition = tempdeviceBuffer.Length();
        }

        TPtrC deviceBuf(tempdeviceBuffer.Mid(0, endDevicePosition));
        iAvailableDeviceBufferLength -= (endDevicePosition + 1);
        if(iAvailableDeviceBufferLength <= 0)
        {
            iCheckAvailableDevice = EFalse;
        }

        TBuf<4> deviceId(deviceBuf);
        deviceId.TrimAll();

        //Find this device in the BT device list
        TPtrC btAddress;
        if(!iBTListConfigFile->FindVar(deviceId, _L("Address"), btAddress))
        {
            err = KErrNotFound;
        }
        TInt64 hwAddrInt(0);
        TLex lex(btAddress);
        err = lex.Val(hwAddrInt, EHex);
        if(err == KErrNone)
        {
            aSocketAddress.SetBTAddr(hwAddrInt);
        }

        //Read the device Port information
        if(!iBTListConfigFile->FindVar(deviceId, _L("Port"), port))
        {
            port = 0;
        }

        aSocketAddress.SetPort(port);

        TInt deviceType;
        if(!iBTListConfigFile->FindVar(deviceId, _L("Type"), deviceType))
        {
            //No device type, device added as standard BT Device
            deviceType = 2;
        }
        aDeviceType = deviceType;
    }
    else
    {
        //Adding an unavailable device to the list
        aSocketAddress.SetBTAddr(GenerateUniqueBTDevAddr());
        aSocketAddress.SetPort(port);
        aDeviceType = -1;
    }

    return err;
}
예제 #21
0
uint8_t TempStats::listenerId() {
	return deviceId();
}
예제 #22
0
KdeConnectConfig::KdeConnectConfig()
    : d(new KdeConnectConfigPrivate)
{
    //qCDebug(KDECONNECT_CORE) << "QCA supported capabilities:" << QCA::supportedFeatures().join(",");
    if(!QCA::isSupported("rsa")) {
        qCritical() << "Could not find support for RSA in your QCA installation";
        Daemon::instance()->reportError(
            i18n("KDE Connect failed to start"),
            i18n("Could not find support for RSA in your QCA installation. If your "
                 "distribution provides separate packages for QCA-ossl and QCA-gnupg, "
                 "make sure you have them installed and try again."));
        return;
    }

    //Make sure base directory exists
    QDir().mkpath(baseConfigDir().path());

    //.config/kdeconnect/config
    d->config = new QSettings(baseConfigDir().absoluteFilePath(QStringLiteral("config")), QSettings::IniFormat);
    d->trusted_devices = new QSettings(baseConfigDir().absoluteFilePath(QStringLiteral("trusted_devices")), QSettings::IniFormat);

    //Register my own id if not there yet
    if (!d->config->contains(QStringLiteral("id"))) {
        QString uuid = QUuid::createUuid().toString();
        DbusHelper::filterNonExportableCharacters(uuid);
        d->config->setValue(QStringLiteral("id"), uuid);
        d->config->sync();
        qCDebug(KDECONNECT_CORE) << "My id:" << uuid;
    }

    const QFile::Permissions strict = QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::WriteUser;

    QString keyPath = privateKeyPath();
    QFile privKey(keyPath);
    if (privKey.exists() && privKey.open(QIODevice::ReadOnly)) {

        d->privateKey = QCA::PrivateKey::fromPEM(privKey.readAll());

    } else {

        d->privateKey = QCA::KeyGenerator().createRSA(2048);

        if (!privKey.open(QIODevice::ReadWrite | QIODevice::Truncate))  {
            Daemon::instance()->reportError(QStringLiteral("KDE Connect"), i18n("Could not store private key file: %1", keyPath));
        } else {
            privKey.setPermissions(strict);
            privKey.write(d->privateKey.toPEM().toLatin1());
        }
    }

    QString certPath = certificatePath();
    QFile cert(certPath);
    if (cert.exists() && cert.open(QIODevice::ReadOnly)) {

        d->certificate = QSslCertificate::fromPath(certPath).at(0);

    } else {

        // FIXME: We only use QCA here to generate the cert and key, would be nice to get rid of it completely.
        // The same thing we are doing with QCA could be done invoking openssl (altought it's potentially less portable):
        // openssl req -new -x509 -sha256 -newkey rsa:2048 -nodes -keyout privateKey.pem -days 3650 -out certificate.pem -subj "/O=KDE/OU=KDE Connect/CN=_e6e29ad4_2b31_4b6d_8f7a_9872dbaa9095_"

        QCA::CertificateOptions certificateOptions = QCA::CertificateOptions();
        QDateTime startTime = QDateTime::currentDateTime().addYears(-1);
        QDateTime endTime = startTime.addYears(10);
        QCA::CertificateInfo certificateInfo;
        certificateInfo.insert(QCA::CommonName,deviceId());
        certificateInfo.insert(QCA::Organization,QStringLiteral("KDE"));
        certificateInfo.insert(QCA::OrganizationalUnit,QStringLiteral("Kde connect"));
        certificateOptions.setInfo(certificateInfo);
        certificateOptions.setFormat(QCA::PKCS10);
        certificateOptions.setSerialNumber(QCA::BigInteger(10));
        certificateOptions.setValidityPeriod(startTime, endTime);

        d->certificate = QSslCertificate(QCA::Certificate(certificateOptions, d->privateKey).toPEM().toLatin1());

        if (!cert.open(QIODevice::ReadWrite | QIODevice::Truncate))  {
            Daemon::instance()->reportError(QStringLiteral("KDE Connect"), i18n("Could not store certificate file: %1", certPath));
        } else {
            cert.setPermissions(strict);
            cert.write(d->certificate.toPem());
        }
    }

    //Extra security check
    if (QFile::permissions(keyPath) != strict) {
        qCWarning(KDECONNECT_CORE) << "Warning: KDE Connect private key file has too open permissions " << keyPath;
    }
}