#include #include #include #include #include #include extern int main( void ) { #define DSP "/dev/dsp" int f = open( DSP, O_RDONLY ); int i, n; fd_set fds; if( f < 0 ) { perror( DSP ); return EXIT_FAILURE; } n = 0; if( ioctl( f, SNDCTL_DSP_SETTRIGGER, &n ) < 0 ) { perror( "SNDCTL_DSP_SETTRIGGER" ); return EXIT_FAILURE; } n = PCM_ENABLE_INPUT | PCM_ENABLE_OUTPUT; if( ioctl( f, SNDCTL_DSP_SETTRIGGER, &n ) < 0 ) { perror( "SNDCTL_DSP_SETTRIGGER" ); return EXIT_FAILURE; } for( i = 0; i < 10; i++ ) { char a[ 1024 ]; FD_ZERO( &fds ); FD_SET( f, &fds ); if( select( f + 1, &fds, NULL, NULL, NULL ) < 0 ) perror( "select" ); if( read( f, a, 1024 ) < 0 ) perror( "read" ); } close( f ); return EXIT_SUCCESS; }