[svn-commits] branch file/coremedia - r7323 in /team/file/coremedia: ./ include/asterisk/ s...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sat Dec 3 19:38:24 CST 2005


Author: file
Date: Sat Dec  3 19:38:22 2005
New Revision: 7323

URL: http://svn.digium.com/view/asterisk?rev=7323&view=rev
Log:
Add checks to shim_volume (thanks stevek!)

Modified:
    team/file/coremedia/coremedia.c
    team/file/coremedia/include/asterisk/frame.h
    team/file/coremedia/shims/shim_volume.c

Modified: team/file/coremedia/coremedia.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/coremedia.c?rev=7323&r1=7322&r2=7323&view=diff
==============================================================================
--- team/file/coremedia/coremedia.c (original)
+++ team/file/coremedia/coremedia.c Sat Dec  3 19:38:22 2005
@@ -256,10 +256,8 @@
     frame = path->decoder->frameout(path->dec_state);
     /* Override subclass to be that of the decoder entry */
     frame->subclass = path->decoder_entry->subclass;
-    /* Get the sample rate of the decoded entry */
   } else {
     frame = f;
-    /* Using the subclass - get the sample rate */
   }
 
   /* If we are here we are absolutely signed linear - so hand off to the shims */
@@ -273,7 +271,6 @@
 
   /* Do our pass through the encoder if available */
   if (path->encoder != NULL) {
-    /* Make sure the sample rate is the same - otherwise we need to change it */
     /* Now run it through this encoder */
     path->encoder->framein(path->enc_state, frame);
     frame = path->encoder->frameout(path->enc_state);

Modified: team/file/coremedia/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/include/asterisk/frame.h?rev=7323&r1=7322&r2=7323&view=diff
==============================================================================
--- team/file/coremedia/include/asterisk/frame.h (original)
+++ team/file/coremedia/include/asterisk/frame.h Sat Dec  3 19:38:22 2005
@@ -92,7 +92,7 @@
 	/*! Subclass, frame dependent */
 	int subclass;				
 	/*! Length of data */
-	int datalen;				
+	int datalen;
 	/*! Number of 8khz samples in this frame */
 	int samples;				
 	/*! Was the data malloc'd?  i.e. should we free it when we discard the frame? */

Modified: team/file/coremedia/shims/shim_volume.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/shims/shim_volume.c?rev=7323&r1=7322&r2=7323&view=diff
==============================================================================
--- team/file/coremedia/shims/shim_volume.c (original)
+++ team/file/coremedia/shims/shim_volume.c Sat Dec  3 19:38:22 2005
@@ -58,6 +58,7 @@
 {
   int i = 0;
   short *s = frame->data;
+  int new_value = 0;
 
   /* Using the private structure - adjust the audio */
   if (pvt == NULL) /* No private structure - just return the audio */
@@ -66,9 +67,16 @@
   /* Okay here is where it gets complicated */
   for (i=0; i<frame->datalen; i++) {
     if (0 > pvt->volume)
-      s[i] = s[i] / (short)abs(pvt->volume);
+      new_value = s[i] / abs(pvt->volume);
     else
-      s[i] = s[i] * (short)pvt->volume;
+      new_value = s[i] * pvt->volume;
+    /* Do sanity checks on the new value */
+    if (new_value > 32767)
+      new_value = 32767;
+    else if (new_value < -32768)
+      new_value = -32768;
+    /* Finally - commit the value */
+    s[i] = (short)new_value;
   }
 
 



More information about the svn-commits mailing list