/* returns the number of contacts put in the sorted array */ static int sort_contacts(hdr_field_t *chdr, contact_t **ct_array, qvalue_t *q_array) { param_t *q_para; qvalue_t q; int n; int i,j; char backup; contact_t *ct_list; hdr_field_t *hdr; n = 0; /* number of sorted contacts */ for(hdr=chdr; hdr; hdr=hdr->next) { if(hdr->type != HDR_CONTACT_T) continue; ct_list = ((contact_body_t*)hdr->parsed)->contacts; for( ; ct_list ; ct_list = ct_list->next ) { /* check the filters first */ backup = ct_list->uri.s[ct_list->uri.len]; ct_list->uri.s[ct_list->uri.len] = 0; if ( run_filters( ct_list->uri.s )==-1 ){ ct_list->uri.s[ct_list->uri.len] = backup; continue; } ct_list->uri.s[ct_list->uri.len] = backup; /* does the contact has a q val? */ q_para = ct_list->q; if (q_para==0 || q_para->body.len==0) { q = DEFAULT_Q_VALUE; } else { if (str2q( &q, q_para->body.s, q_para->body.len)!=0) { LM_ERR("invalid q param\n"); /* skip this contact */ continue; } } LM_DBG("sort_contacts: <%.*s> q=%d\n", ct_list->uri.len,ct_list->uri.s,q); /*insert the contact into the sorted array */ for(i=0;i<n;i++) { /* keep in mind that the contact list is reversed */ if (q_array[i]<=q) continue; break; } if (i!=MAX_CONTACTS_PER_REPLY) { /* insert the contact at this position */ for( j=n-1-1*(n==MAX_CONTACTS_PER_REPLY) ; j>=i ; j-- ) { ct_array[j+1] = ct_array[j]; q_array[j+1] = q_array[j]; } ct_array[j+1] = ct_list; q_array[j+1] = q; if (n!=MAX_CONTACTS_PER_REPLY) n++; } } } return n; }
bool SoundBuffer_Session_Impl::mix_to(float **sample_data, float **temp_data, int num_samples, int num_channels) { MutexSection mutex_lock(&mutex); get_data_in_mixer_frequency(num_samples, temp_data); run_filters(temp_data, num_samples); mix_channels(num_channels, num_samples, sample_data, temp_data); return playing; }
/* returns the number of contacts put in the sorted array */ static int sort_contacts(contact_t *ct_list, contact_t **ct_array) { static qvalue_t q_array[MAX_CONTACTS_PER_REPLY]; param_t *q_para; qvalue_t q; int n; int i,j; char backup; n = 0; /* number of sorted contacts */ for( ; ct_list ; ct_list = ct_list->next ) { /* check the filters first */ backup = ct_list->uri.s[ct_list->uri.len]; ct_list->uri.s[ct_list->uri.len] = 0; if ( run_filters( ct_list->uri.s )==-1 ){ ct_list->uri.s[ct_list->uri.len] = backup; continue; } ct_list->uri.s[ct_list->uri.len] = backup; /* does the contact has a q val? */ q_para = ct_list->q; if (q_para==0 || q_para->body.len==0) { q = DEFAULT_Q_VALUE; } else { if (str2q( &q, q_para->body.s, q_para->body.len)!=0) { LOG(L_ERR, "ERROR:uac_redirect:sort_contacts: " "invalid q param\n"); /* skip this contact */ continue; } } DBG("DEBUG:uac_redirect:sort_contacts: <%.*s> q=%d\n", ct_list->uri.len,ct_list->uri.s,q); /*insert the contact into the sorted array */ for(i=0;i<n;i++) { /* keep in mind that the contact list is reversts */ if (q_array[i]<q) continue; break; } if (i!=MAX_CONTACTS_PER_REPLY) { /* insert the contact at this position */ for( j=n-1-1*(n==MAX_CONTACTS_PER_REPLY) ; j>=i ; j-- ) { ct_array[j+1] = ct_array[j]; q_array[j+1] = q_array[j]; } ct_array[j+1] = ct_list; q_array[j+1] = q; if (n!=MAX_CONTACTS_PER_REPLY) n++; } } return n; }
/* returns the number of contacts put in the sorted array */ static void sort_contacts(contact_t *ct_list, str *ct_array, qvalue_t *q_array, int *n) { param_t *q_para; qvalue_t q; int i, j, rc; char backup; for( ; ct_list ; ct_list = ct_list->next ) { /* check the filters first */ backup = ct_list->uri.s[ct_list->uri.len]; ct_list->uri.s[ct_list->uri.len] = 0; if ( run_filters( ct_list->uri.s )==-1 ){ ct_list->uri.s[ct_list->uri.len] = backup; continue; } ct_list->uri.s[ct_list->uri.len] = backup; /* does the contact has a q val? */ q_para = ct_list->q; if (q_para==0 || q_para->body.len==0) { q = DEFAULT_Q_VALUE; } else { rc = str2q( &q, q_para->body.s, q_para->body.len); if (rc != 0) { LM_ERR("invalid qvalue (%.*s): %s\n", q_para->body.len, q_para->body.s, qverr2str(rc)); /* skip this contact */ continue; } } LM_DBG("sort_contacts: <%.*s> q=%d\n", ct_list->uri.len,ct_list->uri.s,q); /*insert the contact into the sorted array */ for(i=0;i<*n;i++) { /* keep in mind that the contact list is reversts */ if (q_array[i]<=q) continue; break; } if (i!=MAX_CONTACTS_PER_REPLY) { /* insert the contact at this position */ for( j=(*n)-1-1*((*n)==MAX_CONTACTS_PER_REPLY) ; j>=i ; j-- ) { ct_array[j+1] = ct_array[j]; q_array[j+1] = q_array[j]; } ct_array[j+1] = ct_list->uri; q_array[j+1] = q; if ((*n)!=MAX_CONTACTS_PER_REPLY) (*n)++; } } }