1 /* GSequencer - Advanced GTK Sequencer 2 * Copyright (C) 2005-2020 Joël Krähemann 3 * 4 * This file is part of GSequencer. 5 * 6 * GSequencer is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * GSequencer is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __AGS_PULSE_SERVER_H__ 21 #define __AGS_PULSE_SERVER_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <ags/ags_api_config.h> 27 28 #if defined(AGS_WITH_PULSE) 29 #include <pulse/pulseaudio.h> 30 #include <pulse/stream.h> 31 #include <pulse/error.h> 32 #endif 33 34 #include <ags/libags.h> 35 36 G_BEGIN_DECLS 37 38 #define AGS_TYPE_PULSE_SERVER (ags_pulse_server_get_type()) 39 #define AGS_PULSE_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_PULSE_SERVER, AgsPulseServer)) 40 #define AGS_PULSE_SERVER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST(class, AGS_TYPE_PULSE_SERVER, AgsPulseServer)) 41 #define AGS_IS_PULSE_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_PULSE_SERVER)) 42 #define AGS_IS_PULSE_SERVER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_PULSE_SERVER)) 43 #define AGS_PULSE_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS(obj, AGS_TYPE_PULSE_SERVER, AgsPulseServerClass)) 44 45 #define AGS_PULSE_SERVER_GET_OBJ_MUTEX(obj) (&(((AgsPulseServer *) obj)->obj_mutex)) 46 47 typedef struct _AgsPulseServer AgsPulseServer; 48 typedef struct _AgsPulseServerClass AgsPulseServerClass; 49 50 /** 51 * AgsPulseServerFlags: 52 * @AGS_PULSE_SERVER_ADDED_TO_REGISTRY: the pulseaudio server was added to registry, see #AgsConnectable::add_to_registry() 53 * @AGS_PULSE_SERVER_CONNECTED: indicates the server was connected by calling #AgsConnectable::connect() 54 * 55 * Enum values to control the behavior or indicate internal state of #AgsPulseServer by 56 * enable/disable as flags. 57 */ 58 typedef enum{ 59 AGS_PULSE_SERVER_ADDED_TO_REGISTRY = 1, 60 AGS_PULSE_SERVER_CONNECTED = 1 << 1, 61 }AgsPulseServerFlags; 62 63 struct _AgsPulseServer 64 { 65 GObject gobject; 66 67 guint flags; 68 69 GRecMutex obj_mutex; 70 71 volatile gboolean running; 72 GThread *thread; 73 74 AgsApplicationContext *application_context; 75 76 AgsUUID *uuid; 77 78 #if defined(AGS_WITH_PULSE) 79 pa_mainloop *main_loop; 80 pa_mainloop_api *main_loop_api; 81 #else 82 gpointer main_loop; 83 gpointer main_loop_api; 84 #endif 85 86 gchar *url; 87 88 guint *port; 89 guint port_count; 90 91 guint n_soundcards; 92 guint n_sequencers; 93 94 GObject *default_soundcard; 95 96 GObject *default_client; 97 GList *client; 98 }; 99 100 struct _AgsPulseServerClass 101 { 102 GObjectClass gobject; 103 }; 104 105 GType ags_pulse_server_get_type(); 106 107 gboolean ags_pulse_server_test_flags(AgsPulseServer *pulse_server, guint flags); 108 void ags_pulse_server_set_flags(AgsPulseServer *pulse_server, guint flags); 109 void ags_pulse_server_unset_flags(AgsPulseServer *pulse_server, guint flags); 110 111 GList* ags_pulse_server_find_url(GList *pulse_server, 112 gchar *url); 113 114 GObject* ags_pulse_server_find_client(AgsPulseServer *pulse_server, 115 gchar *client_uuid); 116 117 GObject* ags_pulse_server_find_port(AgsPulseServer *pulse_server, 118 gchar *port_uuid); 119 120 void ags_pulse_server_add_client(AgsPulseServer *pulse_server, 121 GObject *pulse_client); 122 void ags_pulse_server_remove_client(AgsPulseServer *pulse_server, 123 GObject *pulse_client); 124 125 void ags_pulse_server_connect_client(AgsPulseServer *pulse_server); 126 void ags_pulse_server_disconnect_client(AgsPulseServer *pulse_server); 127 128 void ags_pulse_server_start_poll(AgsPulseServer *pulse_server); 129 130 AgsPulseServer* ags_pulse_server_new(gchar *url); 131 132 G_END_DECLS 133 134 #endif /*__AGS_PULSE_SERVER_H__*/ 135