Changeset 3422:1e1481777215 in roaraudio for libroarpulse


Ignore:
Timestamp:
02/11/10 21:45:26 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

wrote some more funcs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarpulse/channelmap.c

    r3420 r3422  
    7676} 
    7777 
     78static struct { 
     79 pa_channel_position_t pos; 
     80 char * name; 
     81} _roar_po_chanpos[] = { 
     82 {PA_CHANNEL_POSITION_INVALID,               "invalid"                    }, 
     83 {PA_CHANNEL_POSITION_MONO,                  "mono"                       }, 
     84 {PA_CHANNEL_POSITION_LEFT,                  "left"                       }, 
     85 {PA_CHANNEL_POSITION_RIGHT,                 "right"                      }, 
     86 {PA_CHANNEL_POSITION_CENTER,                "center"                     }, 
     87 {PA_CHANNEL_POSITION_FRONT_LEFT,            "front-left"                 }, 
     88 {PA_CHANNEL_POSITION_FRONT_RIGHT,           "front-right"                }, 
     89 {PA_CHANNEL_POSITION_FRONT_CENTER,          "front-center"               }, 
     90 {PA_CHANNEL_POSITION_REAR_CENTER,           "rear-center"                }, 
     91 {PA_CHANNEL_POSITION_REAR_LEFT,             "rear-left"                  }, 
     92 {PA_CHANNEL_POSITION_REAR_RIGHT,            "rear-right"                 }, 
     93 {PA_CHANNEL_POSITION_LFE,                   "lfe"                        }, 
     94 {PA_CHANNEL_POSITION_SUBWOOFER,             "subwoofer"                  }, 
     95 {PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,  "front-left-of-center"       }, 
     96 {PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, "front-right-of-center"      }, 
     97 {PA_CHANNEL_POSITION_SIDE_LEFT,             "side-left"                  }, 
     98 {PA_CHANNEL_POSITION_SIDE_RIGHT,            "side-right"                 }, 
     99 {PA_CHANNEL_POSITION_AUX0,                  "aux0"                       }, 
     100 {PA_CHANNEL_POSITION_AUX1,                  "aux1"                       }, 
     101 {PA_CHANNEL_POSITION_AUX2,                  "aux2"                       }, 
     102 {PA_CHANNEL_POSITION_AUX3,                  "aux3"                       }, 
     103 {PA_CHANNEL_POSITION_AUX4,                  "aux4"                       }, 
     104 {PA_CHANNEL_POSITION_AUX5,                  "aux5"                       }, 
     105 {PA_CHANNEL_POSITION_AUX6,                  "aux6"                       }, 
     106 {PA_CHANNEL_POSITION_AUX7,                  "aux7"                       }, 
     107 {PA_CHANNEL_POSITION_AUX8,                  "aux8"                       }, 
     108 {PA_CHANNEL_POSITION_AUX9,                  "aux9"                       }, 
     109 {PA_CHANNEL_POSITION_AUX10,                 "aux10"                      }, 
     110 {PA_CHANNEL_POSITION_AUX11,                 "aux11"                      }, 
     111 {PA_CHANNEL_POSITION_AUX12,                 "aux12"                      }, 
     112 {PA_CHANNEL_POSITION_AUX13,                 "aux13"                      }, 
     113 {PA_CHANNEL_POSITION_AUX14,                 "aux14"                      }, 
     114 {PA_CHANNEL_POSITION_AUX15,                 "aux15"                      }, 
     115 {PA_CHANNEL_POSITION_AUX16,                 "aux16"                      }, 
     116 {PA_CHANNEL_POSITION_AUX17,                 "aux17"                      }, 
     117 {PA_CHANNEL_POSITION_AUX18,                 "aux18"                      }, 
     118 {PA_CHANNEL_POSITION_AUX19,                 "aux19"                      }, 
     119 {PA_CHANNEL_POSITION_AUX20,                 "aux20"                      }, 
     120 {PA_CHANNEL_POSITION_AUX21,                 "aux21"                      }, 
     121 {PA_CHANNEL_POSITION_AUX22,                 "aux22"                      }, 
     122 {PA_CHANNEL_POSITION_AUX23,                 "aux23"                      }, 
     123 {PA_CHANNEL_POSITION_AUX24,                 "aux24"                      }, 
     124 {PA_CHANNEL_POSITION_AUX25,                 "aux25"                      }, 
     125 {PA_CHANNEL_POSITION_AUX26,                 "aux26"                      }, 
     126 {PA_CHANNEL_POSITION_AUX27,                 "aux27"                      }, 
     127 {PA_CHANNEL_POSITION_AUX28,                 "aux28"                      }, 
     128 {PA_CHANNEL_POSITION_AUX29,                 "aux29"                      }, 
     129 {PA_CHANNEL_POSITION_AUX30,                 "aux30"                      }, 
     130 {PA_CHANNEL_POSITION_AUX31,                 "aux31"                      }, 
     131 {PA_CHANNEL_POSITION_TOP_CENTER,            "top-center"                 }, 
     132 {PA_CHANNEL_POSITION_TOP_FRONT_LEFT,        "top-front-left"             }, 
     133 {PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,       "top-front-right"            }, 
     134 {PA_CHANNEL_POSITION_TOP_FRONT_CENTER,      "top-front-center"           }, 
     135 {PA_CHANNEL_POSITION_TOP_REAR_LEFT,         "top-rear-left"              }, 
     136 {PA_CHANNEL_POSITION_TOP_REAR_RIGHT,        "top-rear-right"             }, 
     137 {PA_CHANNEL_POSITION_TOP_REAR_CENTER,       "top-rear-center"            }, 
     138 {PA_CHANNEL_POSITION_MAX,                   "max"                        }, 
     139 {PA_CHANNEL_POSITION_INVALID, NULL} 
     140}; 
     141 
    78142/** Return a text label for the specified channel position */ 
    79 const char* pa_channel_position_to_string(pa_channel_position_t pos); 
     143const char* pa_channel_position_to_string(pa_channel_position_t pos) { 
     144 int i; 
     145 
     146 for (i = 0; _roar_po_chanpos[i].name != NULL; i++) 
     147  if ( _roar_po_chanpos[i].pos == pos ) 
     148   return _roar_po_chanpos[i].name; 
     149 
     150 return NULL; 
     151} 
    80152 
    81153/** The maximum length of strings returned by pa_channel_map_snprint() */ 
     
    83155 
    84156/** Make a humand readable string from the specified channel map */ 
    85 char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map); 
     157char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map) { 
     158 const char * g; 
     159 char * c = s; 
     160 int i; 
     161 size_t len; 
     162 size_t todo = l; 
     163 
     164 if ( map == NULL || s == NULL || l == 0 ) 
     165  return NULL; 
     166 
     167 *c = 0; 
     168 
     169 for (i = 0; i < map->channels; i++) { 
     170  g = pa_channel_position_to_string(map->map[i]); 
     171 
     172  if ( g == NULL ) 
     173   return NULL; 
     174 
     175  len = strlen(g); 
     176 
     177  if ( (len + 1) < todo ) { 
     178   memcpy(c, g, len); 
     179   c[len] = ','; 
     180   c    += len + 1; 
     181   todo -= len + 1; 
     182  } else { 
     183   return NULL; 
     184  } 
     185 } 
     186 
     187 c[-1]  = 0; 
     188 s[l-1] = 0; 
     189 
     190 return s; 
     191} 
    86192 
    87193/** Parse a channel position list into a channel map structure. \since 0.8.1 */ 
Note: See TracChangeset for help on using the changeset viewer.