daemon: handle rename of apps that have non-unique names
This commit is contained in:
parent
bbfd70e66d
commit
ac1de1cc6a
|
@ -58,7 +58,7 @@ struct ladish_app_supervisor
|
|||
uint64_t next_id;
|
||||
struct list_head applist;
|
||||
void * on_app_renamed_context;
|
||||
void (* on_app_renamed)(void * context, const char * old_name, const char * new_app_name);
|
||||
ladish_app_supervisor_on_app_renamed_callback on_app_renamed;
|
||||
};
|
||||
|
||||
bool
|
||||
|
@ -67,7 +67,7 @@ ladish_app_supervisor_create(
|
|||
const char * opath,
|
||||
const char * name,
|
||||
void * context,
|
||||
void (* on_app_renamed)(void * context, const char * old_name, const char * new_app_name))
|
||||
ladish_app_supervisor_on_app_renamed_callback on_app_renamed)
|
||||
{
|
||||
struct ladish_app_supervisor * supervisor_ptr;
|
||||
|
||||
|
@ -925,7 +925,7 @@ static void set_app_properties(struct dbus_method_call * call_ptr)
|
|||
|
||||
if (name_buffer != NULL)
|
||||
{
|
||||
supervisor_ptr->on_app_renamed(supervisor_ptr->on_app_renamed_context, app_ptr->name, name_buffer);
|
||||
supervisor_ptr->on_app_renamed(supervisor_ptr->on_app_renamed_context, app_ptr->uuid, app_ptr->name, name_buffer);
|
||||
free(app_ptr->name);
|
||||
app_ptr->name = name_buffer;
|
||||
}
|
||||
|
|
|
@ -51,11 +51,13 @@ typedef struct ladish_app_tag { int unused; /**< fake */ } * ladish_app_handle;
|
|||
* Type of function that is called when app is renamed
|
||||
*
|
||||
* @param[in] context User defined context that was supplied to ladish_app_supervisor_create()
|
||||
* @param[in] uuid uuid of the app
|
||||
* @param[in] old_name Old name of the app
|
||||
* @param[in] new_name New name of the app
|
||||
*/
|
||||
typedef void (* ladish_app_supervisor_on_app_renamed_callback)(
|
||||
void * context,
|
||||
const uuid_t uuid,
|
||||
const char * old_name,
|
||||
const char * new_app_name);
|
||||
|
||||
|
|
|
@ -35,9 +35,6 @@
|
|||
|
||||
extern const struct dbus_interface_descriptor g_interface_room;
|
||||
|
||||
/* implemented in studio.c */
|
||||
void ladish_on_app_renamed(void * context, const char * old_name, const char * new_app_name);
|
||||
|
||||
static bool port_is_input(uint32_t flags)
|
||||
{
|
||||
bool playback;
|
||||
|
@ -302,7 +299,7 @@ ladish_room_create(
|
|||
uuid_clear(room_ptr->template_uuid);
|
||||
}
|
||||
|
||||
if (!ladish_app_supervisor_create(&room_ptr->app_supervisor, object_path, room_ptr->name, room_ptr->graph, ladish_on_app_renamed))
|
||||
if (!ladish_app_supervisor_create(&room_ptr->app_supervisor, object_path, room_ptr->name, room_ptr->graph, ladish_virtualizer_rename_app))
|
||||
{
|
||||
log_error("ladish_app_supervisor_create() failed.");
|
||||
goto destroy;
|
||||
|
|
|
@ -509,23 +509,6 @@ static void ladish_studio_on_jack_server_disappeared(void)
|
|||
ladish_environment_reset(&g_studio.env_store, ladish_environment_jack_server_present);
|
||||
}
|
||||
|
||||
void ladish_on_app_renamed(void * context, const char * old_name, const char * new_app_name)
|
||||
{
|
||||
ladish_client_handle client;
|
||||
|
||||
client = ladish_graph_find_client_by_name(g_studio.jack_graph, old_name, false);
|
||||
if (client != NULL)
|
||||
{
|
||||
ladish_graph_rename_client(g_studio.jack_graph, client, new_app_name);
|
||||
}
|
||||
|
||||
client = ladish_graph_find_client_by_name(context, old_name, false);
|
||||
if (client != NULL)
|
||||
{
|
||||
ladish_graph_rename_client(context, client, new_app_name);
|
||||
}
|
||||
}
|
||||
|
||||
bool ladish_studio_init(void)
|
||||
{
|
||||
log_info("studio object construct");
|
||||
|
@ -574,7 +557,7 @@ bool ladish_studio_init(void)
|
|||
goto jack_graph_destroy;
|
||||
}
|
||||
|
||||
if (!ladish_app_supervisor_create(&g_studio.app_supervisor, STUDIO_OBJECT_PATH, "studio", g_studio.studio_graph, ladish_on_app_renamed))
|
||||
if (!ladish_app_supervisor_create(&g_studio.app_supervisor, STUDIO_OBJECT_PATH, "studio", g_studio.studio_graph, ladish_virtualizer_rename_app))
|
||||
{
|
||||
log_error("ladish_app_supervisor_create() failed.");
|
||||
goto studio_graph_destroy;
|
||||
|
|
|
@ -1230,3 +1230,27 @@ ladish_virtualizer_destroy(
|
|||
}
|
||||
|
||||
#undef virtualizer_ptr
|
||||
|
||||
#define vgraph ((ladish_graph_handle)vgraph_context)
|
||||
void
|
||||
ladish_virtualizer_rename_app(
|
||||
void * vgraph_context,
|
||||
const uuid_t uuid,
|
||||
const char * old_name,
|
||||
const char * new_app_name)
|
||||
{
|
||||
ladish_client_handle client;
|
||||
|
||||
client = ladish_graph_find_client_by_app(vgraph, uuid);
|
||||
if (client != NULL)
|
||||
{
|
||||
ladish_graph_rename_client(vgraph, client, new_app_name);
|
||||
}
|
||||
|
||||
client = ladish_graph_find_client_by_app(g_studio.jack_graph, uuid);
|
||||
if (client != NULL)
|
||||
{
|
||||
ladish_graph_rename_client(g_studio.jack_graph, client, new_app_name);
|
||||
}
|
||||
}
|
||||
#undef vgraph
|
||||
|
|
|
@ -60,7 +60,12 @@ ladish_virtualizer_remove_app(
|
|||
const uuid_t app_uuid,
|
||||
const char * app_name);
|
||||
|
||||
void ladish_virtualizer_rename_app(void * context, const char * old_name, const char * new_app_name);
|
||||
void
|
||||
ladish_virtualizer_rename_app(
|
||||
void * vgraph_context,
|
||||
const uuid_t uuid,
|
||||
const char * old_name,
|
||||
const char * new_app_name);
|
||||
|
||||
void
|
||||
ladish_virtualizer_destroy(
|
||||
|
|
Loading…
Reference in New Issue