ioctl() SOUND_MIXER_WRITE_RECSRC fails with Invalid Argument

OSS specific Linux discussion (x86/amd64)

Moderators: hannu, dev, kodachi, cesium

ioctl() SOUND_MIXER_WRITE_RECSRC fails with Invalid Argument

Postby trax2010 » Wed Dec 30, 2009 5:41 am

Hello,

The following code is from an stable release of a project, and compiles fine, but fails with "mixer set to mic: Invalid Argument".
I'm running Fedora 11, and am using the v4.2 RPM from this site's download page.
I don't understand this. OSS is running fine for me, and Audacity can record just fine without any error of this sort.

Why is this happening?

Thanks

Code: Select all
    if ((mixerFD = open("/dev/mixer", O_RDONLY)) < 0) {
        if (errno == EBUSY) {
            fprintf(stderr, "%s %d: mixer device busy.\n",
                    __FILE__, __LINE__);
            fprintf(stderr, "%s %d: Using current setting.\n",
                    __FILE__, __LINE__);
        }
        else {
            fprintf(stderr, "%s %d: %s\n", __FILE__, __LINE__,
                    strerror(errno));
            exit(1);
        }
    }

    int32 sourceMic = SOUND_MASK_MIC;

    if (ioctl(mixerFD, SOUND_MIXER_WRITE_RECSRC, &sourceMic) < 0) {
        if (errno == ENXIO)
            fprintf(stderr,
                    "%s %d: can't set mic source for this device.\n",
                    __FILE__, __LINE__);
        else {
            fprintf(stderr,
                    "%s %d: mixer set to mic: %s\n",
                    __FILE__, __LINE__, strerror(errno));
            exit(1);
        }
    }
trax2010
 
Posts: 1
Joined: Wed Dec 30, 2009 5:30 am

Re: ioctl() SOUND_MIXER_WRITE_RECSRC fails with Invalid Argument

Postby cesium » Thu Dec 31, 2009 12:32 am

AFAICT, the code is fine. The problem is probably that OSSv4 doesn't implement the old OSSv3 mixer interface for all its drivers (see this for new API, this for old API). I guess you're using an OSSv4 driver (oss_hdaudio probably?) which doesn't implement it.
cesium
 
Posts: 896
Joined: Sun Aug 12, 2007 12:51 am


Return to Linux

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron