FYI typically what you are really doing is
your program -> talks to library -> talks to drivers -> talks to hardware. Talking directly to hardware is extremely involved for complex data like video/sound. You can talk directly to very simple devices with minimal effort (like a simple joystick), anything else is either going to be a big project in and of itself or using someone else's solution.