mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	dbusiface-memstats: Implement the Memstats D-Bus interface.
This commit is contained in:
		
							parent
							
								
									0fc055226c
								
							
						
					
					
						commit
						44770c59e9
					
				
					 4 changed files with 281 additions and 0 deletions
				
			
		| 
						 | 
					@ -1281,6 +1281,7 @@ module_dbus_protocol_la_SOURCES = \
 | 
				
			||||||
		modules/dbus/iface-client.c modules/dbus/iface-client.h \
 | 
							modules/dbus/iface-client.c modules/dbus/iface-client.h \
 | 
				
			||||||
		modules/dbus/iface-core.c modules/dbus/iface-core.h \
 | 
							modules/dbus/iface-core.c modules/dbus/iface-core.h \
 | 
				
			||||||
		modules/dbus/iface-device.c modules/dbus/iface-device.h \
 | 
							modules/dbus/iface-device.c modules/dbus/iface-device.h \
 | 
				
			||||||
 | 
							modules/dbus/iface-memstats.c modules/dbus/iface-memstats.h \
 | 
				
			||||||
		modules/dbus/iface-module.c modules/dbus/iface-module.h \
 | 
							modules/dbus/iface-module.c modules/dbus/iface-module.h \
 | 
				
			||||||
		modules/dbus/iface-sample.c modules/dbus/iface-sample.h \
 | 
							modules/dbus/iface-sample.c modules/dbus/iface-sample.h \
 | 
				
			||||||
		modules/dbus/iface-stream.c modules/dbus/iface-stream.h \
 | 
							modules/dbus/iface-stream.c modules/dbus/iface-stream.h \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,6 +41,7 @@
 | 
				
			||||||
#include "iface-card.h"
 | 
					#include "iface-card.h"
 | 
				
			||||||
#include "iface-client.h"
 | 
					#include "iface-client.h"
 | 
				
			||||||
#include "iface-device.h"
 | 
					#include "iface-device.h"
 | 
				
			||||||
 | 
					#include "iface-memstats.h"
 | 
				
			||||||
#include "iface-module.h"
 | 
					#include "iface-module.h"
 | 
				
			||||||
#include "iface-sample.h"
 | 
					#include "iface-sample.h"
 | 
				
			||||||
#include "iface-stream.h"
 | 
					#include "iface-stream.h"
 | 
				
			||||||
| 
						 | 
					@ -114,6 +115,8 @@ struct pa_dbusiface_core {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_hook_slot *extension_registered_slot;
 | 
					    pa_hook_slot *extension_registered_slot;
 | 
				
			||||||
    pa_hook_slot *extension_unregistered_slot;
 | 
					    pa_hook_slot *extension_unregistered_slot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats *memstats;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum property_handler_index {
 | 
					enum property_handler_index {
 | 
				
			||||||
| 
						 | 
					@ -1940,6 +1943,7 @@ pa_dbusiface_core *pa_dbusiface_core_new(pa_core *core) {
 | 
				
			||||||
    c->fallback_source = pa_namereg_get_default_source(core);
 | 
					    c->fallback_source = pa_namereg_get_default_source(core);
 | 
				
			||||||
    c->extension_registered_slot = pa_dbus_protocol_hook_connect(c->dbus_protocol, PA_DBUS_PROTOCOL_HOOK_EXTENSION_REGISTERED, PA_HOOK_NORMAL, extension_registered_cb, c);
 | 
					    c->extension_registered_slot = pa_dbus_protocol_hook_connect(c->dbus_protocol, PA_DBUS_PROTOCOL_HOOK_EXTENSION_REGISTERED, PA_HOOK_NORMAL, extension_registered_cb, c);
 | 
				
			||||||
    c->extension_unregistered_slot = pa_dbus_protocol_hook_connect(c->dbus_protocol, PA_DBUS_PROTOCOL_HOOK_EXTENSION_UNREGISTERED, PA_HOOK_NORMAL, extension_unregistered_cb, c);
 | 
					    c->extension_unregistered_slot = pa_dbus_protocol_hook_connect(c->dbus_protocol, PA_DBUS_PROTOCOL_HOOK_EXTENSION_UNREGISTERED, PA_HOOK_NORMAL, extension_unregistered_cb, c);
 | 
				
			||||||
 | 
					    c->memstats = pa_dbusiface_memstats_new(core, OBJECT_PATH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (card = pa_idxset_first(core->cards, &idx); card; card = pa_idxset_next(core->cards, &idx))
 | 
					    for (card = pa_idxset_first(core->cards, &idx); card; card = pa_idxset_next(core->cards, &idx))
 | 
				
			||||||
        pa_hashmap_put(c->cards, PA_UINT32_TO_PTR(idx), pa_dbusiface_card_new(card, OBJECT_PATH));
 | 
					        pa_hashmap_put(c->cards, PA_UINT32_TO_PTR(idx), pa_dbusiface_card_new(card, OBJECT_PATH));
 | 
				
			||||||
| 
						 | 
					@ -2042,6 +2046,7 @@ void pa_dbusiface_core_free(pa_dbusiface_core *c) {
 | 
				
			||||||
    pa_hashmap_free(c->clients, free_client_cb, NULL);
 | 
					    pa_hashmap_free(c->clients, free_client_cb, NULL);
 | 
				
			||||||
    pa_hook_slot_free(c->extension_registered_slot);
 | 
					    pa_hook_slot_free(c->extension_registered_slot);
 | 
				
			||||||
    pa_hook_slot_free(c->extension_unregistered_slot);
 | 
					    pa_hook_slot_free(c->extension_unregistered_slot);
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats_free(c->memstats);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_dbus_protocol_unref(c->dbus_protocol);
 | 
					    pa_dbus_protocol_unref(c->dbus_protocol);
 | 
				
			||||||
    pa_core_unref(c->core);
 | 
					    pa_core_unref(c->core);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										231
									
								
								src/modules/dbus/iface-memstats.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										231
									
								
								src/modules/dbus/iface-memstats.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,231 @@
 | 
				
			||||||
 | 
					/***
 | 
				
			||||||
 | 
					  This file is part of PulseAudio.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Copyright 2009 Tanu Kaskinen
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  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 <dbus/dbus.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <pulsecore/core-scache.h>
 | 
				
			||||||
 | 
					#include <pulsecore/core-util.h>
 | 
				
			||||||
 | 
					#include <pulsecore/dbus-util.h>
 | 
				
			||||||
 | 
					#include <pulsecore/protocol-dbus.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "iface-memstats.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define OBJECT_NAME "memstats"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handle_get_current_memblocks(DBusConnection *conn, DBusMessage *msg, void *userdata);
 | 
				
			||||||
 | 
					static void handle_get_current_memblocks_size(DBusConnection *conn, DBusMessage *msg, void *userdata);
 | 
				
			||||||
 | 
					static void handle_get_accumulated_memblocks(DBusConnection *conn, DBusMessage *msg, void *userdata);
 | 
				
			||||||
 | 
					static void handle_get_accumulated_memblocks_size(DBusConnection *conn, DBusMessage *msg, void *userdata);
 | 
				
			||||||
 | 
					static void handle_get_sample_cache_size(DBusConnection *conn, DBusMessage *msg, void *userdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct pa_dbusiface_memstats {
 | 
				
			||||||
 | 
					    pa_core *core;
 | 
				
			||||||
 | 
					    char *path;
 | 
				
			||||||
 | 
					    pa_dbus_protocol *dbus_protocol;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum property_handler_index {
 | 
				
			||||||
 | 
					    PROPERTY_HANDLER_CURRENT_MEMBLOCKS,
 | 
				
			||||||
 | 
					    PROPERTY_HANDLER_CURRENT_MEMBLOCKS_SIZE,
 | 
				
			||||||
 | 
					    PROPERTY_HANDLER_ACCUMULATED_MEMBLOCKS,
 | 
				
			||||||
 | 
					    PROPERTY_HANDLER_ACCUMULATED_MEMBLOCKS_SIZE,
 | 
				
			||||||
 | 
					    PROPERTY_HANDLER_SAMPLE_CACHE_SIZE,
 | 
				
			||||||
 | 
					    PROPERTY_HANDLER_MAX
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_dbus_property_handler property_handlers[PROPERTY_HANDLER_MAX] = {
 | 
				
			||||||
 | 
					    [PROPERTY_HANDLER_CURRENT_MEMBLOCKS]          = { .property_name = "CurrentMemblocks",         .type = "u", .get_cb = handle_get_current_memblocks,          .set_cb = NULL },
 | 
				
			||||||
 | 
					    [PROPERTY_HANDLER_CURRENT_MEMBLOCKS_SIZE]     = { .property_name = "CurrentMemblocksSize",     .type = "u", .get_cb = handle_get_current_memblocks_size,     .set_cb = NULL },
 | 
				
			||||||
 | 
					    [PROPERTY_HANDLER_ACCUMULATED_MEMBLOCKS]      = { .property_name = "AccumulatedMemblocks",     .type = "u", .get_cb = handle_get_accumulated_memblocks,      .set_cb = NULL },
 | 
				
			||||||
 | 
					    [PROPERTY_HANDLER_ACCUMULATED_MEMBLOCKS_SIZE] = { .property_name = "AccumulatedMemblocksSize", .type = "u", .get_cb = handle_get_accumulated_memblocks_size, .set_cb = NULL },
 | 
				
			||||||
 | 
					    [PROPERTY_HANDLER_SAMPLE_CACHE_SIZE]          = { .property_name = "SampleCacheSize",          .type = "u", .get_cb = handle_get_sample_cache_size,          .set_cb = NULL }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_dbus_interface_info memstats_interface_info = {
 | 
				
			||||||
 | 
					    .name = PA_DBUSIFACE_MEMSTATS_INTERFACE,
 | 
				
			||||||
 | 
					    .method_handlers = NULL,
 | 
				
			||||||
 | 
					    .n_method_handlers = 0,
 | 
				
			||||||
 | 
					    .property_handlers = property_handlers,
 | 
				
			||||||
 | 
					    .n_property_handlers = PROPERTY_HANDLER_MAX,
 | 
				
			||||||
 | 
					    .get_all_properties_cb = handle_get_all,
 | 
				
			||||||
 | 
					    .signals = NULL,
 | 
				
			||||||
 | 
					    .n_signals = 0
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handle_get_current_memblocks(DBusConnection *conn, DBusMessage *msg, void *userdata) {
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats *m = userdata;
 | 
				
			||||||
 | 
					    const pa_mempool_stat *stat;
 | 
				
			||||||
 | 
					    dbus_uint32_t current_memblocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(conn);
 | 
				
			||||||
 | 
					    pa_assert(msg);
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    stat = pa_mempool_get_stat(m->core->mempool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_memblocks = pa_atomic_load(&stat->n_allocated);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, ¤t_memblocks);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handle_get_current_memblocks_size(DBusConnection *conn, DBusMessage *msg, void *userdata) {
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats *m = userdata;
 | 
				
			||||||
 | 
					    const pa_mempool_stat *stat;
 | 
				
			||||||
 | 
					    dbus_uint32_t current_memblocks_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(conn);
 | 
				
			||||||
 | 
					    pa_assert(msg);
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    stat = pa_mempool_get_stat(m->core->mempool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_memblocks_size = pa_atomic_load(&stat->allocated_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, ¤t_memblocks_size);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handle_get_accumulated_memblocks(DBusConnection *conn, DBusMessage *msg, void *userdata) {
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats *m = userdata;
 | 
				
			||||||
 | 
					    const pa_mempool_stat *stat;
 | 
				
			||||||
 | 
					    dbus_uint32_t accumulated_memblocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(conn);
 | 
				
			||||||
 | 
					    pa_assert(msg);
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    stat = pa_mempool_get_stat(m->core->mempool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    accumulated_memblocks = pa_atomic_load(&stat->n_accumulated);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &accumulated_memblocks);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handle_get_accumulated_memblocks_size(DBusConnection *conn, DBusMessage *msg, void *userdata) {
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats *m = userdata;
 | 
				
			||||||
 | 
					    const pa_mempool_stat *stat;
 | 
				
			||||||
 | 
					    dbus_uint32_t accumulated_memblocks_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(conn);
 | 
				
			||||||
 | 
					    pa_assert(msg);
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    stat = pa_mempool_get_stat(m->core->mempool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    accumulated_memblocks_size = pa_atomic_load(&stat->accumulated_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &accumulated_memblocks_size);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handle_get_sample_cache_size(DBusConnection *conn, DBusMessage *msg, void *userdata) {
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats *m = userdata;
 | 
				
			||||||
 | 
					    dbus_uint32_t sample_cache_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(conn);
 | 
				
			||||||
 | 
					    pa_assert(msg);
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    sample_cache_size = pa_scache_total_size(m->core);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &sample_cache_size);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdata) {
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats *m = userdata;
 | 
				
			||||||
 | 
					    const pa_mempool_stat *stat;
 | 
				
			||||||
 | 
					    dbus_uint32_t current_memblocks;
 | 
				
			||||||
 | 
					    dbus_uint32_t current_memblocks_size;
 | 
				
			||||||
 | 
					    dbus_uint32_t accumulated_memblocks;
 | 
				
			||||||
 | 
					    dbus_uint32_t accumulated_memblocks_size;
 | 
				
			||||||
 | 
					    dbus_uint32_t sample_cache_size;
 | 
				
			||||||
 | 
					    DBusMessage *reply = NULL;
 | 
				
			||||||
 | 
					    DBusMessageIter msg_iter;
 | 
				
			||||||
 | 
					    DBusMessageIter dict_iter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(conn);
 | 
				
			||||||
 | 
					    pa_assert(msg);
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    stat = pa_mempool_get_stat(m->core->mempool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_memblocks = pa_atomic_load(&stat->n_allocated);
 | 
				
			||||||
 | 
					    current_memblocks_size = pa_atomic_load(&stat->allocated_size);
 | 
				
			||||||
 | 
					    accumulated_memblocks = pa_atomic_load(&stat->n_accumulated);
 | 
				
			||||||
 | 
					    accumulated_memblocks_size = pa_atomic_load(&stat->accumulated_size);
 | 
				
			||||||
 | 
					    sample_cache_size = pa_scache_total_size(m->core);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((reply = dbus_message_new_method_return(msg)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dbus_message_iter_init_append(reply, &msg_iter);
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_iter_open_container(&msg_iter, DBUS_TYPE_ARRAY, "{sv}", &dict_iter));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_CURRENT_MEMBLOCKS].property_name, DBUS_TYPE_UINT32, ¤t_memblocks);
 | 
				
			||||||
 | 
					    pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_CURRENT_MEMBLOCKS_SIZE].property_name, DBUS_TYPE_UINT32, ¤t_memblocks_size);
 | 
				
			||||||
 | 
					    pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_ACCUMULATED_MEMBLOCKS].property_name, DBUS_TYPE_UINT32, &accumulated_memblocks);
 | 
				
			||||||
 | 
					    pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_ACCUMULATED_MEMBLOCKS_SIZE].property_name, DBUS_TYPE_UINT32, &accumulated_memblocks_size);
 | 
				
			||||||
 | 
					    pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_SAMPLE_CACHE_SIZE].property_name, DBUS_TYPE_UINT32, &sample_cache_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_iter_close_container(&msg_iter, &dict_iter));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_connection_send(conn, reply, NULL));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dbus_message_unref(reply);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pa_dbusiface_memstats *pa_dbusiface_memstats_new(pa_core *core, const char *path_prefix) {
 | 
				
			||||||
 | 
					    pa_dbusiface_memstats *m;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(core);
 | 
				
			||||||
 | 
					    pa_assert(path_prefix);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m = pa_xnew(pa_dbusiface_memstats, 1);
 | 
				
			||||||
 | 
					    m->core = pa_core_ref(core);
 | 
				
			||||||
 | 
					    m->path = pa_sprintf_malloc("%s/%s", path_prefix, OBJECT_NAME);
 | 
				
			||||||
 | 
					    m->dbus_protocol = pa_dbus_protocol_get(core);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se(pa_dbus_protocol_add_interface(m->dbus_protocol, m->path, &memstats_interface_info, m) >= 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return m;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void pa_dbusiface_memstats_free(pa_dbusiface_memstats *m) {
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se(pa_dbus_protocol_remove_interface(m->dbus_protocol, m->path, memstats_interface_info.name) >= 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_xfree(m->path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_unref(m->dbus_protocol);
 | 
				
			||||||
 | 
					    pa_core_unref(m->core);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_xfree(m);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char *pa_dbusiface_memstats_get_path(pa_dbusiface_memstats *m) {
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return m->path;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										44
									
								
								src/modules/dbus/iface-memstats.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/modules/dbus/iface-memstats.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,44 @@
 | 
				
			||||||
 | 
					#ifndef foodbusifacememstatshfoo
 | 
				
			||||||
 | 
					#define foodbusifacememstatshfoo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/***
 | 
				
			||||||
 | 
					  This file is part of PulseAudio.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Copyright 2009 Tanu Kaskinen
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  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.
 | 
				
			||||||
 | 
					***/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This object implements the D-Bus interface org.PulseAudio.Core1.Memstats.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * See http://pulseaudio.org/wiki/DBusInterface for the Memstats interface
 | 
				
			||||||
 | 
					 * documentation.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <pulsecore/core.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "iface-core.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define PA_DBUSIFACE_MEMSTATS_INTERFACE PA_DBUSIFACE_CORE_INTERFACE ".Memstats"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct pa_dbusiface_memstats pa_dbusiface_memstats;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pa_dbusiface_memstats *pa_dbusiface_memstats_new(pa_core *core, const char *path_prefix);
 | 
				
			||||||
 | 
					void pa_dbusiface_memstats_free(pa_dbusiface_memstats *m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char *pa_dbusiface_memstats_get_path(pa_dbusiface_memstats *m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue