Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9240053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:07:22+00:00 2026-06-18T08:07:22+00:00

I want to port same function from oss mixer to alsa but I don’t

  • 0

I want to port same function from oss mixer to alsa but I don’t now how to check if device
channel have capture mask.
Code for OSS:

These functions handle the mixer device

static int mixer_fd = -1, mixer_src = -1;

int mixer_init(char *mixer_device, char *mixer_source)
{
    int i;  
    mixer_src = -1; 
    for (i=0;i<SOUND_MIXER_NRDEVICES;i++)
        if (strcmp(mixer_source, devices[i]) == 0) 
            mixer_src = i;

    mixer_fd = open(mixer_device, O_RDWR);
    if (mixer_src < 0)  
        return -1;          
    if (mixer_fd < 0)
        return 0;
    return 1;
}

char** mixer_get_rec_devices(void)
{
    int i, o, devmask, res;
    char** result;

    if ((ioctl(mixer_fd, SOUND_MIXER_READ_RECMASK, &devmask)) == -1)
    return NULL;
    else
    {
        result = malloc(sizeof(char*)*SOUND_MIXER_NRDEVICES);
        o = 0;
        for (i=0;i<SOUND_MIXER_NRDEVICES;i++)
            {
            res = (devmask >> i)%2;
                if (res)
            {
                result[o] = malloc(strlen(devices[i])+1);
                sprintf(result[o], "%s", devices[i]);
                o++;
            }
            result[o] = NULL;   
        }
    }
    return result;
}

int mixer_set_rec_device(void)
{
    int devmask, recmask;

    if (mixer_fd <= 0)
        return 0;

    if (mixer_src < 0)
        return 0;

    if ((ioctl(mixer_fd, SOUND_MIXER_READ_RECMASK, &devmask)) == -1)
        return 0;

    recmask = 1 << mixer_src;
    if (!(recmask & devmask))
        return 0;

    if ((ioctl(mixer_fd, SOUND_MIXER_WRITE_RECSRC, &recmask)) == -1)
        return 0;
    return 1;
}

I need help to port this code to ALSA mixer.

function “mixer_set_rec_device()” is used to check if channel mixer can record if user activate recording, where settings.mixer is channel choose by user.

if (!mixer_set_rec_device()) {
        fprintf(stderr, "Could not set \"%s\" as recording Source", settings.mixer);
        return -1;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:07:23+00:00Added an answer on June 18, 2026 at 8:07 am

    Some devices can capture from multiple sources; these devices typically have several boolean mixer controls named xxxxx Capture Switch.

    Some devices can capture from only one source; these devices typically have an enumerated mixer control named Capture Source.

    In the general case, the device’s mixer might work entirely different.

    In any case, general-purpose applications should never modify the user’s mixer configuration, but just record from some PCM device; configuring the mixer should be done by the user, or by some specialized mixer application that knows the hardware.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to port my application to CodeIgniter but i am wondering whether i
I want to check which port is used, when the port is not explicitly
i want to configure tomcat 7 to use port 80 on windows 7, but
When my window is resized, i don't want the contents to scale but just
I want to port an small open source AES encryption class to Android, and
I want to port this SQL query, which works just fine on SQL Server,
I want to port a python app that uses mechanize for the iPhone. This
I have a some doubles that I want to port into NSDecimalNumber, because I'm
I am a QT developer and I want to port my app to an
I have a date picker library written for MooTools that I want to port

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.