[Freeswitch-branches] [commit] r11691 - freeswitch/branches/gmaruzz/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Sun Feb 8 07:09:15 PST 2009
Author: gmaruzz
Date: Sun Feb 8 09:09:14 2009
New Revision: 11691
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 09:09:14 2009
@@ -126,8 +126,6 @@
unsigned int howmany;
if (SAMPLERATE_SKYPIAX == 8000) {
- NOTICA("sizeof(short)=%d, \tSAMPLES_PER_FRAME=%d, \tSAMPLES_PER_FRAME/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), SAMPLES_PER_FRAME, SAMPLES_PER_FRAME/sizeof(short));
- NOTICA("sizeof(short)=%d, \tlen=%d, \tlen/sizeof(short)/2=%d\n", SKYPIAX_P_LOG, sizeof(short), len, len/sizeof(short)/2);
a = 0;
/* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
for (i = 0; i < len / sizeof(short); i++) {
@@ -135,51 +133,53 @@
i++;
a++;
}
-
+ /* if not yet done, let's store half incoming frame */
if (!tech_pvt->audiobuf_is_loaded) {
- for (i = 0; i < (len / sizeof(short)) / 2; i++) {
+ for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
tech_pvt->audiobuf[i] = srv_out[i];
}
tech_pvt->audiobuf_is_loaded = 1;
} else {
-
- howmany = len / sizeof(short) / 2;
- for (i = 0; i < howmany; i++){
+ /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
+ for (i = 0; i < SAMPLES_PER_FRAME / 2; i++){
totalbuf[i] = tech_pvt->audiobuf[i];
}
-
- for (a = 0; a < howmany; a++) {
+ for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) {
totalbuf[i] = srv_out[a];
i++;
}
-
- howmany = len;
-
- howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany);
+ /* send the complete frame through the pipe to our code waiting for incoming audio */
+ howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short));
+ if(howmany != SAMPLES_PER_FRAME * sizeof(short)){
+ ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, SAMPLES_PER_FRAME * sizeof(short));
+ }
+ /* done with the stored half frame */
tech_pvt->audiobuf_is_loaded = 0;
}
} else if (SAMPLERATE_SKYPIAX == 16000) {
- NOTICA("sizeof(short)=%d, SAMPLES_PER_FRAME=%d, SAMPLES_PER_FRAME/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), SAMPLES_PER_FRAME, SAMPLES_PER_FRAME/sizeof(short));
- NOTICA("sizeof(short)=%d, len=%d, len/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), len, len/sizeof(short));
-
+ /* if not yet done, let's store half incoming frame */
if (!tech_pvt->audiobuf_is_loaded) {
- for (i = 0; i < (len / sizeof(short)); i++) {
+ for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
tech_pvt->audiobuf[i] = srv_in[i];
}
tech_pvt->audiobuf_is_loaded = 1;
} else {
- howmany = SAMPLES_PER_FRAME * sizeof(short);
-
- for (i = 0; i < (len / sizeof(short)); i++){
+ /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
+ for (i = 0; i < (SAMPLES_PER_FRAME / 2); i++){
totalbuf[i] = tech_pvt->audiobuf[i];
}
- for (a = 0; a < (len / sizeof(short)); a++) {
+ for (a = 0; a < (SAMPLES_PER_FRAME / 2); a++) {
totalbuf[i] = srv_in[a];
i++;
}
- howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany);
+ /* send the complete frame through the pipe to our code waiting for incoming audio */
+ howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short));
+ if(howmany != SAMPLES_PER_FRAME * sizeof(short)){
+ ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, SAMPLES_PER_FRAME * sizeof(short));
+ }
+ /* done with the stored half frame */
tech_pvt->audiobuf_is_loaded = 0;
}
More information about the Freeswitch-branches
mailing list