annotate src/adplug/core/players.cxx @ 3203:f5456241bff9 default tip

changed include path from audacious to audlegacy.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 10 Nov 2009 05:19:25 +0900
parents 88ba14f18587
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * AdPlug - Replayer for many OPL2/OPL3 audio file formats.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 * Copyright (C) 1999 - 2003 Simon Peter <dn.tlp@gmx.net>, et al.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 * Lesser General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 * players.h - Players enumeration, by Simon Peter <dn.tlp@gmx.net>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
21
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
22 #include <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
24
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
25 #include "players.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27 /***** CPlayerDesc *****/
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
28
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
29 CPlayerDesc::CPlayerDesc()
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
30 : factory(0), extensions(0), extlength(0)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
31 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
34 CPlayerDesc::CPlayerDesc(const CPlayerDesc &pd)
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
35 : factory(pd.factory), filetype(pd.filetype), extlength(pd.extlength)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36 {
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
37 if(pd.extensions) {
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
38 extensions = (char *)malloc(extlength);
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
39 memcpy(extensions, pd.extensions, extlength);
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
40 } else
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
41 extensions = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
42 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
43
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
44 CPlayerDesc::CPlayerDesc(Factory f, const std::string &type, const char *ext)
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
45 : factory(f), filetype(type), extensions(0)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
46 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
47 const char *i = ext;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
48
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
49 // Determine length of passed extensions list
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
50 while(*i) i += strlen(i) + 1;
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
51 extlength = i - ext + 1; // length = difference between last and first char + 1
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
52
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
53 extensions = (char *)malloc(extlength);
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
54 memcpy(extensions, ext, extlength);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
55 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
56
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
57 CPlayerDesc::~CPlayerDesc()
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
58 {
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
59 if(extensions) free(extensions);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
60 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
61
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
62 void CPlayerDesc::add_extension(const char *ext)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
63 {
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
64 unsigned long newlength = extlength + strlen(ext) + 1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
65
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
66 extensions = (char *)realloc(extensions, newlength);
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
67 strcpy(extensions + extlength - 1, ext);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
68 extensions[newlength - 1] = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
69 extlength = newlength;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
70 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
71
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
72 const char *CPlayerDesc::get_extension(unsigned int n) const
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
73 {
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
74 const char *i = extensions;
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
75 unsigned int j;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
76
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
77 for(j = 0; j < n && (*i); j++, i += strlen(i) + 1) ;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
78 return (*i != '\0' ? i : 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
79 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
80
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
81 /***** CPlayers *****/
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
82
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
83 const CPlayerDesc *CPlayers::lookup_filetype(const std::string &ftype) const
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
84 {
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
85 const_iterator i;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
86
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
87 for(i = begin(); i != end(); i++)
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
88 if((*i)->filetype == ftype)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
89 return *i;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
90
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
91 return 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
92 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
94 const CPlayerDesc *CPlayers::lookup_extension(const std::string &extension) const
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
95 {
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
96 const_iterator i;
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
97 unsigned int j;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
98
956
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
99 for(i = begin(); i != end(); i++)
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
100 for(j = 0; (*i)->get_extension(j); j++)
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
101 if(!stricmp(extension.c_str(), (*i)->get_extension(j)))
88ba14f18587 [svn] I said to indent it, not to break it, hmmkay?
chainsaw
parents: 955
diff changeset
102 return *i;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
103
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
104 return 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
105 }