mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	add API function to perform volume adjustment on a frame of SLINEAR data
documentation cleanup git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6874 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		
							
								
								
									
										19
									
								
								frame.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								frame.c
									
									
									
									
									
								
							| @@ -1252,3 +1252,22 @@ int ast_codec_get_len(int format, int samples) | ||||
|  | ||||
| 	return len; | ||||
| } | ||||
|  | ||||
| int ast_frame_adjust_volume(struct ast_frame *f, int adjustment) | ||||
| { | ||||
| 	int count; | ||||
| 	short *fdata = f->data; | ||||
|  | ||||
| 	if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR)) | ||||
| 		return -1; | ||||
|  | ||||
| 	for (count = 0; count < f->samples; count++) { | ||||
| 		if (adjustment > 0) { | ||||
| 			fdata[count] *= abs(adjustment); | ||||
| 		} else if (adjustment < 0) { | ||||
| 			fdata[count] /= abs(adjustment); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user