annotate src/sid/xs_slsup.c @ 2022:c6023e5efd06

warning fixes
author William Pitcock <nenolod@atheme.org>
date Thu, 11 Oct 2007 15:19:28 -0500
parents e566e18e9e3d
children 89d4e09a8988
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1574
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 File information window
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 (C) Copyright 1999-2007 Tecnic Software productions (TNSP)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 (at your option) any later version.
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 GNU General Public License for more details.
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License along
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 with this program; if not, write to the Free Software Foundation, Inc.,
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 #include "xs_slsup.h"
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 #include "xs_config.h"
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 static t_xs_sldb *xs_sldb_db = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 XS_MUTEX(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 static t_xs_stildb *xs_stildb_db = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 XS_MUTEX(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 /* STIL-database handling
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 gint xs_stil_init(void)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 XS_MUTEX_LOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 if (!xs_cfg.stilDBPath) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 return -1;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 XS_MUTEX_LOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 /* Check if already initialized */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 if (xs_stildb_db)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 xs_stildb_free(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 /* Allocate database */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 xs_stildb_db = (t_xs_stildb *) g_malloc0(sizeof(t_xs_stildb));
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 if (!xs_stildb_db) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 XS_MUTEX_UNLOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 return -2;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 /* Read the database */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 if (xs_stildb_read(xs_stildb_db, xs_cfg.stilDBPath) != 0) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 xs_stildb_free(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 xs_stildb_db = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 XS_MUTEX_UNLOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 return -3;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 /* Create index */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 if (xs_stildb_index(xs_stildb_db) != 0) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 xs_stildb_free(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 xs_stildb_db = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 XS_MUTEX_UNLOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 return -4;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 XS_MUTEX_UNLOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 return 0;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 void xs_stil_close(void)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 XS_MUTEX_LOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 xs_stildb_free(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 xs_stildb_db = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 XS_MUTEX_UNLOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 t_xs_stil_node *xs_stil_get(gchar *pcFilename)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 t_xs_stil_node *pResult;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 gchar *tmpFilename;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 XS_MUTEX_LOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 XS_MUTEX_LOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 if (xs_cfg.stilDBEnable && xs_stildb_db) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 if (xs_cfg.hvscPath) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 /* Remove postfixed directory separator from HVSC-path */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 tmpFilename = xs_strrchr(xs_cfg.hvscPath, '/');
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 if (tmpFilename && (tmpFilename[1] == 0))
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 tmpFilename[0] = 0;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 /* Remove HVSC location-prefix from filename */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 tmpFilename = strstr(pcFilename, xs_cfg.hvscPath);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 if (tmpFilename)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 tmpFilename += strlen(xs_cfg.hvscPath);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 else
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 tmpFilename = pcFilename;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 } else
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 tmpFilename = pcFilename;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 pResult = xs_stildb_get_node(xs_stildb_db, tmpFilename);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 } else
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 pResult = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 XS_MUTEX_UNLOCK(xs_stildb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 return pResult;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 /* Song length database handling glue
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 gint xs_songlen_init(void)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 XS_MUTEX_LOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 if (!xs_cfg.songlenDBPath) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 return -1;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 XS_MUTEX_LOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 /* Check if already initialized */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 if (xs_sldb_db)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 xs_sldb_free(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 /* Allocate database */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 xs_sldb_db = (t_xs_sldb *) g_malloc0(sizeof(t_xs_sldb));
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 if (!xs_sldb_db) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 XS_MUTEX_UNLOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 return -2;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 /* Read the database */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 if (xs_sldb_read(xs_sldb_db, xs_cfg.songlenDBPath) != 0) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 xs_sldb_free(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 xs_sldb_db = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 XS_MUTEX_UNLOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 return -3;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 /* Create index */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 if (xs_sldb_index(xs_sldb_db) != 0) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 xs_sldb_free(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 xs_sldb_db = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 XS_MUTEX_UNLOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 return -4;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 XS_MUTEX_UNLOCK(xs_cfg);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 XS_MUTEX_UNLOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 return 0;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 void xs_songlen_close(void)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 XS_MUTEX_LOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 xs_sldb_free(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 xs_sldb_db = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 XS_MUTEX_UNLOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 t_xs_sldb_node *xs_songlen_get(const gchar * pcFilename)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 t_xs_sldb_node *pResult;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 XS_MUTEX_LOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 if (xs_cfg.songlenDBEnable && xs_sldb_db)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 pResult = xs_sldb_get(xs_sldb_db, pcFilename);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 else
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 pResult = NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 XS_MUTEX_UNLOCK(xs_sldb_db);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 return pResult;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 /* Allocate a new tune information structure
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 t_xs_tuneinfo *xs_tuneinfo_new(const gchar * pcFilename,
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 gint nsubTunes, gint startTune, const gchar * sidName,
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 const gchar * sidComposer, const gchar * sidCopyright,
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 gint loadAddr, gint initAddr, gint playAddr,
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 gint dataFileLen, const gchar *sidFormat, gint sidModel)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 t_xs_tuneinfo *pResult;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 t_xs_sldb_node *tmpLength;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 gint i;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 /* Allocate structure */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 pResult = (t_xs_tuneinfo *) g_malloc0(sizeof(t_xs_tuneinfo));
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 if (!pResult) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 xs_error(_("Could not allocate memory for t_xs_tuneinfo ('%s')\n"),
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 pcFilename);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 return NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 pResult->sidFilename = XS_CS_FILENAME(pcFilename);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 if (!pResult->sidFilename) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 xs_error(_("Could not allocate sidFilename ('%s')\n"),
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 pcFilename);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 g_free(pResult);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 return NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 /* Allocate space for subtune information */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231 pResult->subTunes = g_malloc0(sizeof(t_xs_subtuneinfo) * (nsubTunes + 1));
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 if (!pResult->subTunes) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 xs_error(_("Could not allocate memory for t_xs_subtuneinfo ('%s', %i)\n"),
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 pcFilename, nsubTunes);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 g_free(pResult->sidFilename);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 g_free(pResult);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 return NULL;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 /* The following allocations don't matter if they fail */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 pResult->sidName = XS_CS_SID(sidName);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 pResult->sidComposer = XS_CS_SID(sidComposer);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 pResult->sidCopyright = XS_CS_SID(sidCopyright);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 pResult->nsubTunes = nsubTunes;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 pResult->startTune = startTune;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 pResult->loadAddr = loadAddr;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 pResult->initAddr = initAddr;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 pResult->playAddr = playAddr;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 pResult->dataFileLen = dataFileLen;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 pResult->sidFormat = XS_CS_SID(sidFormat);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 pResult->sidModel = sidModel;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 /* Get length information (NOTE: Do not free this!) */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 tmpLength = xs_songlen_get(pcFilename);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 /* Fill in sub-tune information */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 for (i = 0; i < pResult->nsubTunes; i++) {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 if (tmpLength && (i < tmpLength->nLengths))
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 pResult->subTunes[i].tuneLength = tmpLength->sLengths[i];
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 else
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 pResult->subTunes[i].tuneLength = -1;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 pResult->subTunes[i].tuneSpeed = -1;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 return pResult;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271 }
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 /* Free given tune information structure
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 */
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 void xs_tuneinfo_free(t_xs_tuneinfo * pTune)
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 {
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 if (!pTune) return;
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 g_free(pTune->subTunes);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 g_free(pTune->sidFilename);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 g_free(pTune->sidName);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 g_free(pTune->sidComposer);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 g_free(pTune->sidCopyright);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 g_free(pTune->sidFormat);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 g_free(pTune);
e566e18e9e3d Huge cleanup and some bugfixes. Temporarily breaks / removes sub-tune
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 }