comparison libaf/af_channels.c @ 29263:0f1b5b68af32

whitespace cosmetics: Remove all trailing whitespace.
author diego
date Wed, 13 May 2009 02:58:57 +0000
parents 8c706ce21c6f
children a93891202051
comparison
equal deleted inserted replaced
29262:7d545a6b8aff 29263:0f1b5b68af32
106 tout+=outs; 106 tout+=outs;
107 } 107 }
108 break; 108 break;
109 } 109 }
110 default: 110 default:
111 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Unsupported number of bytes/sample: %i" 111 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Unsupported number of bytes/sample: %i"
112 " please report this error on the MPlayer mailing list. \n",bps); 112 " please report this error on the MPlayer mailing list. \n",bps);
113 } 113 }
114 } 114 }
115 115
116 // Make sure the routes are sane 116 // Make sure the routes are sane
117 static int check_routes(af_channels_t* s, int nin, int nout) 117 static int check_routes(af_channels_t* s, int nin, int nout)
118 { 118 {
119 int i; 119 int i;
120 if((s->nr < 1) || (s->nr > AF_NCH)){ 120 if((s->nr < 1) || (s->nr > AF_NCH)){
121 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be" 121 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be"
122 " between 1 and %i. Current value is %i\n",AF_NCH,s->nr); 122 " between 1 and %i. Current value is %i\n",AF_NCH,s->nr);
123 return AF_ERROR; 123 return AF_ERROR;
124 } 124 }
125 125
126 for(i=0;i<s->nr;i++){ 126 for(i=0;i<s->nr;i++){
127 if((s->route[i][FR] >= nin) || (s->route[i][TO] >= nout)){ 127 if((s->route[i][FR] >= nin) || (s->route[i][TO] >= nout)){
128 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Invalid routing in pair nr. %i.\n", i); 128 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] Invalid routing in pair nr. %i.\n", i);
129 return AF_ERROR; 129 return AF_ERROR;
130 } 130 }
140 case AF_CONTROL_REINIT: 140 case AF_CONTROL_REINIT:
141 141
142 // Set default channel assignment 142 // Set default channel assignment
143 if(!s->router){ 143 if(!s->router){
144 int i; 144 int i;
145 // Make sure this filter isn't redundant 145 // Make sure this filter isn't redundant
146 if(af->data->nch == ((af_data_t*)arg)->nch) 146 if(af->data->nch == ((af_data_t*)arg)->nch)
147 return AF_DETACH; 147 return AF_DETACH;
148 148
149 // If mono: fake stereo 149 // If mono: fake stereo
150 if(((af_data_t*)arg)->nch == 1){ 150 if(((af_data_t*)arg)->nch == 1){
178 if(s->nr){ 178 if(s->nr){
179 char* cp = &((char*)arg)[n]; 179 char* cp = &((char*)arg)[n];
180 int ch = 0; 180 int ch = 0;
181 // Sanity check 181 // Sanity check
182 if((s->nr < 1) || (s->nr > AF_NCH)){ 182 if((s->nr < 1) || (s->nr > AF_NCH)){
183 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be" 183 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of routing pairs must be"
184 " between 1 and %i. Current value is %i\n",AF_NCH,s->nr); 184 " between 1 and %i. Current value is %i\n",AF_NCH,s->nr);
185 } 185 }
186 s->router = 1; 186 s->router = 1;
187 // Scan for pairs on commandline 187 // Scan for pairs on commandline
188 while((*cp == ':') && (ch < s->nr)){ 188 while((*cp == ':') && (ch < s->nr)){
189 sscanf(cp, ":%i:%i%n" ,&s->route[ch][FR], &s->route[ch][TO], &n); 189 sscanf(cp, ":%i:%i%n" ,&s->route[ch][FR], &s->route[ch][TO], &n);
190 mp_msg(MSGT_AFILTER, MSGL_V, "[channels] Routing from channel %i to" 190 mp_msg(MSGT_AFILTER, MSGL_V, "[channels] Routing from channel %i to"
191 " channel %i\n",s->route[ch][FR],s->route[ch][TO]); 191 " channel %i\n",s->route[ch][FR],s->route[ch][TO]);
192 cp = &cp[n]; 192 cp = &cp[n];
193 ch++; 193 ch++;
194 } 194 }
195 } 195 }
196 196
197 if(AF_OK != af->control(af,AF_CONTROL_CHANNELS | AF_CONTROL_SET ,&nch)) 197 if(AF_OK != af->control(af,AF_CONTROL_CHANNELS | AF_CONTROL_SET ,&nch))
198 return AF_ERROR; 198 return AF_ERROR;
199 return AF_OK; 199 return AF_OK;
200 } 200 }
201 case AF_CONTROL_CHANNELS | AF_CONTROL_SET: 201 case AF_CONTROL_CHANNELS | AF_CONTROL_SET:
202 // Reinit must be called after this function has been called 202 // Reinit must be called after this function has been called
203 203
204 // Sanity check 204 // Sanity check
205 if(((int*)arg)[0] <= 0 || ((int*)arg)[0] > AF_NCH){ 205 if(((int*)arg)[0] <= 0 || ((int*)arg)[0] > AF_NCH){
206 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of output channels must be" 206 mp_msg(MSGT_AFILTER, MSGL_ERR, "[channels] The number of output channels must be"
207 " between 1 and %i. Current value is %i\n",AF_NCH,((int*)arg)[0]); 207 " between 1 and %i. Current value is %i\n",AF_NCH,((int*)arg)[0]);
208 return AF_ERROR; 208 return AF_ERROR;
209 } 209 }
210 210
211 af->data->nch=((int*)arg)[0]; 211 af->data->nch=((int*)arg)[0];
212 if(!s->router) 212 if(!s->router)
213 mp_msg(MSGT_AFILTER, MSGL_V, "[channels] Changing number of channels" 213 mp_msg(MSGT_AFILTER, MSGL_V, "[channels] Changing number of channels"
214 " to %i\n",af->data->nch); 214 " to %i\n",af->data->nch);
215 return AF_OK; 215 return AF_OK;
216 case AF_CONTROL_CHANNELS | AF_CONTROL_GET: 216 case AF_CONTROL_CHANNELS | AF_CONTROL_GET:
217 *(int*)arg = af->data->nch; 217 *(int*)arg = af->data->nch;
218 return AF_OK; 218 return AF_OK;
244 return AF_OK; 244 return AF_OK;
245 } 245 }
246 return AF_UNKNOWN; 246 return AF_UNKNOWN;
247 } 247 }
248 248
249 // Deallocate memory 249 // Deallocate memory
250 static void uninit(struct af_instance_s* af) 250 static void uninit(struct af_instance_s* af)
251 { 251 {
252 free(af->setup); 252 free(af->setup);
253 if (af->data) 253 if (af->data)
254 free(af->data->audio); 254 free(af->data->audio);
260 { 260 {
261 af_data_t* c = data; // Current working data 261 af_data_t* c = data; // Current working data
262 af_data_t* l = af->data; // Local data 262 af_data_t* l = af->data; // Local data
263 af_channels_t* s = af->setup; 263 af_channels_t* s = af->setup;
264 int i; 264 int i;
265 265
266 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data)) 266 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
267 return NULL; 267 return NULL;
268 268
269 // Reset unused channels 269 // Reset unused channels
270 memset(l->audio,0,c->len / c->nch * l->nch); 270 memset(l->audio,0,c->len / c->nch * l->nch);
271 271
272 if(AF_OK == check_routes(s,c->nch,l->nch)) 272 if(AF_OK == check_routes(s,c->nch,l->nch))
273 for(i=0;i<s->nr;i++) 273 for(i=0;i<s->nr;i++)
274 copy(c->audio,l->audio,c->nch,s->route[i][FR], 274 copy(c->audio,l->audio,c->nch,s->route[i][FR],
275 l->nch,s->route[i][TO],c->len,c->bps); 275 l->nch,s->route[i][TO],c->len,c->bps);
276 276
277 // Set output data 277 // Set output data
278 c->audio = l->audio; 278 c->audio = l->audio;
279 c->len = c->len / c->nch * l->nch; 279 c->len = c->len / c->nch * l->nch;
280 c->nch = l->nch; 280 c->nch = l->nch;
281 281