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

PUBLIC int csoundListChannels ( CSOUND *  csound,
CsoundChannelListEntry **  lst 
)

Returns a list of allocated channels in *lst. A CsoundChannelListEntry structure contains the name and type of a channel, with the type having the same format as in the case of csoundGetChannelPtr(). The return value is the number of channels, which may be zero if there are none, or CSOUND_MEMORY if there is not enough memory for allocating the list. In the case of no channels or an error, *lst is set to NULL. Notes: the caller is responsible for freeing the list returned in *lst with csoundDeleteChannelList(). The name pointers may become invalid after calling csoundReset().

Definition at line 655 of file bus.c.

References csoundListChannels().

Referenced by csoundListChannels().

{
    channelEntry_t  *pp;
    size_t          i, n;

    *lst = (CsoundChannelListEntry*) NULL;
    if (csound->chn_db == NULL)
      return 0;
    /* count the number of channels */
    for (n = (size_t) 0, i = (size_t) 0; i < (size_t) 256; i++) {
      for (pp = ((channelEntry_t**) csound->chn_db)[i];
           pp != NULL;
           pp = pp->nxt, n++)
        ;
    }
    if (!n)
      return 0;
    /* create list, initially in unsorted order */
    *lst = (CsoundChannelListEntry*) malloc(n * sizeof(CsoundChannelListEntry));
    if (UNLIKELY(*lst == NULL))
      return CSOUND_MEMORY;
    for (n = (size_t) 0, i = (size_t) 0; i < (size_t) 256; i++) {
      for (pp = ((channelEntry_t**) csound->chn_db)[i];
           pp != NULL;
           pp = pp->nxt, n++) {
        (*lst)[n].name = pp->name;
        (*lst)[n].type = pp->type;
      }
    }
    /* sort list */
    qsort((void*) (*lst), n, sizeof(CsoundChannelListEntry), cmp_func);
    /* return the number of channels */
    return (int)n;
}


Generated by  Doxygen 1.6.0   Back to index