diff -Nur audacious-plugin-fc-0.5.1-orig/src/configure.c audacious-plugin-fc-0.5.1/src/configure.c
--- audacious-plugin-fc-0.5.1-orig/src/configure.c 2010-06-20 19:32:39.000000000 +0200
+++ audacious-plugin-fc-0.5.1/src/configure.c 2010-07-21 16:41:23.000000000 +0200
@@ -28,7 +28,7 @@
void fc_ip_load_config()
{
- ConfigDb *cfg;
+ mcs_handle_t *cfg;
fc_myConfig.frequency = FREQ_SAMPLE_44;
fc_myConfig.precision = 8;
@@ -197,7 +197,7 @@
static void config_ok(GtkWidget * widget, gpointer data)
{
- ConfigDb *cfg;
+ mcs_handle_t *cfg;
if (GTK_TOGGLE_BUTTON(Bits16)->active)
fc_myConfig.precision = 16;
diff -Nur audacious-plugin-fc-0.5.1-orig/src/main.c audacious-plugin-fc-0.5.1/src/main.c
--- audacious-plugin-fc-0.5.1-orig/src/main.c 2010-07-10 12:46:00.000000000 +0200
+++ audacious-plugin-fc-0.5.1/src/main.c 2010-07-23 10:03:42.000000000 +0200
@@ -22,12 +22,16 @@
#include <glib.h>
#include <fc14audiodecoder.h>
+#if __AUDACIOUS_PLUGIN_API__ < 16
+#error "At least Audacious 2.4 beta1 is required."
+#endif
+
#include "config.h"
#include "configure.h"
struct audioFormat
{
- AFormat xmmsAFormat;
+ gint xmmsAFormat;
gint bits, freq, channels;
gint zeroSample;
};
@@ -54,7 +58,7 @@
unsigned char magicBuf[5];
int ret;
- if ( 5 != aud_vfs_fread(magicBuf,1,5,fd) ) {
+ if ( 5 != vfs_fread(magicBuf,1,5,fd) ) {
return 1;
}
dec = fc14dec_new();
@@ -63,11 +67,11 @@
return ret;
}
-void ip_play_file(InputPlayback *playback) {
+gboolean ip_play(InputPlayback *playback, const gchar *filename, VFSFile *fd,
+ gint start_time, gint stop_time, gboolean pause) {
void *decoder = NULL;
gpointer sampleBuf = NULL;
size_t sampleBufSize;
- VFSFile *fd;
gpointer fileBuf = NULL;
size_t fileLen;
gboolean haveModule = FALSE;
@@ -75,38 +79,34 @@
gboolean haveSampleBuf = FALSE;
struct audioFormat myFormat;
+ if (fd == NULL) {
+ return FALSE;
+ }
+
playback->playing = FALSE;
- jumpToTime = -1;
- decoder = fc14dec_new();
+ jumpToTime = (start_time > 0) ? start_time : -1;
- fd = aud_vfs_fopen(playback->filename,"rb");
- if (!fd) {
- goto PLAY_FAILURE_1;
- }
- if ( aud_vfs_fseek(fd,0,SEEK_END)!=0 ) {
- aud_vfs_fclose(fd);
- goto PLAY_FAILURE_1;
- }
- fileLen = aud_vfs_ftell(fd);
- if ( aud_vfs_fseek(fd,0,SEEK_SET)!=0 ) {
- aud_vfs_fclose(fd);
- goto PLAY_FAILURE_1;
+ if ( vfs_fseek(fd,0,SEEK_END)!=0 ) {
+ return FALSE;
+ }
+ fileLen = vfs_ftell(fd);
+ if ( vfs_fseek(fd,0,SEEK_SET)!=0 ) {
+ return FALSE;
}
fileBuf = g_malloc(fileLen);
if ( !fileBuf ) {
- aud_vfs_fclose(fd);
- goto PLAY_FAILURE_1;
+ return FALSE;
}
- if ( fileLen != aud_vfs_fread((char*)fileBuf,1,fileLen,fd) ) {
- aud_vfs_fclose(fd);
+ if ( fileLen != vfs_fread((char*)fileBuf,1,fileLen,fd) ) {
g_free(fileBuf);
- goto PLAY_FAILURE_1;
+ return FALSE;
}
- aud_vfs_fclose(fd);
+ decoder = fc14dec_new();
haveModule = fc14dec_init(decoder,fileBuf,fileLen);
g_free(fileBuf);
if ( !haveModule ) {
- goto PLAY_FAILURE_1;
+ fc14dec_delete(decoder);
+ return FALSE;
}
myFormat.freq = fc_myConfig.frequency;
@@ -159,6 +159,9 @@
while (formatList[++i].bits != 0);
}
if ( audioDriverOK ) {
+ if (pause) {
+ playback->output->pause(TRUE);
+ }
sampleBufSize = 512*(myFormat.bits/8)*myFormat.channels;
sampleBuf = g_malloc(sampleBufSize);
haveSampleBuf = (sampleBuf != NULL);
@@ -168,9 +171,9 @@
if ( haveSampleBuf && haveModule ) {
int msecSongLen = fc14dec_duration(decoder);
- Tuple *t = aud_tuple_new_from_filename( playback->filename );
- aud_tuple_associate_int(t, FIELD_LENGTH, NULL, msecSongLen);
- aud_tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced");
+ Tuple *t = tuple_new_from_filename( playback->filename );
+ tuple_associate_int(t, FIELD_LENGTH, NULL, msecSongLen);
+ tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced");
playback->set_tuple( playback, t );
/* bitrate => 4*1000 will be displayed as "4 CHANNELS" */
@@ -180,19 +183,9 @@
playback->set_pb_ready(playback);
while ( playback->playing ) {
- fc14dec_buffer_fill(decoder,sampleBuf,sampleBufSize);
- if ( playback->playing && jumpToTime<0 ) {
-#if __AUDACIOUS_PLUGIN_API__ >= 13
- playback->output->write_audio(sampleBuf,sampleBufSize);
-#else
- playback->pass_audio(playback,myFormat.xmmsAFormat,myFormat.channels,sampleBufSize,sampleBuf,NULL);
-#endif
- }
- if ( fc14dec_song_end(decoder) && jumpToTime<0 ) {
- playback->eof = TRUE;
- playback->playing = FALSE;
+ if (stop_time >= 0 && playback->output->written_time () >= stop_time) {
+ goto DRAIN;
}
-
g_mutex_lock(seek_mutex);
if ( jumpToTime != -1 ) {
fc14dec_seek(decoder,jumpToTime);
@@ -201,44 +194,94 @@
g_cond_signal(seek_cond);
}
g_mutex_unlock(seek_mutex);
+
+ fc14dec_buffer_fill(decoder,sampleBuf,sampleBufSize);
+ if ( playback->playing && jumpToTime<0 ) {
+ playback->output->write_audio(sampleBuf,sampleBufSize);
+ }
+ if ( fc14dec_song_end(decoder) && jumpToTime<0 ) {
+ playback->eof = TRUE;
+ playback->playing = FALSE;
+ DRAIN:
+ while (playback->output->buffer_playing() && playback->playing) {
+ g_usleep(20000);
+ }
+ break;
+ }
}
- playback->playing = FALSE;
- playback->output->close_audio();
}
+ CLEANUP:
+ g_mutex_lock(seek_mutex);
+ playback->playing = FALSE;
+ g_cond_signal(seek_cond); /* wake up any waiting request */
+ g_mutex_unlock(seek_mutex);
- PLAY_FAILURE_2:
+ playback->output->close_audio();
g_free(sampleBuf);
- PLAY_FAILURE_1:
fc14dec_delete(decoder);
+ return FALSE;
}
void ip_stop(InputPlayback *playback) {
- playback->playing = FALSE;
+ g_mutex_lock(seek_mutex);
+ if (playback->playing) {
+ playback->playing = FALSE;
+ playback->output->abort_write();
+ g_cond_signal(seek_cond);
+ }
+ g_mutex_unlock(seek_mutex);
}
void ip_pause(InputPlayback *playback, gshort p) {
- playback->output->pause(p);
+ g_mutex_lock(seek_mutex);
+ if (playback->playing) {
+ playback->output->pause(p);
+ }
+ g_mutex_unlock(seek_mutex);
}
void ip_mseek(InputPlayback *playback, gulong msec) {
g_mutex_lock(seek_mutex);
- jumpToTime = msec;
- g_cond_wait(seek_cond, seek_mutex);
+ if (playback->playing) {
+ jumpToTime = msec;
+ playback->output->abort_write();
+ g_cond_signal(seek_cond);
+ g_cond_wait(seek_cond, seek_mutex);
+ }
g_mutex_unlock(seek_mutex);
}
-void ip_seek(InputPlayback *playback, gint secs) {
- gulong msec = secs * 1000;
- ip_mseek(playback, msec);
-}
-
-Tuple* ip_get_song_tuple(const gchar *filename) {
- Tuple *t = aud_tuple_new_from_filename(filename);
-
- /* delay length detection to start of playback */
- aud_tuple_associate_int(t, FIELD_LENGTH, NULL, -1);
- aud_tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced");
- /* aud_tuple_associate_string(ti, FIELD_TITLE, NULL, tmp); */
+Tuple *ip_probe_for_tuple(const gchar *filename, VFSFile *fd) {
+ void *decoder = NULL;
+ gpointer fileBuf = NULL;
+ size_t fileLen;
+ Tuple *t;
+ if ( fd==NULL || vfs_fseek(fd,0,SEEK_END)!=0 ) {
+ return NULL;
+ }
+ fileLen = vfs_ftell(fd);
+ if ( vfs_fseek(fd,0,SEEK_SET)!=0 ) {
+ return NULL;
+ }
+ fileBuf = g_malloc(fileLen);
+ if ( !fileBuf ) {
+ return NULL;
+ }
+ if ( fileLen != vfs_fread((char*)fileBuf,1,fileLen,fd) ) {
+ g_free(fileBuf);
+ return NULL;
+ }
+ decoder = fc14dec_new();
+ if (fc14dec_init(decoder,fileBuf,fileLen)) {
+ t = tuple_new_from_filename(filename);
+ tuple_associate_int(t, FIELD_LENGTH, NULL, fc14dec_duration(decoder));
+ tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced");
+ }
+ else {
+ t = NULL;
+ }
+ g_free(fileBuf);
+ fc14dec_delete(decoder);
return t;
}
diff -Nur audacious-plugin-fc-0.5.1-orig/src/plugin.c audacious-plugin-fc-0.5.1/src/plugin.c
--- audacious-plugin-fc-0.5.1-orig/src/plugin.c 2010-06-20 19:00:14.000000000 +0200
+++ audacious-plugin-fc-0.5.1/src/plugin.c 2010-07-23 10:03:42.000000000 +0200
@@ -6,13 +6,14 @@
void ip_cleanup(void);
void fc_ip_about(void);
void fc_ip_configure(void);
-gint ip_is_valid_file_vfs(const gchar *fileName, VFSFile *fd);
-void ip_play_file(InputPlayback *playback);
+gint ip_is_valid_file_vfs(const gchar *filename, VFSFile *fd);
+gboolean ip_play(InputPlayback *playback, const gchar *filename, VFSFile *fd,
+ gint start_time, gint stop_time, gboolean pause);
void ip_stop(InputPlayback *playback);
void ip_pause(InputPlayback *playback, gshort p);
void ip_seek(InputPlayback *playback, gint secs);
void ip_mseek(InputPlayback *playback, gulong msec);
-Tuple* ip_get_song_tuple(const gchar *filename);
+Tuple *ip_probe_for_tuple(const gchar *filename, VFSFile *fd);
InputPlugin iplugin =
{
@@ -22,13 +23,12 @@
.configure = fc_ip_configure,
.have_subtune = FALSE,
.vfs_extensions = fc_fmts,
- .play_file = ip_play_file,
+ .play = ip_play,
.stop = ip_stop,
.pause = ip_pause,
- .seek = ip_seek,
.mseek = ip_mseek,
.cleanup = ip_cleanup,
- .get_song_tuple = ip_get_song_tuple,
+ .probe_for_tuple = ip_probe_for_tuple,
.is_our_file_from_vfs = ip_is_valid_file_vfs
};