src/stream-manager-dbus.c src/stream-manager-dbus-priv.h \
src/stream-manager-restriction.c src/stream-manager-restriction-priv.h \
src/stream-manager-filter.c src/stream-manager-volume-filter.h \
- src/device-manager.c src/device-manager.h src/tizen-device.c src/tizen-device.h src/tizen-device-def.c src/tizen-device-def.h \
+ src/device-manager.c src/device-manager.h src/device-manager-priv.h \
+ src/device-manager-db.c src/device-manager-db-priv.h \
+ src/tizen-device.c src/tizen-device.h src/tizen-device-def.c src/tizen-device-def.h \
src/subscribe-observer.c src/subscribe-observer.h
module_tizenaudio_policy_la_LDFLAGS = $(MODULE_LDFLAGS) -L$(pulsemodlibexecdir)
module_tizenaudio_policy_la_LIBADD = $(MODULE_LIBADD) $(DBUS_LIBS) $(VCONF_LIBS) $(INIPARSER_LIBS) $(LIBJSON_LIBS) libhal-interface.la libcommunicator.la
Name: pulseaudio-modules-tizen
Summary: Pulseaudio modules for Tizen
-Version: 11.1.16
+Version: 11.1.17
Release: 0
Group: Multimedia/Audio
License: LGPL-2.1+
--- /dev/null
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2018 Sangchul Lee <sc11.lee@samsung.com>
+
+ 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.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio 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 GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifndef foodevicemanagerdbprivfoo
+#define foodevicemanagerdbprivfoo
+
+#include "device-manager.h"
+
+typedef struct _prefer_entry {
+ bool avoid_resampling;
+ pa_sample_format_t format;
+ uint32_t rate;
+} prefer_entry;
+
+int32_t init_database(pa_device_manager *dm);
+int32_t write_prefer_entry(pa_device_manager *dm, const char *key, prefer_entry *e);
+prefer_entry *read_prefer_entry(pa_device_manager *dm, const char *key); /* prefer_entry should be freed by using pa_xfree() */
+void deinit_database(pa_device_manager *dm);
+
+#endif
--- /dev/null
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2018 Sangchul Lee <sc11.lee@samsung.com>
+
+ 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.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio 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 GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <errno.h>
+#include <pulsecore/core-error.h>
+#include <pulsecore/core-util.h>
+#include "device-manager-priv.h"
+#include "device-manager-db-priv.h"
+
+static void dump_prefer_entry(prefer_entry *e) {
+ pa_assert(e);
+
+ pa_log_info("device preference 'avoid-resampling(%d), format(%s), rate(%d)'",
+ e->avoid_resampling, pa_sample_format_to_string(e->format), e->rate);
+}
+
+int32_t init_database(pa_device_manager *dm) {
+ char *db_path;
+
+ pa_assert(dm);
+
+ if (!(db_path = pa_state_path("device-preferences", true))) {
+ pa_log_error("failed to get path for database");
+ return -1;
+ }
+
+ if (!(dm->database = pa_database_open(db_path, true))) {
+ pa_log_error("failed to open database '%s': %s", db_path, pa_cstrerror(errno));
+ pa_xfree(db_path);
+ return -1;
+ }
+ pa_log_info("database file '%s'", db_path);
+
+ pa_xfree(db_path);
+
+ return 0;
+}
+
+int32_t write_prefer_entry(pa_device_manager *dm, const char *key, prefer_entry *e) {
+ pa_tagstruct *t;
+ pa_datum db_key;
+ pa_datum db_data;
+ int ret;
+
+ pa_assert(dm);
+ pa_assert(dm->database);
+ pa_assert(key);
+ pa_assert(e);
+
+ t = pa_tagstruct_new();
+ pa_tagstruct_put(t,
+ PA_TAG_BOOLEAN, e->avoid_resampling,
+ PA_TAG_U8, e->format,
+ PA_TAG_U32, e->rate,
+ PA_TAG_INVALID);
+
+ db_key.data = (char*)key;
+ db_key.size = strlen(key);
+
+ db_data.data = (void *)pa_tagstruct_data(t, &db_data.size);
+
+ if ((ret = pa_database_set(dm->database, &db_key, &db_data, true))) {
+ pa_log_error("failed to write preference to db");
+ } else {
+ dump_prefer_entry(e);
+ pa_database_sync(dm->database);
+ pa_log_info("write sync successfully");
+ }
+
+ pa_tagstruct_free(t);
+
+ return ret;
+}
+
+prefer_entry* read_prefer_entry(pa_device_manager *dm, const char *key) {
+ pa_tagstruct *t;
+ prefer_entry *e;
+ pa_datum db_key;
+ pa_datum db_data;
+
+ pa_assert(dm);
+ pa_assert(dm->database);
+ pa_assert(key);
+
+ pa_zero(db_data);
+
+ db_key.data = (char*)key;
+ db_key.size = strlen(key);
+
+ if (!pa_database_get(dm->database, &db_key, &db_data)) {
+ pa_log_error("failed to get data with key %s", key);
+ return NULL;
+ }
+
+ t = pa_tagstruct_new_fixed(db_data.data, db_data.size);
+
+ e = pa_xnew0(prefer_entry, 1);
+
+ if (pa_tagstruct_get(t,
+ PA_TAG_BOOLEAN, &e->avoid_resampling,
+ PA_TAG_U8, &e->format,
+ PA_TAG_U32, &e->rate,
+ PA_TAG_INVALID)) {
+ pa_log_error("failed to get preference values from tagstruct");
+ pa_xfree(e);
+ }
+
+ pa_tagstruct_free(t);
+ pa_datum_free(&db_data);
+
+ dump_prefer_entry(e);
+
+ return e;
+}
+
+void deinit_database(pa_device_manager *dm) {
+ pa_assert(dm);
+
+ if (dm->database)
+ pa_database_close(dm->database);
+}
--- /dev/null
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2018 Sangchul Lee <sc11.lee@samsung.com>
+
+ 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.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio 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 GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifndef foodevicemanagerprivfoo
+#define foodevicemanagerprivfoo
+
+#ifdef HAVE_DBUS
+#include <pulsecore/dbus-shared.h>
+#include <pulsecore/dbus-util.h>
+#include <pulsecore/protocol-dbus.h>
+#endif
+#include <pulsecore/hashmap.h>
+#include <pulsecore/idxset.h>
+#include <pulsecore/database.h>
+#include "communicator.h"
+#include "hal-interface.h"
+
+/*
+ Structure to save parsed information about device-file.
+*/
+struct device_file_map
+{
+ /* { key:device_string -> value:device_file_prop } */
+ pa_idxset *playback;
+ pa_idxset *capture;
+};
+
+struct pa_device_manager {
+ PA_REFCNT_DECLARE;
+
+ pa_core *core;
+ pa_hook_slot *sink_put_hook_slot, *sink_unlink_hook_slot, *sink_state_changed_slot;
+ pa_hook_slot *source_put_hook_slot, *source_unlink_hook_slot, *source_state_changed_slot;
+ pa_hook_slot *comm_hook_device_connection_changed_slot;
+ pa_hook_slot *comm_hook_device_state_changed_slot;
+ pa_hook_slot *comm_hook_device_running_changed_slot;
+ pa_communicator *comm;
+ pa_hal_interface *hal_interface;
+
+ /*
+ Idxset for save parsed information about device-type.
+ { device_type_info }
+ */
+ pa_idxset *type_infos;
+ /* For save Parsed information about device-file */
+ struct device_file_map *file_map;
+
+ /* device list */
+ pa_idxset *device_list;
+ /*
+ Hashmap for save statuses got through dbus.
+ { key:device_type -> value:(audio_detected_type_t or device_detected_t) }
+ */
+ pa_idxset *device_status;
+ pa_dbus_connection *dbus_conn;
+
+ /* database for device preferences */
+ pa_database *database;
+};
+
+#endif
#include <pulsecore/namereg.h>
#include <pulsecore/shared.h>
#include <pulsecore/dynarray.h>
-#include <pulsecore/hashmap.h>
#include <vconf.h>
#include <vconf-keys.h>
-#ifdef HAVE_DBUS
-#include <pulsecore/dbus-shared.h>
-#include <pulsecore/dbus-util.h>
-#include <pulsecore/protocol-dbus.h>
-#endif
-#include "communicator.h"
-#include "hal-interface.h"
#include "stream-manager.h"
#include "device-manager.h"
+#include "device-manager-priv.h"
+#include "device-manager-db-priv.h"
#define SHARED_DEVICE_MANAGER "tizen-device-manager"
DM_DEVICE_CHANGED_INFO_MAX
} dm_device_changed_info_t;
-
-/*
- Structure to save parsed information about device-file.
-*/
-struct device_file_map {
- /* { key:device_string -> value:device_file_prop } */
- pa_idxset *playback;
- pa_idxset *capture;
-};
-
/***************** structures for static information get from json *********/
/*
/* For save that this devie_type is activated or not on sink/source */
int status;
};
-/******************************************************************************/
-struct pa_device_manager {
- PA_REFCNT_DECLARE;
-
- pa_core *core;
- pa_hook_slot *sink_put_hook_slot, *sink_unlink_hook_slot, *sink_state_changed_slot;
- pa_hook_slot *source_put_hook_slot, *source_unlink_hook_slot, *source_state_changed_slot;
- pa_hook_slot *comm_hook_device_connection_changed_slot;
- pa_hook_slot *comm_hook_device_state_changed_slot;
- pa_hook_slot *comm_hook_device_running_changed_slot;
- pa_communicator *comm;
- pa_hal_interface *hal_interface;
- /*
- Idxset for save parsed information about device-type.
- { device_type_info }
- */
- pa_idxset *type_infos;
- /* For save Parsed information about device-file */
- struct device_file_map *file_map;
-
- /* device list */
- pa_idxset *device_list;
- /*
- Hashmap for save statuses got through dbus.
- { key:device_type -> value:(audio_detected_type_t or device_detected_t) }
- */
- pa_idxset *device_status;
- pa_dbus_connection *dbus_conn;
-};
+/******************************************************************************/
struct composite_type {
const char *type;
}
}
-static void dbus_init(pa_device_manager *dm) {
+static void init_dbus(pa_device_manager *dm) {
DBusError error;
pa_dbus_connection *connection = NULL;
pa_assert(dm);
- pa_log_info("Dbus init");
+ pa_log_info("init Dbus");
dbus_error_init(&error);
if (!(connection = pa_dbus_bus_get(dm->core, DBUS_BUS_SYSTEM, &error)) || dbus_error_is_set(&error)) {
dbus_error_free(&error);
}
-static void dbus_deinit(pa_device_manager *dm) {
+static void deinit_dbus(pa_device_manager *dm) {
pa_assert(dm);
- pa_log_info("Dbus deinit");
+ pa_log_info("deinit Dbus");
endpoint_done(dm);
unwatch_signals(dm);
dm->device_list = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
dm->device_status = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
- dbus_init(dm);
+ init_dbus(dm);
dm->sink_put_hook_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE+10, (pa_hook_cb_t) sink_put_hook_callback, dm);
dm->sink_unlink_hook_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_EARLY, (pa_hook_cb_t) sink_unlink_hook_callback, dm);
if (dm->device_status)
pa_idxset_free(dm->device_status, NULL);
- dbus_deinit(dm);
+ deinit_dbus(dm);
if (dm->core)
pa_shared_remove(dm->core, SHARED_DEVICE_MANAGER);