diff --git a/audacious-plugin-fc-0.5.1-plugin-api16.patch b/audacious-plugin-fc-0.5.1-plugin-api16.patch index 710fc38..39e1ff6 100644 --- a/audacious-plugin-fc-0.5.1-plugin-api16.patch +++ b/audacious-plugin-fc-0.5.1-plugin-api16.patch @@ -21,8 +21,17 @@ diff -Nur audacious-plugin-fc-0.5.1-orig/src/configure.c audacious-plugin-fc-0.5 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-21 16:41:08.000000000 +0200 -@@ -27,7 +27,7 @@ ++++ audacious-plugin-fc-0.5.1/src/main.c 2010-07-23 10:03:42.000000000 +0200 +@@ -22,12 +22,16 @@ + #include + #include + ++#if __AUDACIOUS_PLUGIN_API__ < 16 ++#error "At least Audacious 2.4 beta1 is required." ++#endif ++ + #include "config.h" + #include "configure.h" struct audioFormat { @@ -31,7 +40,7 @@ diff -Nur audacious-plugin-fc-0.5.1-orig/src/main.c audacious-plugin-fc-0.5.1/sr gint bits, freq, channels; gint zeroSample; }; -@@ -54,7 +54,7 @@ +@@ -54,7 +58,7 @@ unsigned char magicBuf[5]; int ret; @@ -40,48 +49,87 @@ diff -Nur audacious-plugin-fc-0.5.1-orig/src/main.c audacious-plugin-fc-0.5.1/sr return 1; } dec = fc14dec_new(); -@@ -79,30 +79,30 @@ - jumpToTime = -1; - decoder = 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"); -+ fd = vfs_fopen(playback->filename,"rb"); - if (!fd) { - goto PLAY_FAILURE_1; - } +- if (!fd) { +- goto PLAY_FAILURE_1; +- } - if ( aud_vfs_fseek(fd,0,SEEK_END)!=0 ) { - aud_vfs_fclose(fd); -+ if ( vfs_fseek(fd,0,SEEK_END)!=0 ) { -+ vfs_fclose(fd); - goto PLAY_FAILURE_1; - } +- 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 ) { -+ vfs_fclose(fd); - goto PLAY_FAILURE_1; ++ return FALSE; } fileBuf = g_malloc(fileLen); if ( !fileBuf ) { - aud_vfs_fclose(fd); -+ vfs_fclose(fd); - goto PLAY_FAILURE_1; +- 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) ) { -+ vfs_fclose(fd); g_free(fileBuf); - goto PLAY_FAILURE_1; +- goto PLAY_FAILURE_1; ++ return FALSE; } - aud_vfs_fclose(fd); -+ vfs_fclose(fd); ++ decoder = fc14dec_new(); haveModule = fc14dec_init(decoder,fileBuf,fileLen); g_free(fileBuf); if ( !haveModule ) { -@@ -168,9 +168,9 @@ +- 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); @@ -94,18 +142,177 @@ diff -Nur audacious-plugin-fc-0.5.1-orig/src/main.c audacious-plugin-fc-0.5.1/sr playback->set_tuple( playback, t ); /* bitrate => 4*1000 will be displayed as "4 CHANNELS" */ -@@ -233,11 +233,11 @@ +@@ -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); } - Tuple* ip_get_song_tuple(const gchar *filename) { -- Tuple *t = aud_tuple_new_from_filename(filename); -+ Tuple *t = tuple_new_from_filename(filename); + 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); + } - /* delay length detection to start of playback */ +-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"); -+ tuple_associate_int(t, FIELD_LENGTH, NULL, -1); -+ tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced"); - /* aud_tuple_associate_string(ti, FIELD_TITLE, NULL, tmp); */ +- /* 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 + }; + diff --git a/audacious-plugin-fc.spec b/audacious-plugin-fc.spec index 7a8548a..5c574af 100644 --- a/audacious-plugin-fc.spec +++ b/audacious-plugin-fc.spec @@ -7,7 +7,7 @@ Summary: Future Composer input plugin for Audacious Name: audacious-plugin-fc Version: 0.5.1 -Release: 3%{?dist} +Release: 4%{?dist} URL: http://xmms-fc.sourceforge.net/ License: GPLv2+ Source: http://downloads.sourceforge.net/xmms-fc/audacious-plugin-fc-%{version}.tar.bz2 @@ -54,6 +54,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Jul 23 2010 Michael Schwendt - 0.5.1-4 +- Larger patch, also to remove deprecated API usage. + * Wed Jul 21 2010 Michael Schwendt - 0.5.1-3 - Patch and rebuild for Audacious 2.4 beta1 generic plugin API/ABI bump.