diff -dPNur xmms-wma-1.0.5/Makefile xmms-wma-1.0.5-ds/Makefile --- xmms-wma-1.0.5/Makefile 2004-03-03 15:47:58.000000000 +0100 +++ xmms-wma-1.0.5-ds/Makefile 2012-11-17 08:49:25.000000000 +0100 @@ -11,7 +11,7 @@ export DEPS := $(SOURCES:%.c=$(DEPDIR)/%.d) all: - @cd ffmpeg-strip-wma; make; cd .. + #@cd ffmpeg-strip-wma; make; cd .. @$(MAKE) --no-print-directory -f Makefile.inc @strip $(PLUGIN_FILE) @echo "The plug-in has been compiled. Run one of the following:" @@ -40,5 +40,5 @@ @echo "The plug-in has been uninstalled." clean: - cd ffmpeg-strip-wma; make clean; cd .. + #cd ffmpeg-strip-wma; make clean; cd .. rm -f $(OBJECTS) $(DEPS) diff -dPNur xmms-wma-1.0.5/Makefile.inc xmms-wma-1.0.5-ds/Makefile.inc --- xmms-wma-1.0.5/Makefile.inc 2005-09-05 14:48:20.000000000 +0200 +++ xmms-wma-1.0.5-ds/Makefile.inc 2012-11-17 08:49:25.000000000 +0100 @@ -1,16 +1,18 @@ CC := gcc -CFLAGS := -O2 -ffast-math -fomit-frame-pointer -fPIC -#CFLAGS := -Wall -g -O3 -CFLAGS += -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -CFLAGS += -I ffmpeg-strip-wma -CFLAGS += `xmms-config --cflags` -LIBS := `xmms-config --libs` -L ffmpeg-strip-wma -lffwma +MYCFLAGS := $(CFLAGS) -fPIC +#MYCFLAGS := -Wall -g -O3 +MYCFLAGS += -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -fPIC +#MYCFLAGS += -I ffmpeg-strip-wma +MYCFLAGS += `xmms-config --cflags` +MYCFLAGS += -I/usr/include/ffmpeg +#LIBS := `xmms-config --libs` -L ffmpeg-strip-wma -lffwma +LIBS := `xmms-config --libs` -lavcodec -lavformat $(PLUGIN_FILE): $(OBJECTS) $(CC) -o $@ $^ $(LIBS) -shared $(OBJDIR)/%.o: %.c - $(CC) -c -o $@ $(CFLAGS) $< + $(CC) -c -o $@ $(MYCFLAGS) $< $(DEPDIR)/%.d: %.c $(CC) -MM $(CFLAGS) $< | sed "s/^$*\.o:/$(OBJDIR)\/$*\.o $(DEPDIR)\/$*\.d:/" > $@ diff -dPNur xmms-wma-1.0.5/xmms-wma.c xmms-wma-1.0.5-ds/xmms-wma.c --- xmms-wma-1.0.5/xmms-wma.c 2005-09-05 22:19:00.000000000 +0200 +++ xmms-wma-1.0.5-ds/xmms-wma.c 2012-11-17 08:40:11.000000000 +0100 @@ -36,14 +36,16 @@ #include #include #include +#include #endif #ifdef HAVE_AV_CONFIG_H #undef HAVE_AV_CONFIG_H #endif -#include "avcodec.h" -#include "avformat.h" +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +#include "libavutil/fifo.h" #include "iir.h" #define ABOUT_TXT "Copyright (C) 2004,2005 Mokrushin I.V. aka McMCC (mcmcc@mail.ru).\n \ @@ -190,8 +192,6 @@ static void wma_init(void) { - avcodec_init(); - avcodec_register_all(); av_register_all(); init_iir(); } @@ -200,9 +200,14 @@ { gchar *ext; ext = strrchr(filename, '.'); - if(ext) + if(ext) { if(!strcasecmp(ext, ".wma")) return 1; + if(!strcasecmp(ext, ".m4a")) + return 1; + if(!strcasecmp(ext, ".aac")) + return 1; + } return 0; } @@ -262,12 +267,24 @@ return splitname; } -static char* w_getstr(char* str) +static char* w_getstr(AVFormatContext *in, char* str) { - if(str && strlen(str) > 0) return str; + AVDictionaryEntry *entry = av_dict_get(in->metadata, str, NULL, 0); + if (!entry) return NULL; + + + if(entry && strlen(entry->value) > 0) { + return entry->value; + } return NULL; } +static int w_getnum(AVFormatContext *in, char* str) { + char *res = w_getstr(in, str); + if (res) return atoi(res); + return 0; +} + static gchar *get_song_title(AVFormatContext *in, gchar * filename) { gchar *ret = NULL; @@ -279,17 +296,14 @@ XMMS_NEW_TITLEINPUT(input); #endif - if((in->title[0] != '\0') || (in->author[0] != '\0') || (in->album[0] != '\0') || - (in->comment[0] != '\0') || (in->genre[0] != '\0') || (in->year != 0) || (in->track != 0)) - { - input->performer = w_getstr(in->author); - input->album_name = w_getstr(in->album); - input->track_name = w_getstr(in->title); - input->year = in->year; - input->track_number = in->track; - input->genre = w_getstr(in->genre); - input->comment = w_getstr(in->comment); - } + input->performer = w_getstr(in, "artist"); + input->album_name = w_getstr(in, "album"); + input->track_name = w_getstr(in, "title"); + input->year = 0;//in->year; + input->track_number = w_getnum(in, "track"); + input->genre = w_getstr(in, "genre"); + input->comment = w_getstr(in, "comment"); + #ifdef BMP input->file_name = g_path_get_basename(filename); input->file_path = g_path_get_dirname(filename); @@ -298,7 +312,7 @@ input->file_path = filename; #endif input->file_ext = extname(filename); - ret = xmms_get_titlestring(xmms_get_gentitle_format(), input); + ret = xmms_charset_get_titlestring(xmms_get_gentitle_format(), input, XMMS_RCC_UTF8); if(input) g_free(input); if(!ret) @@ -337,21 +351,23 @@ return; #endif - av_find_stream_info(in); - (*len_real) = get_song_time(in); - (*title_real) = get_song_title(in, filename); + if (!av_find_stream_info(in)) { + (*len_real) = get_song_time(in); + (*title_real) = get_song_title(in, filename); + } av_close_input_file(in); } - static void wma_playbuff(int out_size) { - FifoBuffer f; + AVFifoBuffer *f; int sst_buff; - - fifo_init(&f, out_size*2); - fifo_write(&f, wma_outbuf, out_size, &f.wptr); - while(!fifo_read(&f, wma_s_outbuf, wma_st_buff, &f.rptr) && wma_decode) - { + + f = av_fifo_alloc(out_size*2); + av_fifo_generic_write(f, wma_outbuf, out_size, NULL); + + while ((av_fifo_size(f) > 0) && wma_decode) { + if (av_fifo_generic_read(f, wma_s_outbuf, wma_st_buff, NULL)) break; + if(wma_eq_on) sst_buff = iir((gpointer)&wma_s_outbuf, wma_st_buff); else @@ -364,7 +380,7 @@ wma_ip.output->write_audio((short *)wma_s_outbuf, sst_buff); memset(wma_s_outbuf, 0, sst_buff); } - fifo_free(&f); + av_fifo_free(f); return; } @@ -373,18 +389,29 @@ uint8_t *inbuf_ptr; int out_size, size, len; AVPacket pkt; + int64_t seek_target; pthread_mutex_lock(&wma_mutex); while(wma_decode){ - if(wma_seekpos != -1) { - av_seek_frame(ic, wma_idx, wma_seekpos * 1000000LL); + if (wma_idx>=0) { + seek_target = av_rescale_q(wma_seekpos * 1000000LL, AV_TIME_BASE_Q, ic->streams[wma_idx]->time_base); + } else { + seek_target = wma_seekpos * 1000000LL; + } + av_seek_frame(ic, wma_idx, seek_target, AVSEEK_FLAG_BACKWARD); wma_ip.output->flush(wma_seekpos * 1000); wma_seekpos = -1; } - if(av_read_frame(ic, &pkt) < 0) break; + if(av_read_frame(ic, &pkt) < 0) { + /*if (url_ferror(&ic->pb) == 0) { + usleep(100000); + continue; + }*/ + break; + } size = pkt.size; inbuf_ptr = pkt.data; @@ -392,8 +419,9 @@ if(size == 0) break; while(size > 0){ - len = avcodec_decode_audio(c, (short *)wma_outbuf, &out_size, - inbuf_ptr, size); + out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; + + len = avcodec_decode_audio3(c, (short *)wma_outbuf, &out_size, &pkt); if(len < 0) break; if(out_size <= 0) continue; @@ -427,10 +455,13 @@ #endif for(wma_idx = 0; wma_idx < ic->nb_streams; wma_idx++) { - c = &ic->streams[wma_idx]->codec; - if(c->codec_type == CODEC_TYPE_AUDIO) break; + c = ic->streams[wma_idx]->codec; + if(c->codec_type == AVMEDIA_TYPE_AUDIO) break; } + if(!c || c->codec_type != AVMEDIA_TYPE_AUDIO) + return; + av_find_stream_info(ic); codec = avcodec_find_decoder(c->codec_id); @@ -459,7 +490,8 @@ { wma_decode = 0; if(wma_pause) wma_do_pause(0); - pthread_join(wma_decode_thread, NULL); + if(wma_decode_thread) + pthread_join(wma_decode_thread, NULL); wma_ip.output->close_audio(); } @@ -468,6 +500,8 @@ char *title; char *tmp; char *message; + char *recoded; + char *msg; AVFormatContext *in = NULL; AVCodecContext *s = NULL; AVCodec *codec; @@ -482,8 +516,8 @@ #endif for(i = 0; i < in->nb_streams; i++) { - s = &in->streams[i]->codec; - if(s->codec_type == CODEC_TYPE_AUDIO) break; + s = in->streams[i]->codec; + if(s->codec_type == AVMEDIA_TYPE_AUDIO) break; } av_find_stream_info(in); @@ -498,6 +532,11 @@ strcpy(message, "\n\n\n"); strcat(message, "File Name: "); + recoded = xmms_rcc_recode(XMMS_RCC_FS, XMMS_RCC_OUT, slashkill(filename)); + if (recoded) { + strcat(message, recoded); + free(recoded); + } else strcat(message, slashkill(filename)); strcat(message, "\n\n"); strcat(message, "Audio Info:\n"); @@ -535,56 +574,85 @@ } strcat(message, "\n"); strcat(message, "Text Info:\n"); - if (in->title[0] != '\0') + msg = w_getstr(in, "title"); + if (msg) { strcat(message, "Title: "); - strcat(message, in->title); + recoded = xmms_rcc_recode(XMMS_RCC_UTF8, XMMS_RCC_OUT, msg); + if (recoded) { + strcat(message, recoded); + free(recoded); + } else + strcat(message, msg); strcat(message, "\n"); - } - if (in->author[0] != '\0') + } + msg = w_getstr(in, "artist"); + if (msg) { strcat(message, "Author: "); - strcat(message, in->author); + recoded = xmms_rcc_recode(XMMS_RCC_UTF8, XMMS_RCC_OUT, msg); + if (recoded) { + strcat(message, recoded); + free(recoded); + } else + strcat(message, msg); strcat(message, "\n"); } - if (in->album[0] != '\0') + msg = w_getstr(in, "album"); + if (msg) { strcat(message, "Album: "); - strcat(message, in->album); + recoded = xmms_rcc_recode(XMMS_RCC_UTF8, XMMS_RCC_OUT, msg); + if (recoded) { + strcat(message, recoded); + free(recoded); + } else + strcat(message, msg); strcat(message, "\n"); } - if (in->year != 0) + msg = w_getstr(in, "date"); + if (msg) { - strcat(message, "Year: "); - sprintf(tmp, "%d", in->year); - strcat(message, tmp); - memset(tmp, 0, 256); + strcat(message, "Date: "); + strcat(message, msg); strcat(message, "\n"); } - if (in->track != 0) + msg = w_getstr(in, "track"); + if (msg) { strcat(message, "Track: "); - sprintf(tmp, "%d", in->track); - strcat(message, tmp); - memset(tmp, 0, 256); + strcat(message, msg); strcat(message, "\n"); } - if (in->genre[0] != '\0') + msg = w_getstr(in, "genre"); + if (msg) { strcat(message, "Genre: "); - strcat(message, in->genre); + strcat(message, msg); strcat(message, "\n"); } - if (in->comment[0] != '\0') + msg = w_getstr(in, "comment"); + if (msg) { strcat(message, "Comments: "); - strcat(message, in->comment); + recoded = xmms_rcc_recode(XMMS_RCC_UTF8, XMMS_RCC_OUT, msg); + if (recoded) { + strcat(message, recoded); + free(recoded); + } else + strcat(message, msg); strcat(message, "\n"); } - if (in->copyright[0] != '\0') + msg = w_getstr(in, "copyright"); + if (msg) { strcat(message, "Copyright: "); - strcat(message, in->copyright); + recoded = xmms_rcc_recode(XMMS_RCC_UTF8, XMMS_RCC_OUT, msg); + if (recoded) { + strcat(message, recoded); + free(recoded); + } else + strcat(message, msg); strcat(message, "\n"); } strcat(message, "\n\n");