Fixed C errors from GCC 4.6.

Fixed errors in .c files.

BUG=
TEST=

Review URL: https://webrtc-codereview.appspot.com/373014

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1563 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
phoglund@webrtc.org 2012-01-27 13:44:26 +00:00
parent 1f992807eb
commit 2f7740973d
3 changed files with 97 additions and 106 deletions

View File

@ -137,8 +137,6 @@ int main(int argc, char* argv[])
int cur_delay = 0; int cur_delay = 0;
char gns_file[100]; char gns_file[100];
WebRtc_UWord16 rtp_num_init = 0;
int nbTest = 0; int nbTest = 0;
WebRtc_Word16 lostFrame; WebRtc_Word16 lostFrame;
float scale = (float)0.7; float scale = (float)0.7;
@ -376,7 +374,6 @@ int main(int argc, char* argv[])
/* Set initial RTP number */ /* Set initial RTP number */
if (!strcmp ("-RTP_INIT", argv[i])) { if (!strcmp ("-RTP_INIT", argv[i])) {
rtp_num_init = atoi(argv[i + 1]);
i++; i++;
} }
} }

View File

@ -38,7 +38,6 @@
#define FS_SWB 32000 #define FS_SWB 32000
#define FS_WB 16000 #define FS_WB 16000
//#define CHANGE_OUTPUT_NAME //#define CHANGE_OUTPUT_NAME
#ifdef HAVE_DEBUG_INFO #ifdef HAVE_DEBUG_INFO
@ -48,41 +47,36 @@
unsigned long framecnt = 0; unsigned long framecnt = 0;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
//--- File IO ---- //--- File IO ----
FILE* inp; FILE* inp;
FILE* outp; FILE* outp;
char inname[500]; char inname[500];
char outname[500]; char outname[500];
/* Runtime statistics */ /* Runtime statistics */
double starttime;
double rate; double rate;
double rateRCU; double rateRCU;
double rateLB;
double rateUB;
unsigned long totalbits = 0; unsigned long totalbits = 0;
unsigned long totalBitsRCU = 0; unsigned long totalBitsRCU = 0;
unsigned long totalsmpls =0; unsigned long totalsmpls =0;
WebRtc_Word32 bottleneck = 39; WebRtc_Word32 bottleneck = 39;
WebRtc_Word16 frameSize = 30; /* ms */ WebRtc_Word16 frameSize = 30; /* ms */
WebRtc_Word16 codingMode = 1; WebRtc_Word16 codingMode = 1;
WebRtc_Word16 shortdata[FRAMESAMPLES_SWB_10ms]; WebRtc_Word16 shortdata[FRAMESAMPLES_SWB_10ms];
WebRtc_Word16 decoded[MAX_FRAMESAMPLES_SWB]; WebRtc_Word16 decoded[MAX_FRAMESAMPLES_SWB];
//WebRtc_UWord16 streamdata[1000]; //WebRtc_UWord16 streamdata[1000];
WebRtc_Word16 speechType[1]; WebRtc_Word16 speechType[1];
WebRtc_Word16 payloadLimit; WebRtc_Word16 payloadLimit;
WebRtc_Word32 rateLimit; WebRtc_Word32 rateLimit;
ISACStruct* ISAC_main_inst; ISACStruct* ISAC_main_inst;
WebRtc_Word16 stream_len = 0; WebRtc_Word16 stream_len = 0;
WebRtc_Word16 declen; WebRtc_Word16 declen;
WebRtc_Word16 err; WebRtc_Word16 err;
WebRtc_Word16 cur_framesmpls; WebRtc_Word16 cur_framesmpls;
int endfile; int endfile;
#ifdef WIN32 #ifdef WIN32
double length_file; double length_file;
@ -93,6 +87,9 @@ int main(int argc, char* argv[])
char outSuffix[500]; char outSuffix[500];
char bitrateFileName[500]; char bitrateFileName[500];
FILE* bitrateFile; FILE* bitrateFile;
double starttime;
double rateLB = 0;
double rateUB = 0;
#endif #endif
FILE* histFile; FILE* histFile;
FILE* averageFile; FILE* averageFile;
@ -120,13 +117,13 @@ int main(int argc, char* argv[])
memset(hist, 0, sizeof(hist)); memset(hist, 0, sizeof(hist));
/* handling wrong input arguments in the command line */ /* handling wrong input arguments in the command line */
if(argc < 5) if(argc < 5)
{ {
int size; int size;
WebRtcIsac_AssignSize(&size); WebRtcIsac_AssignSize(&size);
printf("\n\nWrong number of arguments or flag values.\n\n"); printf("\n\nWrong number of arguments or flag values.\n\n");
printf("Usage:\n\n"); printf("Usage:\n\n");
printf("%s infile outfile -bn bottelneck [options] \n\n", argv[0]); printf("%s infile outfile -bn bottelneck [options] \n\n", argv[0]);
printf("with:\n"); printf("with:\n");
@ -138,7 +135,7 @@ int main(int argc, char* argv[])
printf("OPTIONS\n"); printf("OPTIONS\n");
printf("-------\n"); printf("-------\n");
printf("-fs sampFreq......... sampling frequency of codec 16 or 32 (default) kHz.\n"); printf("-fs sampFreq......... sampling frequency of codec 16 or 32 (default) kHz.\n");
printf("-plim payloadLim..... payload limit in bytes,\n"); printf("-plim payloadLim..... payload limit in bytes,\n");
printf(" default is the maximum possible.\n"); printf(" default is the maximum possible.\n");
printf("-rlim rateLim........ rate limit in bits/sec, \n"); printf("-rlim rateLim........ rate limit in bits/sec, \n");
printf(" default is the maimum possible.\n"); printf(" default is the maimum possible.\n");
@ -155,18 +152,18 @@ int main(int argc, char* argv[])
printf("structure size %d bytes\n", size); printf("structure size %d bytes\n", size);
exit(0); exit(0);
} }
/* Get Bottleneck value */ /* Get Bottleneck value */
bottleneck = readParamInt(argc, argv, "-bn", 50000); bottleneck = readParamInt(argc, argv, "-bn", 50000);
fprintf(stderr,"\nfixed bottleneck rate of %d bits/s\n\n", bottleneck); fprintf(stderr,"\nfixed bottleneck rate of %d bits/s\n\n", bottleneck);
/* Get Input and Output files */ /* Get Input and Output files */
sscanf(argv[1], "%s", inname); sscanf(argv[1], "%s", inname);
sscanf(argv[2], "%s", outname); sscanf(argv[2], "%s", outname);
codingMode = readSwitch(argc, argv, "-I"); codingMode = readSwitch(argc, argv, "-I");
sampFreqKHz = (WebRtc_Word16)readParamInt(argc, argv, "-fs", 32); sampFreqKHz = (WebRtc_Word16)readParamInt(argc, argv, "-fs", 32);
if(readParamString(argc, argv, "-h", histFileName, 500) > 0) if(readParamString(argc, argv, "-h", histFileName, 500) > 0)
{ {
@ -182,7 +179,7 @@ int main(int argc, char* argv[])
// NO recording of hitstogram // NO recording of hitstogram
histFile = NULL; histFile = NULL;
} }
packetLossPercent = readParamInt(argc, argv, "-ploss", 0); packetLossPercent = readParamInt(argc, argv, "-ploss", 0);
@ -199,7 +196,7 @@ int main(int argc, char* argv[])
{ {
averageFile = NULL; averageFile = NULL;
} }
onlyEncode = readSwitch(argc, argv, "-enc"); onlyEncode = readSwitch(argc, argv, "-enc");
onlyDecode = readSwitch(argc, argv, "-dec"); onlyDecode = readSwitch(argc, argv, "-dec");
@ -233,7 +230,7 @@ valid values are 8 and 16.\n", sampFreqKHz);
exit(1); exit(1);
} }
#ifdef WIN32 #ifdef WIN32
_splitpath(outname, outDrive, outPath, outPrefix, outSuffix); _splitpath(outname, outDrive, outPath, outPrefix, outSuffix);
_makepath(bitrateFileName, outDrive, outPath, "bitrate", ".txt"); _makepath(bitrateFileName, outDrive, outPath, "bitrate", ".txt");
@ -244,28 +241,30 @@ valid values are 8 and 16.\n", sampFreqKHz);
printf("\n"); printf("\n");
printf("Input.................... %s\n", inname); printf("Input.................... %s\n", inname);
printf("Output................... %s\n", outname); printf("Output................... %s\n", outname);
printf("Encoding Mode............ %s\n", printf("Encoding Mode............ %s\n",
(codingMode == 1)? "Channel-Independent":"Channel-Adaptive"); (codingMode == 1)? "Channel-Independent":"Channel-Adaptive");
printf("Bottleneck............... %d bits/sec\n", bottleneck); printf("Bottleneck............... %d bits/sec\n", bottleneck);
printf("Packet-loss Percentage... %d\n", packetLossPercent); printf("Packet-loss Percentage... %d\n", packetLossPercent);
printf("\n"); printf("\n");
#ifdef WIN32
starttime = clock()/(double)CLOCKS_PER_SEC; /* Runtime statistics */ starttime = clock()/(double)CLOCKS_PER_SEC; /* Runtime statistics */
#endif
/* Initialize the ISAC and BN structs */ /* Initialize the ISAC and BN structs */
err = WebRtcIsac_Create(&ISAC_main_inst); err = WebRtcIsac_Create(&ISAC_main_inst);
WebRtcIsac_SetEncSampRate(ISAC_main_inst, (sampFreqKHz == 16)? kIsacWideband: kIsacSuperWideband); WebRtcIsac_SetEncSampRate(ISAC_main_inst, (sampFreqKHz == 16)? kIsacWideband: kIsacSuperWideband);
WebRtcIsac_SetDecSampRate(ISAC_main_inst, (sampFreqKHz == 16)? kIsacWideband: kIsacSuperWideband); WebRtcIsac_SetDecSampRate(ISAC_main_inst, (sampFreqKHz == 16)? kIsacWideband: kIsacSuperWideband);
/* Error check */ /* Error check */
if (err < 0) { if (err < 0) {
fprintf(stderr,"\n\n Error in create.\n\n"); fprintf(stderr,"\n\n Error in create.\n\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
framecnt = 0; framecnt = 0;
endfile = 0; endfile = 0;
/* Initialize encoder and decoder */ /* Initialize encoder and decoder */
if(WebRtcIsac_EncoderInit(ISAC_main_inst, codingMode) < 0) if(WebRtcIsac_EncoderInit(ISAC_main_inst, codingMode) < 0)
{ {
@ -277,7 +276,7 @@ valid values are 8 and 16.\n", sampFreqKHz);
printf("cannot initialize decoder\n"); printf("cannot initialize decoder\n");
return -1; return -1;
} }
//{ //{
// WebRtc_Word32 b1, b2; // WebRtc_Word32 b1, b2;
// FILE* fileID = fopen("GetBNTest.txt", "w"); // FILE* fileID = fopen("GetBNTest.txt", "w");
@ -330,10 +329,10 @@ valid values are 8 and 16.\n", sampFreqKHz);
// } // }
//#endif //#endif
while (endfile == 0) while (endfile == 0)
{ {
fprintf(stderr," \rframe = %7li", framecnt); fprintf(stderr," \rframe = %7li", framecnt);
//============== Readind from the file and encoding ================= //============== Readind from the file and encoding =================
cur_framesmpls = 0; cur_framesmpls = 0;
stream_len = 0; stream_len = 0;
@ -364,26 +363,26 @@ valid values are 8 and 16.\n", sampFreqKHz);
{ {
while(stream_len == 0) while(stream_len == 0)
{ {
// Read 10 ms speech block // Read 10 ms speech block
endfile = readframe(shortdata, inp, samplesIn10Ms); endfile = readframe(shortdata, inp, samplesIn10Ms);
if(endfile) if(endfile)
{ {
break; break;
} }
cur_framesmpls += samplesIn10Ms; cur_framesmpls += samplesIn10Ms;
//-------- iSAC encoding --------- //-------- iSAC encoding ---------
stream_len = WebRtcIsac_Encode(ISAC_main_inst, shortdata, stream_len = WebRtcIsac_Encode(ISAC_main_inst, shortdata,
(WebRtc_Word16*)payload); (WebRtc_Word16*)payload);
if(stream_len < 0) if(stream_len < 0)
{ {
// exit if returned with error // exit if returned with error
//errType=WebRtcIsac_GetErrorCode(ISAC_main_inst); //errType=WebRtcIsac_GetErrorCode(ISAC_main_inst);
fprintf(stderr,"\nError in encoder\n"); fprintf(stderr,"\nError in encoder\n");
getchar(); getchar();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -397,8 +396,8 @@ valid values are 8 and 16.\n", sampFreqKHz);
get_arrival_time(cur_framesmpls, stream_len, bottleneck, &packetData, get_arrival_time(cur_framesmpls, stream_len, bottleneck, &packetData,
sampFreqKHz * 1000, sampFreqKHz * 1000); sampFreqKHz * 1000, sampFreqKHz * 1000);
if(WebRtcIsac_UpdateBwEstimate(ISAC_main_inst, if(WebRtcIsac_UpdateBwEstimate(ISAC_main_inst,
payload, stream_len, packetData.rtp_number, payload, stream_len, packetData.rtp_number,
packetData.sample_count, packetData.sample_count,
packetData.arrival_time) < 0) packetData.arrival_time) < 0)
{ {
@ -414,7 +413,7 @@ valid values are 8 and 16.\n", sampFreqKHz);
maxStreamLen = (stream_len > maxStreamLen)? stream_len:maxStreamLen; maxStreamLen = (stream_len > maxStreamLen)? stream_len:maxStreamLen;
packetCntr++; packetCntr++;
hist[stream_len]++; hist[stream_len]++;
if(averageFile != NULL) if(averageFile != NULL)
{ {
@ -433,7 +432,7 @@ valid values are 8 and 16.\n", sampFreqKHz);
WebRtc_UWord8 auxUW8; WebRtc_UWord8 auxUW8;
auxUW8 = (WebRtc_UWord8)(((stream_len & 0x7F00) >> 8) & 0xFF); auxUW8 = (WebRtc_UWord8)(((stream_len & 0x7F00) >> 8) & 0xFF);
fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp); fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp);
auxUW8 = (WebRtc_UWord8)(stream_len & 0xFF); auxUW8 = (WebRtc_UWord8)(stream_len & 0xFF);
fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp); fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp);
fwrite(payload, 1, stream_len, outp); fwrite(payload, 1, stream_len, outp);
@ -451,23 +450,23 @@ valid values are 8 and 16.\n", sampFreqKHz);
} }
else else
{ {
declen = WebRtcIsac_Decode(ISAC_main_inst, payload, declen = WebRtcIsac_Decode(ISAC_main_inst, payload,
stream_len, decoded, speechType); stream_len, decoded, speechType);
} }
if(declen <= 0) if(declen <= 0)
{ {
//errType=WebRtcIsac_GetErrorCode(ISAC_main_inst); //errType=WebRtcIsac_GetErrorCode(ISAC_main_inst);
fprintf(stderr,"\nError in decoder.\n"); fprintf(stderr,"\nError in decoder.\n");
getchar(); getchar();
exit(1); exit(1);
} }
// Write decoded speech frame to file // Write decoded speech frame to file
fwrite(decoded, sizeof(WebRtc_Word16), declen, outp); fwrite(decoded, sizeof(WebRtc_Word16), declen, outp);
cur_framesmpls = declen; cur_framesmpls = declen;
} }
// Update Statistics // Update Statistics
framecnt++; framecnt++;
totalsmpls += cur_framesmpls; totalsmpls += cur_framesmpls;
if(stream_len > 0) if(stream_len > 0)
{ {
@ -481,19 +480,20 @@ valid values are 8 and 16.\n", sampFreqKHz);
rate = ((double)totalbits * (sampFreqKHz)) / (double)totalsmpls; rate = ((double)totalbits * (sampFreqKHz)) / (double)totalsmpls;
rateRCU = ((double)totalBitsRCU * (sampFreqKHz)) / (double)totalsmpls; rateRCU = ((double)totalBitsRCU * (sampFreqKHz)) / (double)totalsmpls;
rateLB = 0;
rateUB = 0;
printf("\n\n"); printf("\n\n");
printf("Sampling Rate......................... %d kHz\n", sampFreqKHz); printf("Sampling Rate......................... %d kHz\n", sampFreqKHz);
printf("Payload Limit......................... %d bytes \n", payloadLimit); printf("Payload Limit......................... %d bytes \n", payloadLimit);
printf("Rate Limit............................ %d bits/sec \n", rateLimit); printf("Rate Limit............................ %d bits/sec \n", rateLimit);
#ifdef HAVE_DEBUG_INFO
rateLB = ((double)debugInfo.lbBytes * 8. * (sampFreqKHz)) / (double)totalsmpls;
rateUB = ((double)debugInfo.ubBytes * 8. * (sampFreqKHz)) / (double)totalsmpls;
#endif
#ifdef WIN32 #ifdef WIN32
#ifdef HAVE_DEBUG_INFO
rateLB = ((double)debugInfo.lbBytes * 8. *
(sampFreqKHz)) / (double)totalsmpls;
rateUB = ((double)debugInfo.ubBytes * 8. *
(sampFreqKHz)) / (double)totalsmpls;
#endif
fprintf(bitrateFile, "%d %10u %d %6.3f %6.3f %6.3f\n", fprintf(bitrateFile, "%d %10u %d %6.3f %6.3f %6.3f\n",
sampFreqKHz, sampFreqKHz,
framecnt, framecnt,
@ -502,20 +502,20 @@ valid values are 8 and 16.\n", sampFreqKHz);
rateUB, rateUB,
rate); rate);
fclose(bitrateFile); fclose(bitrateFile);
#endif #endif // WIN32
printf("\n"); printf("\n");
printf("Measured bit-rate..................... %0.3f kbps\n", rate); printf("Measured bit-rate..................... %0.3f kbps\n", rate);
printf("Measured RCU bit-ratre................ %0.3f kbps\n", rateRCU); printf("Measured RCU bit-ratre................ %0.3f kbps\n", rateRCU);
printf("Maximum bit-rate/payloadsize.......... %0.3f / %d\n", printf("Maximum bit-rate/payloadsize.......... %0.3f / %d\n",
maxStreamLen * 8 / 0.03, maxStreamLen); maxStreamLen * 8 / 0.03, maxStreamLen);
printf("Measured packet-loss.................. %0.1f%% \n", printf("Measured packet-loss.................. %0.1f%% \n",
100.0f * (float)lostPacketCntr / (float)packetCntr); 100.0f * (float)lostPacketCntr / (float)packetCntr);
//#ifdef HAVE_DEBUG_INFO //#ifdef HAVE_DEBUG_INFO
// printf("Measured lower-band bit-rate.......... %0.3f kbps (%.0f%%)\n", // printf("Measured lower-band bit-rate.......... %0.3f kbps (%.0f%%)\n",
// rateLB, (double)(rateLB) * 100. /(double)(rate)); // rateLB, (double)(rateLB) * 100. /(double)(rate));
// printf("Measured upper-band bit-rate.......... %0.3f kbps (%.0f%%)\n", // printf("Measured upper-band bit-rate.......... %0.3f kbps (%.0f%%)\n",
// rateUB, (double)(rateUB) * 100. /(double)(rate)); // rateUB, (double)(rateUB) * 100. /(double)(rate));
// //
// printf("Maximum payload lower-band............ %d bytes (%0.3f kbps)\n", // printf("Maximum payload lower-band............ %d bytes (%0.3f kbps)\n",
@ -525,17 +525,17 @@ valid values are 8 and 16.\n", sampFreqKHz);
//#endif //#endif
printf("\n"); printf("\n");
/* Runtime statistics */ /* Runtime statistics */
#ifdef WIN32 #ifdef WIN32
runtime = (double)(clock()/(double)CLOCKS_PER_SEC-starttime); runtime = (double)(clock()/(double)CLOCKS_PER_SEC-starttime);
length_file = ((double)framecnt*(double)declen/(sampFreqKHz*1000)); length_file = ((double)framecnt*(double)declen/(sampFreqKHz*1000));
printf("Length of speech file................ %.1f s\n", length_file); printf("Length of speech file................ %.1f s\n", length_file);
printf("Time to run iSAC..................... %.2f s (%.2f %% of realtime)\n\n", printf("Time to run iSAC..................... %.2f s (%.2f %% of realtime)\n\n",
runtime, (100*runtime/length_file)); runtime, (100*runtime/length_file));
#endif #endif
printf("\n\n_______________________________________________\n"); printf("\n\n_______________________________________________\n");
if(histFile != NULL) if(histFile != NULL)
{ {
int n; int n;
@ -558,9 +558,9 @@ valid values are 8 and 16.\n", sampFreqKHz);
fclose(inp); fclose(inp);
fclose(outp); fclose(outp);
WebRtcIsac_Free(ISAC_main_inst); WebRtcIsac_Free(ISAC_main_inst);
#ifdef CHANGE_OUTPUT_NAME #ifdef CHANGE_OUTPUT_NAME
{ {
@ -590,7 +590,7 @@ valid values are 8 and 16.\n", sampFreqKHz);
} }
#endif #endif
exit(0); exit(0);
} }
#ifdef HAVE_DEBUG_INFO #ifdef HAVE_DEBUG_INFO
@ -598,7 +598,7 @@ int setupDebugStruct(debugStruct* str)
{ {
str->prevPacketLost = 0; str->prevPacketLost = 0;
str->currPacketLost = 0; str->currPacketLost = 0;
OPEN_FILE_WB(str->res0to4FilePtr, "Res0to4.dat"); OPEN_FILE_WB(str->res0to4FilePtr, "Res0to4.dat");
OPEN_FILE_WB(str->res4to8FilePtr, "Res4to8.dat"); OPEN_FILE_WB(str->res4to8FilePtr, "Res4to8.dat");
OPEN_FILE_WB(str->res8to12FilePtr, "Res8to12.dat"); OPEN_FILE_WB(str->res8to12FilePtr, "Res8to12.dat");

View File

@ -15,36 +15,36 @@
#include "utility.h" #include "utility.h"
/* function for reading audio data from PCM file */ /* function for reading audio data from PCM file */
int int
readframe( readframe(
short* data, short* data,
FILE* inp, FILE* inp,
int length) int length)
{ {
short k, rlen, status = 0; short k, rlen, status = 0;
unsigned char* ptrUChar; unsigned char* ptrUChar;
ptrUChar = (unsigned char*)data; ptrUChar = (unsigned char*)data;
rlen = (short)fread(data, sizeof(short), length, inp); rlen = (short)fread(data, sizeof(short), length, inp);
if (rlen < length) { if (rlen < length) {
for (k = rlen; k < length; k++) for (k = rlen; k < length; k++)
data[k] = 0; data[k] = 0;
status = 1; status = 1;
} }
// Assuming that our PCM files are written in Intel machines // Assuming that our PCM files are written in Intel machines
for(k = 0; k < length; k++) for(k = 0; k < length; k++)
{ {
data[k] = (short)ptrUChar[k<<1] | ((((short)ptrUChar[(k<<1) + 1]) << 8) & 0xFF00); data[k] = (short)ptrUChar[k<<1] | ((((short)ptrUChar[(k<<1) + 1]) << 8) & 0xFF00);
} }
return status; return status;
} }
short short
readSwitch( readSwitch(
int argc, int argc,
char* argv[], char* argv[],
char* strID) char* strID)
{ {
short n; short n;
@ -58,11 +58,11 @@ readSwitch(
return 0; return 0;
} }
double double
readParamDouble( readParamDouble(
int argc, int argc,
char* argv[], char* argv[],
char* strID, char* strID,
double defaultVal) double defaultVal)
{ {
double returnVal = defaultVal; double returnVal = defaultVal;
@ -82,11 +82,11 @@ readParamDouble(
return returnVal; return returnVal;
} }
int int
readParamInt( readParamInt(
int argc, int argc,
char* argv[], char* argv[],
char* strID, char* strID,
int defaultVal) int defaultVal)
{ {
int returnVal = defaultVal; int returnVal = defaultVal;
@ -106,12 +106,12 @@ readParamInt(
return returnVal; return returnVal;
} }
int int
readParamString( readParamString(
int argc, int argc,
char* argv[], char* argv[],
char* strID, char* strID,
char* stringParam, char* stringParam,
int maxSize) int maxSize)
{ {
int paramLenght = 0; int paramLenght = 0;
@ -132,7 +132,7 @@ readParamString(
return paramLenght; return paramLenght;
} }
void void
get_arrival_time( get_arrival_time(
int current_framesamples, /* samples */ int current_framesamples, /* samples */
int packet_size, /* bytes */ int packet_size, /* bytes */
@ -142,8 +142,7 @@ get_arrival_time(
short receiverSampFreqHz) short receiverSampFreqHz)
{ {
unsigned int travelTimeMs; unsigned int travelTimeMs;
const int headerSizeByte = 35; const int headerSizeByte = 35;
unsigned int dummy;
int headerRate; int headerRate;
@ -156,27 +155,22 @@ get_arrival_time(
//travelTimeMs = ((packet_size + HeaderSize) * 8 * sampFreqHz) / //travelTimeMs = ((packet_size + HeaderSize) * 8 * sampFreqHz) /
// (bottleneck + HeaderRate) // (bottleneck + HeaderRate)
travelTimeMs = (unsigned int)floor((double)((packet_size + headerSizeByte) * 8 * 1000) travelTimeMs = (unsigned int)floor((double)((packet_size + headerSizeByte) * 8 * 1000)
/ (double)(bottleneck + headerRate) + 0.5); / (double)(bottleneck + headerRate) + 0.5);
if(BN_data->whenPrevPackLeftMs > BN_data->whenPackGeneratedMs) if(BN_data->whenPrevPackLeftMs > BN_data->whenPackGeneratedMs)
{ {
BN_data->whenPrevPackLeftMs += travelTimeMs; BN_data->whenPrevPackLeftMs += travelTimeMs;
} }
else else
{ {
BN_data->whenPrevPackLeftMs = BN_data->whenPackGeneratedMs + BN_data->whenPrevPackLeftMs = BN_data->whenPackGeneratedMs +
travelTimeMs; travelTimeMs;
} }
BN_data->arrival_time = (BN_data->whenPrevPackLeftMs *
dummy = (BN_data->whenPrevPackLeftMs *
(receiverSampFreqHz / 1000)) - BN_data->arrival_time;
BN_data->arrival_time = (BN_data->whenPrevPackLeftMs *
(receiverSampFreqHz / 1000)); (receiverSampFreqHz / 1000));
// if (BN_data->arrival_time < BN_data->sample_count) // if (BN_data->arrival_time < BN_data->sample_count)
// BN_data->arrival_time = BN_data->sample_count; // BN_data->arrival_time = BN_data->sample_count;