Mercurial > audlegacy-plugins
annotate src/psf2/plugin.c @ 2747:ead11a126bdd
clean up warnings.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Mon, 30 Jun 2008 23:05:32 -0500 |
parents | aa2e0f33f55d |
children | fe0d1cff2cd0 |
rev | line source |
---|---|
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1 /* |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2 Audio Overload SDK - main driver. for demonstration only, not user friendly! |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
4 Copyright (c) 2007-2008 R. Belmont and Richard Bannister. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
5 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
6 All rights reserved. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
7 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
8 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
9 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
10 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
11 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
12 * Neither the names of R. Belmont and Richard Bannister nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
13 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
15 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
16 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
17 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
18 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
19 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
20 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
21 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
22 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
23 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
25 */ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
26 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
27 #include <stdio.h> |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
28 #include <stdlib.h> |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
29 #include <string.h> |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
30 |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
31 #include <audacious/plugin.h> |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
32 |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
33 #include "ao.h" |
2744
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
34 #include "corlett.h" |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
35 #include "eng_protos.h" |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
36 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
37 /* file types */ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
38 static uint32 type; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
39 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
40 static struct |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
41 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
42 uint32 sig; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
43 char *name; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
44 int32 (*start)(uint8 *, uint32); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
45 int32 (*stop)(void); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
46 int32 (*command)(int32, int32); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
47 uint32 rate; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
48 } types[] = { |
2744
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
49 { 0x50534602, "Sony PlayStation 2 (.psf2)", psf2_start, psf2_stop, psf2_command, 60 }, |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
50 { 0xffffffff, "", NULL, NULL, NULL, 0 } |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
51 }; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
52 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
53 static char *path; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
54 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
55 /* ao_get_lib: called to load secondary files */ |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
56 int ao_get_lib(char *filename, uint8 **buffer, uint64 *length) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
57 { |
2747 | 58 guchar *filebuf; |
59 gsize size; | |
2746
aa2e0f33f55d
use aud_vfs_file_get_contents().
William Pitcock <nenolod@atheme.org>
parents:
2744
diff
changeset
|
60 char buf[PATH_MAX]; |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
61 |
2746
aa2e0f33f55d
use aud_vfs_file_get_contents().
William Pitcock <nenolod@atheme.org>
parents:
2744
diff
changeset
|
62 snprintf(buf, PATH_MAX, "%s/%s", dirname(path), filename); |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
63 |
2747 | 64 aud_vfs_file_get_contents(buf, (gchar **) &filebuf, &size); |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
65 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
66 *buffer = filebuf; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
67 *length = (uint64)size; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
68 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
69 return AO_SUCCESS; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
70 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
71 |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
72 void psf2_play(InputPlayback *data) |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
73 { |
2747 | 74 guchar *buffer; |
75 gsize size; | |
76 uint32 filesig; | |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
77 |
2746
aa2e0f33f55d
use aud_vfs_file_get_contents().
William Pitcock <nenolod@atheme.org>
parents:
2744
diff
changeset
|
78 path = g_strdup(data->filename); |
2747 | 79 aud_vfs_file_get_contents(data->filename, (gchar **) &buffer, &size); |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
80 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
81 // now try to identify the file |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
82 type = 0; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
83 filesig = buffer[0]<<24 | buffer[1]<<16 | buffer[2]<<8 | buffer[3]; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
84 while (types[type].sig != 0xffffffff) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
85 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
86 if (filesig == types[type].sig) |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
87 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
88 break; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
89 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
90 else |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
91 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
92 type++; |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
93 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
94 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
95 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
96 // now did we identify it above or just fall through? |
2738 | 97 if (types[type].sig == 0xffffffff) |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
98 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
99 printf("ERROR: File is unknown, signature bytes are %02x %02x %02x %02x\n", buffer[0], buffer[1], buffer[2], buffer[3]); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
100 free(buffer); |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
101 return; |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
102 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
103 |
2738 | 104 if (psf2_start(buffer, size) != AO_SUCCESS) |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
105 { |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
106 free(buffer); |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
107 printf("ERROR: Engine rejected file!\n"); |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
108 return; |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
109 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
110 |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
111 data->output->open_audio(FMT_S16_NE, 44100, 2); |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
112 |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
113 data->playing = TRUE; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
114 data->set_pb_ready(data); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
115 while (data->playing) |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
116 { |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
117 psf2_execute(data); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
118 } |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
119 |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
120 free(buffer); |
2746
aa2e0f33f55d
use aud_vfs_file_get_contents().
William Pitcock <nenolod@atheme.org>
parents:
2744
diff
changeset
|
121 g_free(path); |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
122 } |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
123 |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
124 void psf2_update(unsigned char *buffer, long count, InputPlayback *playback) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
125 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
126 const int mask = ~((((16 / 8) * 2)) - 1); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
127 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
128 while (count > 0) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
129 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
130 int t = playback->output->buffer_free() & mask; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
131 if (t > count) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
132 playback->pass_audio(playback, FMT_S16_NE, 2, count, buffer, NULL); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
133 else |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
134 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
135 if (t) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
136 playback->pass_audio(playback, FMT_S16_NE, 2, t, buffer, NULL); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
137 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
138 g_usleep((count-t)*1000*5/441/2); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
139 } |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
140 count -= t; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
141 buffer += t; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
142 } |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
143 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
144 #if 0 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
145 if (seek) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
146 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
147 if(sexypsf_seek(seek)) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
148 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
149 playback->output->flush(seek); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
150 seek = 0; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
151 } |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
152 else // negative time - must make a C time machine |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
153 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
154 sexypsf_stop(); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
155 return; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
156 } |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
157 } |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
158 if (stop) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
159 sexypsf_stop(); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
160 #endif |
2737
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
161 } |
62cc6d667119
Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
162 |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
163 void psf2_Stop(InputPlayback *playback) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
164 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
165 playback->playing = FALSE; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
166 } |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
167 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
168 void psf2_pause(InputPlayback *playback, short p) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
169 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
170 playback->output->pause(p); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
171 } |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
172 |
2744
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
173 static int psf2_is_our_fd(gchar *filename, VFSFile *file) |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
174 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
175 gchar magic[4]; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
176 aud_vfs_fread(magic, 1, 4, file); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
177 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
178 if (!memcmp(magic, "PSF\x02", 4)) |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
179 return 1; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
180 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
181 return 0; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
182 } |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
183 |
2744
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
184 static Tuple *psf2_tuple(gchar *filename) |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
185 { |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
186 Tuple *t; |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
187 corlett_t *c; |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
188 guchar *buf; |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
189 gsize sz; |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
190 |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
191 aud_vfs_file_get_contents(filename, (gchar **) &buf, &sz); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
192 |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
193 if (!buf) |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
194 return NULL; |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
195 |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
196 if (corlett_decode(buf, sz, NULL, NULL, &c) != AO_SUCCESS) |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
197 return NULL; |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
198 |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
199 t = aud_tuple_new_from_filename(filename); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
200 |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
201 aud_tuple_associate_int(t, FIELD_LENGTH, NULL, psfTimeToMS(c->inf_length)); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
202 aud_tuple_associate_string(t, FIELD_ARTIST, NULL, c->inf_artist); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
203 aud_tuple_associate_string(t, FIELD_ALBUM, NULL, c->inf_game); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
204 aud_tuple_associate_string(t, -1, "game", c->inf_game); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
205 aud_tuple_associate_string(t, FIELD_TITLE, NULL, c->inf_title); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
206 aud_tuple_associate_string(t, FIELD_COPYRIGHT, NULL, c->inf_copy); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
207 aud_tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced"); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
208 aud_tuple_associate_string(t, FIELD_CODEC, NULL, "PlayStation2 Audio"); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
209 aud_tuple_associate_string(t, -1, "console", "PlayStation 2"); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
210 |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
211 free(c); |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
212 |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
213 return t; |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
214 } |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
215 |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
216 gchar *psf2_fmts[] = { "psf2", "minipsf2", NULL }; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
217 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
218 InputPlugin psf2_ip = |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
219 { |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
220 .description = "PSF2 Audio Plugin", |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
221 .play_file = psf2_play, |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
222 .stop = psf2_Stop, |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
223 .pause = psf2_pause, |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
224 #if 0 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
225 .seek = sexypsf_xmms_seek, |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
226 .get_song_info = sexypsf_xmms_getsonginfo, |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
227 #endif |
2744
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
228 .get_song_tuple = psf2_tuple, |
af1338519322
Plugin works kinda, but stopping after track ends isn't done yet.
William Pitcock <nenolod@atheme.org>
parents:
2742
diff
changeset
|
229 .is_our_file_from_vfs = psf2_is_our_fd, |
2742
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
230 .vfs_extensions = psf2_fmts, |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
231 }; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
232 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
233 InputPlugin *psf2_iplist[] = { &psf2_ip, NULL }; |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
234 |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
235 DECLARE_PLUGIN(psf2, NULL, NULL, psf2_iplist, NULL, NULL, NULL, NULL, NULL); |
fd5373830ac1
Initial plugin. Don't use this unless you like aud to use 100% cpu.
William Pitcock <nenolod@atheme.org>
parents:
2741
diff
changeset
|
236 |