1. avoid pollution of /tmp directory by storing focus runtime files to dedicated sub-directory
2. makes easy migration(e.g. mounting host directory) for container support
[Version] 0.13.15
[Issue] Cleanup
Change-Id: Idf5dacb8bd75c14d9f5a8d47f3c0559eeb5a24c4
#include <mm_debug.h>
#include <poll.h>
#include <fcntl.h>
+#include <string.h>
#include "include/mm_sound_mgr_focus_dbus.h"
#include "../include/mm_sound_utils.h"
gchar* path2 = NULL;
if (is_watch)
- path = g_strdup_printf("/tmp/FOCUS.%d.%d.wch", instance_id, handle);
+ path = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d.wch", instance_id, handle);
else
- path = g_strdup_printf("/tmp/FOCUS.%d.%d", instance_id, handle);
+ path = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d", instance_id, handle);
if (postfix) {
path2 = g_strconcat(path, postfix, NULL);
return path;
}
-static void __clear_focus_pipe(focus_node_t *node)
+static void __remove_focus_pipe(focus_node_t *node, bool is_return)
{
- char *filename = NULL;
- char *filename2 = NULL;
+ g_autofree gchar *filename = NULL;
- debug_fenter();
+ g_assert(node);
- if (!node->is_for_watch) {
- filename = __get_focus_pipe_path(node->pid, node->handle_id, NULL, false);
- filename2 = __get_focus_pipe_path(node->pid, node->handle_id, "r", false);
- } else {
- filename = __get_focus_pipe_path(node->pid, node->handle_id, NULL, true);
- filename2 = __get_focus_pipe_path(node->pid, node->handle_id, "r", true);
- }
- if (filename) {
- if (remove(filename)) {
- char str_error[256];
- strerror_r(errno, str_error, sizeof(str_error));
- debug_error("remove() failure, filename(%s), err[%s]", filename, str_error);
- } else {
- debug_log("removed file(%s)", filename);
- }
- free(filename);
- }
- if (filename2) {
- if (remove(filename2)) {
- char str_error[256];
- strerror_r(errno, str_error, sizeof(str_error));
- debug_error("remove() failure, filename2(%s), err[%s]", filename2, str_error);
- } else {
- debug_log("removed file(%s)", filename2);
- }
- free(filename2);
+ filename = __get_focus_pipe_path(node->pid, node->handle_id, is_return ? "r" : NULL, node->is_for_watch);
+ g_assert(filename);
+
+ if (remove(filename)) {
+ char str_error[256];
+ strerror_r(errno, str_error, sizeof(str_error));
+ debug_error("remove() failure, filename(%s), err[%s]", filename, str_error);
+ return;
}
+ debug_log("focus-pipe(%s) removed", filename);
+}
+
+static void __clear_focus_pipe(focus_node_t *node)
+{
+ debug_fenter();
+
+ __remove_focus_pipe(node, false);
+ __remove_focus_pipe(node, true);
+
debug_fleave();
}
#define PA_READY "/tmp/.pa_ready"
#define SOUND_SERVER_READY "/tmp/.sound_server_ready"
#define FOCUS_SERVER_READY "/tmp/.focus_server_ready"
+#define FOCUS_PATH_PREFIX "/tmp/focus/FOCUS."
#define MM_SOUND_NAME_NUM 32
int rett = 0;
int tmpfd = -1;
unsigned int buf = 0;
- char *filename2 = g_strdup_printf("/tmp/FOCUS.%d.%dr", focus_handle->focus_pid, cb_data.handle);
+ char *filename2 = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%dr", focus_handle->focus_pid, cb_data.handle);
unlink_if_symbolic_link(filename2);
tmpfd = open(filename2, O_WRONLY | O_NONBLOCK);
int rett = 0;
int tmpfd = -1;
int buf = -1;
- char *filename2 = g_strdup_printf("/tmp/FOCUS.%d.%d.wchr", focus_handle->focus_pid, cb_data.handle);
+ char *filename2 = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d.wchr", focus_handle->focus_pid, cb_data.handle);
unlink_if_symbolic_link(filename2);
tmpfd = open(filename2, O_WRONLY | O_NONBLOCK);
}
if (is_for_watching) {
- filename = g_strdup_printf("/tmp/FOCUS.%d.%d.wch",
+ filename = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d.wch",
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
} else {
- filename = g_strdup_printf("/tmp/FOCUS.%d.%d",
+ filename = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d",
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
}
unlink_if_symbolic_link(filename);
pre_mask = umask(0);
if (mknod(filename, S_IFIFO|0666, 0))
- debug_error("mknod() failure, errno(%d)", errno);
+ debug_error("mknod(%s) failure, errno(%d)", filename, errno);
umask(pre_mask);
g_focus_sound_handle[index].focus_fd = open(filename, O_RDWR|O_NONBLOCK);
if (g_focus_sound_handle[index].focus_fd == -1) {
- debug_error("Open fail : index(%d), file open error(%d)", index, errno);
+ debug_error("Open fail : index(%d), file(%s) open error(%d)", index, filename, errno);
} else {
- debug_msg("Open success : index(%d), filename(%s), fd(%d)",
+ debug_msg("Open success : index(%d), file(%s), fd(%d)",
index, filename, g_focus_sound_handle[index].focus_fd);
}
g_free(filename);
filename = NULL;
if (is_for_watching) {
- filename = g_strdup_printf("/tmp/FOCUS.%d.%d.wchr",
+ filename = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d.wchr",
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
} else {
- filename = g_strdup_printf("/tmp/FOCUS.%d.%dr",
+ filename = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%dr",
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
}
pre_mask = umask(0);
if (mknod(filename, S_IFIFO | 0666, 0))
- debug_error("mknod() failure, errno(%d)", errno);
+ debug_error("mknod(%s) failure, errno(%d)", filename, errno);
umask(pre_mask);
g_free(filename);
filename = NULL;
}
if (is_for_watching) {
- filename = g_strdup_printf("/tmp/FOCUS.%d.%d.wch",
+ filename = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d.wch",
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
} else {
- filename = g_strdup_printf("/tmp/FOCUS.%d.%d",
+ filename = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d",
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
}
filename = NULL;
if (is_for_watching) {
- filename = g_strdup_printf("/tmp/FOCUS.%d.%d.wchr",
+ filename = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%d.wchr",
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
} else {
- filename = g_strdup_printf("/tmp/FOCUS.%d.%dr",
+ filename = g_strdup_printf(FOCUS_PATH_PREFIX"%d.%dr",
g_focus_sound_handle[index].focus_pid,
g_focus_sound_handle[index].handle);
}
--- /dev/null
+d /tmp/focus 0755 owner users - -
+t /tmp/focus - - - - security.SMACK64="User::App::Shared"
Name: libmm-sound
Summary: MMSound Package contains client lib and focus server binary
-Version: 0.13.14
+Version: 0.13.15
Release: 0
Group: System/Libraries
License: Apache-2.0
Source4: focus-server.service
Source5: focus-server.path
Source6: focus-server.conf
+Source7: focus.conf
Requires: security-config
%if "%{tizen_profile_name}" == "tv"
Source7: focus-server-tv.service
BuildRequires: pkgconfig(lwipc)
%endif
%if 0%{?gtests:1}
-BuildRequires: pkgconfig(gmock)
+BuildRequires: pkgconfig(gmock)
%endif
-BuildRequires: pkgconfig(alsa)
-BuildRequires: pkgconfig(speexdsp)
-BuildRequires: pkgconfig(dbus-1)
-BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(alsa)
+BuildRequires: pkgconfig(speexdsp)
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(libsystemd)
%description
MMSound package contains focus-server and client interfaces connected to audio system
cp %{SOURCE3} %{buildroot}/usr/share/dbus-1/system-services/org.tizen.AudioAec.service
%endif
+mkdir -p %{buildroot}%{_tmpfilesdir}
+install -m 0644 %SOURCE7 %{buildroot}%{_tmpfilesdir}/focus.conf
+
%post
/sbin/ldconfig
%{_unitdir}/audio-aec.service
%{_datadir}/dbus-1/system-services/org.tizen.AudioAec.service
%endif
+%{_tmpfilesdir}/focus.conf
%license LICENSE.APLv2
/etc/dbus-1/system.d/focus-server.conf