Skip to content
Snippets Groups Projects
Commit a40e852e authored by Kevin P. Fleming's avatar Kevin P. Fleming
Browse files

don't pass short arguments by value, it will cause compiler warnings on most...

don't pass short arguments by value, it will cause compiler warnings on most platforms about implicit conversions (thanks Luigi!)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6901 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 8fb55e24
No related branches found
No related tags found
No related merge requests found
...@@ -1257,15 +1257,19 @@ int ast_frame_adjust_volume(struct ast_frame *f, int adjustment) ...@@ -1257,15 +1257,19 @@ int ast_frame_adjust_volume(struct ast_frame *f, int adjustment)
{ {
int count; int count;
short *fdata = f->data; short *fdata = f->data;
short adjust_value = abs(adjustment);
if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR)) if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR))
return -1; return -1;
if (!adjustment)
return 0;
for (count = 0; count < f->samples; count++) { for (count = 0; count < f->samples; count++) {
if (adjustment > 0) { if (adjustment > 0) {
ast_slinear_saturated_multiply(&fdata[count], abs(adjustment)); ast_slinear_saturated_multiply(&fdata[count], &adjust_value);
} else if (adjustment < 0) { } else if (adjustment < 0) {
ast_slinear_saturated_divide(&fdata[count], abs(adjustment)); ast_slinear_saturated_divide(&fdata[count], &adjust_value);
} }
} }
...@@ -1289,7 +1293,7 @@ int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2) ...@@ -1289,7 +1293,7 @@ int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2)
for (count = 0, data1 = f1->data, data2 = f2->data; for (count = 0, data1 = f1->data, data2 = f2->data;
count < f1->samples; count < f1->samples;
count++, data1++, data2++) count++, data1++, data2++)
ast_slinear_saturated_add(data1, *data2); ast_slinear_saturated_add(data1, data2);
return 0; return 0;
} }
...@@ -169,11 +169,11 @@ char *ast_uri_encode(char *string, char *outbuf, int buflen, int doreserved); ...@@ -169,11 +169,11 @@ char *ast_uri_encode(char *string, char *outbuf, int buflen, int doreserved);
*/ */
void ast_uri_decode(char *s); void ast_uri_decode(char *s);
static inline void ast_slinear_saturated_add(short *input, short value) static inline void ast_slinear_saturated_add(short *input, short *value)
{ {
int res; int res;
res = (int) *input + value; res = (int) *input + *value;
if (res > 32767) if (res > 32767)
*input = 32767; *input = 32767;
else if (res < -32767) else if (res < -32767)
...@@ -182,11 +182,11 @@ static inline void ast_slinear_saturated_add(short *input, short value) ...@@ -182,11 +182,11 @@ static inline void ast_slinear_saturated_add(short *input, short value)
*input = (short) res; *input = (short) res;
} }
static inline void ast_slinear_saturated_multiply(short *input, short value) static inline void ast_slinear_saturated_multiply(short *input, short *value)
{ {
int res; int res;
res = (int) *input * value; res = (int) *input * *value;
if (res > 32767) if (res > 32767)
*input = 32767; *input = 32767;
else if (res < -32767) else if (res < -32767)
...@@ -195,9 +195,9 @@ static inline void ast_slinear_saturated_multiply(short *input, short value) ...@@ -195,9 +195,9 @@ static inline void ast_slinear_saturated_multiply(short *input, short value)
*input = (short) res; *input = (short) res;
} }
static inline void ast_slinear_saturated_divide(short *input, short value) static inline void ast_slinear_saturated_divide(short *input, short *value)
{ {
*input /= value; *input /= *value;
} }
extern int test_for_thread_safety(void); extern int test_for_thread_safety(void);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment