[asterisk-commits] file: branch group/media_formats r407406 - in /team/group/media_formats: apps...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 5 09:27:52 CST 2014


Author: file
Date: Wed Feb  5 09:27:48 2014
New Revision: 407406

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407406
Log:
Expose built-in cached formats as pointers so developers have a much easier time.

Modified:
    team/group/media_formats/apps/app_alarmreceiver.c
    team/group/media_formats/apps/app_amd.c
    team/group/media_formats/apps/app_chanspy.c
    team/group/media_formats/channels/chan_alsa.c
    team/group/media_formats/channels/chan_oss.c
    team/group/media_formats/include/asterisk/codec.h
    team/group/media_formats/include/asterisk/format_cache.h
    team/group/media_formats/main/codec.c
    team/group/media_formats/pbx/pbx_spool.c

Modified: team/group/media_formats/apps/app_alarmreceiver.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_alarmreceiver.c?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/apps/app_alarmreceiver.c (original)
+++ team/group/media_formats/apps/app_alarmreceiver.c Wed Feb  5 09:27:48 2014
@@ -195,9 +195,6 @@
 /* Misc variables */
 static char event_file[14] = "/event-XXXXXX";
 
-static struct ast_format *ulaw_format;
-static struct ast_format *alaw_format;
-
 /*!
  * \brief Attempt to access a database variable and increment it
  *
@@ -802,19 +799,19 @@
 	char signalling_type[64] = "";
 	event_node_t *event_head = NULL;
 
-	if ((ast_format_cmp(ast_channel_writeformat(chan), ulaw_format) == AST_FORMAT_CMP_NOT_EQUAL) &&
-		(ast_format_cmp(ast_channel_writeformat(chan), alaw_format) == AST_FORMAT_CMP_NOT_EQUAL)) {
+	if ((ast_format_cmp(ast_channel_writeformat(chan), ast_format_ulaw) == AST_FORMAT_CMP_NOT_EQUAL) &&
+		(ast_format_cmp(ast_channel_writeformat(chan), ast_format_alaw) == AST_FORMAT_CMP_NOT_EQUAL)) {
 		ast_verb(4, "AlarmReceiver: Setting write format to Mu-law\n");
-		if (ast_set_write_format(chan, ulaw_format)) {
+		if (ast_set_write_format(chan, ast_format_ulaw)) {
 			ast_log(LOG_WARNING, "AlarmReceiver: Unable to set write format to Mu-law on %s\n",ast_channel_name(chan));
 			return -1;
 		}
 	}
 
-	if ((ast_format_cmp(ast_channel_readformat(chan), ulaw_format) == AST_FORMAT_CMP_NOT_EQUAL) &&
-		(ast_format_cmp(ast_channel_readformat(chan), alaw_format) == AST_FORMAT_CMP_NOT_EQUAL)) {
+	if ((ast_format_cmp(ast_channel_readformat(chan), ast_format_ulaw) == AST_FORMAT_CMP_NOT_EQUAL) &&
+		(ast_format_cmp(ast_channel_readformat(chan), ast_format_alaw) == AST_FORMAT_CMP_NOT_EQUAL)) {
 		ast_verb(4, "AlarmReceiver: Setting read format to Mu-law\n");
-		if (ast_set_read_format(chan, ulaw_format)) {
+		if (ast_set_read_format(chan, ast_format_ulaw)) {
 			ast_log(LOG_WARNING, "AlarmReceiver: Unable to set read format to Mu-law on %s\n",ast_channel_name(chan));
 			return -1;
 		}
@@ -963,9 +960,6 @@
  */
 static int unload_module(void)
 {
-	ao2_ref(ulaw_format, -1);
-	ao2_ref(alaw_format, -1);
-
 	return ast_unregister_application(app);
 }
 
@@ -981,30 +975,13 @@
  */
 static int load_module(void)
 {
-	ulaw_format = ast_format_cache_get("ulaw");
-	if (!ulaw_format) {
-		ast_log(LOG_ERROR, "Expected format 'ulaw' in format cache does not exist\n");
-		return AST_MODULE_LOAD_DECLINE;
-	}
-
-	alaw_format = ast_format_cache_get("alaw");
-	if (!alaw_format) {
-		ast_log(LOG_ERROR, "Expected format 'alaw' in format cache does not exist\n");
-		ao2_ref(alaw_format, -1);
-		return AST_MODULE_LOAD_DECLINE;
-	}
-
 	if (load_config(0)) {
 		if (ast_register_application_xml(app, alarmreceiver_exec)) {
-			ao2_ref(ulaw_format, -1);
-			ao2_ref(alaw_format, -1);
 			return AST_MODULE_LOAD_FAILURE;
 		}
 		return AST_MODULE_LOAD_SUCCESS;
 	}
 
-	ao2_ref(ulaw_format, -1);
-	ao2_ref(alaw_format, -1);
 	return AST_MODULE_LOAD_DECLINE;
 }
 

Modified: team/group/media_formats/apps/app_amd.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_amd.c?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/apps/app_amd.c (original)
+++ team/group/media_formats/apps/app_amd.c Wed Feb  5 09:27:48 2014
@@ -52,6 +52,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/config.h"
 #include "asterisk/app.h"
+#include "asterisk/format_cache.h"
 
 /*** DOCUMENTATION
 	<application name="AMD" language="en_US">
@@ -163,7 +164,7 @@
 	struct ast_frame *f = NULL;
 	struct ast_dsp *silenceDetector = NULL;
 	int dspsilence = 0, framelength = 0;
-	struct ast_format readFormat;
+	struct ast_format *readFormat;
 	int inInitialSilence = 1;
 	int inGreeting = 0;
 	int voiceDuration = 0;
@@ -202,11 +203,10 @@
 		AST_APP_ARG(argMaximumWordLength);
 	);
 
-	ast_format_clear(&readFormat);
 	ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", ast_channel_name(chan),
 		S_COR(ast_channel_caller(chan)->ani.number.valid, ast_channel_caller(chan)->ani.number.str, "(N/A)"),
 		S_COR(ast_channel_redirecting(chan)->from.number.valid, ast_channel_redirecting(chan)->from.number.str, "(N/A)"),
-		ast_getformatname(ast_channel_readformat(chan)));
+		ast_channel_readformat(chan)->codec->name);
 
 	/* Lets parse the arguments. */
 	if (!ast_strlen_zero(parse)) {
@@ -255,8 +255,8 @@
 				minimumWordLength, betweenWordsSilence, maximumNumberOfWords, silenceThreshold, maximumWordLength);
 
 	/* Set read format to signed linear so we get signed linear frames in */
-	ast_format_copy(&readFormat, ast_channel_readformat(chan));
-	if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR) < 0 ) {
+	readFormat = ast_format_copy(ast_channel_readformat(chan));
+	if (ast_set_read_format(chan, ast_format_slin) < 0 ) {
 		ast_log(LOG_WARNING, "AMD: Channel [%s]. Unable to set to linear mode, giving up\n", ast_channel_name(chan));
 		pbx_builtin_setvar_helper(chan , "AMDSTATUS", "");
 		pbx_builtin_setvar_helper(chan , "AMDCAUSE", "");
@@ -412,8 +412,9 @@
 	pbx_builtin_setvar_helper(chan , "AMDCAUSE" , amdCause);
 
 	/* Restore channel read format */
-	if (readFormat.id && ast_set_read_format(chan, &readFormat))
+	if (readFormat && ast_set_read_format(chan, readFormat))
 		ast_log(LOG_WARNING, "AMD: Unable to restore read format on '%s'\n", ast_channel_name(chan));
+	ao2_cleanup(readFormat);
 
 	/* Free the DSP used to detect silence */
 	ast_dsp_free(silenceDetector);
@@ -510,10 +511,10 @@
  */
 static int load_module(void)
 {
-	if (load_config(0))
+	if (load_config(0) || ast_register_application_xml(app, amd_exec)) {
 		return AST_MODULE_LOAD_DECLINE;
-	if (ast_register_application_xml(app, amd_exec))
-		return AST_MODULE_LOAD_FAILURE;
+	}
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: team/group/media_formats/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_chanspy.c?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/apps/app_chanspy.c (original)
+++ team/group/media_formats/apps/app_chanspy.c Wed Feb  5 09:27:48 2014
@@ -57,6 +57,7 @@
 #include "asterisk/autochan.h"
 #include "asterisk/stasis_channels.h"
 #include "asterisk/json.h"
+#include "asterisk/format_cache.h"
 
 #define AST_NAME_STRLEN 256
 #define NUM_SPYGROUPS 128
@@ -441,9 +442,6 @@
 {
 	struct chanspy_translation_helper *csth = data;
 	struct ast_frame *f, *cur;
-	struct ast_format format_slin;
-
-	ast_format_set(&format_slin, AST_FORMAT_SLINEAR, 0);
 
 	ast_audiohook_lock(&csth->spy_audiohook);
 	if (csth->spy_audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
@@ -454,9 +452,9 @@
 
 	if (ast_test_flag(&csth->flags, OPTION_READONLY)) {
 		/* Option 'o' was set, so don't mix channel audio */
-		f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, &format_slin);
+		f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, ast_format_slin);
 	} else {
-		f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, &format_slin);
+		f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, ast_format_slin);
 	}
 
 	ast_audiohook_unlock(&csth->spy_audiohook);
@@ -1122,7 +1120,7 @@
 		.volume = '#',
 		.exit = '\0',
 	};
-	struct ast_format oldwf;
+	struct ast_format *oldwf;
 	int volfactor = 0;
 	int res;
 	char *mailbox = NULL;
@@ -1135,7 +1133,6 @@
 	char *parse = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, parse);
-	ast_format_clear(&oldwf);
 
 	if (args.spec && !strcmp(args.spec, "all"))
 		args.spec = NULL;
@@ -1199,8 +1196,8 @@
 		ast_clear_flag(&flags, AST_FLAGS_ALL);
 	}
 
-	ast_format_copy(&oldwf, ast_channel_writeformat(chan));
-	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
+	oldwf = ast_format_copy(ast_channel_writeformat(chan));
+	if (ast_set_write_format(chan, ast_format_slin) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 		return -1;
 	}
@@ -1220,8 +1217,9 @@
 	if (fd)
 		close(fd);
 
-	if (oldwf.id && ast_set_write_format(chan, &oldwf) < 0)
+	if (oldwf && ast_set_write_format(chan, oldwf) < 0)
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
+	ao2_cleanup(oldwf);
 
 	if (ast_test_flag(&flags, OPTION_EXITONHANGUP)) {
 		ast_verb(3, "Stopped spying due to the spied-on channel hanging up.\n");
@@ -1242,7 +1240,7 @@
 		.volume = '#',
 		.exit = '\0',
 	};
-	struct ast_format oldwf;
+	struct ast_format *oldwf;
 	int volfactor = 0;
 	int res;
 	char *mailbox = NULL;
@@ -1254,7 +1252,6 @@
 	char *parse = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, parse);
-	ast_format_clear(&oldwf);
 
 	if (!ast_strlen_zero(args.context) && (ptr = strchr(args.context, '@'))) {
 		exten = args.context;
@@ -1324,8 +1321,8 @@
 		ast_clear_flag(&flags, AST_FLAGS_ALL);
 	}
 
-	ast_format_copy(&oldwf, ast_channel_writeformat(chan));
-	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
+	oldwf = ast_format_copy(ast_channel_writeformat(chan));
+	if (ast_set_write_format(chan, ast_format_slin) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 		return -1;
 	}
@@ -1346,8 +1343,9 @@
 	if (fd)
 		close(fd);
 
-	if (oldwf.id && ast_set_write_format(chan, &oldwf) < 0)
+	if (oldwf && ast_set_write_format(chan, oldwf) < 0)
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
+	ao2_cleanup(oldwf);
 
 	return res;
 }
@@ -1361,13 +1359,13 @@
 		.volume = '\0',
 		.exit = '*',
 	};
-	struct ast_format oldwf;
+	struct ast_format *oldwf;
 	int res;
 	char *mygroup = NULL;
 
 	/* Coverity - This uninit_use should be ignored since this macro initializes the flags */
 	ast_clear_flag(&flags, AST_FLAGS_ALL);
-	ast_format_clear(&oldwf);
+
 	if (!ast_strlen_zero(data)) {
 		mygroup = ast_strdupa(data);
 	}
@@ -1375,16 +1373,17 @@
 	ast_set_flag(&flags, OPTION_DTMF_CYCLE);
 	ast_set_flag(&flags, OPTION_DAHDI_SCAN);
 
-	ast_format_copy(&oldwf, ast_channel_writeformat(chan));
-	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
+	oldwf = ast_format_copy(ast_channel_writeformat(chan));
+	if (ast_set_write_format(chan, ast_format_slin) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 		return -1;
 	}
 
 	res = common_exec(chan, &flags, 0, 0, &user_options, mygroup, NULL, spec, NULL, NULL, NULL, NULL);
 
-	if (oldwf.id && ast_set_write_format(chan, &oldwf) < 0)
+	if (oldwf && ast_set_write_format(chan, oldwf) < 0)
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
+	ao2_cleanup(oldwf);
 
 	return res;
 }

Modified: team/group/media_formats/channels/chan_alsa.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_alsa.c?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/channels/chan_alsa.c (original)
+++ team/group/media_formats/channels/chan_alsa.c Wed Feb  5 09:27:48 2014
@@ -141,9 +141,6 @@
 static int autoanswer = 1;
 static int mute = 0;
 static int noaudiocapture = 0;
-
-/* Signed linear format that is used by all channels and frames */
-static struct ast_format *slin_format;
 
 static struct ast_channel *alsa_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause);
 static int alsa_digit(struct ast_channel *c, char digit, unsigned int duration);
@@ -515,7 +512,7 @@
 		}
 
 		f.frametype = AST_FRAME_VOICE;
-		f.subclass.format = ast_format_copy(slin_format);
+		f.subclass.format = ast_format_copy(ast_format_slin);
 		f.samples = FRAME_SIZE;
 		f.datalen = FRAME_SIZE * 2;
 		f.data.ptr = buf;
@@ -589,8 +586,8 @@
 
 	ast_channel_tech_set(tmp, &alsa_tech);
 	ast_channel_set_fd(tmp, 0, readdev);
-	ast_channel_set_readformat(tmp, slin_format);
-	ast_channel_set_writeformat(tmp, slin_format);
+	ast_channel_set_readformat(tmp, ast_format_slin);
+	ast_channel_set_writeformat(tmp, ast_format_slin);
 	ast_channel_nativeformats_set(tmp, alsa_tech.capabilities);
 
 	ast_channel_tech_pvt_set(tmp, p);
@@ -623,7 +620,7 @@
 	char buf[256];
 	struct ast_channel *tmp = NULL;
 
-	if (!ast_format_cap_iscompatible_format(cap, slin_format)) {
+	if (!ast_format_cap_iscompatible_format(cap, ast_format_slin)) {
 		ast_log(LOG_NOTICE, "Asked to get a channel of format '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), cap));
 		return NULL;
 	}
@@ -961,16 +958,10 @@
 	struct ast_variable *v;
 	struct ast_flags config_flags = { 0 };
 
-	slin_format = ast_format_cache_get("slin");
-	if (!slin_format) {
-		ast_log(LOG_ERROR, "Expected format 'slin' in format cache does not exist\n");
-		return AST_MODULE_LOAD_DECLINE;
-	}
-
 	if (!(alsa_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_add(alsa_tech.capabilities, slin_format, 0);
+	ast_format_cap_add(alsa_tech.capabilities, ast_format_slin, 0);
 
 	/* Copy the default jb config over global_jbconf */
 	memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
@@ -1051,9 +1042,6 @@
 	ao2_cleanup(alsa_tech.capabilities);
 	alsa_tech.capabilities = NULL;
 
-	ao2_cleanup(slin_format);
-	slin_format = NULL;
-
 	return 0;
 }
 

Modified: team/group/media_formats/channels/chan_oss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_oss.c?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/channels/chan_oss.c (original)
+++ team/group/media_formats/channels/chan_oss.c Wed Feb  5 09:27:48 2014
@@ -242,9 +242,6 @@
 static char *config = "oss.conf";	/* default config file */
 
 static int oss_debug;
-
-/* Signed linear format that is used by all channels and frames */
-static struct ast_format *slin_format;
 
 /*!
  * \brief descriptor for one of our channels.
@@ -730,7 +727,7 @@
 		return f;
 	/* ok we can build and deliver the frame to the caller */
 	f->frametype = AST_FRAME_VOICE;
-	f->subclass.format = ast_format_copy(slin_format);
+	f->subclass.format = ast_format_copy(ast_format_slin);
 	f->samples = FRAME_SIZE;
 	f->datalen = FRAME_SIZE * 2;
 	f->data.ptr = o->oss_read_buf + AST_FRIENDLY_OFFSET;
@@ -808,8 +805,8 @@
 		setformat(o, O_RDWR);
 	ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
 
-	ast_channel_set_readformat(c, slin_format);
-	ast_channel_set_writeformat(c, slin_format);
+	ast_channel_set_readformat(c, ast_format_slin);
+	ast_channel_set_writeformat(c, ast_format_slin);
 	ast_channel_nativeformats_set(c, oss_tech.capabilities);
 
 	/* if the console makes the call, add video to the offer */
@@ -866,7 +863,7 @@
 		/* XXX we could default to 'dsp' perhaps ? */
 		return NULL;
 	}
-	if (!ast_format_cap_iscompatible_format(cap, slin_format)) {
+	if (!ast_format_cap_iscompatible_format(cap, ast_format_slin)) {
 		ast_log(LOG_NOTICE, "Format %s unsupported\n", ast_getformatname_multiple(buf, sizeof(buf), cap));
 		return NULL;
 	}
@@ -1457,12 +1454,6 @@
 	char *ctg = NULL;
 	struct ast_flags config_flags = { 0 };
 
-	slin_format = ast_format_cache_get("slin");
-	if (!slin_format) {
-		ast_log(LOG_ERROR, "Expected format 'slin' in format cache does not exist\n");
-		return AST_MODULE_LOAD_DECLINE;
-	}
-
 	/* Copy the default jb config over global_jbconf */
 	memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
 
@@ -1491,7 +1482,7 @@
 	if (!(oss_tech.capabilities = ast_format_cap_alloc(0))) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	ast_format_cap_add(oss_tech.capabilities, slin_format, 0);
+	ast_format_cap_add(oss_tech.capabilities, ast_format_slin, 0);
 
 	/* TODO XXX CONSOLE VIDEO IS DISABLE UNTIL IT HAS A MAINTAINER
 	 * add console_video_formats to oss_tech.capabilities once this occurs. */
@@ -1529,9 +1520,6 @@
 	ao2_cleanup(oss_tech.capabilities);
 	oss_tech.capabilities = NULL;
 
-	ao2_cleanup(slin_format);
-	slin_format = NULL;
-
 	return 0;
 }
 

Modified: team/group/media_formats/include/asterisk/codec.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/codec.h?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/include/asterisk/codec.h (original)
+++ team/group/media_formats/include/asterisk/codec.h Wed Feb  5 09:27:48 2014
@@ -150,4 +150,13 @@
  */
 const char *ast_codec_media_type2str(enum ast_media_type type);
 
+/*!
+ * \brief Get the number of samples contained within a frame
+ *
+ * \param frame The frame itself
+ *
+ * \retval number of samples in the frame
+ */
+unsigned int ast_codec_get_samples(struct ast_frame *frame);
+
 #endif /* _AST_CODEC_H */

Modified: team/group/media_formats/include/asterisk/format_cache.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_cache.h?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/include/asterisk/format_cache.h (original)
+++ team/group/media_formats/include/asterisk/format_cache.h Wed Feb  5 09:27:48 2014
@@ -27,6 +27,21 @@
 #define _AST_FORMAT_CACHE_H_
 
 struct ast_format;
+
+/*!
+ * \brief Built-in cached signed linear format.
+ */
+extern struct ast_format *ast_format_slin;
+
+/*!
+ * \brief Built-in cached ulaw format.
+ */
+extern struct ast_format *ast_format_ulaw;
+
+/*!
+ * \brief Builtin- cached alaw format.
+ */
+extern struct ast_format *ast_format_alaw;
 
 /*!
  * \brief Initialize format cache support within the core.

Modified: team/group/media_formats/main/codec.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/codec.c?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/main/codec.c (original)
+++ team/group/media_formats/main/codec.c Wed Feb  5 09:27:48 2014
@@ -323,4 +323,21 @@
 	default:
 		return "<unknown>";
 	}
+}
+
+unsigned int ast_codec_get_samples(struct ast_frame *frame)
+{
+	if ((frame->frametype != AST_FRAME_VOICE) &&
+		(frame->frametype != AST_FRAME_VIDEO) &&
+		(frame->frametype != AST_FRAME_IMAGE)) {
+		return 0;
+	}
+
+	if (!frame->subclass.format->codec->get_samples) {
+		ast_log(LOG_WARNING, "Unable to calculate samples for codec %s\n",
+			frame->subclass.format->codec->name);
+		return 0;
+	}
+
+	return frame->subclass.format->codec->get_samples(frame);
 }

Modified: team/group/media_formats/pbx/pbx_spool.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/pbx/pbx_spool.c?view=diff&rev=407406&r1=407405&r2=407406
==============================================================================
--- team/group/media_formats/pbx/pbx_spool.c (original)
+++ team/group/media_formats/pbx/pbx_spool.c Wed Feb  5 09:27:48 2014
@@ -75,8 +75,6 @@
 
 static char qdir[255];
 static char qdonedir[255];
-
-static struct ast_format *slin_format;
 
 struct outgoing {
 	int retries;                              /*!< Current number of retries */
@@ -152,7 +150,7 @@
 		free_outgoing(o);
 		return NULL;
 	}
-	ast_format_cap_add(o->capabilities, slin_format, 0);
+	ast_format_cap_add(o->capabilities, ast_format_slin, 0);
 
 	return o;
 }
@@ -902,12 +900,6 @@
 	}
 	snprintf(qdonedir, sizeof(qdir), "%s/%s", ast_config_AST_SPOOL_DIR, "outgoing_done");
 
-	slin_format = ast_format_cache_get("slin");
-	if (!slin_format) {
-		ast_log(LOG_ERROR, "Expected format 'slin' in format cache does not exist\n");
-		return AST_MODULE_LOAD_DECLINE;
-	}
-
 	if ((ret = ast_pthread_create_detached_background(&thread, NULL, scan_thread, NULL))) {
 		ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret);
 		return AST_MODULE_LOAD_FAILURE;




More information about the asterisk-commits mailing list