1 /* 2 * libInstPatch 3 * Copyright (C) 1999-2014 Element Green <element@elementsofsound.org> 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public License 7 * as published by the Free Software Foundation; version 2.1 8 * of the License only. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 * 02110-1301, USA or on the web at http://www.gnu.org. 19 */ 20 #ifndef __IPATCH_SAMPLE_DATA_H__ 21 #define __IPATCH_SAMPLE_DATA_H__ 22 23 #include <stdarg.h> 24 #include <glib.h> 25 #include <glib-object.h> 26 27 /* forward type declarations */ 28 29 typedef struct _IpatchSampleData IpatchSampleData; 30 typedef struct _IpatchSampleDataClass IpatchSampleDataClass; 31 32 #include <libinstpatch/IpatchItem.h> 33 #include <libinstpatch/IpatchSampleStore.h> 34 #include <libinstpatch/IpatchFile.h> 35 36 #define IPATCH_TYPE_SAMPLE_DATA (ipatch_sample_data_get_type ()) 37 #define IPATCH_SAMPLE_DATA(obj) \ 38 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPATCH_TYPE_SAMPLE_DATA, IpatchSampleData)) 39 #define IPATCH_SAMPLE_DATA_CLASS(klass) \ 40 (G_TYPE_CHECK_CLASS_CAST ((klass), IPATCH_TYPE_SAMPLE_DATA, IpatchSampleDataClass)) 41 #define IPATCH_IS_SAMPLE_DATA(obj) \ 42 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPATCH_TYPE_SAMPLE_DATA)) 43 #define IPATCH_IS_SAMPLE_DATA_CLASS(klass) \ 44 (G_TYPE_CHECK_CLASS_TYPE ((klass), IPATCH_TYPE_SAMPLE_DATA)) 45 #define IPATCH_SAMPLE_DATA_GET_CLASS(obj) \ 46 (G_TYPE_INSTANCE_GET_CLASS ((obj), IPATCH_TYPE_SAMPLE_DATA, IpatchSampleDataClass)) 47 48 /* Sample data instance */ 49 struct _IpatchSampleData 50 { 51 IpatchItem parent_instance; 52 GSList *samples; /* list of IpatchSampleStore (1st is native sample) */ 53 int usecount; /* Count of users of this sample data object */ 54 }; 55 56 struct _IpatchSampleDataClass 57 { 58 IpatchItemClass parent_class; 59 }; 60 61 /** 62 * IPATCH_SAMPLE_DATA_UNUSED_FLAG_SHIFT: (skip) 63 */ 64 /* Reserve 3 item flags for expansion */ 65 #define IPATCH_SAMPLE_DATA_UNUSED_FLAG_SHIFT \ 66 (IPATCH_CONTAINER_UNUSED_FLAG_SHIFT + 3) 67 68 /** 69 * IpatchSampleDataMigrateFlags: 70 * @IPATCH_SAMPLE_DATA_MIGRATE_REMOVE_NEW_IF_UNUSED: Remove unused #IpatchSampleStore objects referencing newfile. 71 * @IPATCH_SAMPLE_DATA_MIGRATE_TO_NEWFILE: Migrate all #IpatchSampleData objects to newfile which have a #IpatchSampleStore 72 * with the same format as the native format therein, default is to only migrate those with their native samples in 73 * oldfile or swap storage. 74 * @IPATCH_SAMPLE_DATA_MIGRATE_LEAVE_IN_SWAP: Leave native samples in #IpatchSampleData objects in swap, even if present in 75 * newfile, default is to migrate samples out of swap in preference for newfile. 76 * @IPATCH_SAMPLE_DATA_MIGRATE_REPLACE: Replace oldfile with newfile (has no effect if newfile is %NULL) 77 * 78 * Since: 1.1.0 79 */ 80 typedef enum 81 { 82 IPATCH_SAMPLE_DATA_MIGRATE_REMOVE_NEW_IF_UNUSED = 1 << 0, 83 IPATCH_SAMPLE_DATA_MIGRATE_TO_NEWFILE = 1 << 1, 84 IPATCH_SAMPLE_DATA_MIGRATE_LEAVE_IN_SWAP = 1 << 2, 85 IPATCH_SAMPLE_DATA_MIGRATE_REPLACE = 1 << 3 86 } IpatchSampleDataMigrateFlags; 87 88 IpatchList *ipatch_get_sample_data_list(void); 89 gboolean ipatch_migrate_file_sample_data(IpatchFile *oldfile, IpatchFile *newfile, const char *filename, 90 guint flags, GError **err); 91 92 GType ipatch_sample_data_get_type(void); 93 IpatchSampleData *ipatch_sample_data_new(void); 94 95 void ipatch_sample_data_used(IpatchSampleData *sampledata); 96 void ipatch_sample_data_unused(IpatchSampleData *sampledata); 97 98 void ipatch_sample_data_add(IpatchSampleData *sampledata, IpatchSampleStore *store); 99 void ipatch_sample_data_remove(IpatchSampleData *sampledata, IpatchSampleStore *store); 100 void ipatch_sample_data_replace_native_sample(IpatchSampleData *sampledata, 101 IpatchSampleStore *store); 102 103 IpatchList *ipatch_sample_data_get_samples(IpatchSampleData *sampledata); 104 guint ipatch_sample_data_get_size(IpatchSampleData *sampledata); 105 IpatchSampleStore *ipatch_sample_data_get_native_sample(IpatchSampleData *sampledata); 106 int ipatch_sample_data_get_native_format(IpatchSampleData *sampledata); 107 108 gboolean ipatch_sample_data_open_native_sample(IpatchSampleData *sampledata, 109 IpatchSampleHandle *handle, char mode, 110 int format, guint32 channel_map, 111 GError **err); 112 113 IpatchSampleStore *ipatch_sample_data_get_cache_sample(IpatchSampleData *sampledata, 114 int format, guint32 channel_map, 115 GError **err); 116 IpatchSampleStore *ipatch_sample_data_lookup_cache_sample(IpatchSampleData *sampledata, 117 int format, guint32 channel_map); 118 gboolean ipatch_sample_data_open_cache_sample(IpatchSampleData *sampledata, 119 IpatchSampleHandle *handle, 120 int format, guint32 channel_map, 121 GError **err); 122 guint64 ipatch_sample_cache_get_unused_size(void); 123 void ipatch_sample_cache_clean(guint64 max_unused_size, guint max_unused_age); 124 125 IpatchSampleData *ipatch_sample_data_get_blank(void); 126 127 #endif 128 129