Mercurial > mplayer.hg
annotate libmpdemux/demux_xmms.c @ 21221:7124c26f3db3
Add generic target that allow compiling without any assembler or otherwise
architecture specific code (except endiannes of course).
Usage example: ./configure --target=generic-linux
author | reimar |
---|---|
date | Sat, 25 Nov 2006 17:58:33 +0000 |
parents | 83c3afeab35d |
children | 02333de881a7 |
rev | line source |
---|---|
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
1 // This is not reentrant because of global static variables, but most of |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
2 // the plugins are not reentrant either perhaps |
8528 | 3 #include "config.h" |
4 | |
5 #include <stdlib.h> | |
6 #include <stdio.h> | |
7 #include <unistd.h> | |
8 #include <pthread.h> | |
9 #include <dlfcn.h> | |
10 #include <dirent.h> | |
11 #include <inttypes.h> | |
8623
440301fef3fe
Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents:
8611
diff
changeset
|
12 #include <string.h> |
440301fef3fe
Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents:
8611
diff
changeset
|
13 #include <sys/stat.h> |
8528 | 14 |
17012 | 15 #include "m_option.h" |
16 #include "libaf/af_format.h" | |
8528 | 17 #include "stream.h" |
18 #include "demuxer.h" | |
19 #include "stheader.h" | |
20 | |
18176
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
21 #include "mp_msg.h" |
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
22 #include "help_mp.h" |
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
23 |
8528 | 24 #define XMMS_PACKETSIZE 65536 // some plugins won't play if this is too small |
25 | |
26 #include "demux_xmms_plugin.h" | |
27 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
28 typedef struct { |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
29 uint64_t spos; // stream position in number of output bytes from 00:00:00 |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
30 InputPlugin* ip; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
31 } xmms_priv_t; |
8528 | 32 |
33 static pthread_mutex_t xmms_mutex; | |
34 static int format = 0x1; // Raw PCM | |
35 static char xmms_audiobuffer[XMMS_PACKETSIZE]; | |
36 static uint32_t xmms_channels; | |
37 static uint32_t xmms_samplerate; | |
38 static uint32_t xmms_afmt; | |
39 static int xmms_length; | |
40 static char *xmms_title=NULL; | |
41 static uint32_t xmms_audiopos=0; | |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
42 static int xmms_playing=0; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
43 static xmms_priv_t *xmms_priv=NULL; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
44 static uint32_t xmms_byterate; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
45 static int64_t xmms_flushto=-1; |
8528 | 46 |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
47 // =========== mplayer xmms outputplugin stuff ============== |
8528 | 48 |
49 static void disk_close(void) {} | |
50 static void disk_pause(short p) {} | |
51 static void disk_init(void) {} | |
52 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
53 static void disk_flush(int time) { |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
54 if (xmms_priv) xmms_flushto=time*((long long) xmms_byterate)/1000LL; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
55 } |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
56 |
8528 | 57 static int disk_free(void) { // vqf plugin sends more than it should |
58 return (XMMS_PACKETSIZE-xmms_audiopos<XMMS_PACKETSIZE/4 ? 0:XMMS_PACKETSIZE-xmms_audiopos-XMMS_PACKETSIZE/4); | |
59 } | |
60 | |
61 static int disk_playing(void) { | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
62 return 0; //?? maybe plugins wait on exit until oplugin is not playing? |
8528 | 63 } |
64 | |
65 static int disk_get_output_time(void) { | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
66 if (xmms_byterate) |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
67 return xmms_priv->spos*1000LL/((long long)xmms_byterate); |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
68 else return 0; |
8528 | 69 } |
70 | |
71 static int disk_open(AFormat fmt, int rate, int nch) { | |
72 switch (fmt) { | |
73 case FMT_U8: | |
14248 | 74 xmms_afmt=AF_FORMAT_U8; |
8528 | 75 break; |
76 case FMT_S8: | |
14248 | 77 xmms_afmt=AF_FORMAT_S8; |
8528 | 78 break; |
79 case FMT_U16_LE: | |
14248 | 80 xmms_afmt=AF_FORMAT_U16_LE; |
8528 | 81 break; |
82 case FMT_U16_NE: | |
83 #if WORDS_BIGENDIAN | |
14248 | 84 xmms_afmt=AF_FORMAT_U16_BE; |
8528 | 85 #else |
14248 | 86 xmms_afmt=AF_FORMAT_U16_LE; |
8528 | 87 #endif |
88 break; | |
89 case FMT_U16_BE: | |
14248 | 90 xmms_afmt=AF_FORMAT_U16_BE; |
8528 | 91 break; |
92 case FMT_S16_NE: | |
14248 | 93 xmms_afmt=AF_FORMAT_S16_NE; |
8528 | 94 break; |
95 case FMT_S16_LE: | |
14248 | 96 xmms_afmt=AF_FORMAT_S16_LE; |
8528 | 97 break; |
98 case FMT_S16_BE: | |
14248 | 99 xmms_afmt=AF_FORMAT_S16_BE; |
8528 | 100 break; |
101 } | |
102 xmms_samplerate=rate; | |
103 xmms_channels=nch; | |
104 return 1; | |
105 } | |
106 | |
107 static void disk_write(void *ptr, int length) { | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
108 if (!xmms_playing) return; |
8528 | 109 pthread_mutex_lock(&xmms_mutex); |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
110 if (xmms_flushto!=-1) { |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
111 xmms_priv->spos=xmms_flushto; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
112 xmms_flushto=-1; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
113 xmms_audiopos=0; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
114 } |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
115 xmms_priv->spos+= length; |
8528 | 116 memcpy(&xmms_audiobuffer[xmms_audiopos],ptr,length); |
117 xmms_audiopos+=length; | |
118 pthread_mutex_unlock(&xmms_mutex); | |
119 } | |
120 | |
121 static OutputPlugin xmms_output_plugin = | |
122 { | |
123 NULL, | |
124 NULL, | |
12860 | 125 "MPlayer output interface plugin ", /* Description */ |
8528 | 126 disk_init, |
127 NULL, /* about */ | |
128 NULL, /* configure */ | |
129 NULL, /* get_volume */ | |
130 NULL, /* set_volume */ | |
131 disk_open, | |
132 disk_write, | |
133 disk_close, | |
134 disk_flush, | |
135 disk_pause, | |
136 disk_free, | |
137 disk_playing, | |
138 disk_get_output_time, | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
139 disk_get_output_time //we pretend that everything written is played at once |
8528 | 140 }; |
141 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
142 // ==================== mplayer xmms inputplugin helper stuff ================= |
8528 | 143 |
144 static InputPlugin* input_plugins[100]; | |
145 static int no_plugins=0; | |
146 | |
147 /* Dummy functions */ | |
10211
4bc481804519
warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
alex
parents:
9211
diff
changeset
|
148 static InputVisType input_get_vis_type(){return 0;} |
8528 | 149 static void input_add_vis_pcm(int time, AFormat fmt, int nch, int length, void *ptr){} |
150 static void input_set_info_text(char * text){} | |
9211 | 151 char *xmms_get_gentitle_format(){ return ""; } |
8528 | 152 /* Dummy functions END*/ |
153 | |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
154 static void input_set_info(char* title,int length, int rate, int freq, int nch){ |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
155 xmms_length=length; |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
156 } |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
157 |
8528 | 158 static void init_plugins(){ |
159 DIR *dir; | |
160 struct dirent *ent; | |
161 | |
162 no_plugins=0; | |
163 | |
164 dir = opendir(XMMS_INPUT_PLUGIN_DIR); | |
165 if (!dir) return; | |
166 | |
167 while ((ent = readdir(dir)) != NULL){ | |
168 char filename[strlen(XMMS_INPUT_PLUGIN_DIR)+strlen(ent->d_name)+4]; | |
169 void* handle; | |
170 sprintf(filename,XMMS_INPUT_PLUGIN_DIR "/%s",ent->d_name); | |
171 handle=dlopen(filename, RTLD_NOW); | |
172 if(handle){ | |
173 void *(*gpi) (void); | |
174 gpi=dlsym(handle, "get_iplugin_info"); | |
175 if(gpi){ | |
176 InputPlugin *p=gpi(); | |
18176
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
177 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_XMMS_FoundPlugin,ent->d_name,p->description); |
8528 | 178 p->handle = handle; |
179 p->filename = strdup(filename); | |
180 p->get_vis_type = input_get_vis_type; | |
181 p->add_vis_pcm = input_add_vis_pcm; | |
182 p->set_info = input_set_info; | |
183 p->set_info_text = input_set_info_text; | |
184 if(p->init) p->init(); | |
185 input_plugins[no_plugins++]=p; | |
186 } else | |
187 dlclose(handle); | |
188 } | |
189 } | |
190 closedir(dir); | |
191 } | |
192 | |
193 static void cleanup_plugins(){ | |
194 while(no_plugins>0){ | |
195 --no_plugins; | |
18176
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
196 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_XMMS_ClosingPlugin,input_plugins[no_plugins]->filename); |
8528 | 197 if(input_plugins[no_plugins]->cleanup) |
198 input_plugins[no_plugins]->cleanup(); | |
199 dlclose(input_plugins[no_plugins]->handle); | |
200 } | |
201 } | |
202 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
203 // ============================ mplayer demuxer stuff =============== |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
204 |
16175 | 205 static int demux_xmms_open(demuxer_t* demuxer) { |
8528 | 206 InputPlugin* ip = NULL; |
207 sh_audio_t* sh_audio; | |
208 WAVEFORMATEX* w; | |
209 xmms_priv_t *priv; | |
210 int i; | |
211 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
212 if (xmms_priv) return 0; // as I said, it's not reentrant :) |
8528 | 213 init_plugins(); |
214 for(i=0;i<no_plugins;i++){ | |
215 if (input_plugins[i]->is_our_file(demuxer->stream->url)){ | |
216 ip=input_plugins[i]; break; | |
217 } | |
218 } | |
219 if(!ip) return 0; // no plugin to handle this... | |
220 | |
221 pthread_mutex_init(&xmms_mutex,NULL); | |
222 | |
19062
83c3afeab35d
drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents:
18710
diff
changeset
|
223 xmms_priv=priv=malloc(sizeof(xmms_priv_t)); |
8528 | 224 memset(priv,0,sizeof(xmms_priv_t)); |
225 priv->ip=ip; | |
226 | |
227 memset(xmms_audiobuffer,0,XMMS_PACKETSIZE); | |
228 | |
229 xmms_channels=0; | |
230 sh_audio = new_sh_audio(demuxer,0); | |
19062
83c3afeab35d
drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents:
18710
diff
changeset
|
231 sh_audio->wf = w = malloc(sizeof(WAVEFORMATEX)); |
8528 | 232 w->wFormatTag = sh_audio->format = format; |
233 | |
234 demuxer->movi_start = 0; | |
235 demuxer->movi_end = 100; | |
236 demuxer->audio->id = 0; | |
237 demuxer->audio->sh = sh_audio; | |
238 demuxer->priv=priv; | |
239 sh_audio->ds = demuxer->audio; | |
240 | |
241 xmms_output_plugin.init(); | |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
242 ip->output = &xmms_output_plugin; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
243 xmms_playing=1; |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
244 ip->play_file(demuxer->stream->url); |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
245 if (ip->get_song_info) ip->get_song_info(demuxer->stream->url,&xmms_title,&xmms_length); |
8528 | 246 if (xmms_length<=0) demuxer->seekable=0; |
247 | |
248 mp_msg(MSGT_DEMUX,MSGL_INFO,"Waiting for the XMMS plugin to start playback of '%s'...\n",demuxer->stream->url); | |
249 while (xmms_channels==0) { | |
250 usleep(10000); | |
251 if(ip->get_time()<0) return 0; | |
252 } | |
253 sh_audio->sample_format= xmms_afmt; | |
254 switch (xmms_afmt) { | |
14248 | 255 case AF_FORMAT_S16_LE: |
256 case AF_FORMAT_S16_BE: | |
257 case AF_FORMAT_U16_LE: | |
258 case AF_FORMAT_U16_BE: | |
8528 | 259 sh_audio->samplesize = 2; |
260 break; | |
261 default: | |
262 sh_audio->samplesize = 1; | |
263 } | |
264 w->wBitsPerSample = sh_audio->samplesize*8; | |
265 w->nChannels = sh_audio->channels = xmms_channels; | |
266 w->nSamplesPerSec = sh_audio->samplerate = xmms_samplerate; | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
267 xmms_byterate = w->nAvgBytesPerSec = xmms_samplerate*sh_audio->channels*sh_audio->samplesize; |
8528 | 268 w->nBlockAlign = sh_audio->samplesize*sh_audio->channels; |
269 w->cbSize = 0; | |
270 | |
16175 | 271 return DEMUXER_TYPE_XMMS; |
8528 | 272 } |
273 | |
16175 | 274 static int demux_xmms_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) { |
8528 | 275 sh_audio_t *sh_audio = demuxer->audio->sh; |
276 xmms_priv_t *priv=demuxer->priv; | |
277 demux_packet_t* dp; | |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
278 |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
279 if (xmms_length<=0) demuxer->seekable=0; |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
280 else demuxer->seekable=1; |
8528 | 281 |
282 while (xmms_audiopos<XMMS_PACKETSIZE/2) { | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
283 if((priv->ip->get_time()<0) || !xmms_playing) |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
284 return 0; |
8528 | 285 usleep(1000); |
286 } | |
287 | |
288 pthread_mutex_lock(&xmms_mutex); | |
289 dp = new_demux_packet(XMMS_PACKETSIZE/2); | |
18710
c528c6c518f1
Clean up audio pts handling, make audio pts tracking in the audio-only
uau
parents:
18176
diff
changeset
|
290 dp->pts = priv->spos / sh_audio->wf->nAvgBytesPerSec; |
8528 | 291 ds->pos = priv->spos; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
292 |
8528 | 293 memcpy(dp->buffer,xmms_audiobuffer,XMMS_PACKETSIZE/2); |
294 memcpy(xmms_audiobuffer,&xmms_audiobuffer[XMMS_PACKETSIZE/2],xmms_audiopos-XMMS_PACKETSIZE/2); | |
295 xmms_audiopos-=XMMS_PACKETSIZE/2; | |
296 pthread_mutex_unlock(&xmms_mutex); | |
297 | |
298 ds_add_packet(ds,dp); | |
299 | |
300 return 1; | |
301 } | |
302 | |
17636 | 303 static void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){ |
8528 | 304 stream_t* s = demuxer->stream; |
305 sh_audio_t* sh_audio = demuxer->audio->sh; | |
306 xmms_priv_t *priv=demuxer->priv; | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
307 int32_t pos; |
8528 | 308 |
309 if(priv->ip->get_time()<0) return; | |
310 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
311 pos = (flags & 1) ? 0 : priv->spos / sh_audio->wf->nAvgBytesPerSec; |
8528 | 312 if (flags & 2) |
313 pos+= rel_seek_secs*xmms_length; | |
314 else | |
315 pos+= rel_seek_secs; | |
316 | |
317 if (pos<0) pos=0; | |
318 if (pos>=xmms_length) pos=xmms_length-1; | |
319 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
320 priv->ip->seek((pos<0)?0:pos); |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
321 priv->spos=pos * sh_audio->wf->nAvgBytesPerSec; |
8528 | 322 } |
323 | |
16175 | 324 static void demux_close_xmms(demuxer_t* demuxer) { |
8528 | 325 xmms_priv_t *priv=demuxer->priv; |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
326 xmms_playing=0; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
327 xmms_audiopos=0; // xmp on exit waits until buffer is free enough |
8611
668161e96ab9
The patch fixes a nullpointer dereference and free of NULL in demux_close_xmms
arpi
parents:
8542
diff
changeset
|
328 if (priv != NULL) { |
668161e96ab9
The patch fixes a nullpointer dereference and free of NULL in demux_close_xmms
arpi
parents:
8542
diff
changeset
|
329 if (priv->ip != NULL) |
668161e96ab9
The patch fixes a nullpointer dereference and free of NULL in demux_close_xmms
arpi
parents:
8542
diff
changeset
|
330 priv->ip->stop(); |
668161e96ab9
The patch fixes a nullpointer dereference and free of NULL in demux_close_xmms
arpi
parents:
8542
diff
changeset
|
331 free(priv); xmms_priv=demuxer->priv=NULL; |
668161e96ab9
The patch fixes a nullpointer dereference and free of NULL in demux_close_xmms
arpi
parents:
8542
diff
changeset
|
332 } |
8528 | 333 cleanup_plugins(); |
334 } | |
335 | |
16175 | 336 static int demux_xmms_control(demuxer_t *demuxer,int cmd, void *arg){ |
8528 | 337 demux_stream_t *d_video=demuxer->video; |
338 sh_audio_t *sh_audio=demuxer->audio->sh; | |
339 xmms_priv_t *priv=demuxer->priv; | |
340 | |
341 switch(cmd) { | |
342 case DEMUXER_CTRL_GET_TIME_LENGTH: | |
343 if (xmms_length<=0) return DEMUXER_CTRL_DONTKNOW; | |
16346
6ff303d2876b
Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents:
16175
diff
changeset
|
344 *((double *)arg)=(double)xmms_length/1000; |
8528 | 345 return DEMUXER_CTRL_GUESS; |
346 | |
347 case DEMUXER_CTRL_GET_PERCENT_POS: | |
348 if (xmms_length<=0) | |
349 return DEMUXER_CTRL_DONTKNOW; | |
350 *((int *)arg)=(int)( priv->spos / (float)(sh_audio->wf->nAvgBytesPerSec) / xmms_length ); | |
351 return DEMUXER_CTRL_OK; | |
352 | |
353 default: | |
354 return DEMUXER_CTRL_NOTIMPL; | |
355 } | |
356 } | |
16175 | 357 |
358 | |
359 demuxer_desc_t demuxer_desc_xmms = { | |
360 "XMMS demuxer", | |
361 "xmms", | |
362 "XMMS", | |
363 "?", | |
364 "requires XMMS plugins", | |
365 DEMUXER_TYPE_XMMS, | |
366 0, // safe autodetect | |
367 demux_xmms_open, | |
368 demux_xmms_fill_buffer, | |
369 NULL, | |
370 demux_close_xmms, | |
371 demux_xmms_seek, | |
372 demux_xmms_control | |
373 }; |