[asterisk-commits] dlee: branch dlee/playback-rebase r389342 - in /team/dlee/playback-rebase/res...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 21 09:15:04 CDT 2013


Author: dlee
Date: Tue May 21 09:15:01 2013
New Revision: 389342

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389342
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

Modified:
    team/dlee/playback-rebase/res/res_stasis_playback.c
    team/dlee/playback-rebase/res/stasis_http/resource_channels.c

Modified: team/dlee/playback-rebase/res/res_stasis_playback.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback-rebase/res/res_stasis_playback.c?view=diff&rev=389342&r1=389341&r2=389342
==============================================================================
--- team/dlee/playback-rebase/res/res_stasis_playback.c (original)
+++ team/dlee/playback-rebase/res/res_stasis_playback.c Tue May 21 09:15:01 2013
@@ -90,32 +90,33 @@
 	}
 }
 
+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_COMPLETE:
+		return "done";
+	}
+
+	return "?";
+}
+
 static struct ast_json *playback_to_json(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_COMPLETE:
-		state = "complete";
-		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);
 }
@@ -211,6 +212,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)
@@ -221,7 +229,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;
 	}

Modified: team/dlee/playback-rebase/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback-rebase/res/stasis_http/resource_channels.c?view=diff&rev=389342&r1=389341&r2=389342
==============================================================================
--- team/dlee/playback-rebase/res/stasis_http/resource_channels.c (original)
+++ team/dlee/playback-rebase/res/stasis_http/resource_channels.c Tue May 21 09:15:01 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 */
@@ -185,7 +183,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