~ubuntu-branches/ubuntu/oneiric/audacious-plugins/oneiric

« back to all changes in this revision

Viewing changes to src/xsf/plugin.c

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-04-13 22:48:07 UTC
  • mfrom: (1.1.12 upstream) (2.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20100413224807-imw9qnn26cxcgefq
Tags: 2.3-1ubuntu1
* Merge from Debian experimental (LP: #494604), remaining change:
  - audacious-plugins suggests timidiy for midi playback
* Build-Depend on libav* for ffaudio.
* Break and replace audacious (<< 2.3).
* Drop audacious-plugins-dev package. "apt-get build-dep audacious-plugins"
  will do the same job.
* audacious-plugins recommends audacious instead of depending on it to break
  the circular dependency (Closes: #528588).

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
}
54
54
 
55
55
static gint seek = 0;
56
 
Tuple *xsf_tuple(gchar *filename)
 
56
Tuple *xsf_tuple(const gchar *filename)
57
57
{
58
58
        Tuple *t;
59
59
        corlett_t *c;
66
66
                return NULL;
67
67
 
68
68
        if (corlett_decode(buf, sz, NULL, NULL, &c) != AO_SUCCESS)
69
 
                return NULL;    
 
69
                return NULL;
70
70
 
71
71
        t = aud_tuple_new_from_filename(filename);
72
72
 
77
77
        aud_tuple_associate_string(t, FIELD_TITLE, NULL, c->inf_title);
78
78
        aud_tuple_associate_string(t, FIELD_COPYRIGHT, NULL, c->inf_copy);
79
79
        aud_tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced");
80
 
        aud_tuple_associate_string(t, FIELD_CODEC, NULL, "Nintendo DS Audio");
81
 
        aud_tuple_associate_string(t, -1, "console", "Nintendo DS");
 
80
        aud_tuple_associate_string(t, FIELD_CODEC, NULL, "GBA/Nintendo DS Audio");
 
81
        aud_tuple_associate_string(t, -1, "console", "GBA/Nintendo DS");
82
82
 
83
83
        free(c);
84
84
        g_free(buf);
126
126
                free(buffer);
127
127
                return;
128
128
        }
129
 
        
 
129
 
130
130
        data->output->open_audio(FMT_S16_NE, 44100, 2);
131
131
 
132
132
        data->set_params(data, title, length, 44100*2*2*8, 44100, 2);
139
139
                while (data->playing && !seek && !data->eof)
140
140
                {
141
141
                        xsf_gen(samples, seglen);
142
 
                        xsf_update(samples, seglen * 4, data);
 
142
                        xsf_update((guint8 *)samples, seglen * 4, data);
143
143
 
144
 
                        if (data->output->output_time() > length)
 
144
                        if (data->output->written_time () > length)
145
145
                                data->eof = TRUE;
146
146
                }
147
147
 
148
148
                if (seek)
149
149
                {
150
 
                        if (seek > data->output->output_time())
 
150
                        if (seek > data->output->written_time ())
151
151
                        {
152
 
                                pos = data->output->output_time();
 
152
                                pos = data->output->written_time ();
153
153
                                while (pos < seek)
154
154
                                {
155
155
                                        xsf_gen(samples, seglen);
161
161
 
162
162
                                continue;
163
163
                        }
164
 
                        else if (seek < data->output->output_time())
 
164
                        else if (seek < data->output->written_time ())
165
165
                        {
166
166
                                data->eof = FALSE;
167
167
 
203
203
 
204
204
                xsf_term();
205
205
 
206
 
                data->output->buffer_free();
207
 
                data->output->buffer_free();
208
 
 
209
206
                while (data->eof && data->output->buffer_playing())
210
207
                        g_usleep(10000);
211
208
 
212
209
                data->output->close_audio();
213
210
 
214
211
                break;
215
 
        }       
 
212
        }
216
213
 
217
214
        g_free(buffer);
218
215
        g_free(path);
221
218
        data->playing = FALSE;
222
219
}
223
220
 
224
 
void xsf_update(unsigned char *buffer, long count, InputPlayback *playback)
 
221
void xsf_update(guint8 *buffer, long count, InputPlayback *playback)
225
222
{
226
 
        const int mask = ~((((16 / 8) * 2)) - 1);
227
 
 
228
223
        if (buffer == NULL)
229
224
        {
230
225
                playback->playing = FALSE;
233
228
                return;
234
229
        }
235
230
 
236
 
        while (count > 0)
237
 
        {
238
 
                int t = playback->output->buffer_free() & mask;
239
 
                if (t > count)
240
 
                        playback->pass_audio(playback, FMT_S16_NE, 2, count, buffer, NULL);
241
 
                else
242
 
                {
243
 
                        if (t)
244
 
                                playback->pass_audio(playback, FMT_S16_NE, 2, t, buffer, NULL);
245
 
 
246
 
                        g_usleep((count-t)*1000*5/441/2);
247
 
                }
248
 
                count -= t;
249
 
                buffer += t;
250
 
        }
 
231
        playback->output->write_audio (buffer, count);
251
232
}
252
233
 
253
234
void xsf_Stop(InputPlayback *playback)
260
241
        playback->output->pause(p);
261
242
}
262
243
 
263
 
int xsf_is_our_fd(gchar *filename, VFSFile *file)
 
244
gint xsf_is_our_fd(const gchar *filename, VFSFile *file)
264
245
{
265
246
        gchar magic[4];
266
247
        aud_vfs_fread(magic, 1, 4, file);
268
249
        if (!memcmp(magic, "PSF$", 4))
269
250
                return 1;
270
251
 
 
252
        if (!memcmp(magic, "PSF\"", 4))
 
253
                return 1;
 
254
 
271
255
        return 0;
272
256
}
273
257
 
276
260
        seek = time * 1000;
277
261
}
278
262
 
279
 
gchar *xsf_fmts[] = { "2sf", "mini2sf", NULL };
 
263
static gchar *xsf_fmts[] = { "2sf", "mini2sf", "gsf", "minigsf", NULL };
280
264
 
281
 
InputPlugin xsf_ip =
 
265
static InputPlugin xsf_ip =
282
266
{
283
 
        .description = "2SF Audio Plugin",
 
267
        .description = "GSF/2SF Audio Plugin",
284
268
        .play_file = xsf_play,
285
269
        .stop = xsf_Stop,
286
270
        .pause = xsf_pause,
290
274
        .vfs_extensions = xsf_fmts,
291
275
};
292
276
 
293
 
InputPlugin *xsf_iplist[] = { &xsf_ip, NULL };
 
277
static InputPlugin *xsf_iplist[] = { &xsf_ip, NULL };
294
278
 
295
279
DECLARE_PLUGIN(psf2, NULL, NULL, xsf_iplist, NULL, NULL, NULL, NULL, NULL);
296
280