From: Miklos S. <mi...@sz...> - 2011-08-08 15:28:55
|
Miklos Szeredi <mi...@sz...> writes: > Hans-Kristian Arntzen <ma...@ar...> writes: > >> I assume this is the correct mailing list for CUSE related posts. > > CUSE and OSSP are maintained by Tejun Heo. I added him to the CC. > >> I've tried to implement a character device emulating OSS, but poll() >> behaves strangely. It always returns immediately no matter the >> timeout, and .revents is set equal to .events for some reason. >> >> The exact same behavior is found in ossp-padsp as well, so I believe >> it's a bug in CUSE. >> Kernel is Linux 3.0 - x86_64, fuse 2.8.5 > > Can you get a debug log from OSSP as well? Oops, sorry. I see now that you already replied, that it was a user error... Thanks, Miklos > > Thanks, > Miklos > >> >> Test program and result log is included. I wonder what could cause this. >> Thanks in advance. >> >> >> >> >> >> #include <sys/soundcard.h> >> #include <stdio.h> >> #include <unistd.h> >> #include <assert.h> >> #include <fcntl.h> >> #include <stdint.h> >> #include <sys/ioctl.h> >> #include <sys/poll.h> >> >> int main(int argc, char *argv[]) >> { >> assert(argc == 2); >> int fd = open(argv[1], O_WRONLY); >> assert(fd >= 0); >> >> int param = 44100; >> int rc = ioctl(fd, SNDCTL_DSP_SPEED, ¶m); >> fprintf(stderr, "SPEED: rc = %d, param = %d\n", >> rc, param); >> >> param = 2; >> rc = ioctl(fd, SNDCTL_DSP_CHANNELS, ¶m); >> fprintf(stderr, "CHANNELS: rc = %d, param = %d\n", >> rc, param); >> >> param = AFMT_S16_LE; >> rc = ioctl(fd, SNDCTL_DSP_SETFMT, ¶m); >> fprintf(stderr, "FMT: rc = %d\n", rc); >> >> audio_buf_info info; >> ioctl(fd, SNDCTL_DSP_GETOSPACE, &info); >> fprintf(stderr, "GETOSPACE: rc = %d, bytes = %d, fragments = %d, fragsize = %d, fragstotal = %d\n", >> rc, info.bytes, info.fragments, info.fragsize, info.fragstotal); >> >> assert(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == 0); >> >> uint8_t buf[1024]; >> unsigned cnt = 0; >> >> for (;;) >> { >> struct pollfd pfd = { >> .events = POLLOUT | POLLIN, // POLLIN for shits 'n giggles. >> }; >> >> if (poll(&pfd, 1, 1000) < 0) >> break; >> >> fprintf(stderr, "poll(): POLLOUT = %d, .events = %u, .revents = %u, Count = %u\n", >> (pfd.revents & POLLOUT) ? 1 : 0, >> pfd.events, >> pfd.revents, >> cnt++); >> >> if ((~pfd.revents) & POLLOUT) >> continue; >> >> audio_buf_info info; >> ioctl(fd, SNDCTL_DSP_GETOSPACE, &info); >> size_t avail = sizeof(buf) < (size_t)info.bytes ? sizeof(buf) : (size_t)info.bytes; >> fprintf(stderr, "OSS write avail: %u\n", (unsigned)info.bytes); >> >> if (read(0, buf, avail) <= 0) >> break; >> >> if (write(fd, buf, avail) < 0) >> break; >> } >> >> close(fd); >> } >> >> SPEED: rc = 0, param = 44100 >> CHANNELS: rc = 0, param = 2 >> FMT: rc = 0 >> GETOSPACE: rc = 0, bytes = 65536, fragments = 4, fragsize = 16384, fragstotal = 4 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 0 >> OSS write avail: 65536 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 1 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 2 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 3 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 4 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 5 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 6 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 7 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 8 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 9 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 10 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 11 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 12 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 13 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 14 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 15 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 16 >> OSS write avail: 49152 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 17 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 18 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 19 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 20 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 21 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 22 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 23 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 24 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 25 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 26 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 27 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 28 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 29 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 30 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 31 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 32 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 33 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 34 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 35 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 36 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 37 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 38 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 39 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 40 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 41 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 42 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 43 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 44 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 45 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 46 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 47 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 48 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 49 >> OSS write avail: 32768 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 50 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 51 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 52 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 53 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 54 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 55 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 56 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 57 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 58 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 59 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 60 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 61 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 62 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 63 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 64 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 65 >> OSS write avail: 16384 >> poll(): POLLOUT = 1, .events = 5, .revents = 5, Count = 66 >> OSS write avail: 0 >> ------------------------------------------------------------------------------ >> Magic Quadrant for Content-Aware Data Loss Prevention >> Research study explores the data loss prevention market. Includes in-depth >> analysis on the changes within the DLP market, and the criteria used to >> evaluate the strengths and weaknesses of these DLP solutions. >> http://www.accelacomm.com/jaw/sfnl/114/51385063/_______________________________________________ >> fuse-devel mailing list >> fus...@li... >> https://lists.sourceforge.net/lists/listinfo/fuse-devel |