Thread: how to read from /dev/ as a stream ?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    111

    how to read from /dev/ as a stream ?

    Hello,...

    i wish to use /dev/video (or /dev/dsp) as a stream and work with it:
    for the basic i wish only to get hold of data and manipulate it
    i tried the next :
    Code:
    include <stdio.h>
    
    int main(int argc,char **argv)
    {
            
            fclose(stdin);
            
            fopen("/dev/dsp","r");
            while(1)
            {
                    putchar(getchar());
            }
            fclose(stdin);
            return 0;
    }
    i wish to "see" the what is sent to the audio transfer (or any other).
    the problem is that i get all the time the same character (i guess it is 0).

    in the end i wish to be able to copy a stream (audio and video) and transfer and transfer it over the network to other pc and there to the correct devices :
    pc1/dev/video1 -> pc2/dev/video1
    pc1/dev/dsp -> pc2/dev/video1
    why Gaos didn't had a wife ?
    http://bsh83.blogspot.com

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Well you've closed stdin, and not assigned the result of fopen() to anything.

    Try freopen()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. read only folder on Windows
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 11-05-2007, 09:18 AM
  2. Determining if stdin stream holds data
    By Stack Overflow in forum C Programming
    Replies: 3
    Last Post: 01-28-2005, 02:52 PM
  3. Buffering??
    By Brain Cell in forum C Programming
    Replies: 15
    Last Post: 09-21-2004, 06:57 AM
  4. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 03:49 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM