[asterisk-commits] branch rizzo/base r10576 - /team/rizzo/base/formats/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Feb 20 14:38:57 MST 2006


Author: rizzo
Date: Mon Feb 20 15:38:53 2006
New Revision: 10576

URL: http://svn.digium.com/view/asterisk?rev=10576&view=rev
Log:
fix the return value of the *seek functions, and simplify
some duplicated code


Modified:
    team/rizzo/base/formats/format_g729.c
    team/rizzo/base/formats/format_ilbc.c
    team/rizzo/base/formats/format_sln.c
    team/rizzo/base/formats/format_vox.c
    team/rizzo/base/formats/format_wav_gsm.c

Modified: team/rizzo/base/formats/format_g729.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/formats/format_g729.c?rev=10576&r1=10575&r2=10576&view=diff
==============================================================================
--- team/rizzo/base/formats/format_g729.c (original)
+++ team/rizzo/base/formats/format_g729.c Mon Feb 20 15:38:53 2006
@@ -115,9 +115,7 @@
 	}
 	/* protect against seeking beyond begining. */
 	offset = (offset < min)?min:offset;
-	if (fseek(fs->f, offset, SEEK_SET) < 0)
-		return -1;
-	return 0;
+	return fseek(fs->f, offset, SEEK_SET);
 }
 
 static int g729_trunc(struct ast_filestream *fs)

Modified: team/rizzo/base/formats/format_ilbc.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/formats/format_ilbc.c?rev=10576&r1=10575&r2=10576&view=diff
==============================================================================
--- team/rizzo/base/formats/format_ilbc.c (original)
+++ team/rizzo/base/formats/format_ilbc.c Mon Feb 20 15:38:53 2006
@@ -113,9 +113,7 @@
 	}
 	/* protect against seeking beyond begining. */
 	offset = (offset < min)?min:offset;
-	if (fseek(fs->f, offset, SEEK_SET) < 0)
-		return -1;
-	return 0;
+	return fseek(fs->f, offset, SEEK_SET);
 }
 
 static int ilbc_trunc(struct ast_filestream *fs)

Modified: team/rizzo/base/formats/format_sln.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/formats/format_sln.c?rev=10576&r1=10575&r2=10576&view=diff
==============================================================================
--- team/rizzo/base/formats/format_sln.c (original)
+++ team/rizzo/base/formats/format_sln.c Mon Feb 20 15:38:53 2006
@@ -104,7 +104,7 @@
 	}
 	/* always protect against seeking past begining. */
 	offset = (offset < min)?min:offset;
-	return fseek(fs->f, offset, SEEK_SET) / 2;
+	return fseek(fs->f, offset, SEEK_SET);
 }
 
 static int slinear_trunc(struct ast_filestream *fs)

Modified: team/rizzo/base/formats/format_vox.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/formats/format_vox.c?rev=10576&r1=10575&r2=10576&view=diff
==============================================================================
--- team/rizzo/base/formats/format_vox.c (original)
+++ team/rizzo/base/formats/format_vox.c Mon Feb 20 15:38:53 2006
@@ -106,8 +106,7 @@
 	  offset = (offset > max)?max:offset;
 	  offset = (offset < min)?min:offset;
      }
-     fseek(fs->f, offset, SEEK_SET);
-	 return ftell(fs->f);
+     return fseek(fs->f, offset, SEEK_SET);
 }
 
 static int vox_trunc(struct ast_filestream *fs)

Modified: team/rizzo/base/formats/format_wav_gsm.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/formats/format_wav_gsm.c?rev=10576&r1=10575&r2=10576&view=diff
==============================================================================
--- team/rizzo/base/formats/format_wav_gsm.c (original)
+++ team/rizzo/base/formats/format_wav_gsm.c Mon Feb 20 15:38:53 2006
@@ -257,7 +257,7 @@
 
 static int write_header(FILE *f)
 {
-	unsigned int hz=htoll(8000);
+	unsigned int hz=htoll(8000);	/* XXX SAMPLE_RATE */
 	unsigned int bhz = htoll(1625);
 	unsigned int hs = htoll(20);
 	unsigned short fmt = htols(49);
@@ -269,71 +269,42 @@
 	unsigned int y_1 = htoll(20160);
 	unsigned int size = htoll(0);
 	/* Write a GSM header, ignoring sizes which will be filled in later */
-	if (fwrite("RIFF", 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&size, 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite("WAVEfmt ", 1, 8, f) != 8) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&hs, 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&fmt, 1, 2, f) != 2) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&chans, 1, 2, f) != 2) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&hz, 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&bhz, 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&x_1, 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&x_2, 1, 2, f) != 2) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&x_3, 1, 2, f) != 2) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite("fact", 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&fhs, 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&y_1, 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite("data", 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
-	if (fwrite(&size, 1, 4, f) != 4) {
-		ast_log(LOG_WARNING, "Unable to write header\n");
-		return -1;
-	}
+	if (fwrite("RIFF", 1, 4, f) != 4)
+		goto error;
+	if (fwrite(&size, 1, 4, f) != 4)
+		goto error;
+	if (fwrite("WAVEfmt ", 1, 8, f) != 8)
+		goto error;
+	if (fwrite(&hs, 1, 4, f) != 4)
+		goto error;
+	if (fwrite(&fmt, 1, 2, f) != 2)
+		goto error;
+	if (fwrite(&chans, 1, 2, f) != 2)
+		goto error;
+	if (fwrite(&hz, 1, 4, f) != 4)
+		goto error;
+	if (fwrite(&bhz, 1, 4, f) != 4)
+		goto error;
+	if (fwrite(&x_1, 1, 4, f) != 4)
+		goto error;
+	if (fwrite(&x_2, 1, 2, f) != 2)
+		goto error;
+	if (fwrite(&x_3, 1, 2, f) != 2)
+		goto error;
+	if (fwrite("fact", 1, 4, f) != 4)
+		goto error;
+	if (fwrite(&fhs, 1, 4, f) != 4)
+		goto error;
+	if (fwrite(&y_1, 1, 4, f) != 4)
+		goto error;
+	if (fwrite("data", 1, 4, f) != 4)
+		goto error;
+	if (fwrite(&size, 1, 4, f) != 4)
+		goto error;
 	return 0;
+error:
+	ast_log(LOG_WARNING, "Unable to write header\n");
+	return -1;
 }
 
 static int wav_open(struct ast_filestream *s)



More information about the asterisk-commits mailing list