Beispiel #1
0
status_t
FTDIDevice::SetControlLineState(uint16 state)
{
	TRACE_FUNCALLS("> FTDIDevice::SetControlLineState(0x%08x, 0x%04x)\n", this, state);

	int32 control;
	control = (state & USB_CDC_CONTROL_SIGNAL_STATE_RTS) ? FTDI_SIO_SET_RTS_HIGH
		: FTDI_SIO_SET_RTS_LOW;

	size_t length = 0;
	status_t status = gUSBModule->send_request(Device(),
		USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
		FTDI_SIO_MODEM_CTRL, control,
		FTDI_PIT_DEFAULT, 0, NULL, &length);

	if (status != B_OK)
		TRACE_ALWAYS("= FTDIDevice::SetControlLineState(): control set request failed: 0x%08x\n", status);

	control = (state & USB_CDC_CONTROL_SIGNAL_STATE_DTR) ? FTDI_SIO_SET_DTR_HIGH
		: FTDI_SIO_SET_DTR_LOW;

	status = gUSBModule->send_request(Device(),
		USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
		FTDI_SIO_MODEM_CTRL, control,
		FTDI_PIT_DEFAULT, 0, NULL, &length);

	if (status != B_OK)
		TRACE_ALWAYS("= FTDIDevice::SetControlLineState(): control set request failed: 0x%08x\n", status);

	TRACE_FUNCRET("< FTDIDevice::SetControlLineState() returns: 0x%08x\n", status);
	return status;
}
bool DeviceManager::getAudioDevices(bool input, std::vector<Device>& devs)
{
    devs.clear();

#if defined(ANDROID)
    // Under Android, we don't access the device file directly.
    // Arbitrary use 0 for the mic and 1 for the output.
    // These ids are used in MediaEngine::SetSoundDevices(in, out);
    // The strings are for human consumption.
    if (input) {
        devs.push_back(Device("audioin", "audiorecord", 0));
    } else {
        devs.push_back(Device("audioout", "audiotrack", 1));
    }
    return true;
#elif defined(HAVE_RTAUDIO)

    // Since we are using RtAudio for audio capture it's best to
    // use RtAudio to enumerate devices to ensure indexes match.
    RtAudio audio;

    // Determine the number of devices available
    auto ndevices = audio.getDeviceCount();
    TraceS(this) << "Get audio devices: " << ndevices << endl;

    // Scan through devices for various capabilities
    RtAudio::DeviceInfo info;
    for (unsigned i = 0; i <= ndevices; i++) {
        try {
            info = audio.getDeviceInfo(i);    // may throw RtAudioError

            TraceS(this) << "Device:"
                << "\n\tName: " << info.name
                << "\n\tOutput Channels: " << info.outputChannels
                << "\n\tInput Channels: " << info.inputChannels
                << "\n\tDuplex Channels: " << info.duplexChannels
                << "\n\tDefault Output: " << info.isDefaultOutput
                << "\n\tDefault Input: " << info.isDefaultInput
                << "\n\tProbed: " << info.probed
                << endl;

            if (info.probed == true && (
                (input && info.inputChannels > 0) ||
                (!input && info.outputChannels > 0))) {

                TraceS(this) << "Adding device: " << info.name << endl;
                Device dev((input ? "audioin" : "audioout"), i, info.name, "",
                    (input ? info.isDefaultInput : info.isDefaultOutput));
                devs.push_back(dev);
            }
        }
        catch (RtAudioError& e) {
            ErrorS(this) << "Cannot probe audio device: " << e.getMessage() << endl;
        }
    }

    return filterDevices(devs, kFilteredAudioDevicesName);
#endif
}
Beispiel #3
0
status_t
BFileGameSound::Init(const entry_ref* file)
{
	fAudioStream = new _gs_media_tracker;
	memset(fAudioStream, 0, sizeof(_gs_media_tracker));

	fAudioStream->file = new BMediaFile(file);
	status_t error = fAudioStream->file->InitCheck();
	if (error != B_OK)
		return error;

	fAudioStream->stream = fAudioStream->file->TrackAt(0);

	// is this is an audio file?
	media_format playFormat;
	if ((error = fAudioStream->stream->EncodedFormat(&playFormat)) != B_OK)
		return error;

	if (!playFormat.IsAudio())
		return B_MEDIA_BAD_FORMAT;

	gs_audio_format dformat = Device()->Format();

	// request the format we want the sound
	memset(&playFormat, 0, sizeof(media_format));
	playFormat.type = B_MEDIA_RAW_AUDIO;
	if (fAudioStream->stream->DecodedFormat(&playFormat) != B_OK)
		return B_MEDIA_BAD_FORMAT;

	// translate the format into a "GameKit" friendly one
	gs_audio_format gsformat;
	media_to_gs_format(&gsformat, &playFormat.u.raw_audio);

	// Since the buffer sized read from the file is most likely differnt
	// then the buffer used by the audio mixer, we must allocate a buffer
	// large enough to hold the largest request.
	fBufferSize = gsformat.buffer_size;
	if (fBufferSize < dformat.buffer_size)
		fBufferSize = dformat.buffer_size;

	// create the buffer
	fBuffer = new char[fBufferSize * 2];
	memset(fBuffer, 0, fBufferSize * 2);

	fFrameSize = gsformat.channel_count * get_sample_size(gsformat.format);
	fAudioStream->frames = fAudioStream->stream->CountFrames();

	// Ask the device to attach our sound to it
	gs_id sound;
	error = Device()->CreateBuffer(&sound, this, &gsformat);
	if (error != B_OK)
		return error;

	return BGameSound::Init(sound);
}
Device Device::parent() const
{
    if (!d)
        return Device();

    struct udev_device *p = udev_device_get_parent(d->udev);

    if (!p)
        return Device();

    return Device(new DevicePrivate(p));
}
Device Device::ancestorOfType(const QString &subsys, const QString &devtype) const
{
    if (!d)
        return Device();

    struct udev_device *p = udev_device_get_parent_with_subsystem_devtype(d->udev,
                                subsys.toLatin1().constData(), devtype.toLatin1().constData());

    if (!p)
        return Device();

    return Device(new DevicePrivate(p));
}
static void ScanDeviceDirectory(const std::string& devdir,
    std::vector<Device>& devices) {

    std::vector<std::string> nodes;
    fs::readdir(devdir, nodes);
    for (unsigned i = 0; i < nodes.size(); i++) {
        std::string filename = nodes[0];
        std::string deviceName = devdir + filename;
        //if (!directoryIterator->IsDots()) {
            if (filename.find("video") == 0 &&
                IsV4L2Device(deviceName)) {
                    devices.push_back(Device("video", i, deviceName));
            }
        //}
    }

        // talk_base::scoped_ptr<talk_base::DirectoryIterator> directoryIterator(
        //     talk_base::Filesystem::IterateDirectory());
        //
        // if (directoryIterator->Iterate(talk_base::Pathname(devdir))) {
        //     do {
        //         std::string filename = directoryIterator->Name();
        //         std::string deviceName = devdir + filename;
        //         if (!directoryIterator->IsDots()) {
        //             if (filename.find("video") == 0 &&
        //                 V4LLookup::IsV4L2Device(deviceName)) {
        //                     devices.push_back(Device(deviceName, deviceName));
        //             }
        //         }
        //     } while (directoryIterator->Next());
        // }
}
nsresult
MulticastDNSDeviceProvider::AddDevice(const nsACString& aServiceName,
                                      const nsACString& aServiceType,
                                      const nsACString& aHost,
                                      const uint16_t aPort)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(mPresentationServer);

  nsresult rv;

  nsCOMPtr<nsIPresentationDevice> device;
  if (NS_WARN_IF(NS_FAILED(rv =
      mPresentationServer->CreateTCPDevice(aHost, /* ID */
                                           aServiceName,
                                           aServiceType,
                                           aHost,
                                           aPort,
                                           getter_AddRefs(device))))) {
    return rv;
  }

  nsCOMPtr<nsIPresentationDeviceListener> listener;
  if (NS_SUCCEEDED(GetListener(getter_AddRefs(listener))) && listener) {
    unused << listener->AddDevice(device);
  }

  mDevices.AppendElement(Device(aHost, DeviceState::eActive));

  return NS_OK;
}
Beispiel #8
0
status_t
DHCPClient::Initialize()
{
	fStatus = _Negotiate(INIT);
	syslog(LOG_DEBUG, "DHCP for %s, status: %s\n", Device(), strerror(fStatus));
	return fStatus;
}
Beispiel #9
0
void GPhidgetManagerWidget::UpdateSubDevicesWidgetList()
{
	GPhidgetManager* pPhidMan = qobject_cast<GPhidgetManager*>(Device());
	QLayout *pLayout = layout();
	if(!pPhidMan || !pLayout)
		return;
	QList<GDevice*> oldList = m_ListDev;
	m_ListDev = pPhidMan->m_SerialPhidgetModules.values();
	// make a list of new items in the m_ListDev
	QList<GDevice*> newDevicesInList = m_ListDev;
	foreach(GDevice* pDev, m_ListDev)
		if(oldList.contains(pDev))
			newDevicesInList.removeOne(pDev);
	// make a list of items that are gone from the m_ListDev
	QList<GDevice*> goneDevicesInList = oldList;
	foreach(GDevice* pDev, oldList)
		if(m_ListDev.contains(pDev))
			goneDevicesInList.removeOne(pDev);

	// lets delete the gone's and create the new's
	foreach(GDevice* pDev, goneDevicesInList) {
		for (int i = 0; i < pLayout->count(); ++i) {
			GDeviceWidget* pWid = qobject_cast<GDeviceWidget*>(pLayout->itemAt(i)->widget());
			if(pWid && goneDevicesInList.contains(pWid->Device())) {
				pLayout->removeWidget(pWid);
				delete pWid;
			}
		}
	}
	foreach(GDevice* pDev, newDevicesInList) {
		GDeviceWidget* subDevWidget = pDev->ProvideNewDeviceGroupBox(this);
		pLayout->addWidget(subDevWidget);
	}
Beispiel #10
0
status_t
HDCS1000Sensor::Probe()
{
	status_t err;
	uint8 data;
	PRINT((CH "()" CT));
	Device()->SetIICBitsMode(8);
	// QuickCam only ?
	err = Device()->ReadIIC8(HDCS_IDENT+1, &data);
	if (err < B_OK)
		return ENODEV;
	if (data == 8) {
		PRINT((CH ": found %s sensor!" CT, Name()));
		return B_OK;
	}
	return ENODEV;
}
Beispiel #11
0
BGameSound *
BPushGameSound::Clone() const
{
	gs_audio_format format = Format();
	size_t frameSize = get_sample_size(format.format) * format.channel_count;
	size_t bufferFrameCount = fPageSize / frameSize;
	
	return new BPushGameSound(bufferFrameCount, &format, fPageCount, Device());
}
Beispiel #12
0
S60Devices::Device S60Devices::deviceForId(const QString &id) const
{
    foreach (const S60Devices::Device &i, m_devices) {
        if (i.id == id) {
            return i;
        }
    }
    return Device();
}
Beispiel #13
0
S60Devices::Device S60Devices::deviceForEpocRoot(const QString &root) const
{
    foreach (const S60Devices::Device &i, m_devices) {
        if (i.epocRoot == root) {
            return i;
        }
    }
    return Device();
}
Beispiel #14
0
shared_ptr< InputDevice const >
Input::Device( InputDevice::EType type ) const
{
    std::tr1::shared_ptr< InputDevice const > pDevice;
    int index = DeviceIndex( type );
    if ( index >= 0 )
        pDevice = Device( index );
    return pDevice;
}
Beispiel #15
0
void HazelnutConfigDialog::OnChoicePowerSource(wxCommandEvent& WXUNUSED(event))
{
	int sel = choice->GetSelection();
	if(sel==-1 || sel==0)
		wxGetApp().SetDevice(Device());
	else
		wxGetApp().SetDevice(*(Device*)choice->GetClientData(sel));

	RefreshInfos();
}
Beispiel #16
0
vector<Device> Platform::GetDevices(cl_device_type typ) const {
	cl_uint n;
	ClCheck(::clGetDeviceIDs(Id, typ, 0, 0, &n));
	cl_device_id *p = (cl_device_id*)alloca(n*sizeof(cl_device_id));
	ClCheck(::clGetDeviceIDs(Id, typ, n, p, 0));
	vector<Device> r(n);
	for (int i=0; i<n; ++i)
		r[i] = Device(*p, HasRetainDeviceFunction);
	return r;
}
Beispiel #17
0
	void Context::CompileSource( const std::string& str_source )
	{
		g_df->CompileSource(str_source);
		
		std::vector<Dataflow::Device*> devs = g_df->GetDevices();

		for( Dataflow::Device* dev : devs )
		{
			m_devices.push_back( Device(dev) );
		}
	}
Beispiel #18
0
Label::Label(cgl::PD3D11Effect pEffect, int x, int y, int width, int height)
	: cgl::drawing::CGLLabel(pEffect, width, height)
{
	SetX((float)x);
	SetY((float)y);

	m_pFactory = NULL;
	m_pFontWrapper = NULL;
	FW1CreateFactory(FW1_VERSION, &m_pFactory);

	m_pFactory->CreateFontWrapper(Device(), L"Consolas", &m_pFontWrapper);
}
Beispiel #19
0
status_t
ProlificDevice::AddDevice(const usb_configuration_info *config)
{
	TRACE_FUNCALLS("> ProlificDevice::AddDevice(%08x, %08x)\n", this, config);

	// check for device type.
	// Linux checks for type 0, 1 and HX, but handles 0 and 1 the same.
	// We'll just check for HX then.
	const usb_device_descriptor *deviceDescriptor = NULL;
	deviceDescriptor = gUSBModule->get_device_descriptor(Device());
	if (deviceDescriptor) {
		fIsHX = (deviceDescriptor->device_class != 0x02
			&& deviceDescriptor->max_packet_size_0 == 0x40);
	}

	int32 pipesSet = 0;
	status_t status = ENODEV;
	if (config->interface_count > 0) {
		usb_interface_info *interface = config->interface[0].active;
		for (size_t i = 0; i < interface->endpoint_count; i++) {
			usb_endpoint_info *endpoint = &interface->endpoint[i];
			if (endpoint->descr->attributes == USB_ENDPOINT_ATTR_INTERRUPT) {
				if (endpoint->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) {
					SetControlPipe(endpoint->handle);
					pipesSet++;
				}
			}
		}

		/* They say that USB-RSAQ1 has 2 interfaces */
		if (config->interface_count >= 2)
			interface = config->interface[1].active;

		for (size_t i = 0; i < interface->endpoint_count; i++) {
			usb_endpoint_info *endpoint = &interface->endpoint[i];
			if (endpoint->descr->attributes == USB_ENDPOINT_ATTR_BULK) {
				if (endpoint->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
					SetReadPipe(endpoint->handle);
				else
					SetWritePipe(endpoint->handle);

				if (++pipesSet >= 3)
					break;
			}
		}

		if (pipesSet >= 3)
			status = B_OK;
	}

	TRACE_FUNCRET("< ProlificDevice::AddDevice() returns: 0x%08x\n", status);
	return status;
}
Beispiel #20
0
vector<Device> Program::get_Devices() {
	cl_uint n;
	ClCheck(::clGetProgramInfo(Handle(), CL_PROGRAM_NUM_DEVICES, sizeof(n), &n, 0));
	vector<Device> devs(n);
	if (n) {
		cl_device_id *devids = (cl_device_id*)alloca(n * sizeof(cl_device_id));
		ClCheck(::clGetProgramInfo(Handle(), CL_PROGRAM_DEVICES, sizeof(cl_device_id)*n, devids, 0));
		for (int i=0; i<n; ++i)
			devs[i] = Device(devids[i]);
	}
	return devs;
}
Beispiel #21
0
status_t
FTDIDevice::ResetDevice()
{
	TRACE_FUNCALLS("> FTDIDevice::ResetDevice(0x%08x)\n", this);

	size_t length = 0;
	status_t status = gUSBModule->send_request(Device(),
		USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
		FTDI_SIO_RESET, FTDI_SIO_RESET_SIO,
		FTDI_PIT_DEFAULT, 0, NULL, &length);

	TRACE_FUNCRET("< FTDIDevice::ResetDevice() returns:%08x\n", status);
	return status;
}
Beispiel #22
0
AudioOutput::Device AudioOutput::getDevice(id_t id)
{
    try
    {
        return audio_.getDeviceInfo(id);
    }
    
    catch(RtAudioError& error)
    {
        error.printMessage();
    }
    
    return Device();
}
Beispiel #23
0
 vector<Device> Program::devices() const
 {
     if(!_ctx || isNull())
         return vector<Device>();
     // !NOTE: Some claims CL_PROGRAM_DEVICES is unreliable
     cl_uint size = detail::programInfo<cl_uint>(_id, CL_PROGRAM_NUM_DEVICES);
     if(size == 0)
         return vector<Device>();
     vector<cl_device_id> buf(size);
     if(!detail::programInfo(_id, CL_PROGRAM_DEVICES, buf.data(), buf.size()))
         return vector<Device>();
     vector<Device> devs(size);
     for(cl_uint i = 0; i < size; ++i)
         devs[i] = Device(buf[i]);
     return devs;
 }
bool
MulticastDNSDeviceProvider::FindDevice(const nsACString& aId,
                                       uint32_t& aIndex)
{
  MOZ_ASSERT(NS_IsMainThread());

  size_t index = mDevices.IndexOf(Device(aId, DeviceState::eUnknown),
                                  0,
                                  DeviceIdComparator());

  if (index == mDevices.NoIndex) {
    return false;
  }

  aIndex = index;
  return true;
}
Beispiel #25
0
/**
 *  @details The list of available packet devices is loaded from the system and
 *           matched against the command-line supplied device name.  Packets are
 *           captured and hosts extracted.
 */
int IPForensics::load_from_device() {
  // load packet capture device list from system
  try {
    load_devices();
  } catch (std::exception const &e) {
    std::cout << ipf::kProgramName << ": ";
    std::cout << "Could not query system for packet capture devices: ";
    std::cout << e.what() << std::endl;
  }
  // select device to use
  Device device = Device(this);
  for (Device d : devices_) {
    if (device_ == d.name()) {
      device = d;
    }
  }
  // exit if invalid device specified
  if (!device_.empty() && device_ != device.name()) {
    std::cout << ipf::kProgramName << ": ";
    std::cout << "Invalid packet capture device \'" << device_ << "\'. ";
    std::cout << "Valid device(s):\n";
    for (size_t i = 0; i < devices_.size(); ++i) {
      std::cout << i+1 << ". " << devices_[i] << '\n';
    }
    std::cout << std::endl;
    return -1;
  }
  // display run-time parameters
  if (verbose_) {
    std::cout << "Using \'" << device.name() << "\' with network address ";
    std::cout << device.net() << " and network mask " << device.mask();
    std::cout << " to capture " << packet_count_ << " packet(s).";
    std::cout << std::endl;
  }
  // capture packets
  int packet_count = device.capture(packet_count_);
  // display packets captured
  if (verbose_) {
    for (Packet p : device.packets()) {
      std::cout << p << std::endl;
    }
  }
  // extract hosts
  load_hosts(device);
  return packet_count;
}
Beispiel #26
0
status_t
CamSensor::ProbeByIICSignature(const uint8 *regList, const uint8 *matchList,
	size_t count)
{
	int i;

	for (i = 0; i < count; i++) {
		uint8 value = 0;
		ssize_t len;
		len = Device()->ReadIIC8(regList[i], &value);
		PRINT((CH ": ReadIIC8 = %d val = %d" CT, len, value));
		if (len < 1)
			return ENODEV;
		if (value != matchList[i])
			return ENODEV;
	}
	return B_OK;
}
void Graphics::LoadTexture( const std::string& Filename, const std::string& AssetName )
{
	auto result = Textures.find( AssetName );

	if( result != Textures.end() )
	{
		return;
	}

	LPDIRECT3DTEXTURE9 tex = NULL;
	
	ErrorCheck( D3DXCreateTextureFromFile( Device(), Filename.c_str(), &tex ), "Creating Texture: " + Filename );
	
	if( tex != NULL )
	{
		Textures[AssetName] = tex;
	}
}
Beispiel #28
0
int main()
{
    std::map<time_t,int>::iterator it;

    Device device = Device();
    //device.print();
    time_t rawtime;

    time(&rawtime);
    for(int i = 0; i < 15; i++) {
        device.add_reading(rawtime-i, i);
    }

    //device.print(10);

    for(int i = 1; i < 6; i++)
        device.rm_reading(rawtime-i);

    //device.print(10);

    device.rm_reading(0);
    device.rm_reading(0);
    //device.print();
    device.save_readings();

    pugi::xml_document doc;
    device.xml(doc);

    //doc.print(std::cout);
    doc.save_file("xml_output.xml");

    device.clear_readings();

    //device.print();

    pugi::xml_document new_doc;
    pugi::xml_parse_result result = new_doc.load_file("xml_output.xml");
    if(result)
        device.process_msg(new_doc);

    //new_doc.print(std::cout);

}
Beispiel #29
0
    NDArrayViewPtr NDArrayView::Alias(bool readOnly/* = false*/) const
    {
        void* tensorView = nullptr;
        switch (m_dataType)
        {
        case DataType::Float:
            tensorView = new TensorView<float>(*(GetTensorView<float>()));
            break;
        case DataType::Double:
            tensorView = new TensorView<double>(*(GetTensorView<double>()));
            break;
        default:
            LogicError("Unsupported DataType %s", DataTypeName(m_dataType));
            break;
        }

        auto aliasView = new NDArrayView(GetDataType(), Device(), GetStorageFormat(), Shape(), IsReadOnly() || readOnly, tensorView);;
        return NDArrayViewPtr(aliasView, [](_ReferenceCounter* ptr) { delete ptr; });
    }
ADDON_STATUS CVisualizationVortex::Create()
{
  g_pluginPath = Presets();

  m_Vortex = new Vortex;

  UserSettings& userSettings = m_Vortex->GetUserSettings();
  userSettings.RandomPresetsEnabled = kodi::GetSettingBoolean("RandomPresets");
  userSettings.TimeBetweenPresets = (float)(kodi::GetSettingInt("TimeBetweenPresets") * 5 + 5);
  userSettings.TimeBetweenPresetsRand = (float)(kodi::GetSettingInt("AdditionalRandomTime") * 5);
  userSettings.TransitionsEnabled = kodi::GetSettingBoolean("EnableTransitions");
  userSettings.StopFirstPreset = kodi::GetSettingBoolean("StopFirstPreset");
  userSettings.ShowFPS = kodi::GetSettingBoolean("ShowFPS");
  userSettings.ShowDebugConsole = kodi::GetSettingBoolean("ShowDebugConsole");
  userSettings.ShowAudioAnalysis = kodi::GetSettingBoolean("ShowAudioAnalysis");
  userSettings.PresetLocked = kodi::GetSettingBoolean("LockPreset");

  m_Vortex->Init(reinterpret_cast<ID3D11DeviceContext*>(Device()), X(), Y(), Width(), Height(), PixelRatio());

  return ADDON_STATUS_OK;
}