[asterisk-commits] mmichelson: branch group/asterisk-cpp r168387 - in /team/group/asterisk-cpp: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 10 17:11:54 CST 2009


Author: mmichelson
Date: Sat Jan 10 17:11:53 2009
New Revision: 168387

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168387
Log:
Got audiohook.c compiling


Modified:
    team/group/asterisk-cpp/include/asterisk/datastore.h
    team/group/asterisk-cpp/include/asterisk/frame.h
    team/group/asterisk-cpp/main/app.c
    team/group/asterisk-cpp/main/audiohook.c

Modified: team/group/asterisk-cpp/include/asterisk/datastore.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/datastore.h?view=diff&rev=168387&r1=168386&r2=168387
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/datastore.h (original)
+++ team/group/asterisk-cpp/include/asterisk/datastore.h Sat Jan 10 17:11:53 2009
@@ -25,8 +25,13 @@
 
 /*! \brief Structure for a data store type */
 struct ast_datastore_info {
+	ast_datastore_info(const char *type, 
+			void (*destroy)(void *data) = NULL, 
+			void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan) = NULL,
+			void *(*duplicate)(void *data) = NULL) :
+			type(type), destroy(destroy), chan_fixup(chan_fixup), duplicate(duplicate) {}
+
 	const char *type;			/*!< Type of data store */
-	void *(*duplicate)(void *data);		/*!< Duplicate item data (used for inheritance) */
 	void (*destroy)(void *data);		/*!< Destroy function */
 
 	/*!
@@ -44,6 +49,7 @@
 	 * \return nothing.
 	 */
 	void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
+	void *(*duplicate)(void *data);		/*!< Duplicate item data (used for inheritance) */
 };
 
 /*! \brief Structure for a data store object */

Modified: team/group/asterisk-cpp/include/asterisk/frame.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/frame.h?view=diff&rev=168387&r1=168386&r2=168387
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/frame.h (original)
+++ team/group/asterisk-cpp/include/asterisk/frame.h Sat Jan 10 17:11:53 2009
@@ -139,6 +139,8 @@
 /*! \brief Data structure associated with a single frame of data
  */
 struct ast_frame {
+	ast_frame() {}
+	ast_frame(enum ast_frame_type frametype, int sublcass, int datalen = 0, int samples = 0, void *ptr = NULL) : frametype(frametype), subclass(subclass), datalen(datalen), samples(samples) {data.ptr = ptr;}
 	/*! Kind of frame */
 	enum ast_frame_type frametype;				
 	/*! Subclass, frame dependent */

Modified: team/group/asterisk-cpp/main/app.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/app.c?view=diff&rev=168387&r1=168386&r2=168387
==============================================================================
--- team/group/asterisk-cpp/main/app.c (original)
+++ team/group/asterisk-cpp/main/app.c Sat Jan 10 17:11:53 2009
@@ -372,10 +372,9 @@
 {
 	short buf[2048 + AST_FRIENDLY_OFFSET / 2];
 	struct linear_state *ls = (struct linear_state *) data;
-	struct ast_frame f = { AST_FRAME_VOICE, };
+	struct ast_frame f (AST_FRAME_VOICE, AST_FORMAT_SLINEAR);
 	int res;
 
-	f.subclass = AST_FORMAT_SLINEAR;
 	f.data.ptr = buf + AST_FRIENDLY_OFFSET / 2;
 	f.offset = AST_FRIENDLY_OFFSET;
 

Modified: team/group/asterisk-cpp/main/audiohook.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/audiohook.c?view=diff&rev=168387&r1=168386&r2=168387
==============================================================================
--- team/group/asterisk-cpp/main/audiohook.c (original)
+++ team/group/asterisk-cpp/main/audiohook.c Sat Jan 10 17:11:53 2009
@@ -161,13 +161,7 @@
 	struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory);
 	int vol = (direction == AST_AUDIOHOOK_DIRECTION_READ ? audiohook->options.read_volume : audiohook->options.write_volume);
 	short buf[samples];
-	struct ast_frame frame = {
-		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
-		.data.ptr = buf,
-		.datalen = sizeof(buf),
-		.samples = samples,
-	};
+	struct ast_frame frame(AST_FRAME_VOICE, AST_FORMAT_SLINEAR, sizeof(buf), samples, (void *) buf);
 
 	/* Ensure the factory is able to give us the samples we want */
 	if (samples > ast_slinfactory_available(factory))
@@ -186,15 +180,10 @@
 
 static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audiohook, size_t samples)
 {
-	int i = 0, usable_read, usable_write;
+	int usable_read, usable_write;
+	size_t i = 0;
 	short buf1[samples], buf2[samples], *read_buf = NULL, *write_buf = NULL, *final_buf = NULL, *data1 = NULL, *data2 = NULL;
-	struct ast_frame frame = {
-		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
-		.data.ptr = NULL,
-		.datalen = sizeof(buf1),
-		.samples = samples,
-	};
+	struct ast_frame frame(AST_FRAME_VOICE, AST_FORMAT_SLINEAR, sizeof(buf1), samples);
 
 	/* Make sure both factories have the required samples */
 	usable_read = (ast_slinfactory_available(&audiohook->read_factory) >= samples ? 1 : 0);
@@ -207,13 +196,13 @@
 	}
 
 	/* If we want to provide only a read factory make sure we aren't waiting for other audio */
-	if (usable_read && !usable_write && (ast_tvdiff_ms(ast_tvnow(), audiohook->write_time) < (samples/8)*2)) {
+	if (usable_read && !usable_write && (ast_tvdiff_ms(ast_tvnow(), audiohook->write_time) < (int) (samples/8)*2)) {
 		ast_debug(3, "Write factory %p was pretty quick last time, waiting for them.\n", &audiohook->write_factory);
 		return NULL;
 	}
 
 	/* If we want to provide only a write factory make sure we aren't waiting for other audio */
-	if (usable_write && !usable_read && (ast_tvdiff_ms(ast_tvnow(), audiohook->read_time) < (samples/8)*2)) {
+	if (usable_write && !usable_read && (ast_tvdiff_ms(ast_tvnow(), audiohook->read_time) < (int) (samples/8)*2)) {
 		ast_debug(3, "Read factory %p was pretty quick last time, waiting for them.\n", &audiohook->read_factory);
 		return NULL;
 	}
@@ -224,7 +213,7 @@
 			read_buf = buf1;
 			/* Adjust read volume if need be */
 			if (audiohook->options.read_volume) {
-				int count = 0;
+				size_t count = 0;
 				short adjust_value = abs(audiohook->options.read_volume);
 				for (count = 0; count < samples; count++) {
 					if (audiohook->options.read_volume > 0)
@@ -243,7 +232,7 @@
 			write_buf = buf2;
 			/* Adjust write volume if need be */
 			if (audiohook->options.write_volume) {
-				int count = 0;
+				size_t count = 0;
 				short adjust_value = abs(audiohook->options.write_volume);
 				for (count = 0; count < samples; count++) {
 					if (audiohook->options.write_volume > 0)
@@ -323,7 +312,7 @@
 
 	if (!chan->audiohooks) {
 		/* Whoops... allocate a new structure */
-		if (!(chan->audiohooks = ast_calloc(1, sizeof(*chan->audiohooks)))) {
+		if (!(chan->audiohooks = (struct ast_audiohook_list *) ast_calloc(1, sizeof(*chan->audiohooks)))) {
 			ast_channel_unlock(chan);
 			return -1;
 		}
@@ -395,7 +384,7 @@
 		ast_audiohook_lock(audiohook);
 		audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
 		ast_audiohook_unlock(audiohook);
-		audiohook->manipulate_callback(audiohook, NULL, NULL, 0);
+		audiohook->manipulate_callback(audiohook, NULL, NULL, (enum ast_audiohook_direction) 0);
 	}
 
 	/* Drop translation paths if present */
@@ -538,7 +527,7 @@
 			AST_LIST_REMOVE_CURRENT(list);
 			audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
 			ast_audiohook_unlock(audiohook);
-			audiohook->manipulate_callback(audiohook, NULL, NULL, 0);
+			audiohook->manipulate_callback(audiohook, NULL, NULL, (enum ast_audiohook_direction) 0);
 			continue;
 		}
 		if (ast_test_flag(audiohook, AST_AUDIOHOOK_WANTS_DTMF))
@@ -607,7 +596,7 @@
 				ast_audiohook_unlock(audiohook);
 				continue;
 			}
-			if (ast_slinfactory_available(&audiohook->write_factory) >= samples && ast_slinfactory_read(&audiohook->write_factory, read_buf, samples)) {
+			if ((int) ast_slinfactory_available(&audiohook->write_factory) >= samples && ast_slinfactory_read(&audiohook->write_factory, read_buf, samples)) {
 				/* Take audio from this whisper source and combine it into our main buffer */
 				for (i = 0, data1 = combine_buf, data2 = read_buf; i < samples; i++, data1++, data2++)
 					ast_slinear_saturated_add(data1, data2);
@@ -616,7 +605,7 @@
 		}
 		AST_LIST_TRAVERSE_SAFE_END
 		/* We take all of the combined whisper sources and combine them into the audio being written out */
-		for (i = 0, data1 = middle_frame->data.ptr, data2 = combine_buf; i < samples; i++, data1++, data2++)
+		for (i = 0, data1 = (short *) middle_frame->data.ptr, data2 = combine_buf; i < samples; i++, data1++, data2++)
 			ast_slinear_saturated_add(data1, data2);
 		end_frame = middle_frame;
 	}
@@ -800,7 +789,7 @@
  */
 static void audiohook_volume_destroy(void *data)
 {
-	struct audiohook_volume *audiohook_volume = data;
+	struct audiohook_volume *audiohook_volume = (struct audiohook_volume *) data;
 
 	/* Destroy the audiohook as it is no longer in use */
 	ast_audiohook_destroy(&audiohook_volume->audiohook);
@@ -812,10 +801,7 @@
 }
 
 /*! \brief Datastore used to store audiohook volume information */
-static const struct ast_datastore_info audiohook_volume_datastore = {
-	.type = "Volume",
-	.destroy = audiohook_volume_destroy,
-};
+static const struct ast_datastore_info audiohook_volume_datastore("Volume", audiohook_volume_destroy);
 
 /*! \brief Helper function which actually gets called by audiohooks to perform the adjustment
  * \param audiohook Audiohook attached to the channel
@@ -840,7 +826,7 @@
 		return 0;
 	}
 
-	audiohook_volume = datastore->data;
+	audiohook_volume = (struct audiohook_volume *) datastore->data;
 
 	/* Based on direction grab the appropriate adjustment value */
 	if (direction == AST_AUDIOHOOK_DIRECTION_READ) {
@@ -869,7 +855,7 @@
 
 	/* If we are able to find the datastore return the contents (which is actually an audiohook_volume structure) */
 	if ((datastore = ast_channel_datastore_find(chan, &audiohook_volume_datastore, NULL))) {
-		return datastore->data;
+		return (struct audiohook_volume *) datastore->data;
 	}
 
 	/* If we are not allowed to create a datastore or if we fail to create a datastore, bail out now as we have nothing for them */
@@ -878,7 +864,7 @@
 	}
 
 	/* Create a new audiohook_volume structure to contain our adjustments and audiohook */
-	if (!(audiohook_volume = ast_calloc(1, sizeof(*audiohook_volume)))) {
+	if (!(audiohook_volume = (struct audiohook_volume *) ast_calloc(1, sizeof(*audiohook_volume)))) {
 		ast_datastore_free(datastore);
 		return NULL;
 	}




More information about the asterisk-commits mailing list