#define WIN32_LEAN_AND_MEAN /* prevents from including too many things */
#include <windows.h> /* GetStdHandle, windows console */
#endif
+#if defined (__APPLE__)
+#include <errno.h>
+#include <libproc.h> /* proc_pidpath, PROC_PIDPATHINFO_MAXSIZE */
+#endif
#include "gst-i18n-lib.h"
#include <locale.h> /* for LC_ALL */
extern gboolean _priv_gst_disable_registry_update;
#endif
+gchar *_gst_executable_path = NULL;
+
#ifndef GST_DISABLE_GST_DEBUG
const gchar *priv_gst_dump_dot_dir;
#endif
#endif
}
+#if defined(__linux__)
+static void
+find_executable_path (void)
+{
+ GError *error = NULL;
+ gchar *path;
+
+ if (_gst_executable_path)
+ return;
+
+ path = g_file_read_link ("/proc/self/exe", &error);
+
+ if (path) {
+ _gst_executable_path = g_path_get_dirname (path);
+ g_free (path);
+ }
+}
+#elif defined(G_OS_WIN32)
+static void
+find_executable_path (void)
+{
+ char buffer[MAX_PATH];
+
+ if (!GetModuleFilename (NULL, buffer, MAX_PATH))
+ return;
+
+ _gst_executable_path = g_strdup (buffer);
+}
+#elif defined(__APPLE__)
+static void
+find_executable_path (void)
+{
+ int ret;
+ pid_t pid;
+ char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
+
+ pid = getpid ();
+ ret = proc_pidpath (pid, pathbuf, sizeof (pathbuf));
+ if (ret > 0)
+ _gst_executable_path = g_strdup (pathbuf);
+}
+#else
+static void
+find_executable_path (void)
+{
+ GST_FIXME ("Couldn't look up executable path, add support for this platform");
+}
+#endif
+
+
/**
* gst_init_check:
* @argc: (inout) (allow-none): pointer to application's argc
return TRUE;
}
+ find_executable_path ();
+
_priv_gst_start_time = gst_util_get_timestamp ();
#ifndef GST_DISABLE_GST_DEBUG
}
g_thread_pool_set_max_unused_threads (0);
bin_class = GST_BIN_CLASS (g_type_class_peek (gst_bin_get_type ()));
- if (bin_class->pool != NULL) {
+ if (bin_class && bin_class->pool != NULL) {
g_thread_pool_free (bin_class->pool, FALSE, TRUE);
bin_class->pool = NULL;
}
_priv_gst_plugin_paths = NULL;
#endif
+ if (_gst_executable_path) {
+ g_free (_gst_executable_path);
+ _gst_executable_path = NULL;
+ }
+
clock = gst_system_clock_obtain ();
gst_object_unref (clock);
gst_object_unref (clock);