/* libxmms-flac - XMMS FLAC input plugin
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006 Josh Coalson
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include "plugin.h"
#include <limits.h>
#include <pthread.h>
DitherContext dither_context;
} stream_data_struct;
-static void FLAC_XMMS__init();
+static void FLAC_XMMS__init(void);
static int FLAC_XMMS__is_our_file(char *filename);
static void FLAC_XMMS__play_file(char *filename);
-static void FLAC_XMMS__stop();
+static void FLAC_XMMS__stop(void);
static void FLAC_XMMS__pause(short p);
static void FLAC_XMMS__seek(int time);
-static int FLAC_XMMS__get_time();
-static void FLAC_XMMS__cleanup();
+static int FLAC_XMMS__get_time(void);
+static void FLAC_XMMS__cleanup(void);
static void FLAC_XMMS__get_song_info(char *filename, char **title, int *length);
static void *play_loop_(void *arg);
static unsigned bitrate_history_[BITRATE_HIST_SIZE];
-InputPlugin *get_iplugin_info()
+InputPlugin *get_iplugin_info(void)
{
flac_ip.description = g_strdup_printf("Reference FLAC Player v%s", FLAC__VERSION_STRING);
return &flac_ip;
}
}
-static gchar* homedir()
+static gchar* homedir(void)
{
gchar *result;
char *env_home = getenv("HOME");
return 0 == strncasecmp(source, "http://", 7);
}
-void FLAC_XMMS__init()
+void FLAC_XMMS__init(void)
{
ConfigFile *cfg;
FLAC__uint32 test = 1;
pthread_create(&decode_thread_, NULL, play_loop_, NULL);
}
-void FLAC_XMMS__stop()
+void FLAC_XMMS__stop(void)
{
if(stream_data_.is_playing) {
stream_data_.is_playing = false;
}
}
-int FLAC_XMMS__get_time()
+int FLAC_XMMS__get_time(void)
{
if(audio_error_)
return -2;
return flac_ip.output->output_time();
}
-void FLAC_XMMS__cleanup()
+void FLAC_XMMS__cleanup(void)
{
safe_decoder_delete_(decoder_);
decoder_ = 0;
if(title) {
if (!is_http_source(filename)) {
static const char *errtitle = "Invalid FLAC File: ";
- *title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1);
- sprintf(*title, "%s\"%s\"", errtitle, filename);
+ if(strlen(errtitle) + 1 + strlen(filename) + 1 + 1 < strlen(filename)) { /* overflow check */
+ *title = NULL;
+ }
+ else {
+ size_t len = strlen(errtitle) + 1 + strlen(filename) + 1 + 1;
+ *title = g_malloc(len);
+ flac_snprintf(*title, len, "%s\"%s\"", errtitle, filename);
+ }
} else {
*title = NULL;
}