Changeset 506
- Timestamp:
- Jun 14, 2006 8:04:04 PM (18 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/types.h
r438 r506 116 116 /** 117 117 * This is a general purpose function set PCM samples to zero. 118 * Since this function is needed by many parts of the library, it is important 119 * that the library should select the best performance for this. 118 * Since this function is needed by many parts of the library, 119 * by putting this functionality in one place, it enables some. 120 * clever people to optimize this function. 120 121 * 121 122 * @param samples The 16bit PCM samples. … … 130 131 131 132 133 /** 134 * This is a general purpose function to copy samples from/to buffers with 135 * equal size. Since this function is needed by many parts of the library, 136 * by putting this functionality in one place, it enables some. 137 * clever people to optimize this function. 138 */ 139 PJ_INLINE(void) pjmedia_copy_samples(pj_int16_t *dst, const pj_int16_t *src, 140 unsigned count) 141 { 142 unsigned i; 143 for (i=0; i<count; ++i) 144 dst[i] = src[i]; 145 } 146 147 132 148 #endif /* __PJMEDIA_TYPES_H__ */ 133 149 -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r492 r506 333 333 { 334 334 struct conf_port *conf_port; 335 pj_str_t name = { " sound-device", 12 };335 pj_str_t name = { "Master/sound", 12 }; 336 336 unsigned i; 337 337 pj_status_t status; … … 994 994 } 995 995 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 1014 996 1015 997 /* … … 1074 1056 if (f.type != PJMEDIA_FRAME_TYPE_AUDIO) { 1075 1057 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); 1078 1060 } 1079 1061 … … 1103 1085 cport->rx_buf_count -= src_count; 1104 1086 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); 1107 1089 } 1108 1090 … … 1112 1094 } else { 1113 1095 1114 copy_samples(frame, cport->rx_buf, count);1096 pjmedia_copy_samples(frame, cport->rx_buf, count); 1115 1097 cport->rx_buf_count -= count; 1116 1098 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); 1119 1101 } 1120 1102 } … … 1202 1184 } else { 1203 1185 // Not necessarry. Buffer has been zeroed before. 1204 // zero_samples(buf, conf->samples_per_frame);1186 // pjmedia_zero_samples(buf, conf->samples_per_frame); 1205 1187 pj_assert(buf[0] == 0); 1206 1188 } … … 1267 1249 * Just copy the samples to tx_buffer. 1268 1250 */ 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 ); 1271 1253 cport->tx_buf_count += conf->samples_per_frame; 1272 1254 } … … 1301 1283 cport->tx_buf_count -= cport->samples_per_frame; 1302 1284 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); 1306 1288 } 1307 1289 … … 1346 1328 mix_buf = conf_port->mix_buf; 1347 1329 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])); 1349 1331 } 1350 1332 … … 1395 1377 1396 1378 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); 1400 1380 conf_port->snd_read_pos = (conf_port->snd_read_pos+1) % RX_BUF_COUNT; 1401 1381 … … 1535 1515 conf->samples_per_frame)); 1536 1516 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); 1539 1519 } else { 1540 zero_samples( frame->buf, conf->samples_per_frame );1520 pjmedia_zero_samples( frame->buf, conf->samples_per_frame ); 1541 1521 } 1542 1522 … … 1567 1547 const pj_int16_t *input = frame->buf; 1568 1548 pj_int16_t *target_snd_buf; 1569 unsigned i;1570 1549 1571 1550 /* Check for correct size. */ … … 1589 1568 1590 1569 /* 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); 1594 1571 1595 1572 /* Switch buffer */ -
pjproject/trunk/pjmedia/src/pjmedia/null_port.c
r411 r506 88 88 pjmedia_frame *frame) 89 89 { 90 unsigned i, count; 91 pj_int16_t *samples = frame->buf; 92 93 count = this_port->info.samples_per_frame; 94 for (i=0; i<count; ++i) { 95 samples[i] = 0; 96 } 90 frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 91 frame->size = this_port->info.samples_per_frame * 2; 92 frame->timestamp.u32.lo += this_port->info.samples_per_frame; 93 pjmedia_zero_samples(frame->buf, this_port->info.samples_per_frame); 97 94 98 95 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.