annotate src/xs_nanosid.c @ 186:31a04bd9310c

Lines
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 18 Aug 2004 05:25:02 +0000
parents 92952aeccb77
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
122
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 NanoSID support
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org>
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 This program is free software; you can redistribute it and/or modify
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 the Free Software Foundation; either version 2 of the License, or
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 (at your option) any later version.
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 GNU General Public License for more details.
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 along with this program; if not, write to the Free Software
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 #include "xmms-sid.h"
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 #ifdef HAVE_NANOSID
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 #include "xs_nanosid.h"
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 #include <stdio.h>
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 #include <xmms/titlestring.h>
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 #include "xs_config.h"
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 #include "xs_support.h"
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 122
diff changeset
31 #include <libNanoSID.h>
122
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 typedef struct {
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 } t_xs_nanosid;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 /*
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 * Check if we can play the given file
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 gboolean xs_nanosid_isourfile(gchar *pcFilename)
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 {
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 if (strstr(pcFilename, ".zsid"))
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 return TRUE;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 else
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 return FALSE;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 }
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 /*
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 * Initialize NanoSID
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 gboolean xs_nanosid_init(t_xs_status *myStatus)
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 {
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 t_xs_nanosid *myPlayer;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 assert(myStatus);
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 /* Allocate internal structures */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 myPlayer = (t_xs_nanosid *) g_malloc0(sizeof(t_xs_nanosid));
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 if (!myPlayer) return FALSE;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 /* Initialize engine */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 myStatus->player = myPlayer;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 return TRUE;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 }
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 /*
136
92952aeccb77 Minor fixes and improvements, nanosid support.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
72 * Close NanoSID
122
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 void xs_nanosid_close(t_xs_status *myStatus)
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 {
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 t_xs_nanosid *myPlayer;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 assert(myStatus);
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 /* Free internals */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 myPlayer = (t_xs_nanosid *) myStatus->player;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 g_free(myPlayer);
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 myStatus->player = NULL;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 }
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 gboolean xs_nanosid_initsong(t_xs_status *myStatus)
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 {
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 t_xs_nanosid *myPlayer = (t_xs_nanosid *) myStatus->player;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 if (!myPlayer) return FALSE;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 }
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 guint xs_nanosid_fillbuffer(t_xs_status *myStatus, gchar *audioBuffer, guint audioBufSize)
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 {
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 t_xs_nanosid *myPlayer = (t_xs_nanosid *) myStatus->player;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 if (!myPlayer) return -1;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 return audioBufSize;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 }
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 gboolean xs_nanosid_loadsid(t_xs_status *myStatus, gchar *pcFilename)
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 {
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 t_xs_nanosid *myPlayer = (t_xs_nanosid *) myStatus->player;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 assert(myStatus);
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 /* Try to get the tune */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 if (!pcFilename) return FALSE;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 return FALSE;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 }
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 /*
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 * Delete INTERNAL information
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 void xs_nanosid_deletesid(t_xs_status *myStatus)
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 {
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 t_xs_nanosid *myPlayer;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 assert(myStatus);
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 myPlayer = (t_xs_nanosid *) myStatus->player;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 if (!myPlayer) return;
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 }
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 /*
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 * Return song information
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 */
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
31072456f6d7 Added initial NanoSID-support sources, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 #endif /* HAVE_NANOSID */