Logo Search packages:      
Sourcecode: pulseaudio version File versions  Download package

pa_channel_map* pa_channel_map_parse ( pa_channel_map map,
const char *  s 
)

Parse a channel position list into a channel map structure.

Since:
0.8.1

Definition at line 454 of file channelmap.c.

References pa_channel_map::channels, pa_channel_map::map, and PA_CHANNELS_MAX.

                                                                          {
    const char *state;
    pa_channel_map map;
    char *p;

    pa_assert(rmap);
    pa_assert(s);

    memset(&map, 0, sizeof(map));

    if (strcmp(s, "stereo") == 0) {
        map.channels = 2;
        map.map[0] = PA_CHANNEL_POSITION_LEFT;
        map.map[1] = PA_CHANNEL_POSITION_RIGHT;
        goto finish;
    }

    state = NULL;
    map.channels = 0;

    while ((p = pa_split(s, ",", &state))) {

        if (map.channels >= PA_CHANNELS_MAX) {
            pa_xfree(p);
            return NULL;
        }

        /* Some special aliases */
        if (strcmp(p, "left") == 0)
            map.map[map.channels++] = PA_CHANNEL_POSITION_LEFT;
        else if (strcmp(p, "right") == 0)
            map.map[map.channels++] = PA_CHANNEL_POSITION_RIGHT;
        else if (strcmp(p, "center") == 0)
            map.map[map.channels++] = PA_CHANNEL_POSITION_CENTER;
        else if (strcmp(p, "subwoofer") == 0)
            map.map[map.channels++] = PA_CHANNEL_POSITION_SUBWOOFER;
        else {
            pa_channel_position_t i;

            for (i = 0; i < PA_CHANNEL_POSITION_MAX; i++)
                if (strcmp(p, table[i]) == 0) {
                    map.map[map.channels++] = i;
                    break;
                }

            if (i >= PA_CHANNEL_POSITION_MAX) {
                pa_xfree(p);
                return NULL;
            }
        }

        pa_xfree(p);
    }

finish:

    if (!pa_channel_map_valid(&map))
        return NULL;

    *rmap = map;
    return rmap;
}


Generated by  Doxygen 1.6.0   Back to index