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_RECYCLING_CONTEXT_H__ 21 #define __AGS_RECYCLING_CONTEXT_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <ags/libags.h> 27 28 #include <ags/audio/ags_sound_enums.h> 29 #include <ags/audio/ags_recycling.h> 30 31 G_BEGIN_DECLS 32 33 #define AGS_TYPE_RECYCLING_CONTEXT (ags_recycling_context_get_type()) 34 #define AGS_RECYCLING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_RECYCLING_CONTEXT, AgsRecyclingContext)) 35 #define AGS_RECYCLING_CONTEXT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_RECYCLING_CONTEXT, AgsRecyclingContextClass)) 36 #define AGS_IS_RECYCLING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_RECYCLING_CONTEXT)) 37 #define AGS_IS_RECYCLING_CONTEXT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_RECYCLING_CONTEXT)) 38 #define AGS_RECYCLING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AGS_TYPE_RECYCLING_CONTEXT, AgsRecyclingContextClass)) 39 40 #define AGS_RECYCLING_CONTEXT_GET_OBJ_MUTEX(obj) (&(((AgsRecyclingContext *) obj)->obj_mutex)) 41 42 typedef struct _AgsRecyclingContext AgsRecyclingContext; 43 typedef struct _AgsRecyclingContextClass AgsRecyclingContextClass; 44 45 typedef enum{ 46 AGS_RECYCLING_CONTEXT_CONNECTED = 1, 47 AGS_RECYCLING_CONTEXT_CHAINED_TO_OUTPUT = 1 << 1, 48 AGS_RECYCLING_CONTEXT_CHAINED_TO_INPUT = 1 << 2, 49 }AgsRecyclingContextFlags; 50 51 struct _AgsRecyclingContext 52 { 53 GObject gobject; 54 55 guint flags; 56 gint sound_scope; 57 58 GRecMutex obj_mutex; 59 60 GObject *recall_id; 61 62 AgsRecyclingContext *parent; 63 GList *children; 64 65 AgsRecycling **recycling; 66 guint64 length; 67 }; 68 69 struct _AgsRecyclingContextClass 70 { 71 GObjectClass gobject; 72 }; 73 74 GType ags_recycling_context_get_type(); 75 76 GList* ags_recycling_context_find_scope(GList *recycling_context, gint sound_scope); 77 78 /* replace, add, remove and insert */ 79 void ags_recycling_context_replace(AgsRecyclingContext *recycling_context, 80 AgsRecycling *recycling, 81 gint position); 82 83 void ags_recycling_context_add(AgsRecyclingContext *recycling_context, 84 AgsRecycling *recycling); 85 void ags_recycling_context_remove(AgsRecyclingContext *recycling_context, 86 AgsRecycling *recycling); 87 void ags_recycling_context_insert(AgsRecyclingContext *recycling_context, 88 AgsRecycling *recycling, 89 gint position); 90 91 /* tolevel, find, find child and find parent */ 92 AgsRecyclingContext* ags_recycling_context_get_toplevel(AgsRecyclingContext *recycling_context); 93 94 gint ags_recycling_context_find(AgsRecyclingContext *recycling_context, 95 AgsRecycling *recycling); 96 gint ags_recycling_context_find_child(AgsRecyclingContext *recycling_context, 97 AgsRecycling *recycling); 98 gint ags_recycling_context_find_parent(AgsRecyclingContext *recycling_context, 99 AgsRecycling *recycling); 100 101 /* add and remove child */ 102 void ags_recycling_context_add_child(AgsRecyclingContext *parent, 103 AgsRecyclingContext *child); 104 void ags_recycling_context_remove_child(AgsRecyclingContext *parent, 105 AgsRecyclingContext *child); 106 107 /* child recall id */ 108 GList* ags_recycling_context_get_child_recall_id(AgsRecyclingContext *recycling_context); 109 110 /* instantiate - reset recycling */ 111 AgsRecyclingContext* ags_recycling_context_reset_recycling(AgsRecyclingContext *recycling_context, 112 AgsRecycling *old_first_recycling, AgsRecycling *old_last_recycling, 113 AgsRecycling *new_first_recycling, AgsRecycling *new_last_recycling); 114 115 /* instantiate */ 116 AgsRecyclingContext* ags_recycling_context_new(guint64 length); 117 118 G_END_DECLS 119 120 #endif /*__AGS_RECYCLING_CONTEXT_H__*/ 121