vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I've got the following problem, that I posted to misc@openbsd.org first. The problem is that if I link an application with pthread, it just won't read from the sound card. if I don't, it reads fine. consider the code below. if compiled as: gcc -o record record.c it works fine, returns: $ ./record 4 returned by read but if compiled: gcc -o record -pthread record.c it won't return anything, as it blocks with the call to read. does anyone have any idea of this fault? ---------8<----------snip here for record.c--------------------- #include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <errno.h> #include <sys/audioio.h> #define FILE_NAME "/dev/audio" #define SAMPLE_RATE 22050 #define CHANNEL 2 #define BITS_PER_SAMPLE 16 #define BUF_SIZE 4 int main(int argc, char **argv) { int fd; audio_info_t audioInfo; unsigned char buf[BUF_SIZE]; unsigned int len = BUF_SIZE; ssize_t ret; fd = open( FILE_NAME, O_RDONLY); AUDIO_INITINFO( &audioInfo); audioInfo.record.sample_rate = SAMPLE_RATE; audioInfo.record.channels = CHANNEL; audioInfo.record.precision = BITS_PER_SAMPLE; audioInfo.record.encoding = AUDIO_ENCODING_LINEAR; if ( ioctl(fd, AUDIO_SETINFO, &audioInfo) ) { printf("can't set audio info, error: %d\n", errno); } ret = read(fd, buf, len); printf("%d returned by read\n", ret); if ( ret == -1 ) { printf("error code %d\n", errno); } close(fd); return 0; } --------->8----------snip here for record.c--------------------- |