summaryrefslogtreecommitdiffstats
path: root/media-plugins/xmms-wma/files/xmms-wma-ds-ffmpeg.patch
blob: 3ad7ceda127065b5e686205c04c5a504656a9ad9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
diff -dPNur xmms-wma-1.0.5/Makefile xmms-wma-1.0.5-new/Makefile
--- xmms-wma-1.0.5/Makefile	2004-03-03 15:47:58.000000000 +0100
+++ xmms-wma-1.0.5-new/Makefile	2007-04-21 22:51:51.000000000 +0200
@@ -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-new/Makefile.inc
--- xmms-wma-1.0.5/Makefile.inc	2005-09-05 14:48:20.000000000 +0200
+++ xmms-wma-1.0.5-new/Makefile.inc	2007-04-21 22:51:51.000000000 +0200
@@ -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-new/xmms-wma.c
--- xmms-wma-1.0.5/xmms-wma.c	2005-09-05 22:19:00.000000000 +0200
+++ xmms-wma-1.0.5-new/xmms-wma.c	2007-04-22 00:47:20.000000000 +0200
@@ -42,8 +42,9 @@
 #undef HAVE_AV_CONFIG_H
 #endif
 
-#include "avcodec.h"
-#include "avformat.h"
+#include "ffmpeg/avcodec.h"
+#include "ffmpeg/avformat.h"
+#include "ffmpeg/fifo.h"
 #include "iir.h"
 
 #define ABOUT_TXT "Copyright (C) 2004,2005 Mokrushin I.V. aka McMCC (mcmcc@mail.ru).\n \
@@ -190,8 +191,6 @@
 
 static void wma_init(void)
 {
-    avcodec_init();
-    avcodec_register_all();
     av_register_all();
     init_iir();
 }
@@ -200,9 +199,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;
 }
 
@@ -337,20 +341,21 @@
 	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)
+    av_fifo_init(&f, out_size*2);
+    av_fifo_write(&f, wma_outbuf, out_size);
+    while(!av_fifo_read(&f, wma_s_outbuf, wma_st_buff) && wma_decode)
     {
         if(wma_eq_on)
             sst_buff = iir((gpointer)&wma_s_outbuf, wma_st_buff);
@@ -364,7 +369,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 +378,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;
@@ -427,10 +443,13 @@
 #endif
     
     for(wma_idx = 0; wma_idx < ic->nb_streams; wma_idx++) {
-        c = &ic->streams[wma_idx]->codec;
+        c = ic->streams[wma_idx]->codec;
         if(c->codec_type == CODEC_TYPE_AUDIO) break;
     }
 
+    if(!c || c->codec_type != CODEC_TYPE_AUDIO)
+	    return;
+
     av_find_stream_info(ic);
 
     codec = avcodec_find_decoder(c->codec_id);
@@ -459,7 +478,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();
 }	
 
@@ -482,7 +502,7 @@
 #endif
 
     for(i = 0; i < in->nb_streams; i++) {
-        s = &in->streams[i]->codec;
+        s = in->streams[i]->codec;
         if(s->codec_type == CODEC_TYPE_AUDIO) break;
     }