[asterisk-commits] branch file/coremedia - r7374 in /team/file/coremedia: ./ apps/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Dec 6 22:10:23 CST 2005


Author: file
Date: Tue Dec  6 22:10:21 2005
New Revision: 7374

URL: http://svn.digium.com/view/asterisk?rev=7374&view=rev
Log:
Fix audio playback and stuff, in a drastic way, until I can convert this totally over to coremedia

Modified:
    team/file/coremedia/apps/Makefile
    team/file/coremedia/coremedia.c
    team/file/coremedia/file.c

Modified: team/file/coremedia/apps/Makefile
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/Makefile?rev=7374&r1=7373&r2=7374&view=diff
==============================================================================
--- team/file/coremedia/apps/Makefile (original)
+++ team/file/coremedia/apps/Makefile Tue Dec  6 22:10:21 2005
@@ -11,7 +11,7 @@
 # the GNU General Public License
 #
 
-APPS=app_dial.so app_playback.so
+APPS=app_dial.so app_playback.so app_voicemail.so
 
 #
 # Obsolete things...

Modified: team/file/coremedia/coremedia.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/coremedia.c?rev=7374&r1=7373&r2=7374&view=diff
==============================================================================
--- team/file/coremedia/coremedia.c (original)
+++ team/file/coremedia/coremedia.c Tue Dec  6 22:10:21 2005
@@ -385,19 +385,26 @@
 	return new_path;
 }
 
+/* Audio resampling - takes in signed linear of one sample rate, spits out a frame with a different sample rate */
+struct ast_frame *ast_coremedia_resample(struct ast_frame *f, int sample_rate, int consume)
+{
+	struct ast_frame *frame = NULL;
+
+	if (f->sample_rate == sample_rate)
+		return f;
+
+	return frame;
+}
+
 /* Do a coremedia translation - based on the ol' ast_translate */
 struct ast_frame *ast_coremedia_translate(struct ast_coremedia_translator_path *path, struct ast_frame *f, int consume)
 {
 	struct timeval delivery;
-	struct ast_frame *frame = NULL;
+	struct ast_frame *frame = NULL, *shim_frame = NULL;
 	struct ast_coremedia_shim *shim = NULL;
 
 	/* Do our pass through the decoder if available */
 	if (path->decoder != NULL) {
-		if (frame->sample_rate != path->decoder_entry->sample_rate) {
-			ast_log(LOG_WARNING,
-					"Uh... frame sample rate not that of the decoder... but this is an encoded frame... ah darn!\n");
-		}
 		path->decoder->framein(path->dec_state, f);
 		frame = path->decoder->frameout(path->dec_state);
 		/* Override subclass to be that of the decoder entry */
@@ -413,8 +420,11 @@
 	while (shim) {
 		if (shim->callback) {
 			if (frame->sample_rate != shim->sample_rate) {
+			  shim_frame = NULL;
+			} else {
+			  shim_frame = frame;
 			}
-			frame = shim->callback(shim->pvt, frame);
+			frame = shim->callback(shim->pvt, shim_frame);
 		}
 		shim = shim->next;
 	}
@@ -424,6 +434,7 @@
 		/* Make sure the incoming sample rate of the frame is acceptable for the encoder */
 		if (frame->sample_rate != path->encoder_entry->sample_rate) {
 			/* We can run this through the sample rate translator because it's signed linear ;) */
+			frame = ast_coremedia_resample(frame, path->encoder_entry->sample_rate, 1);
 		}
 		/* Now run it through this encoder */
 		path->encoder->framein(path->enc_state, frame);
@@ -435,6 +446,7 @@
 	} else {
 		/* Okay we are feeding out straight signed linear - see if they want it at another sample rate */
 		if (path->sample_rate > 0 && path->sample_rate != frame->sample_rate) {
+			frame = ast_coremedia_resample(frame, path->sample_rate, 1);
 		}
 	}
 

Modified: team/file/coremedia/file.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/file.c?rev=7374&r1=7373&r2=7374&view=diff
==============================================================================
--- team/file/coremedia/file.c (original)
+++ team/file/coremedia/file.c Tue Dec  6 22:10:21 2005
@@ -412,30 +412,27 @@
 								ast_log(LOG_WARNING, "Out of memory\n");
 							break;
 						case ACTION_OPEN:
-							if ((ret < 0) && ((chan->writeformat->format & f->format) ||
-										((f->format >= AST_FORMAT_MAX_AUDIO) && fmt))) {
-								bfile = fopen(fn, "r");
-								if (bfile) {
-									ret = 1;
-									s = f->open(bfile);
-									if (s) {
-										s->lasttimeout = -1;
-										s->fmt = f;
-										s->trans = NULL;
-										s->filename = NULL;
-										if (s->fmt->format < AST_FORMAT_MAX_AUDIO)
-											chan->stream = s;
-										else
-											chan->vstream = s;
-									} else {
-										fclose(bfile);
-										ast_log(LOG_WARNING, "Unable to open file on %s\n", fn);
-										ret = -1;
-									}
-								} else{
-									ast_log(LOG_WARNING, "Couldn't open file %s\n", fn);
+							bfile = fopen(fn, "r");
+							if (bfile) {
+								ret = 1;
+								s = f->open(bfile);
+								if (s) {
+									s->lasttimeout = -1;
+									s->fmt = f;
+									s->trans = NULL;
+									s->filename = NULL;
+									if (s->fmt->format < AST_FORMAT_MAX_AUDIO)
+										chan->stream = s;
+									else
+										chan->vstream = s;
+								} else {
+									fclose(bfile);
+									ast_log(LOG_WARNING, "Unable to open file on %s\n", fn);
 									ret = -1;
 								}
+							} else{
+								ast_log(LOG_WARNING, "Couldn't open file %s\n", fn);
+								ret = -1;
 							}
 							break;
 						default:
@@ -577,8 +574,6 @@
 	struct ast_frame *fr;
 	int whennext = 0;
 
-	ast_log(LOG_NOTICE, "Going to audio\n");
-
 	while(!whennext) {
 		fr = s->fmt->read(s, &whennext);
 		if (fr) {
@@ -816,8 +811,6 @@
 			ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (language '%s')\n", filename, preflang ? preflang : "default");
 #endif
 		return 0;
-	} else {
-	  ast_log(LOG_NOTICE, "Did not find what we need\n");
 	}
 	return -1;
 }



More information about the asterisk-commits mailing list