Source

asterisk-voicechanger / app_voicechanger.c

Diff from to

app_voicechanger.c

 	struct voicechanger *vc;
 	if (data) {
 		vc = (struct voicechanger *)data;
-		if (vc->ah) {
-			ast_free(vc->ah);
-		}
-		vc_soundtouch_free(vc->st8k);
-		vc_soundtouch_free(vc->st16k);
-		ast_free(vc);
-		ast_log(LOG_DEBUG, "freed voice changer resources\n");
+		vc_soundtouch_free(vc->st8k); vc->st8k = NULL;
+		vc_soundtouch_free(vc->st16k); vc->st16k = NULL;
+		ast_audiohook_detach(vc->ah);
+		ast_audiohook_destroy(vc->ah);
+		ast_free(data);
 	}
+	ast_log(LOG_DEBUG, "freed voice changer resources\n");
 }
 
 static int install_vc(struct ast_channel *chan, float pitch)
 	struct ast_datastore *ds;
 	struct voicechanger *vc;
 
+	ast_log(LOG_DEBUG, "pitch is %f\n", pitch);
 	if (-0.1 < pitch && pitch < 0.1) {
 		return 0;
 	}
 static int uninstall_vc(struct ast_channel *chan)
 {
 	struct ast_datastore *ds;
-	struct voicechanger *vc;
 	ast_log(LOG_DEBUG, "Detaching Voice Changer from channel...\n");
 	ast_channel_lock(chan);
 	ds = ast_channel_datastore_find(chan, dsinfo, app);
+	if (ds) {
+		ast_channel_datastore_remove(chan, ds);
+		ast_datastore_free(ds);
+	}
 	ast_channel_unlock(chan);
-	if (ds) {
-		vc = (struct voicechanger *)ds->data;
-		if (ast_audiohook_detach_source(chan, app) != 0) {
-			ast_log(LOG_WARNING, "could not find audiohook :(\n");
-		}
-	} else {
-		ast_log(LOG_NOTICE, "voicechanger doesn't seem attached\n");
-	}
 	return 0;
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.