pkgconfig \
. \
server \
- testsuite
+ testsuite \
+ focus_server
lib_LTLIBRARIES = libmmfsound.la
server/plugin/wav/Makefile
server/plugin/ogg/Makefile
server/plugin/tone/Makefile
+focus_server/Makefile
pkgconfig/Makefile
pkgconfig/mm-sound.pc
pkgconfig/mm-keysound.pc
--- /dev/null
+bin_PROGRAMS = focus_server
+focus_server_SOURCES = mm_sound_mgr_focus_ipc.c \
+ mm_sound_mgr_focus_dbus.c \
+ mm_sound_focus_server.c \
+ mm_sound_mgr_focus.c
+
+focus_server_CFLAGS = -I$(srcdir)/../include \
+ -I$(srcdir)/include \
+ $(MMCOMMON_CFLAGS) \
+ $(MMLOGSVR_CFLAGS) \
+ -DMMF_LOG_OWNER=0x004 \
+ -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" \
+ -D__DEBUG_MODE__ -D__USE_LOGMANAGER__ \
+ $(GLIB2_CFLAGS) \
+ $(GIO_CFLAGS)
+
+focus_server_LDADD = $(MMLOGSVR_LIBS) \
+ -ldl -lrt \
+ $(MMCOMMON_LIBS) \
+ $(GLIB2_LIBS) \
+ $(GIO_LIBS) \
+ $(srcdir)/../libmmfsound.la \
+ $(srcdir)/../common/libmmfsoundcommon.la
+
+if USE_LWIPC
+focus_server_CFLAGS += $(LWIPC_CFLAGS) -DUSE_LWIPC
+focus_server_LDADD += $(LWIPC_LIBS)
+endif
+
+if USE_SECURITY
+focus_server_CFLAGS += $(SECURITY_CFLAGS) -DUSE_SECURITY
+focus_server_LDADD += $(SECURITY_LIBS)
+endif
+
+focus_server_DEPENDENCIES = $(srcdir)/../common/libmmfsoundcommon.la
+if !USE_PRELINK
+focus_server_CFLAGS += -fPIC -pie
+endif
} container_info_t;
#endif
-//int __mm_sound_mgr_ipc_create_focus_node(mm_ipc_msg_t *msg);
#ifdef SUPPORT_CONTAINER
int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type, bool is_for_session, const char* container_name, int container_pid);
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session, const char* container_name, int container_pid);
#else
int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type, bool is_for_session);
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session);
#endif
-//int __mm_sound_mgr_ipc_destroy_focus_node(mm_ipc_msg_t *msg);
-int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id);
int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, bool reacquisition);
-
int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info);
-
int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, const char* name );
-
int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name);
-//int __mm_sound_mgr_ipc_set_focus_watch_cb(mm_ipc_msg_t *msg);
-#ifdef SUPPORT_CONTAINER
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session, const char* container_name, int container_pid);
-#else
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session);
-#endif
-//int __mm_sound_mgr_ipc_unset_focus_watch_cb(mm_ipc_msg_t *msg);
int __mm_sound_mgr_focus_ipc_unwatch_focus(int pid, int handle_id);
-
+int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id);
int __mm_sound_mgr_focus_ipc_emergent_exit(int pid);
#endif /* __MM_SOUND_MGR_FOCUS_IPC_H__ */
--- /dev/null
+/*
+ * libmm-sound
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <getopt.h>
+
+#include <mm_debug.h>
+
+#include <fcntl.h>
+#include <semaphore.h>
+
+#include "../include/mm_sound_common.h"
+#include "include/mm_sound_mgr_focus.h"
+#include "include/mm_sound_mgr_focus_dbus.h"
+
+#define USE_SYSTEM_SERVER_PROCESS_MONITORING
+
+typedef struct {
+ int startserver;
+ int printlist;
+ int testmode;
+} server_arg;
+
+static int _get_option(int argc, char **argv, server_arg *arg);
+static int _usage(int argc, char **argv);
+
+static struct sigaction sigint_action; /* Backup pointer of SIGINT handler */
+static struct sigaction sigabrt_action; /* Backup pointer of SIGABRT signal handler */
+static struct sigaction sigsegv_action; /* Backup pointer of SIGSEGV fault signal handler */
+static struct sigaction sigterm_action; /* Backup pointer of SIGTERM signal handler */
+static struct sigaction sigsys_action; /* Backup pointer of SIGSYS signal handler */
+static void _exit_handler(int sig);
+
+GMainLoop *g_mainloop;
+
+static void _mainloop_run()
+{
+ g_mainloop = g_main_loop_new(NULL, TRUE);
+ if (g_mainloop == NULL) {
+ debug_error("g_main_loop_new() failed\n");
+ }
+
+ g_main_loop_run(g_mainloop);
+}
+
+static sem_t* _sem_create_n_wait()
+{
+ sem_t* sem = NULL;
+
+ if ((sem = sem_open("booting-sound", O_CREAT, 0660, 0)) == SEM_FAILED) {
+ debug_error("error creating sem : %d", errno);
+ return NULL;
+ }
+
+ debug_msg("returning sem [%p]", sem);
+ return sem;
+}
+
+static int _get_option(int argc, char **argv, server_arg *arg)
+{
+ int c;
+ static struct option long_options[] = {
+ {"start", 0, 0, 'S'},
+ {"help", 0, 0, 'H'},
+ {"testmode", 0, 0, 'T'},
+ {0, 0, 0, 0}
+ };
+ memset(arg, 0, sizeof(server_arg));
+
+ arg->testmode = 0;
+
+ while (1) {
+ int opt_idx = 0;
+
+ c = getopt_long (argc, argv, "SFLHRUP:Tiurd", long_options, &opt_idx);
+ if (c == -1)
+ break;
+ switch (c)
+ {
+ case 'S': /* Start daemon */
+ arg->startserver = 1;
+ break;
+ case 'T': /* Test mode */
+ arg->testmode = 1;
+ break;
+ case 'H': /* help msg */
+ default:
+ return _usage(argc, argv);
+ }
+ }
+ if (argc == 1)
+ return _usage(argc, argv);
+ return 0;
+}
+
+//__attribute__ ((destructor))
+static void _exit_handler(int sig)
+{
+ switch (sig) {
+ case SIGINT:
+ sigaction(SIGINT, &sigint_action, NULL);
+ debug_error("signal(SIGINT) error");
+ break;
+ case SIGABRT:
+ sigaction(SIGABRT, &sigabrt_action, NULL);
+ debug_error("signal(SIGABRT) error");
+ break;
+ case SIGSEGV:
+ sigaction(SIGSEGV, &sigsegv_action, NULL);
+ debug_error("signal(SIGSEGV) error");
+ break;
+ case SIGTERM:
+ sigaction(SIGTERM, &sigterm_action, NULL);
+ debug_error("signal(SIGTERM) error");
+ break;
+ case SIGSYS:
+ sigaction(SIGSYS, &sigsys_action, NULL);
+ debug_error("signal(SIGSYS) error");
+ break;
+ default:
+ break;
+ }
+ raise(sig);
+}
+
+static int _usage(int argc, char **argv)
+{
+ fprintf(stderr, "Usage: %s [Options]\n", argv[0]);
+ fprintf(stderr, "\t%-20s: start focus server.\n", "--start,-S");
+ fprintf(stderr, "\t%-20s: help message.\n", "--help,-H");
+
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ sem_t* sem = NULL;
+ server_arg serveropt;
+ struct sigaction action;
+#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
+ int pid;
+#endif
+#ifdef TIZEN_TV
+ int fd_ss_ready = -1;
+#endif
+
+ action.sa_handler = _exit_handler;
+ action.sa_flags = 0;
+ sigemptyset(&action.sa_mask);
+
+ if (_get_option(argc, argv, &serveropt))
+ return 1;
+
+ debug_warning("focus_server [%d] init \n", getpid());
+
+ if (serveropt.startserver) {
+ sem = _sem_create_n_wait();
+ }
+ /* Daemon process create */
+ if (!serveropt.testmode && serveropt.startserver) {
+#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
+ daemon(0,0); //chdir to ("/"), and close stdio
+#endif
+ }
+
+ /* focus Server Starts!!!*/
+ debug_warning("focus_server [%d] start \n", getpid());
+
+ signal(SIGPIPE, SIG_IGN); //ignore SIGPIPE
+
+#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
+ while (1) {
+ if ((pid = fork()) < 0) {
+ fprintf(stderr, "Sub Fork Error\n");
+ return 2;
+ } else if (pid == 0) {
+ break;
+ } else if (pid > 0) {
+ wait(&ret);
+ fprintf(stderr, "Killed by signal [%05X]\n", ret);
+ fprintf(stderr, "Daemon is run againg\n");
+ }
+ }
+#endif
+ sigaction(SIGABRT, &action, &sigabrt_action);
+ sigaction(SIGSEGV, &action, &sigsegv_action);
+ sigaction(SIGTERM, &action, &sigterm_action);
+ sigaction(SIGSYS, &action, &sigsys_action);
+
+ if (serveropt.startserver) {
+ MMSoundMgrFocusDbusInit();
+ MMSoundMgrFocusInit();
+ }
+
+ debug_warning("focus_server [%d] initialization complete...now, start running!!\n", getpid());
+
+ if (serveropt.startserver) {
+ unlink(PA_READY); // remove pa_ready file after focus-server init.
+
+ if (sem) {
+ if (sem_post(sem) == -1) {
+ debug_error("error sem post : %d", errno);
+ } else {
+ debug_msg("Ready to play booting sound!!!!");
+ }
+ }
+
+#ifdef TIZEN_TV
+ /* FIXME : This code is moved from sound_server temporally for TV migration
+ As other modules which has dependancy on this file is cleared,
+ this code will be removed */
+ /* broadcast if we're ready */
+#ifdef USE_LWIPC
+ if (LwipcEventDone(SOUND_SERVER_READY) < 0) {
+ debug_error("cannot create SOUND_SERVER_READY(sound_server_ready)");
+ } else {
+ debug_warning("SOUND_SERVER_READY(%s) event was created", SOUND_SERVER_READY);
+ }
+#else
+ if ((fd_ss_ready = creat(SOUND_SERVER_READY, 0644)) != -1) {
+ debug_warning("SOUND_SERVER_READY(%s) file was created", SOUND_SERVER_READY);
+ close(fd_ss_ready);
+ } else {
+ debug_error("cannot create SOUND_SERVER_READY(/tmp/.sound_server_ready)");
+ }
+#endif
+#endif
+
+ _mainloop_run();
+ }
+
+ debug_warning("focus_server [%d] terminating \n", getpid());
+
+ if (serveropt.startserver) {
+ MMSoundMgrFocusDbusFini();
+ MMSoundMgrFocusFini();
+ }
+
+ debug_warning("focus_server [%d] exit ----------------- END \n", getpid());
+
+ return 0;
+}
x = g_list_remove (x, node); \
g_free (node); \
} \
-} while(0)
+} while (0)
#define UPDATE_FOCUS_TAKEN_INFO(x_postfix, x_node, x_pid, x_hid, x_by_session) do { \
debug_msg("updating node[%p], taken_"#x_postfix"[%d] : pid = [%d], handle_id = [%d], is_for_session = [%d]", x_node, i, x_pid, x_hid, x_by_session); \
x_node->taken_##x_postfix[i].pid = x_pid; \
x_node->taken_##x_postfix[i].handle_id = x_hid; \
x_node->taken_##x_postfix[i].by_session = x_by_session; \
-} while(0)
+} while (0)
#ifdef SUPPORT_CONTAINER
static void __set_container_data(int pid, int handle, const char* container_name, int container_pid)
filename2 = __get_focus_pipe_path(node->pid, node->handle_id, "r", true);
}
if (filename) {
- if(remove(filename))
+ if (remove(filename))
debug_error("remove() failure, filename(%s), errno(%d)", filename, errno);
else
debug_log("removed file(%s)", filename);
free(filename);
}
if (filename2) {
- if(remove(filename2))
+ if (remove(filename2))
debug_error("remove() failure, filename2(%s), errno(%d)", filename2, errno);
else
debug_log("removed file(%s)", filename2);
} else {
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
if (node->taken_by_id[i].pid == param->pid) {
- if(my_node->taken_by_id[i].pid) {
+ if (my_node->taken_by_id[i].pid) {
/* If exists update the taken focus info to my victim node */
if (node->taken_by_id[i].by_session && !node->status) {
UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id, my_node->taken_by_id[i].by_session);
}
/* Check if there's activating focus for session for the same PID of incomming param*/
- if(my_node->is_for_session) {
+ if (my_node->is_for_session) {
for (list = g_focus_node_list; list != NULL; list = list->next) {
node = (focus_node_t *)list->data;
if (!node) {
g_list_foreach (g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
list = g_focus_node_list;
- while(list) {
+ while (list) {
node = (focus_node_t *)list->data;
if (node && (node->pid == param->pid)) {
debug_log("found pid node");
- if(node->is_for_watch) {
+ if (node->is_for_watch) {
debug_log("clearing watch cb of pid(%d) handle(%d)", node->pid, node->handle_id);
__clear_focus_pipe(node);
g_focus_node_list = g_list_remove(g_focus_node_list, node);
connection = g_dbus_method_invocation_get_connection(invocation);
sender = g_dbus_method_invocation_get_sender(invocation);
- debug_error ("connection = %p, sender = %s", connection, sender);
+ debug_error("connection = %p, sender = %s", connection, sender);
- value = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
+ value = g_dbus_connection_call_sync(connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
"org.freedesktop.DBus", "GetConnectionUnixProcessID",
g_variant_new("(s)", sender, NULL), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
if (value) {
g_variant_get(value, "(u)", &pid);
- debug_error ("Sender PID = [%d]", pid);
+ debug_error("Sender PID = [%d]", pid);
} else {
- debug_error ("err code = %d, err msg = %s", err->code, err->message);
+ debug_error("err code = %d, err msg = %s", err->code, err->message);
}
return pid;
}
debug_fleave();
}
-static void handle_method_unwatch_focus (GDBusMethodInvocation* invocation)
+static void handle_method_unwatch_focus(GDBusMethodInvocation* invocation)
{
int ret = MM_ERROR_NONE;
int pid = 0;
debug_log("Own name (%s) for focus-server", wellknown_name);
- oid = g_bus_own_name(bus_type, wellknown_name , G_BUS_NAME_OWNER_FLAGS_NONE,
+ oid = g_bus_own_name(bus_type, wellknown_name, G_BUS_NAME_OWNER_FLAGS_NONE,
on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
if (oid <= 0) {
debug_error("Dbus own name failed");
*owner_id = oid;
}
+ debug_log("OwnerID (%d) for focus-server", *owner_id);
+
return MM_ERROR_NONE;
}
static void _mm_sound_mgr_focus_dbus_unown_name(guint oid)
{
- debug_log("Unown name for focus-server");
+ debug_log("Unown name for focus-server [%d]", oid);
if (oid > 0) {
g_bus_unown_name(oid);
}
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
LOGE("g_bus_get_sync() error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
return ret;
}
- result = g_dbus_connection_call_sync (conn,
+ result = g_dbus_connection_call_sync(conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
i = 0;
g_variant_iter_init(&iter, item);
while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "&s", &name)) {
- debug_log ("name : %s", name);
+ debug_log("name : %s", name);
stream_list->stream_types[i++] = strdup(name);
}
- g_variant_unref (item);
- g_variant_unref (child);
+ g_variant_unref(item);
+ g_variant_unref(child);
child = g_variant_get_child_value(result, 1);
item = g_variant_get_variant(child);
i = 0;
g_variant_iter_init(&iter, item);
while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "i", &priority)) {
- debug_log ("priority : %d", priority);
+ debug_log("priority : %d", priority);
stream_list->priorities[i++] = priority;
}
- g_variant_unref (item);
- g_variant_unref (child);
+ g_variant_unref(item);
+ g_variant_unref(child);
g_variant_unref(result);
}
return MM_ERROR_SOUND_INTERNAL;
if (_mm_sound_mgr_focus_dbus_own_name(G_BUS_TYPE_SYSTEM, BUS_NAME_FOCUS_SERVER, &focus_server_owner_id) != MM_ERROR_NONE) {
- debug_error ("dbus own name for focus-server error\n");
+ debug_error("dbus own name for focus-server error\n");
return MM_ERROR_SOUND_INTERNAL;
}
if (mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_EMERGENT_EXIT, emergent_exit_signal_handler, NULL, NULL, &emergent_exit_subs_id) != MM_ERROR_NONE) {
- debug_error ("dbus signal subscribe for emergent exit error\n");
+ debug_error("dbus signal subscribe for emergent exit error\n");
return MM_ERROR_SOUND_INTERNAL;
}
if (emergent_exit_subs_id != 0)
mm_sound_dbus_signal_unsubscribe(emergent_exit_subs_id);
_mm_sound_mgr_focus_dbus_unown_name(focus_server_owner_id);
- g_dbus_node_info_unref (introspection_data);
+ g_dbus_node_info_unref(introspection_data);
debug_leave();
}
[Unit]
-Description=Start the sound profile service
+Description=Start the focus profile service
DefaultDependencies=false
After=factory-init.service pulseaudio.service
--- /dev/null
+[Unit]
+Description=Path activation for the "focus-server" programme
+
+[Path]
+PathExists=/tmp/.pa_ready
[Unit]
-Description=Start the sound profile service
+Description=Start the focus profile service
[Service]
ExecStart=/usr/bin/focus_server -S
Group: System/Libraries
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-Source1: sound-server.service
-Source2: sound-server.path
-Source3: focus-server.conf
-Source4: sound-server.conf
+Source3: sound-server.conf
+Source4: focus-server.service
+Source5: focus-server.path
+Source6: focus-server.conf
Requires: security-config
%if "%{?tizen_profile_name}" == "tv"
-Source7: sound-server-tv.service
+Source8: focus-server-tv.service
%endif
+Source9: org.tizen.SoundServer.service
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(mm-common)
cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
cp LICENSE.APLv2 %{buildroot}/usr/share/license/libmm-sound-tool
mkdir -p %{buildroot}/etc/dbus-1/system.d/
-cp %{SOURCE3} %{buildroot}/etc/dbus-1/system.d/focus-server.conf
-cp %{SOURCE4} %{buildroot}/etc/dbus-1/system.d/sound-server.conf
+cp %{SOURCE3} %{buildroot}/etc/dbus-1/system.d/sound-server.conf
+cp %{SOURCE6} %{buildroot}/etc/dbus-1/system.d/focus-server.conf
%if "%{?tizen_profile_name}" == "tv"
-cp %{SOURCE7} %{SOURCE1}
+cp %{SOURCE8} %{SOURCE4}
%endif
+mkdir -p %{buildroot}/usr/share/dbus-1/system-services/
+cp %{SOURCE9} %{buildroot}/usr/share/dbus-1/system-services/org.tizen.SoundServer.service
%make_install
%if "%{?tizen_profile_name}" == "tv"
%else
install -d %{buildroot}%{_unitdir}/multi-user.target.wants
%endif
-install -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/
-install -m0644 %{SOURCE2} %{buildroot}%{_unitdir}/
+install -m0644 %{SOURCE4} %{buildroot}%{_unitdir}/
+install -m0644 %{SOURCE5} %{buildroot}%{_unitdir}/
%if "%{?tizen_profile_name}" == "tv"
-ln -sf ../sound-server.path %{buildroot}%{_unitdir}/sysinit.target.wants/sound-server.path
+ln -sf ../focus-server.path %{buildroot}%{_unitdir}/sysinit.target.wants/focus-server.path
%else
-ln -sf ../sound-server.path %{buildroot}%{_unitdir}/multi-user.target.wants/sound-server.path
+ln -sf ../focus-server.path %{buildroot}%{_unitdir}/multi-user.target.wants/focus-server.path
%endif
%post
/sbin/ldconfig
%manifest libmm-sound.manifest
%defattr(-,root,root,-)
%caps(cap_chown,cap_dac_override,cap_fowner,cap_lease=eip) %{_bindir}/focus_server
+%caps(cap_chown,cap_dac_override,cap_fowner,cap_lease=eip) %{_bindir}/sound_server
%{_libdir}/libmmfsound.so.*
%{_libdir}/libmmfsoundcommon.so.*
%{_libdir}/libmmfkeysound.so.*
%{_libdir}/soundplugins/libsoundplugintremoloogg.so
%endif
%if "%{?tizen_profile_name}" == "tv"
-%{_unitdir}/sysinit.target.wants/sound-server.path
+%{_unitdir}/sysinit.target.wants/focus-server.path
%else
-%{_unitdir}/multi-user.target.wants/sound-server.path
+%{_unitdir}/multi-user.target.wants/focus-server.path
%endif
-%{_unitdir}/sound-server.service
-%{_unitdir}/sound-server.path
+%{_unitdir}/focus-server.service
+%{_unitdir}/focus-server.path
+/usr/share/sounds/sound-server/*
%{_datadir}/license/%{name}
%{_datadir}/license/libmm-sound-tool
-/usr/share/sounds/sound-server/*
-/etc/dbus-1/system.d/focus-server.conf
/etc/dbus-1/system.d/sound-server.conf
+/etc/dbus-1/system.d/focus-server.conf
+%{_datadir}/dbus-1/system-services/org.tizen.SoundServer.service
%files devel
%defattr(-,root,root,-)
--- /dev/null
+[D-BUS Service]
+Name=org.tizen.SoundServer
+Exec=/usr/bin/sound_server -S
+User=multimedia_fw
+Group=multimedia_fw
+++ /dev/null
-[Unit]
-Description=Path activation for the "sound-server" programme
-
-[Path]
-PathExists=/tmp/.pa_ready
SUBDIRS = plugin
-bin_PROGRAMS = focus_server
-focus_server_SOURCES = mm_sound_mgr_codec.c \
+bin_PROGRAMS = sound_server
+sound_server_SOURCES = mm_sound_mgr_codec.c \
mm_sound_mgr_ipc.c \
mm_sound_mgr_ipc_dbus.c \
mm_sound_mgr_run.c \
- mm_sound_mgr_focus.c \
- mm_sound_mgr_focus_dbus.c \
- mm_sound_mgr_focus_ipc.c \
mm_sound_plugin.c \
mm_sound_server.c \
mm_sound_thread_pool.c
-focus_server_CFLAGS = -I$(srcdir)/../include \
+sound_server_CFLAGS = -I$(srcdir)/../include \
-I$(srcdir)/include \
$(MMCOMMON_CFLAGS) \
$(MMLOGSVR_CFLAGS) \
-DMMF_LOG_OWNER=0x002 \
-DMMF_DEBUG_PREFIX=\"MMF-SOUND\" \
- -D__DEBUG_MODE__ -DUSE_VCONF -D__USE_LOGMANAGER__ \
+ -D__DEBUG_MODE__ -D__USE_LOGMANAGER__ \
$(MMSESSION_CFLAGS) \
- $(AUDIOSESSIONMGR_CFLAGS) \
- $(VCONF_CFLAGS) \
$(GLIB2_CFLAGS) \
$(GIO_CFLAGS)
-focus_server_LDADD = $(MMLOGSVR_LIBS) \
+sound_server_LDADD = $(MMLOGSVR_LIBS) \
-ldl -lrt \
$(MMCOMMON_LIBS) \
$(MMSESSION_LIBS) \
- $(AUDIOSESSIONMGR_LIBS) \
$(GLIB2_LIBS) \
$(GIO_LIBS) \
- $(VCONF_LIBS) \
$(srcdir)/../libmmfsound.la \
$(srcdir)/../common/libmmfsoundcommon.la
if USE_PULSE
-focus_server_CFLAGS += -DPULSE_CLIENT $(PA_CFLAGS) $(PASIMPLE_CFLAGS)
-focus_server_LDADD += $(PA_LIBS) $(PASIMPLE_CFLAGS)
-endif
-
-if USE_LWIPC
-focus_server_CFLAGS += $(LWIPC_CFLAGS) -DUSE_LWIPC
-focus_server_LDADD += $(LWIPC_LIBS)
+sound_server_CFLAGS += -DPULSE_CLIENT $(PA_CFLAGS) $(PASIMPLE_CFLAGS)
+sound_server_LDADD += $(PA_LIBS) $(PASIMPLE_CFLAGS)
endif
if USE_SECURITY
-focus_server_CFLAGS += $(SECURITY_CFLAGS) -DUSE_SECURITY
-focus_server_LDADD += $(SECURITY_LIBS)
+sound_server_CFLAGS += $(SECURITY_CFLAGS) -DUSE_SECURITY
+sound_server_LDADD += $(SECURITY_LIBS)
endif
-focus_server_DEPENDENCIES = $(srcdir)/../common/libmmfsoundcommon.la
+sound_server_DEPENDENCIES = $(srcdir)/../common/libmmfsoundcommon.la
if !USE_PRELINK
-focus_server_CFLAGS += -fPIC -pie
+sound_server_CFLAGS += -fPIC -pie
endif
installsounddir = $(prefix)/share/sounds/sound-server
installsound_DATA = sounds/Tizen_HW_Touch.ogg
*
*/
-#ifndef __MM_SOUND_THREAd_POOL_H__
-#define __MM_SOUND_THREAd_POOL_H__
+#ifndef __MM_SOUND_THREAD_POOL_H__
+#define __MM_SOUND_THREAD_POOL_H__
+
+#include <glib.h>
int MMSoundThreadPoolDump(int fulldump);
int MMSoundThreadPoolInit(void);
+gboolean IsMMSoundThreadPoolRunning(void);
int MMSoundThreadPoolRun(void *param, void (*func)(void*));
int MMSoundThreadPoolFini(void);
-#endif /* __MM_SOUND_THREAd_POOL_H__ */
+#endif /* __MM_SOUND_THREAD_POOL_H__ */
connection = g_dbus_method_invocation_get_connection(invocation);
sender = g_dbus_method_invocation_get_sender(invocation);
- debug_error ("connection = %p, sender = %s", connection, sender);
+ debug_error("connection = %p, sender = %s", connection, sender);
- value = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
+ value = g_dbus_connection_call_sync(connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
"org.freedesktop.DBus", "GetConnectionUnixProcessID",
g_variant_new("(s)", sender, NULL), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
if (value) {
g_variant_get(value, "(u)", &pid);
- debug_error ("Sender PID = [%d]", pid);
+ debug_msg("Sender PID = [%d]", pid);
} else {
- debug_error ("err code = %d, err msg = %s", err->code, err->message);
+ debug_error("err code = %d, err msg = %s", err->code, err->message);
}
return pid;
}
{
const char *method_name;
method_name = g_dbus_method_invocation_get_method_name(invocation);
- debug_error("Method Call '%s' success", method_name);
+ debug_msg("Method Call '%s' success", method_name);
g_dbus_method_invocation_return_value(invocation, params);
}
static void _method_call_return_error(GDBusMethodInvocation *invocation, int ret)
debug_log("Own name (%s) for sound-server", wellknown_name);
- oid = g_bus_own_name(bus_type, wellknown_name , G_BUS_NAME_OWNER_FLAGS_NONE,
+ oid = g_bus_own_name(bus_type, wellknown_name, G_BUS_NAME_OWNER_FLAGS_NONE,
on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
if (oid <= 0) {
debug_error("Dbus own name failed");
*owner_id = oid;
}
+ debug_log("OwnerID (%d) for sound-server", *owner_id);
+
return MM_ERROR_NONE;
}
static void _mm_sound_mgr_dbus_unown_name(guint oid)
{
- debug_log("Unown name for Sound-Server");
+ debug_log("Unown name for Sound-Server [%d]", oid);
if (oid > 0) {
g_bus_unown_name(oid);
}
}
-int __mm_sound_mgr_ipc_dbus_notify_device_connected (mm_sound_device_t *device, gboolean is_connected)
+int __mm_sound_mgr_ipc_dbus_notify_device_connected(mm_sound_device_t *device, gboolean is_connected)
{
int ret = MM_ERROR_NONE;
GVariantBuilder builder;
return ret;
}
-int __mm_sound_mgr_ipc_dbus_notify_device_info_changed (mm_sound_device_t *device, int changed_device_info_type)
+int __mm_sound_mgr_ipc_dbus_notify_device_info_changed(mm_sound_device_t *device, int changed_device_info_type)
{
int ret = MM_ERROR_NONE;
GVariantBuilder builder;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
LOGE("g_bus_get_sync() error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
return ret;
}
- result = g_dbus_connection_call_sync (conn,
+ result = g_dbus_connection_call_sync(conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
i = 0;
g_variant_iter_init(&iter, item);
while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "&s", &name)) {
- debug_log ("name : %s", name);
+ debug_log("name : %s", name);
stream_list->stream_types[i++] = strdup(name);
}
- g_variant_unref (item);
- g_variant_unref (child);
+ g_variant_unref(item);
+ g_variant_unref(child);
child = g_variant_get_child_value(result, 1);
item = g_variant_get_variant(child);
i = 0;
g_variant_iter_init(&iter, item);
while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "i", &priority)) {
- debug_log ("priority : %d", priority);
+ debug_log("priority : %d", priority);
stream_list->priorities[i++] = priority;
}
- g_variant_unref (item);
- g_variant_unref (child);
+ g_variant_unref(item);
+ g_variant_unref(child);
g_variant_unref(result);
}
{
debug_enter();
- introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
- if (!introspection_data)
+ introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
+ if (!introspection_data) {
+ debug_error("g_dbus_node_info_new_for_xml() failed...");
return MM_ERROR_SOUND_INTERNAL;
+ }
if (_mm_sound_mgr_dbus_own_name(G_BUS_TYPE_SYSTEM, BUS_NAME_SOUND_SERVER, &sound_server_owner_id) != MM_ERROR_NONE) {
- debug_error ("dbus own name for sound-server error\n");
+ debug_error("dbus own name for sound-server error\n");
return MM_ERROR_SOUND_INTERNAL;
}
debug_enter("\n");
_mm_sound_mgr_dbus_unown_name(sound_server_owner_id);
- g_dbus_node_info_unref (introspection_data);
+ g_dbus_node_info_unref(introspection_data);
debug_leave("\n");
}
#include <unistd.h>
#include <getopt.h>
-#include <vconf.h>
#include <mm_error.h>
#include <mm_debug.h>
-#ifdef USE_LWIPC
-#include <lwipc.h>
-#endif
-
-#include <fcntl.h>
-#include <semaphore.h>
-
#include "../include/mm_sound_common.h"
#include "include/mm_sound_thread_pool.h"
#include "include/mm_sound_mgr_run.h"
#include "include/mm_sound_mgr_codec.h"
#include "include/mm_sound_mgr_ipc_dbus.h"
-#include "include/mm_sound_mgr_focus.h"
-#include "include/mm_sound_mgr_focus_dbus.h"
#include "../config.h" /* for PLUGIN_DIR */
#define PLUGIN_ENV "MM_SOUND_PLUGIN_PATH"
#define PLUGIN_MAX 30
#define MAX_PLUGIN_DIR_PATH_LEN 256
+#define SHUTDOWN_TIMEOUT_SEC 10
#define USE_SYSTEM_SERVER_PROCESS_MONITORING
int testmode;
} server_arg;
-static int getOption(int argc, char **argv, server_arg *arg);
+static int _get_option(int argc, char **argv, server_arg *arg);
static int _usage(int argc, char **argv);
static struct sigaction sigint_action; /* Backup pointer of SIGINT handler */
GMainLoop *g_mainloop;
-static void _mainloop_run()
-{
- g_mainloop = g_main_loop_new(NULL, TRUE);
- if (g_mainloop == NULL) {
- debug_error("g_main_loop_new() failed\n");
- }
- g_main_loop_run(g_mainloop);
-}
-
-static sem_t* sem_create_n_wait()
+static gboolean _shutdown_timer_cb(gpointer user_data)
{
- sem_t* sem = NULL;
-
- if ((sem = sem_open ("booting-sound", O_CREAT, 0660, 0))== SEM_FAILED) {
- debug_error ("error creating sem : %d", errno);
- return NULL;
+ if (!IsMMSoundThreadPoolRunning()) {
+ debug_warning("Thread pool is not running..quit mainloop now!");
+ g_main_loop_quit(g_mainloop);
+ return FALSE;
}
- debug_msg ("returning sem [%p]", sem);
- return sem;
+ debug_warning("still running......keep timer...");
+ return TRUE;
}
-int main(int argc, char **argv)
+static void _mainloop_run()
{
- sem_t* sem = NULL;
- server_arg serveropt;
- struct sigaction action;
-#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
- int pid;
-#endif
-
- action.sa_handler = _exit_handler;
- action.sa_flags = 0;
- sigemptyset(&action.sa_mask);
-
- if (getOption(argc, argv, &serveropt))
- return 1;
-
- debug_warning("sound_server [%d] init \n", getpid());
-
- if (serveropt.startserver) {
- sem = sem_create_n_wait();
- }
- /* Daemon process create */
- if (!serveropt.testmode && serveropt.startserver) {
-#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
- daemon(0,0); //chdir to ("/"), and close stdio
-#endif
- }
-
- /* Sound Server Starts!!!*/
- debug_warning("sound_server [%d] start \n", getpid());
-
- signal(SIGPIPE, SIG_IGN); //ignore SIGPIPE
-
-#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
- while(1)
- {
- if ((pid = fork()) < 0)
- {
- fprintf(stderr, "Sub Fork Error\n");
- return 2;
- }
- else if(pid == 0)
- {
- break;
- }
- else if(pid > 0)
- {
- wait(&ret);
- fprintf(stderr, "Killed by signal [%05X]\n", ret);
- fprintf(stderr, "Daemon is run againg\n");
- }
- }
-#endif
- sigaction(SIGABRT, &action, &sigabrt_action);
- sigaction(SIGSEGV, &action, &sigsegv_action);
- sigaction(SIGTERM, &action, &sigterm_action);
- sigaction(SIGSYS, &action, &sigsys_action);
-
- if (serveropt.startserver || serveropt.printlist) {
- MMSoundThreadPoolInit();
- MMSoundMgrRunInit(serveropt.plugdir);
- MMSoundMgrCodecInit(serveropt.plugdir);
- MMSoundMgrDbusInit();
- MMSoundMgrFocusDbusInit();
- MMSoundMgrFocusInit();
- }
-
- debug_warning("sound_server [%d] initialization complete...now, start running!!\n", getpid());
-
- if (serveropt.startserver) {
- /* Start Run types */
- MMSoundMgrRunRunAll();
-
- unlink(PA_READY); // remove pa_ready file after sound-server init.
-
- if (sem) {
- if (sem_post(sem) == -1) {
- debug_error ("error sem post : %d", errno);
- } else {
- debug_msg ("Ready to play booting sound!!!!");
- }
- }
-#ifdef TIZEN_TV
-#ifdef USE_LWIPC
- /* broadcast if we're ready */
- if (LwipcEventDone(SOUND_SERVER_READY) < 0) {
- debug_error("cannot create SOUND_SERVER_READY(sound_server_ready)");
- } else {
- debug_warning("SOUND_SERVER_READY(%s) event was created", SOUND_SERVER_READY);
- }
-#else
- if (creat(SOUND_SERVER_READY, 0644) != -1) {
- debug_warning("SOUND_SERVER_READY(%s) file was created", SOUND_SERVER_READY);
- } else {
- debug_error("cannot create SOUND_SERVER_READY(/tmp/.sound_server_ready)");
- }
-#endif
-#endif
- /* Start MainLoop */
- _mainloop_run();
- }
-
- debug_warning("sound_server [%d] terminating \n", getpid());
-
- if (serveropt.startserver || serveropt.printlist) {
- MMSoundMgrRunStopAll();
- MMSoundMgrDbusFini();
- MMSoundMgrCodecFini();
- MMSoundMgrRunFini();
- MMSoundThreadPoolFini();
+ g_mainloop = g_main_loop_new(NULL, TRUE);
+ if (g_mainloop == NULL) {
+ debug_error("g_main_loop_new() failed\n");
}
- debug_warning("sound_server [%d] exit ----------------- END \n", getpid());
+ g_timeout_add_seconds(SHUTDOWN_TIMEOUT_SEC, _shutdown_timer_cb, NULL);
- return 0;
+ g_main_loop_run(g_mainloop);
}
-static int getOption(int argc, char **argv, server_arg *arg)
+static int _get_option(int argc, char **argv, server_arg *arg)
{
int c;
char *plugin_env_dir = NULL;
memset(arg, 0, sizeof(server_arg));
plugin_env_dir = getenv(PLUGIN_ENV);
- if (plugin_env_dir) {
- MMSOUND_STRNCPY(arg->plugdir, plugin_env_dir, MAX_PLUGIN_DIR_PATH_LEN);
- } else {
- MMSOUND_STRNCPY(arg->plugdir, PLUGIN_DIR, MAX_PLUGIN_DIR_PATH_LEN);
- }
+ MMSOUND_STRNCPY(arg->plugdir, (plugin_env_dir? plugin_env_dir : PLUGIN_DIR), MAX_PLUGIN_DIR_PATH_LEN);
arg->testmode = 0;
- while (1)
- {
+ while (1) {
int opt_idx = 0;
- c = getopt_long (argc, argv, "SFLHRUP:Tiurd", long_options, &opt_idx);
+ c = getopt_long(argc, argv, "SFLHRUP:Tiurd", long_options, &opt_idx);
if (c == -1)
break;
- switch (c)
- {
+ switch (c) {
case 'S': /* Start daemon */
arg->startserver = 1;
break;
break;
case 'H': /* help msg */
default:
- return _usage(argc, argv);
+ return _usage(argc, argv);
}
}
if (argc == 1)
debug_log("All run-type plugin stopped\n");
}
- switch(sig)
- {
+ switch(sig) {
case SIGINT:
sigaction(SIGINT, &sigint_action, NULL);
debug_error("signal(SIGINT) error");
return 1;
}
+int main(int argc, char **argv)
+{
+ server_arg serveropt;
+ struct sigaction action;
+#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
+ int pid;
+#endif
+
+ action.sa_handler = _exit_handler;
+ action.sa_flags = 0;
+ sigemptyset(&action.sa_mask);
+
+ if (_get_option(argc, argv, &serveropt))
+ return 1;
+
+ debug_warning("sound_server [%d] init \n", getpid());
+
+ /* Daemon process create */
+ if (!serveropt.testmode && serveropt.startserver) {
+#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
+ daemon(0,0); //chdir to ("/"), and close stdio
+#endif
+ }
+
+ /* Sound Server Starts!!!*/
+ debug_warning("sound_server [%d] start \n", getpid());
+
+ signal(SIGPIPE, SIG_IGN); //ignore SIGPIPE
+
+#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
+ while (1) {
+ if ((pid = fork()) < 0) {
+ fprintf(stderr, "Sub Fork Error\n");
+ return 2;
+ } else if(pid == 0) {
+ break;
+ } else if(pid > 0) {
+ wait(&ret);
+ fprintf(stderr, "Killed by signal [%05X]\n", ret);
+ fprintf(stderr, "Daemon is run againg\n");
+ }
+ }
+#endif
+ sigaction(SIGABRT, &action, &sigabrt_action);
+ sigaction(SIGSEGV, &action, &sigsegv_action);
+ sigaction(SIGTERM, &action, &sigterm_action);
+ sigaction(SIGSYS, &action, &sigsys_action);
+
+ if (serveropt.startserver || serveropt.printlist) {
+ MMSoundThreadPoolInit();
+ MMSoundMgrRunInit(serveropt.plugdir);
+ MMSoundMgrCodecInit(serveropt.plugdir);
+ MMSoundMgrDbusInit();
+ }
+
+ debug_warning("sound_server [%d] initialization complete...now, start running!!\n", getpid());
+
+ if (serveropt.startserver) {
+ /* Start Run types */
+ MMSoundMgrRunRunAll();
+
+ /* Start MainLoop */
+ _mainloop_run();
+ }
+
+ debug_warning("sound_server [%d] terminating \n", getpid());
+
+ if (serveropt.startserver || serveropt.printlist) {
+ MMSoundMgrRunStopAll();
+ MMSoundMgrDbusFini();
+ MMSoundMgrCodecFini();
+ MMSoundMgrRunFini();
+ MMSoundThreadPoolFini();
+ }
+
+ debug_warning("sound_server [%d] exit ----------------- END \n", getpid());
+
+ return 0;
+}
#define MAX_UNUSED_THREADS_IN_THREADPOOL 10
+#define MIN_RUNNING_THREAD 0
+
typedef struct __THREAD_INFO
{
void (*func)(gpointer data);
return MM_ERROR_NONE;
}
+gboolean IsMMSoundThreadPoolRunning(void)
+{
+ MMSoundThreadPoolDump(FALSE);
+ return (g_thread_pool_get_num_threads(g_pool) > MIN_RUNNING_THREAD);
+}
+
int MMSoundThreadPoolInit()
{
int i=0;