[asterisk-commits] dlee: branch dlee/playback-controls r389449 - in /team/dlee/playback-controls...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 21 16:52:58 CDT 2013


Author: dlee
Date: Tue May 21 16:52:55 2013
New Revision: 389449

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389449
Log:
Addressed review feedback.

* Remove debugging statements
* Implemented some stub functions I forgot to do
* Extracted playback state_to_string function
* Plugged a memory leak
........

Merged revisions 389342 from http://svn.asterisk.org/svn/asterisk/team/dlee/playback-rebase

Modified:
    team/dlee/playback-controls/   (props changed)
    team/dlee/playback-controls/res/res_stasis_playback.c
    team/dlee/playback-controls/res/stasis_http/resource_channels.c

Propchange: team/dlee/playback-controls/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue May 21 16:52:55 2013
@@ -1,1 +1,1 @@
-/team/dlee/playback-rebase:1-388954 /trunk:1-388896
+/team/dlee/playback-rebase:1-388954,389342 /trunk:1-388896

Modified: team/dlee/playback-controls/res/res_stasis_playback.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback-controls/res/res_stasis_playback.c?view=diff&rev=389449&r1=389448&r2=389449
==============================================================================
--- team/dlee/playback-controls/res/res_stasis_playback.c (original)
+++ team/dlee/playback-controls/res/res_stasis_playback.c Tue May 21 16:52:55 2013
@@ -97,6 +97,28 @@
 	}
 }
 
+static const char *state_to_string(enum stasis_app_playback_state state)
+{
+	switch (state) {
+	case STASIS_PLAYBACK_STATE_QUEUED:
+		return "queued";
+	case STASIS_PLAYBACK_STATE_PLAYING:
+		return "playing";
+	case STASIS_PLAYBACK_STATE_PAUSED:
+		return "paused";
+	case STASIS_PLAYBACK_STATE_STOPPED:
+	case STASIS_PLAYBACK_STATE_COMPLETE:
+	case STASIS_PLAYBACK_STATE_CANCELED:
+		/* It doesn't really matter how we got here, but all of these
+		 * states really just mean 'done' */
+		return "done";
+	case STASIS_PLAYBACK_STATE_MAX:
+		break;
+	}
+
+	return "?";
+}
+
 static void playback_publish(struct stasis_app_playback *playback)
 {
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
@@ -222,6 +244,13 @@
 	return NULL;
 }
 
+static void playback_dtor(void *obj)
+{
+	struct stasis_app_playback *playback = obj;
+
+	ast_string_field_free_memory(playback);
+}
+
 struct stasis_app_playback *stasis_app_control_play_uri(
 	struct stasis_app_control *control, const char *uri,
 	const char *language, int skipms, long offsetms)
@@ -232,7 +261,7 @@
 	ast_debug(3, "%s: Sending play(%s) command\n",
 		stasis_app_control_get_channel_id(control), uri);
 
-	playback = ao2_alloc(sizeof(*playback) + strlen(uri) + 1, NULL);
+	playback = ao2_alloc(sizeof(*playback), playback_dtor);
 	if (!playback || ast_string_field_init(playback, 128) ){
 		return NULL;
 	}
@@ -292,38 +321,17 @@
 	const struct stasis_app_playback *playback)
 {
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
-	char *state = "?";
 
 	if (playback == NULL) {
 		return NULL;
 	}
 
-	switch (playback->state) {
-	case STASIS_PLAYBACK_STATE_QUEUED:
-		state = "queued";
-		break;
-	case STASIS_PLAYBACK_STATE_PLAYING:
-		state = "playing";
-		break;
-	case STASIS_PLAYBACK_STATE_PAUSED:
-		state = "paused";
-		break;
-	case STASIS_PLAYBACK_STATE_STOPPED:
-	case STASIS_PLAYBACK_STATE_COMPLETE:
-	case STASIS_PLAYBACK_STATE_CANCELED:
-		/* It doesn't really matter how we got here, but all of these
-		 * states really just mean 'done' */
-		state = "done";
-		break;
-	case STASIS_PLAYBACK_STATE_MAX:
-		break;
-	}
 
 	json = ast_json_pack("{s: s, s: s, s: s, s: s}",
 		"id", playback->id,
 		"media_uri", playback->media,
 		"language", playback->language,
-		"state", state);
+		"state", state_to_string(playback->state));
 
 	return ast_json_ref(json);
 }

Modified: team/dlee/playback-controls/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback-controls/res/stasis_http/resource_channels.c?view=diff&rev=389449&r1=389448&r2=389449
==============================================================================
--- team/dlee/playback-controls/res/stasis_http/resource_channels.c (original)
+++ team/dlee/playback-controls/res/stasis_http/resource_channels.c Tue May 21 16:52:55 2013
@@ -149,8 +149,6 @@
 
 	ast_assert(response != NULL);
 
-	ast_verb(1, "%s(%s, %s)\n", __func__, args->channel_id, args->media);
-
 	control = find_control(response, args->channel_id);
 	if (control == NULL) {
 		/* Response filled in by find_control */
@@ -186,7 +184,6 @@
 	}
 
 	stasis_http_response_created(response, playback_url);
-	ast_verb(1, " %s - done\n", __func__);
 }
 void stasis_http_record_channel(struct ast_variable *headers, struct ast_record_channel_args *args, struct stasis_http_response *response)
 {




More information about the asterisk-commits mailing list