Mercurial > mplayer.hg
annotate libmpdemux/demux_xmms.c @ 11619:179138947307
This patch contains bugfixes for the esd audio output driver that I
uncovered while trying to send sound to a remote esd server over a
wireless (11 mbs, just enough to handle to sound) link.
First, the sound was full "ticking" sounds. I found a bug that
prevented the "send the remainder of this block" code from ever being
called - so large chunks of audio were simply being ignored. Fixing
this bug removed the "ticking" from audio streams.
Fixing this bug, however, uncovered another problem - when the socket
buffer was full, doing a blocking write to finish the buffer would take
far too long and would turn video into a chunky mess. I'd imagine this
blocking write would be fine for an audio-only stream, but it turns out
to hold up the video far too much.
The solution in this patch is to write as much data as possible to the
socket, and then return as soon as possible, reporting the number of
bytes actually written accurately back to mplayer. I've tested it on
both local and remote esd servers, and it works well.
Patch by Benjamin Osheroff <ben@gimbo.net>
author | attila |
---|---|
date | Wed, 10 Dec 2003 12:19:13 +0000 |
parents | 57bdcdb061d7 |
children | 03d3ab9f6400 |
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 |
10594
57bdcdb061d7
Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents:
10211
diff
changeset
|
15 #include "../m_option.h" |
8528 | 16 #include "../libao2/afmt.h" |
17 #include "stream.h" | |
18 #include "demuxer.h" | |
19 #include "stheader.h" | |
20 | |
21 #define XMMS_PACKETSIZE 65536 // some plugins won't play if this is too small | |
22 | |
23 #include "demux_xmms_plugin.h" | |
24 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
25 typedef struct { |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
26 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
|
27 InputPlugin* ip; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
28 } xmms_priv_t; |
8528 | 29 |
30 static pthread_mutex_t xmms_mutex; | |
31 static int format = 0x1; // Raw PCM | |
32 static char xmms_audiobuffer[XMMS_PACKETSIZE]; | |
33 static uint32_t xmms_channels; | |
34 static uint32_t xmms_samplerate; | |
35 static uint32_t xmms_afmt; | |
36 static int xmms_length; | |
37 static char *xmms_title=NULL; | |
38 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
|
39 static int xmms_playing=0; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
40 static xmms_priv_t *xmms_priv=NULL; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
41 static uint32_t xmms_byterate; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
42 static int64_t xmms_flushto=-1; |
8528 | 43 |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
44 // =========== mplayer xmms outputplugin stuff ============== |
8528 | 45 |
46 static void disk_close(void) {} | |
47 static void disk_pause(short p) {} | |
48 static void disk_init(void) {} | |
49 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
50 static void disk_flush(int time) { |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
51 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
|
52 } |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
53 |
8528 | 54 static int disk_free(void) { // vqf plugin sends more than it should |
55 return (XMMS_PACKETSIZE-xmms_audiopos<XMMS_PACKETSIZE/4 ? 0:XMMS_PACKETSIZE-xmms_audiopos-XMMS_PACKETSIZE/4); | |
56 } | |
57 | |
58 static int disk_playing(void) { | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
59 return 0; //?? maybe plugins wait on exit until oplugin is not playing? |
8528 | 60 } |
61 | |
62 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
|
63 if (xmms_byterate) |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
64 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
|
65 else return 0; |
8528 | 66 } |
67 | |
68 static int disk_open(AFormat fmt, int rate, int nch) { | |
69 switch (fmt) { | |
70 case FMT_U8: | |
71 xmms_afmt=AFMT_U8; | |
72 break; | |
73 case FMT_S8: | |
74 xmms_afmt=AFMT_S8; | |
75 break; | |
76 case FMT_U16_LE: | |
77 xmms_afmt=AFMT_U16_LE; | |
78 break; | |
79 case FMT_U16_NE: | |
80 #if WORDS_BIGENDIAN | |
81 xmms_afmt=AFMT_U16_BE; | |
82 #else | |
83 xmms_afmt=AFMT_U16_LE; | |
84 #endif | |
85 break; | |
86 case FMT_U16_BE: | |
87 xmms_afmt=AFMT_U16_BE; | |
88 break; | |
89 case FMT_S16_NE: | |
90 xmms_afmt=AFMT_S16_NE; | |
91 break; | |
92 case FMT_S16_LE: | |
93 xmms_afmt=AFMT_S16_LE; | |
94 break; | |
95 case FMT_S16_BE: | |
96 xmms_afmt=AFMT_S16_BE; | |
97 break; | |
98 } | |
99 xmms_samplerate=rate; | |
100 xmms_channels=nch; | |
101 return 1; | |
102 } | |
103 | |
104 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
|
105 if (!xmms_playing) return; |
8528 | 106 pthread_mutex_lock(&xmms_mutex); |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
107 if (xmms_flushto!=-1) { |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
108 xmms_priv->spos=xmms_flushto; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
109 xmms_flushto=-1; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
110 xmms_audiopos=0; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
111 } |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
112 xmms_priv->spos+= length; |
8528 | 113 memcpy(&xmms_audiobuffer[xmms_audiopos],ptr,length); |
114 xmms_audiopos+=length; | |
115 pthread_mutex_unlock(&xmms_mutex); | |
116 } | |
117 | |
118 static OutputPlugin xmms_output_plugin = | |
119 { | |
120 NULL, | |
121 NULL, | |
122 "Mplayer output interface Plugin ", /* Description */ | |
123 disk_init, | |
124 NULL, /* about */ | |
125 NULL, /* configure */ | |
126 NULL, /* get_volume */ | |
127 NULL, /* set_volume */ | |
128 disk_open, | |
129 disk_write, | |
130 disk_close, | |
131 disk_flush, | |
132 disk_pause, | |
133 disk_free, | |
134 disk_playing, | |
135 disk_get_output_time, | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
136 disk_get_output_time //we pretend that everything written is played at once |
8528 | 137 }; |
138 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
139 // ==================== mplayer xmms inputplugin helper stuff ================= |
8528 | 140 |
141 static InputPlugin* input_plugins[100]; | |
142 static int no_plugins=0; | |
143 | |
144 /* Dummy functions */ | |
10211
4bc481804519
warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
alex
parents:
9211
diff
changeset
|
145 static InputVisType input_get_vis_type(){return 0;} |
8528 | 146 static void input_add_vis_pcm(int time, AFormat fmt, int nch, int length, void *ptr){} |
147 static void input_set_info_text(char * text){} | |
9211 | 148 char *xmms_get_gentitle_format(){ return ""; } |
8528 | 149 /* Dummy functions END*/ |
150 | |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
151 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
|
152 xmms_length=length; |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
153 } |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
154 |
8528 | 155 static void init_plugins(){ |
156 DIR *dir; | |
157 struct dirent *ent; | |
158 | |
159 no_plugins=0; | |
160 | |
161 dir = opendir(XMMS_INPUT_PLUGIN_DIR); | |
162 if (!dir) return; | |
163 | |
164 while ((ent = readdir(dir)) != NULL){ | |
165 char filename[strlen(XMMS_INPUT_PLUGIN_DIR)+strlen(ent->d_name)+4]; | |
166 void* handle; | |
167 sprintf(filename,XMMS_INPUT_PLUGIN_DIR "/%s",ent->d_name); | |
168 handle=dlopen(filename, RTLD_NOW); | |
169 if(handle){ | |
170 void *(*gpi) (void); | |
171 gpi=dlsym(handle, "get_iplugin_info"); | |
172 if(gpi){ | |
173 InputPlugin *p=gpi(); | |
174 printf("XMMS: found plugin: %s (%s)\n",ent->d_name,p->description); | |
175 p->handle = handle; | |
176 p->filename = strdup(filename); | |
177 p->get_vis_type = input_get_vis_type; | |
178 p->add_vis_pcm = input_add_vis_pcm; | |
179 p->set_info = input_set_info; | |
180 p->set_info_text = input_set_info_text; | |
181 if(p->init) p->init(); | |
182 input_plugins[no_plugins++]=p; | |
183 } else | |
184 dlclose(handle); | |
185 } | |
186 } | |
187 closedir(dir); | |
188 } | |
189 | |
190 static void cleanup_plugins(){ | |
191 while(no_plugins>0){ | |
192 --no_plugins; | |
193 printf("XMMS: Closing plugin %s\n",input_plugins[no_plugins]->filename); | |
194 if(input_plugins[no_plugins]->cleanup) | |
195 input_plugins[no_plugins]->cleanup(); | |
196 dlclose(input_plugins[no_plugins]->handle); | |
197 } | |
198 } | |
199 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
200 // ============================ mplayer demuxer stuff =============== |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
201 |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
202 //extern void resync_audio_stream(sh_audio_t *sh_audio); |
8528 | 203 |
204 int demux_xmms_open(demuxer_t* demuxer) { | |
205 InputPlugin* ip = NULL; | |
206 sh_audio_t* sh_audio; | |
207 WAVEFORMATEX* w; | |
208 xmms_priv_t *priv; | |
209 int i; | |
210 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
211 if (xmms_priv) return 0; // as I said, it's not reentrant :) |
8528 | 212 init_plugins(); |
213 for(i=0;i<no_plugins;i++){ | |
214 if (input_plugins[i]->is_our_file(demuxer->stream->url)){ | |
215 ip=input_plugins[i]; break; | |
216 } | |
217 } | |
218 if(!ip) return 0; // no plugin to handle this... | |
219 | |
220 pthread_mutex_init(&xmms_mutex,NULL); | |
221 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
222 xmms_priv=priv=(xmms_priv_t *)malloc(sizeof(xmms_priv_t)); |
8528 | 223 memset(priv,0,sizeof(xmms_priv_t)); |
224 priv->ip=ip; | |
225 | |
226 memset(xmms_audiobuffer,0,XMMS_PACKETSIZE); | |
227 | |
228 xmms_channels=0; | |
229 sh_audio = new_sh_audio(demuxer,0); | |
230 sh_audio->wf = w = (WAVEFORMATEX*)malloc(sizeof(WAVEFORMATEX)); | |
231 w->wFormatTag = sh_audio->format = format; | |
232 | |
233 demuxer->movi_start = 0; | |
234 demuxer->movi_end = 100; | |
235 demuxer->audio->id = 0; | |
236 demuxer->audio->sh = sh_audio; | |
237 demuxer->priv=priv; | |
238 sh_audio->ds = demuxer->audio; | |
239 | |
240 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
|
241 ip->output = &xmms_output_plugin; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
242 xmms_playing=1; |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
243 ip->play_file(demuxer->stream->url); |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
244 if (ip->get_song_info) ip->get_song_info(demuxer->stream->url,&xmms_title,&xmms_length); |
8528 | 245 if (xmms_length<=0) demuxer->seekable=0; |
246 | |
247 mp_msg(MSGT_DEMUX,MSGL_INFO,"Waiting for the XMMS plugin to start playback of '%s'...\n",demuxer->stream->url); | |
248 while (xmms_channels==0) { | |
249 usleep(10000); | |
250 if(ip->get_time()<0) return 0; | |
251 } | |
252 sh_audio->sample_format= xmms_afmt; | |
253 switch (xmms_afmt) { | |
254 case AFMT_S16_LE: | |
255 case AFMT_S16_BE: | |
256 case AFMT_U16_LE: | |
257 case AFMT_U16_BE: | |
258 sh_audio->samplesize = 2; | |
259 break; | |
260 default: | |
261 sh_audio->samplesize = 1; | |
262 } | |
263 w->wBitsPerSample = sh_audio->samplesize*8; | |
264 w->nChannels = sh_audio->channels = xmms_channels; | |
265 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
|
266 xmms_byterate = w->nAvgBytesPerSec = xmms_samplerate*sh_audio->channels*sh_audio->samplesize; |
8528 | 267 w->nBlockAlign = sh_audio->samplesize*sh_audio->channels; |
268 w->cbSize = 0; | |
269 | |
270 return 1; | |
271 } | |
272 | |
273 int demux_xmms_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) { | |
274 sh_audio_t *sh_audio = demuxer->audio->sh; | |
275 xmms_priv_t *priv=demuxer->priv; | |
276 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
|
277 |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
278 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
|
279 else demuxer->seekable=1; |
8528 | 280 |
281 while (xmms_audiopos<XMMS_PACKETSIZE/2) { | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
282 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
|
283 return 0; |
8528 | 284 usleep(1000); |
285 } | |
286 | |
287 pthread_mutex_lock(&xmms_mutex); | |
288 dp = new_demux_packet(XMMS_PACKETSIZE/2); | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
289 ds->pts = priv->spos / sh_audio->wf->nAvgBytesPerSec; |
8528 | 290 ds->pos = priv->spos; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
291 |
8528 | 292 memcpy(dp->buffer,xmms_audiobuffer,XMMS_PACKETSIZE/2); |
293 memcpy(xmms_audiobuffer,&xmms_audiobuffer[XMMS_PACKETSIZE/2],xmms_audiopos-XMMS_PACKETSIZE/2); | |
294 xmms_audiopos-=XMMS_PACKETSIZE/2; | |
295 pthread_mutex_unlock(&xmms_mutex); | |
296 | |
297 ds_add_packet(ds,dp); | |
298 | |
299 return 1; | |
300 } | |
301 | |
302 void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){ | |
303 stream_t* s = demuxer->stream; | |
304 sh_audio_t* sh_audio = demuxer->audio->sh; | |
305 xmms_priv_t *priv=demuxer->priv; | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
306 int32_t pos; |
8528 | 307 |
308 if(priv->ip->get_time()<0) return; | |
309 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
310 pos = (flags & 1) ? 0 : priv->spos / sh_audio->wf->nAvgBytesPerSec; |
8528 | 311 if (flags & 2) |
312 pos+= rel_seek_secs*xmms_length; | |
313 else | |
314 pos+= rel_seek_secs; | |
315 | |
316 if (pos<0) pos=0; | |
317 if (pos>=xmms_length) pos=xmms_length-1; | |
318 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
319 priv->ip->seek((pos<0)?0:pos); |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
320 priv->spos=pos * sh_audio->wf->nAvgBytesPerSec; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
321 sh_audio->delay=pos; //priv->spos / sh_audio->wf->nAvgBytesPerSec; |
8528 | 322 } |
323 | |
324 int demux_close_xmms(demuxer_t* demuxer) { | |
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 return 1; | |
335 } | |
336 | |
337 int demux_xmms_control(demuxer_t *demuxer,int cmd, void *arg){ | |
338 demux_stream_t *d_video=demuxer->video; | |
339 sh_audio_t *sh_audio=demuxer->audio->sh; | |
340 xmms_priv_t *priv=demuxer->priv; | |
341 | |
342 switch(cmd) { | |
343 case DEMUXER_CTRL_GET_TIME_LENGTH: | |
344 if (xmms_length<=0) return DEMUXER_CTRL_DONTKNOW; | |
345 *((unsigned long *)arg)=(unsigned long)xmms_length/1000; | |
346 return DEMUXER_CTRL_GUESS; | |
347 | |
348 case DEMUXER_CTRL_GET_PERCENT_POS: | |
349 if (xmms_length<=0) | |
350 return DEMUXER_CTRL_DONTKNOW; | |
351 *((int *)arg)=(int)( priv->spos / (float)(sh_audio->wf->nAvgBytesPerSec) / xmms_length ); | |
352 return DEMUXER_CTRL_OK; | |
353 | |
354 default: | |
355 return DEMUXER_CTRL_NOTIMPL; | |
356 } | |
357 } |