]> code.delx.au - pulseaudio/blobdiff - src/modules/module-volume-restore.c
modules: Fix resource leak in alsa-card
[pulseaudio] / src / modules / module-volume-restore.c
index 21c714915f6635d71ef074c957a9275a24248840..cd397e270ea77a7084d6f7eaef190ca7c2a1eefa 100644 (file)
@@ -5,7 +5,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
@@ -35,7 +35,8 @@
 PA_MODULE_AUTHOR("Lennart Poettering");
 PA_MODULE_DESCRIPTION("Compatibility module");
 PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_LOAD_ONCE(true);
+PA_MODULE_DEPRECATED("Please use module-stream-restore instead of module-volume-restore!");
 
 static const char* const valid_modargs[] = {
     "table",
@@ -46,7 +47,8 @@ static const char* const valid_modargs[] = {
 
 int pa__init(pa_module*m) {
     pa_modargs *ma = NULL;
-    pa_bool_t restore_device = TRUE, restore_volume = TRUE;
+    bool restore_device = true, restore_volume = true;
+    pa_module *n;
     char *t;
 
     pa_assert(m);
@@ -62,20 +64,22 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    pa_log_warn("module-volume-restore is obsolete. It has been replaced by module-stream-restore. We will now load the latter but please make sure to remove module-volume-restore from your configuration.");
+    pa_log_warn("We will now load module-stream-restore. Please make sure to remove module-volume-restore from your configuration.");
 
     t = pa_sprintf_malloc("restore_volume=%s restore_device=%s", pa_yes_no(restore_volume), pa_yes_no(restore_device));
-    pa_module_load(m->core, "module-stream-restore", t);
+    n = pa_module_load(m->core, "module-stream-restore", t);
     pa_xfree(t);
 
-    pa_module_unload_request(m, TRUE);
+    if (n)
+        pa_module_unload_request(m, true);
 
     pa_modargs_free(ma);
-    return 0;
+
+    return n ? 0 : -1;
 
 fail:
     if (ma)
         pa_modargs_free(ma);
 
-    return  -1;
+    return -1;
 }