From e34209e5df13b4f3dd228af857cf0d303b21db48 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 15 Aug 2004 00:03:01 +0000 Subject: Update to current polypaudio library git-svn-id: file:///home/lennart/svn/public/paman/trunk@6 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- ServerInfo.cc | 67 +++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 25 deletions(-) (limited to 'ServerInfo.cc') diff --git a/ServerInfo.cc b/ServerInfo.cc index 2a32f00..7866683 100644 --- a/ServerInfo.cc +++ b/ServerInfo.cc @@ -33,6 +33,8 @@ void SinkInfo::update(const struct pa_sink_info &i) { if (window) window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); } void SinkInfo::showWindow() { @@ -70,6 +72,8 @@ void SourceInfo::update(const struct pa_source_info &i) { if (window) window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); } void SourceInfo::showWindow() { @@ -103,6 +107,9 @@ void ClientInfo::update(const struct pa_client_info &i) { if (window) window->updateInfo(*this); + + g_assert(mainWindow); + mainWindow->updateInfo(*this); } void ClientInfo::showWindow() { @@ -138,6 +145,8 @@ void ModuleInfo::update(const struct pa_module_info &i) { if (window) window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); } void ModuleInfo::showWindow() { @@ -163,57 +172,53 @@ static void server_info_callback(struct pa_context *c, const struct pa_server_in static void sink_info_callback(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata) { ServerInfoManager *si = (ServerInfoManager*) userdata; - if (!is_last && i) - si->updateInfo(*i); + if (i) si->updateInfo(*i); } static void source_info_callback(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata) { ServerInfoManager *si = (ServerInfoManager*) userdata; - if (!is_last && i) - si->updateInfo(*i); + if (i) si->updateInfo(*i); } static void client_info_callback(struct pa_context *c, const struct pa_client_info *i, int is_last, void *userdata) { ServerInfoManager *si = (ServerInfoManager*) userdata; - if (!is_last && i) - si->updateInfo(*i); + if (i) si->updateInfo(*i); } static void module_info_callback(struct pa_context *c, const struct pa_module_info *i, int is_last, void *userdata) { ServerInfoManager *si = (ServerInfoManager*) userdata; - if (!is_last && i) - si->updateInfo(*i); + if (i) si->updateInfo(*i); } static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) { ServerInfoManager *si = (ServerInfoManager*) userdata; -// fprintf(stderr, "EV: %u %u\n", t, index); + //fprintf(stderr, "EV: %u %u\n", t, index); switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { case PA_SUBSCRIPTION_EVENT_SINK: if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) si->removeSinkInfo(index); else - pa_context_get_sink_info_by_index(c, index, sink_info_callback, si); + pa_operation_unref(pa_context_get_sink_info_by_index(c, index, sink_info_callback, si)); break; case PA_SUBSCRIPTION_EVENT_SOURCE: if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) si->removeSourceInfo(index); else - pa_context_get_source_info_by_index(c, index, source_info_callback, si); + pa_operation_unref(pa_context_get_source_info_by_index(c, index, source_info_callback, si)); break; case PA_SUBSCRIPTION_EVENT_MODULE: - if ((t && PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) si->removeModuleInfo(index); else - pa_context_get_module_info(c, index, module_info_callback, si); + pa_operation_unref(pa_context_get_module_info(c, index, module_info_callback, si)); break; case PA_SUBSCRIPTION_EVENT_CLIENT: - if ((t && PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) si->removeClientInfo(index); else - pa_context_get_client_info(c, index, client_info_callback, si); + pa_operation_unref(pa_context_get_client_info(c, index, client_info_callback, si)); break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: // fprintf(stderr, "SINK INPUT EVENT\n"); @@ -229,14 +234,24 @@ static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_ ServerInfoManager::ServerInfoManager(struct pa_context &c) : context(c) { - pa_context_get_server_info(&c, server_info_callback, this); - pa_context_get_sink_info_list(&c, sink_info_callback, this); - pa_context_get_source_info_list(&c, source_info_callback, this); - pa_context_get_module_info_list(&c, module_info_callback, this); - pa_context_get_client_info_list(&c, client_info_callback, this); - pa_context_subscribe(&c, (enum pa_subscription_mask) (PA_SUBSCRIPTION_FACILITY_SINK|PA_SUBSCRIPTION_FACILITY_SOURCE|PA_SUBSCRIPTION_FACILITY_MODULE|PA_SUBSCRIPTION_FACILITY_SINK_INPUT|PA_SUBSCRIPTION_FACILITY_SOURCE_OUTPUT|PA_SUBSCRIPTION_FACILITY_CLIENT), subscribe_callback, this); + pa_operation_unref(pa_context_get_server_info(&c, server_info_callback, this)); + pa_operation_unref(pa_context_get_sink_info_list(&c, sink_info_callback, this)); + pa_operation_unref(pa_context_get_source_info_list(&c, source_info_callback, this)); + pa_operation_unref(pa_context_get_module_info_list(&c, module_info_callback, this)); + pa_operation_unref(pa_context_get_client_info_list(&c, client_info_callback, this)); + + pa_context_set_subscribe_callback(&c, subscribe_callback, this); + + pa_operation_unref(pa_context_subscribe(&c, (enum pa_subscription_mask) + (PA_SUBSCRIPTION_MASK_SINK| + PA_SUBSCRIPTION_MASK_SOURCE| + PA_SUBSCRIPTION_MASK_MODULE| + PA_SUBSCRIPTION_MASK_SINK_INPUT| + PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT| + PA_SUBSCRIPTION_MASK_CLIENT), NULL, NULL)); } + ServerInfoManager::~ServerInfoManager() { for (std::map::iterator i = sinks.begin(); i != sinks.end(); i++) delete i->second; @@ -274,9 +289,10 @@ void ServerInfoManager::updateInfo(const struct pa_source_info &i) { } void ServerInfoManager::updateInfo(const struct pa_client_info &i) { - ClientInfo *si; - if ((si = clients[i.index])) - si->update(i); + ClientInfo *ci; + + if ((ci = clients[i.index])) + ci->update(i); else { ClientInfo *n = new ClientInfo(i); clients[i.index] = n; @@ -341,7 +357,7 @@ ModuleInfo* ServerInfoManager::getModuleInfo(uint32_t index) { void ServerInfoManager::removeSinkInfo(uint32_t index) { SinkInfo *i; - fprintf(stderr, "REMOVE %i\n", index); + if ((i = sinks[index])) { sinks.erase(index); mainWindow->removeInfo(*i); @@ -360,6 +376,7 @@ void ServerInfoManager::removeSourceInfo(uint32_t index) { void ServerInfoManager::removeClientInfo(uint32_t index) { ClientInfo *i; + if ((i = clients[index])) { clients.erase(index); mainWindow->removeInfo(*i); -- cgit