*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
#include <vlc_common.h>
#include <pulse/pulseaudio.h>
-#include "vlcpulse.h"
+#include "audio_output/vlcpulse.h"
#include <assert.h>
#include <stdlib.h>
#include <locale.h>
return 0;
}
+static void context_event_cb(pa_context *c, const char *name, pa_proplist *pl,
+ void *userdata)
+{
+ vlc_object_t *obj = userdata;
+
+ msg_Warn (obj, "unhandled context event \"%s\"", name);
+ (void) c;
+ (void) pl;
+}
+
/**
* Initializes the PulseAudio main loop and connects to the PulseAudio server.
* @return a PulseAudio context on success, or NULL on error
pa_proplist *props = pa_proplist_new ();
if (likely(props != NULL))
{
- pa_proplist_sets (props, PA_PROP_APPLICATION_NAME, ua);
- pa_proplist_sets (props, PA_PROP_APPLICATION_ID, "org.VideoLAN.VLC");
- pa_proplist_sets (props, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
- pa_proplist_sets (props, PA_PROP_APPLICATION_ICON_NAME, PACKAGE_NAME);
+ char *str;
+
+ if (ua != NULL)
+ pa_proplist_sets (props, PA_PROP_APPLICATION_NAME, ua);
+
+ str = var_InheritString (obj, "app-id");
+ if (str != NULL)
+ {
+ pa_proplist_sets (props, PA_PROP_APPLICATION_ID, str);
+ free (str);
+ }
+ str = var_InheritString (obj, "app-version");
+ if (str != NULL)
+ {
+ pa_proplist_sets (props, PA_PROP_APPLICATION_VERSION, str);
+ free (str);
+ }
+ str = var_InheritString (obj, "app-icon-name");
+ if (str != NULL)
+ {
+ pa_proplist_sets (props, PA_PROP_APPLICATION_ICON_NAME, str);
+ free (str);
+ }
//pa_proplist_sets (props, PA_PROP_APPLICATION_LANGUAGE, _("C"));
pa_proplist_sets (props, PA_PROP_APPLICATION_LANGUAGE,
setlocale (LC_MESSAGES, NULL));
//pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_BINARY,
// PACKAGE_NAME);
- char buf[sysconf (_SC_GETPW_R_SIZE_MAX)];
- struct passwd pwbuf, *pw;
+ for (size_t max = sysconf (_SC_GETPW_R_SIZE_MAX), len = max % 1024 + 1024;
+ len < max; len += 1024)
+ {
+ struct passwd pwbuf, *pw;
+ char buf[len];
+
+ if (getpwuid_r (getuid (), &pwbuf, buf, sizeof (buf), &pw) == 0)
+ {
+ if (pw != NULL)
+ pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_USER,
+ pw->pw_name);
+ break;
+ }
+ }
- if (getpwuid_r (getuid (), &pwbuf, buf, sizeof (buf), &pw) == 0
- && pw != NULL)
- pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_USER,
- pw->pw_name);
+ for (size_t max = sysconf (_SC_HOST_NAME_MAX), len = max % 1024 + 1024;
+ len < max; len += 1024)
+ {
+ char hostname[len];
- char hostname[sysconf (_SC_HOST_NAME_MAX)];
- if (gethostname (hostname, sizeof (hostname)) == 0)
- pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_HOST,
- hostname);
+ if (gethostname (hostname, sizeof (hostname)) == 0)
+ {
+ pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_HOST,
+ hostname);
+ break;
+ }
+ }
const char *session = getenv ("XDG_SESSION_COOKIE");
if (session != NULL)
goto fail;
pa_context_set_state_callback (ctx, context_state_cb, mainloop);
+ pa_context_set_event_callback (ctx, context_event_cb, obj);
if (pa_context_connect (ctx, NULL, 0, NULL) < 0
|| context_wait (ctx, mainloop))
{
{
pa_threaded_mainloop_lock (mainloop);
pa_context_disconnect (ctx);
+ pa_context_set_event_callback (ctx, NULL, NULL);
pa_context_set_state_callback (ctx, NULL, NULL);
pa_context_unref (ctx);
pa_threaded_mainloop_unlock (mainloop);