summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-08-15 00:03:01 +0000
committerLennart Poettering <lennart@poettering.net>2004-08-15 00:03:01 +0000
commite34209e5df13b4f3dd228af857cf0d303b21db48 (patch)
tree9cd51fad791cf2bb54953fe51bc4acda9aa313d4
parent4d38b0a057c9c78c3e400c953b6ab5ea6d2a37b0 (diff)
Update to current polypaudio library
git-svn-id: file:///home/lennart/svn/public/paman/trunk@6 cdefa82f-4ce1-0310-97f5-ab6066f37c3c
-rw-r--r--MainWindow.cc1
-rw-r--r--ServerInfo.cc67
-rw-r--r--paman.cc78
-rw-r--r--paman.glade10
4 files changed, 94 insertions, 62 deletions
diff --git a/MainWindow.cc b/MainWindow.cc
index dfa47b9..fdb817a 100644
--- a/MainWindow.cc
+++ b/MainWindow.cc
@@ -115,6 +115,7 @@ void MainWindow::updateInfo(SourceInfo &i) {
}
void MainWindow::updateInfo(ClientInfo &i) {
+
if (!i.treeRef)
i.treeRef = Gtk::TreeRowReference(clientTreeStore, Gtk::TreePath(clientTreeStore->append()));
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<int, SinkInfo*>::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);
diff --git a/paman.cc b/paman.cc
index 6fb0d88..0c1741d 100644
--- a/paman.cc
+++ b/paman.cc
@@ -16,30 +16,52 @@ ServerInfoManager *serverInfoManager = NULL;
struct pa_context *context = NULL;
struct pa_mainloop_api *mainloop_api = NULL;
-static void context_complete_callback(struct pa_context *c, int success, void *userdata) {
- g_assert(c && mainWindow && !serverInfoManager);
-
- if (!success) {
- mainWindow->showFailure(pa_strerror(pa_context_errno(c)));
- //pa_context_free(context); /* Mrprmfmfl! */
+static void context_state_callback(struct pa_context *c, void *userdata) {
+ g_assert(c && mainWindow);
+
+ switch (pa_context_get_state(c)) {
+ case PA_CONTEXT_CONNECTING:
+ mainWindow->showSuccess("Connecting ...");
+ mainWindow->connectButton->set_sensitive(false);
+ return;
+
+ case PA_CONTEXT_AUTHORIZING:
+ mainWindow->showSuccess("Authorizing ...");
+ return;
+
+ case PA_CONTEXT_SETTING_NAME:
+ mainWindow->showSuccess("Setting name ...");
+ return;
+
+ case PA_CONTEXT_READY:
+ mainWindow->showSuccess("Ready");
+ g_assert(!serverInfoManager);
+ serverInfoManager = new ServerInfoManager(*c);
+ return;
+
+ case PA_CONTEXT_TERMINATED:
+ mainWindow->showSuccess("Disconnected");
+ break;
+
+ case PA_CONTEXT_FAILED:
+ default:
+ mainWindow->showFailure(pa_strerror(pa_context_errno(c)));
+ break;
+
+ }
+
+ if (context) {
+ pa_context_unref(context);
context = NULL;
- mainWindow->connectButton->set_sensitive(true);
- return;
}
- mainWindow->showSuccess("Connected");
- mainWindow->connectButton->set_sensitive(false);
- serverInfoManager = new ServerInfoManager(*c);
-}
-
-static void die_callback(struct pa_context *c, void *userdata) {
- mainWindow->clearAllData();
- mainWindow->showFailure(pa_strerror(pa_context_errno(c)));
- delete serverInfoManager;
- serverInfoManager = NULL;
- //pa_context_free(contetx); /* Mrprmfmfl! */
- context = NULL;
+ if (serverInfoManager) {
+ delete serverInfoManager;
+ serverInfoManager = NULL;
+ }
+
mainWindow->connectButton->set_sensitive(true);
+ mainWindow->clearAllData();
}
void create_connection() {
@@ -47,22 +69,16 @@ void create_connection() {
delete serverInfoManager;
serverInfoManager = NULL;
}
+
if (context) {
- pa_context_free(context);
+ pa_context_unref(context);
context = NULL;
}
- mainWindow->showSuccess("Connecting ...");
context = pa_context_new(mainloop_api, "Polypaudio Manager");
g_assert(context);
- pa_context_set_die_callback(context, die_callback, NULL);
-
- if (pa_context_connect(context, NULL, context_complete_callback, NULL) < 0) {
- context_complete_callback(context, 0, NULL);
- return;
- }
-
- mainWindow->connectButton->set_sensitive(false);
+ pa_context_set_state_callback(context, context_state_callback, NULL);
+ pa_context_connect(context, NULL);
}
int main(int argc, char *argv[]) {
@@ -89,7 +105,7 @@ quit:
delete serverInfoManager;
if (context)
- pa_context_free(context);
+ pa_context_unref(context);
mainloop_api = NULL;
if (mainWindow)
diff --git a/paman.glade b/paman.glade
index e7bb10e..a4e8179 100644
--- a/paman.glade
+++ b/paman.glade
@@ -896,7 +896,7 @@
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<child>
@@ -1463,7 +1463,7 @@
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<child>
@@ -1894,7 +1894,6 @@
</widget>
<widget class="GtkWindow" id="moduleWindow">
- <property name="visible">True</property>
<property name="title" translatable="yes">Module</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
@@ -1904,7 +1903,7 @@
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<child>
@@ -2235,7 +2234,6 @@
</widget>
<widget class="GtkWindow" id="clientWindow">
- <property name="visible">True</property>
<property name="title" translatable="yes">Client</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
@@ -2245,7 +2243,7 @@
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<child>