annotate src/xs_slsup.c @ 980:1cd7dead1b56

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