Ignore:
Timestamp:
Jun 14, 2006 8:04:04 PM (18 years ago)
Author:
bennylp
Message:

Standardise clearing and copying frame with pjmedia_zero_samples() and pjmedia_copy_samples()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/conference.c

    r492 r506  
    333333{ 
    334334    struct conf_port *conf_port; 
    335     pj_str_t name = { "sound-device", 12 }; 
     335    pj_str_t name = { "Master/sound", 12 }; 
    336336    unsigned i; 
    337337    pj_status_t status; 
     
    994994} 
    995995 
    996 /* Copy samples */ 
    997 PJ_INLINE(void) copy_samples(pj_int16_t *dst,  
    998                                 const pj_int16_t *src, 
    999                                 unsigned count) 
    1000 { 
    1001     unsigned i; 
    1002     for (i=0; i<count; ++i) 
    1003         dst[i] = src[i]; 
    1004 } 
    1005  
    1006 /* Zero samples. */ 
    1007 PJ_INLINE(void) zero_samples(pj_int16_t *buf, unsigned count) 
    1008 { 
    1009     unsigned i; 
    1010     for (i=0; i<count; ++i) 
    1011         buf[i] = 0; 
    1012 } 
    1013  
    1014996 
    1015997/* 
     
    10741056            if (f.type != PJMEDIA_FRAME_TYPE_AUDIO) { 
    10751057                TRACE_((THIS_FILE, "  get_frame returned non-audio")); 
    1076                 zero_samples( cport->rx_buf + cport->rx_buf_count, 
    1077                               cport->samples_per_frame); 
     1058                pjmedia_zero_samples( cport->rx_buf + cport->rx_buf_count, 
     1059                                      cport->samples_per_frame); 
    10781060            } 
    10791061 
     
    11031085            cport->rx_buf_count -= src_count; 
    11041086            if (cport->rx_buf_count) { 
    1105                 copy_samples(cport->rx_buf, cport->rx_buf+src_count, 
    1106                              cport->rx_buf_count); 
     1087                pjmedia_copy_samples(cport->rx_buf, cport->rx_buf+src_count, 
     1088                                     cport->rx_buf_count); 
    11071089            } 
    11081090 
     
    11121094        } else { 
    11131095 
    1114             copy_samples(frame, cport->rx_buf, count); 
     1096            pjmedia_copy_samples(frame, cport->rx_buf, count); 
    11151097            cport->rx_buf_count -= count; 
    11161098            if (cport->rx_buf_count) { 
    1117                 copy_samples(cport->rx_buf, cport->rx_buf+count, 
    1118                              cport->rx_buf_count); 
     1099                pjmedia_copy_samples(cport->rx_buf, cport->rx_buf+count, 
     1100                                     cport->rx_buf_count); 
    11191101            } 
    11201102        } 
     
    12021184    } else { 
    12031185        // Not necessarry. Buffer has been zeroed before. 
    1204         // zero_samples(buf, conf->samples_per_frame); 
     1186        // pjmedia_zero_samples(buf, conf->samples_per_frame); 
    12051187        pj_assert(buf[0] == 0); 
    12061188    } 
     
    12671249         * Just copy the samples to tx_buffer. 
    12681250         */ 
    1269         copy_samples( cport->tx_buf + cport->tx_buf_count, 
    1270                       buf, conf->samples_per_frame ); 
     1251        pjmedia_copy_samples( cport->tx_buf + cport->tx_buf_count, 
     1252                              buf, conf->samples_per_frame ); 
    12711253        cport->tx_buf_count += conf->samples_per_frame; 
    12721254    } 
     
    13011283        cport->tx_buf_count -= cport->samples_per_frame; 
    13021284        if (cport->tx_buf_count) { 
    1303             copy_samples(cport->tx_buf,  
    1304                         cport->tx_buf + cport->samples_per_frame, 
    1305                         cport->tx_buf_count); 
     1285            pjmedia_copy_samples(cport->tx_buf,  
     1286                                cport->tx_buf + cport->samples_per_frame, 
     1287                                cport->tx_buf_count); 
    13061288        } 
    13071289 
     
    13461328        mix_buf = conf_port->mix_buf; 
    13471329 
    1348         for (j=0; j<conf->samples_per_frame; ++j) mix_buf[j] = 0; 
     1330        pj_memset(mix_buf, 0, conf->samples_per_frame*sizeof(mix_buf[0])); 
    13491331    } 
    13501332 
     
    13951377 
    13961378            snd_buf = conf_port->snd_buf[conf_port->snd_read_pos]; 
    1397             for (j=0; j<conf->samples_per_frame; ++j) { 
    1398                 ((pj_int16_t*)frame->buf)[j] = snd_buf[j]; 
    1399             } 
     1379            pjmedia_copy_samples(frame->buf, snd_buf, conf->samples_per_frame); 
    14001380            conf_port->snd_read_pos = (conf_port->snd_read_pos+1) % RX_BUF_COUNT; 
    14011381 
     
    15351515                           conf->samples_per_frame)); 
    15361516 
    1537         copy_samples( frame->buf, (pj_int16_t*)conf->ports[0]->mix_buf,  
    1538                       conf->samples_per_frame); 
     1517        pjmedia_copy_samples( frame->buf, (pj_int16_t*)conf->ports[0]->mix_buf,  
     1518                              conf->samples_per_frame); 
    15391519    } else { 
    1540         zero_samples( frame->buf, conf->samples_per_frame );  
     1520        pjmedia_zero_samples( frame->buf, conf->samples_per_frame );  
    15411521    } 
    15421522 
     
    15671547    const pj_int16_t *input = frame->buf; 
    15681548    pj_int16_t *target_snd_buf; 
    1569     unsigned i; 
    15701549 
    15711550    /* Check for correct size. */ 
     
    15891568     
    15901569    /* Copy samples from audio device to target rx_buffer */ 
    1591     for (i=0; i<conf->samples_per_frame; ++i) { 
    1592         target_snd_buf[i] = ((pj_int16_t*)input)[i]; 
    1593     } 
     1570    pjmedia_copy_samples(target_snd_buf, input, conf->samples_per_frame); 
    15941571 
    15951572    /* Switch buffer */ 
Note: See TracChangeset for help on using the changeset viewer.