I have been attempting to change which audio device my computer sends sound to. My end goal is to create a program that can make my laptop output to its built-in speakers even when headphones are plugged into the headphone jack.
I stumbled across this project, but the methods it uses (specifically AudioHardwareSetProperty) are deprecated. It also just doesn't work (it will say it changed the output device, but sound will still go to my headphones).
CoreAudio seems very poorly documented and I could not find ANY code online that did not use that function. I would go with the deprecated function if it did what I wanted, but it doesn't. I'm unsure weather it's broken or just doesn't do what I think it does, but that really doesn't matter in the end.
I attempted to look at the comments on AudioHardwareSetProperty but all I found was this in the discussion section:
Note that the value of the property should not be considered changed until the
HAL has called the listeners as many properties values are changed
asynchronously. Also note that the same functionality is provided by the
function AudioObjectGetPropertyData().
This is obviously not true, since I know for a fact that AudioObjectGetPropertyData is used for getting information about one specific audio device.
Is what I am trying to do possible with CoreAudio?
Related
So I'm using the Vinculum-II microcontroller to build a simple USB application but I'm kinda stuck. I downloaded a reference project from http://www.ftdichip.com/Firmware/Precompiled/HIDUART.zip and want to modify this in order to make my project (which is a basic USB converter) happen.
The project compiles and flashes succesfully, however when I try running it, it does not detect anything, nor any information is sent via UART. I tried debugging it, and after the HID (mouse) is detected, the software crashes when it enters the following function: vos_dev_ioctl(hUSBHOST_1, &hc_iocb);
I tried some other examples from the book (http://www.ftdichip.com/Support/Documents/TechnicalPublications/USBDesignByExample.htm[2] (chapter 9, stage 2)) which work, but as soon as I modify the code the slightest bit (renaming and adding a parameter to a function which is not used), which does not have anything to do with the functionality, it crashes. The function where the code freezes are VOS specific functions (vos_lock_mutex / vos_dev_ioctl/ etc ..). The VOS seems to wait for something to resume from that function, but that thing that it's waiting for, never comes. The system gets stuck in the idle task.
I'm becoming mad trying to figure out how to resolve this task. My goal is pretty easy, copy a file on the USB stick every time that it is inserted and then release the USB stick turning off the LED. What is the best way to solve it?
1) I found this article
http://geekswithblogs.net/BruceEitman/archive/2008/06/13/windows-ce-monitoring-for-disk-insertion-to-add-support-for.aspx
or
http://geekswithblogs.net/BruceEitman/archive/2008/06/13/windows-ce-monitoring-for-disk-insertion-to-add-support-for.aspx
but I can't translate it on VB.NET project.
2) Then I read that is enough to use RequestDeviceNotifications for block devices. But How can I do that in VB.NET?
I would like to avoid OpenNetCF if possible.
Thank you
Since you don't want to "use OpenNETCF" I assume that you don't want to use any libraries or capabilities not built in to the CF. We'll skip the argument of that silliness and the "value of your time" discussion and take that as a requirement.
What you need to do is:
Use P/Invoke to call CreateMsgQueue. That's going to give you back a Handle. You'll probably want to do CloseMsgQueue as well for completeness
P/Invoke RequestDeviceNotifications and pass it the handle returned from #1 above along with the DEVCLASS GUID value for the device notifications you want - probably STORE_MOUNT_GUID. Again, adding StopDeviceNotifications for completeness is a good idea.
At that point you'll get a message on the queue whenever a insert or remove happens. You then call ReadMsgQueue to get the DEVDETAIL data in the message.
Parse the DEVDETAIL and look at the fAttached member.
It'd take me a while to write that for you, so you'll need to do this on your own.
Start writing the project, find P/Invoke routines for the calls you need (like FindFirstFile and CreateProcess). On SO, have a look at Storage Card Problem In windows mobile and How to register form for WM_DEVICECHANGE message in windows mobile.
You are only going to be dead in the water if you can not find a particular call that you can't make.
As you work through your project, post (or search for) the actual problems you run into.
Otherwise, it sounds like you are asking someone to write the project and hand it to you.
I want to develop a VGA graphics driver (for Linux(Ubuntu)) with support for the basic primitives such as putpixel, drawline, fillrect and bitblt. I want to do it in protected mode.
I´ve been googling for a week and the following four links are the best I have found:
http://www.brackeen....vga/basics.html
http://www.osdever.n...VGA/vga/vga.htm
http://bos.asmhacker...sing%20bios.htm
Unfortunately, the first one uses a BIOS call so I cannot use it. The second link has lots of information on the VGA registers but no examples showing how to make them work together. The third example is a example to switch in 13h mode but i've tried it and nothing happened. Can you guys give me a hint? Thanks in advance!
--Vincenzo
my code at http://bos.asmhackers.net/docs/vga_without_bios/snippet_5/vga.php
works fine if you are in 32bit mode with full hardware access. Unfortunately I doubt that any Linux variant will let you directly access the VGA ports. I'm not sure how you develop this driver, but if you made sure that you have full access to the VGA ports it should work. In my example code I only switch between mode 0x03 and 0x13, but in the folders above you'll be able to find port values for most other common VGA modes, as well as C code to do the switch if you prefer that.
Christoffer code include files are found BOS operating system source code like text.inc and font8x16.inc
http://bos.asmhackers.net/downloads.php
This is coming many many years later but I think it's still very relevant and if somebody is struggling I hope they can find it useful.
First of all, it is completely possible to configure VGA only using registers without interrupts, as hard as it may be. A useful resource about registers and how to configure them can be found here, but unless you have a ton of time to spare to learn how to properly do all of it, move to the following section.
If you wish to really learn how to do it, I suggest going through with the documentation provided earlier. However, some of it is already done!
Chris Giese did a great job demonstrating exactly how to do this for MS-DOS system, and while you may think that doesn't help you, it really does.
Chris's code can be found here. If you want another useful codes check here as well.
Now, while it only works for MS-DOS it's actually easy to convert to other systems. The code already contains all data needed to configure the registers in many different modes. And that's the part that saves you a ton of time going through documentation.
The code uses functions outportb, inportb, which are MS-DOS functions, to write/read single byte to/from a port. Therefore, you have to redefine these functions to read/write for your own system. Redefinition complexity depends on the system you operate on.
In addition, you will also need to provide means to write to physical memory region between 0xA0000-0xBFFFF which corresponds to standard VGA memory area. Once you have that allocated, you need to also redefine the functions pokeb pokew peekb which will help you output things (text or pixel data) on the screen.
One last note: the code is already defined to work with many different modes including both text and display modes.
I was wondering if there were equivalents of the above mentioned functions for Linux (X11) - I can't seem to find them.
The Xlib functions you want are XQueryPointer() and XWarpPointer().
I've had issues with these not always returning what one would expect. The XTest extension as mentioned above was able to suit my needs. In particular the library function XTestFakeRelativeMotionEvent() worked well for what I was doing. YMMV.
Letting GetCursorPos apart, what you essentially want to do here is to emulate user input, like motion of the mouse pointer to a given location, or mouse button/keyboard input.
This is not part of the standard X11 API. However, the XTest extension provides this functionality and it should come with every decent X11 implementation out there. Another possibility may be the XTrap extension.
Here is the reference of XTest:
X11 XTEST EXTENSION (PDF)
For GetCursorPos, I don't know of a simple equivalent right now (although I assume it is there). What you can always do, however, is to process motion events, which will tell you where the pointer was moved to, whenever it is moved.
I am writing windows32 hooks around DirectX 6.1 library to DirectX 9.0c; Idea is to replace all calls to DX 6.1 3D device with calls to Direct 9.0c and inject some custom code, so old game which I am patching (99' year) will be able to use shaders, post-effects, etc.
The old DX 6.1 3D device was created by creating DDraw module. Game is then enumerating device caps. In my module the entire DDraw module is skiped and 3D view is initialized. So I have problem as I can't give the game Ddraw4 device caps which it requires as I do not have DDraw device at all!
So my question is how to obtain DDraw4 device caps without initializing DDraw4 device. Perhaps it will be sufficient to create fixed list and feed it to the game, but I have no idea what should be on that list (I gave what I thought it should be, and the game exited - logger showed it was just after device caps checked)
I've never tried this, but you might try the following. Assuming you don't have the 6.1 SDK, you could make the DDCAPS structure (the DirectDraw one) yourself (it's basically just DWORDs), then get the capabilities (D3DCAPS9) using the DX9 GetDeviceCaps function. Next, take the values you need from the acquired caps (using DX9) and set the equivalent values for DirectDraw in your DDCAPS structure. You could then feed this populated caps structure to the game. A few caveats--as you mentioned, you don't know what it needs specifically, so it's kind of hit and miss (unless you have the source code). Also, there may not be a 1:1 mapping for the caps structure values (between DX9 and DDraw). Finally--this ties in with not having the 6.1 SDK--if you don't know the flag values, you might set a flag incorrectly when setting the values according to the acquired caps. As I mentioned, this may be way off (or require a lot of detective work), but I figured it might be something you could try.
The solution was a bit crude, but most importantly - is working flawlessly.
I've written small self-contained utility, which initialize DDraw 6.1, than gets device caps, then dump them to the file on disk (device caps is Plain Old C format structure, so saving it is really simple) and quits. Then I can read the device caps file from disk and return it when application ask me for them.