Mercurial > mplayer.hg
annotate libmpdemux/demux_xmms.c @ 31624:40c30c70ead0
Fix memory leak for subtitles decoded by libavcodec.
author | reimar |
---|---|
date | Sun, 11 Jul 2010 07:37:02 +0000 |
parents | cd81fce1f010 |
children | d332ea379205 |
rev | line source |
---|---|
22271 | 1 /* |
22272 | 2 * Copyright (C) 2002-2004 Balatoni Denes and A'rpi |
22271 | 3 * |
26742
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
4 * This file is part of MPlayer. |
22271 | 5 * |
26742
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
6 * MPlayer is free software; you can redistribute it and/or modify |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
9 * (at your option) any later version. |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
10 * |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
11 * MPlayer is distributed in the hope that it will be useful, |
22272 | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
22271 | 15 * |
26742
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
0c1db5fd3f79
Use standard license headers with standard formatting.
diego
parents:
25883
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
22271 | 19 */ |
20 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
21 // This is not reentrant because of global static variables, but most of |
22272 | 22 // the plugins are not reentrant either perhaps |
8528 | 23 #include "config.h" |
24 | |
25 #include <stdlib.h> | |
26 #include <stdio.h> | |
27 #include <unistd.h> | |
28 #include <pthread.h> | |
29 #include <dlfcn.h> | |
30 #include <dirent.h> | |
31 #include <inttypes.h> | |
8623
440301fef3fe
Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents:
8611
diff
changeset
|
32 #include <string.h> |
440301fef3fe
Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents:
8611
diff
changeset
|
33 #include <sys/stat.h> |
8528 | 34 |
17012 | 35 #include "m_option.h" |
36 #include "libaf/af_format.h" | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22274
diff
changeset
|
37 #include "stream/stream.h" |
8528 | 38 #include "demuxer.h" |
39 #include "stheader.h" | |
40 | |
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
|
41 #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
|
42 #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
|
43 |
8528 | 44 #define XMMS_PACKETSIZE 65536 // some plugins won't play if this is too small |
45 | |
46 #include "demux_xmms_plugin.h" | |
47 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
48 typedef struct { |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
49 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
|
50 InputPlugin* ip; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
51 } xmms_priv_t; |
8528 | 52 |
53 static pthread_mutex_t xmms_mutex; | |
54 static int format = 0x1; // Raw PCM | |
55 static char xmms_audiobuffer[XMMS_PACKETSIZE]; | |
56 static uint32_t xmms_channels; | |
57 static uint32_t xmms_samplerate; | |
58 static uint32_t xmms_afmt; | |
59 static int xmms_length; | |
60 static char *xmms_title=NULL; | |
61 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
|
62 static int xmms_playing=0; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
63 static xmms_priv_t *xmms_priv=NULL; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
64 static uint32_t xmms_byterate; |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
65 static int64_t xmms_flushto=-1; |
8528 | 66 |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
67 // =========== mplayer xmms outputplugin stuff ============== |
8528 | 68 |
69 static void disk_close(void) {} | |
70 static void disk_pause(short p) {} | |
71 static void disk_init(void) {} | |
72 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
73 static void disk_flush(int time) { |
22270 | 74 if (xmms_priv) xmms_flushto=time*((long long) xmms_byterate)/1000LL; |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
75 } |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
76 |
8528 | 77 static int disk_free(void) { // vqf plugin sends more than it should |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26742
diff
changeset
|
78 return XMMS_PACKETSIZE - xmms_audiopos < XMMS_PACKETSIZE / 4 ? |
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26742
diff
changeset
|
79 0 : XMMS_PACKETSIZE - xmms_audiopos - XMMS_PACKETSIZE / 4; |
8528 | 80 } |
81 | |
82 static int disk_playing(void) { | |
22270 | 83 return 0; //?? maybe plugins wait on exit until oplugin is not playing? |
8528 | 84 } |
85 | |
86 static int disk_get_output_time(void) { | |
22270 | 87 if (xmms_byterate) |
88 return xmms_priv->spos*1000LL/((long long)xmms_byterate); | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
89 else return 0; |
8528 | 90 } |
91 | |
92 static int disk_open(AFormat fmt, int rate, int nch) { | |
93 switch (fmt) { | |
22270 | 94 case FMT_U8: |
95 xmms_afmt=AF_FORMAT_U8; | |
96 break; | |
97 case FMT_S8: | |
98 xmms_afmt=AF_FORMAT_S8; | |
99 break; | |
100 case FMT_U16_LE: | |
101 xmms_afmt=AF_FORMAT_U16_LE; | |
102 break; | |
103 case FMT_U16_NE: | |
29401
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
28339
diff
changeset
|
104 #if HAVE_BIGENDIAN |
22270 | 105 xmms_afmt=AF_FORMAT_U16_BE; |
8528 | 106 #else |
22270 | 107 xmms_afmt=AF_FORMAT_U16_LE; |
8528 | 108 #endif |
22270 | 109 break; |
110 case FMT_U16_BE: | |
111 xmms_afmt=AF_FORMAT_U16_BE; | |
112 break; | |
113 case FMT_S16_NE: | |
114 xmms_afmt=AF_FORMAT_S16_NE; | |
115 break; | |
116 case FMT_S16_LE: | |
117 xmms_afmt=AF_FORMAT_S16_LE; | |
118 break; | |
119 case FMT_S16_BE: | |
120 xmms_afmt=AF_FORMAT_S16_BE; | |
121 break; | |
8528 | 122 } |
123 xmms_samplerate=rate; | |
124 xmms_channels=nch; | |
125 return 1; | |
126 } | |
127 | |
128 static void disk_write(void *ptr, int length) { | |
22270 | 129 if (!xmms_playing) return; |
130 pthread_mutex_lock(&xmms_mutex); | |
131 if (xmms_flushto!=-1) { | |
132 xmms_priv->spos=xmms_flushto; | |
133 xmms_flushto=-1; | |
134 xmms_audiopos=0; | |
135 } | |
136 xmms_priv->spos+= length; | |
137 memcpy(&xmms_audiobuffer[xmms_audiopos],ptr,length); | |
138 xmms_audiopos+=length; | |
139 pthread_mutex_unlock(&xmms_mutex); | |
8528 | 140 } |
141 | |
142 static OutputPlugin xmms_output_plugin = | |
143 { | |
22270 | 144 NULL, |
145 NULL, | |
146 "MPlayer output interface plugin ", /* Description */ | |
147 disk_init, | |
148 NULL, /* about */ | |
149 NULL, /* configure */ | |
150 NULL, /* get_volume */ | |
151 NULL, /* set_volume */ | |
152 disk_open, | |
153 disk_write, | |
154 disk_close, | |
155 disk_flush, | |
156 disk_pause, | |
157 disk_free, | |
158 disk_playing, | |
159 disk_get_output_time, | |
160 disk_get_output_time //we pretend that everything written is played at once | |
8528 | 161 }; |
162 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
163 // ==================== mplayer xmms inputplugin helper stuff ================= |
8528 | 164 |
165 static InputPlugin* input_plugins[100]; | |
166 static int no_plugins=0; | |
167 | |
168 /* Dummy functions */ | |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
26758
diff
changeset
|
169 static InputVisType input_get_vis_type(void){return 0;} |
22272 | 170 static void input_add_vis_pcm(int time, AFormat fmt, int nch, int length, |
171 void *ptr){} | |
8528 | 172 static void input_set_info_text(char * text){} |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
26758
diff
changeset
|
173 char *xmms_get_gentitle_format(void){ return ""; } |
8528 | 174 /* Dummy functions END*/ |
175 | |
22272 | 176 static void input_set_info(char* title,int length, int rate, int freq, int nch) |
177 { | |
8536
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
178 xmms_length=length; |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
179 } |
ff192e1b018f
xmp hangign I noticed too, and is fixed with this patch, seeking works now
arpi
parents:
8528
diff
changeset
|
180 |
22265
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
181 static void init_plugins_from_dir(const char *plugin_dir){ |
8528 | 182 DIR *dir; |
183 struct dirent *ent; | |
22270 | 184 |
22265
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
185 dir = opendir(plugin_dir); |
8528 | 186 if (!dir) return; |
22270 | 187 |
8528 | 188 while ((ent = readdir(dir)) != NULL){ |
22270 | 189 char filename[strlen(plugin_dir)+strlen(ent->d_name)+4]; |
190 void* handle; | |
191 sprintf(filename, "%s/%s", plugin_dir, ent->d_name); | |
192 handle=dlopen(filename, RTLD_NOW); | |
193 if(handle){ | |
194 void *(*gpi) (void); | |
195 gpi=dlsym(handle, "get_iplugin_info"); | |
196 if(gpi){ | |
197 InputPlugin *p=gpi(); | |
22272 | 198 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_XMMS_FoundPlugin, |
199 ent->d_name,p->description); | |
22270 | 200 p->handle = handle; |
201 p->filename = strdup(filename); | |
202 p->get_vis_type = input_get_vis_type; | |
203 p->add_vis_pcm = input_add_vis_pcm; | |
204 p->set_info = input_set_info; | |
205 p->set_info_text = input_set_info_text; | |
206 if(p->init) p->init(); | |
207 input_plugins[no_plugins++]=p; | |
208 } else | |
209 dlclose(handle); | |
210 } | |
8528 | 211 } |
212 closedir(dir); | |
213 } | |
214 | |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
26758
diff
changeset
|
215 static void init_plugins(void) { |
22265
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
216 char *home; |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
217 |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
218 no_plugins=0; |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
219 |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
220 home = getenv("HOME"); |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
221 if(home != NULL) { |
22270 | 222 char xmms_home[strlen(home) + 15]; |
223 sprintf(xmms_home, "%s/.xmms/Plugins", home); | |
224 init_plugins_from_dir(xmms_home); | |
22265
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
225 } |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
226 |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
227 init_plugins_from_dir(XMMS_INPUT_PLUGIN_DIR); |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
228 } |
02333de881a7
probe ~/.xmms/Plugins for plugins too, so users without root access on their
ivo
parents:
19062
diff
changeset
|
229 |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
26758
diff
changeset
|
230 static void cleanup_plugins(void) { |
8528 | 231 while(no_plugins>0){ |
22270 | 232 --no_plugins; |
22272 | 233 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_XMMS_ClosingPlugin, |
234 input_plugins[no_plugins]->filename); | |
22270 | 235 if(input_plugins[no_plugins]->cleanup) |
236 input_plugins[no_plugins]->cleanup(); | |
237 dlclose(input_plugins[no_plugins]->handle); | |
8528 | 238 } |
239 } | |
240 | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
241 // ============================ mplayer demuxer stuff =============== |
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
242 |
16175 | 243 static int demux_xmms_open(demuxer_t* demuxer) { |
22270 | 244 InputPlugin* ip = NULL; |
245 sh_audio_t* sh_audio; | |
246 WAVEFORMATEX* w; | |
247 xmms_priv_t *priv; | |
248 int i; | |
8528 | 249 |
22270 | 250 if (xmms_priv) return 0; // as I said, it's not reentrant :) |
251 init_plugins(); | |
252 for(i=0;i<no_plugins;i++){ | |
253 if (input_plugins[i]->is_our_file(demuxer->stream->url)){ | |
254 ip=input_plugins[i]; break; | |
255 } | |
256 } | |
257 if(!ip) return 0; // no plugin to handle this... | |
258 | |
22272 | 259 pthread_mutex_init(&xmms_mutex,NULL); |
8528 | 260 |
22270 | 261 xmms_priv=priv=malloc(sizeof(xmms_priv_t)); |
262 memset(priv,0,sizeof(xmms_priv_t)); | |
263 priv->ip=ip; | |
8528 | 264 |
22270 | 265 memset(xmms_audiobuffer,0,XMMS_PACKETSIZE); |
266 | |
267 xmms_channels=0; | |
31609
cd81fce1f010
Make the stream language an argument to the stream creation function
reimar
parents:
29401
diff
changeset
|
268 sh_audio = new_sh_audio(demuxer,0, NULL); |
22270 | 269 sh_audio->wf = w = malloc(sizeof(WAVEFORMATEX)); |
270 w->wFormatTag = sh_audio->format = format; | |
8528 | 271 |
22270 | 272 demuxer->movi_start = 0; |
273 demuxer->movi_end = 100; | |
274 demuxer->audio->id = 0; | |
275 demuxer->audio->sh = sh_audio; | |
276 demuxer->priv=priv; | |
277 sh_audio->ds = demuxer->audio; | |
8528 | 278 |
22270 | 279 xmms_output_plugin.init(); |
280 ip->output = &xmms_output_plugin; | |
281 xmms_playing=1; | |
282 ip->play_file(demuxer->stream->url); | |
22272 | 283 if (ip->get_song_info) |
284 ip->get_song_info(demuxer->stream->url,&xmms_title,&xmms_length); | |
22270 | 285 if (xmms_length<=0) demuxer->seekable=0; |
8528 | 286 |
22274 | 287 mp_msg(MSGT_DEMUX,MSGL_INFO,MSGTR_MPDEMUX_XMMS_WaitForStart, |
288 demuxer->stream->url); | |
22270 | 289 while (xmms_channels==0) { |
290 usleep(10000); | |
291 if(ip->get_time()<0) return 0; | |
292 } | |
293 sh_audio->sample_format= xmms_afmt; | |
294 switch (xmms_afmt) { | |
295 case AF_FORMAT_S16_LE: | |
296 case AF_FORMAT_S16_BE: | |
297 case AF_FORMAT_U16_LE: | |
298 case AF_FORMAT_U16_BE: | |
299 sh_audio->samplesize = 2; | |
300 break; | |
301 default: | |
302 sh_audio->samplesize = 1; | |
303 } | |
304 w->wBitsPerSample = sh_audio->samplesize*8; | |
305 w->nChannels = sh_audio->channels = xmms_channels; | |
22272 | 306 w->nSamplesPerSec = sh_audio->samplerate = xmms_samplerate; |
307 xmms_byterate = w->nAvgBytesPerSec = | |
308 xmms_samplerate*sh_audio->channels*sh_audio->samplesize; | |
22270 | 309 w->nBlockAlign = sh_audio->samplesize*sh_audio->channels; |
310 w->cbSize = 0; | |
311 | |
312 return DEMUXER_TYPE_XMMS; | |
8528 | 313 } |
314 | |
16175 | 315 static int demux_xmms_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) { |
22270 | 316 sh_audio_t *sh_audio = demuxer->audio->sh; |
317 xmms_priv_t *priv=demuxer->priv; | |
318 demux_packet_t* dp; | |
8528 | 319 |
22270 | 320 if (xmms_length<=0) demuxer->seekable=0; |
321 else demuxer->seekable=1; | |
322 | |
323 while (xmms_audiopos<XMMS_PACKETSIZE/2) { | |
324 if((priv->ip->get_time()<0) || !xmms_playing) | |
325 return 0; | |
326 usleep(1000); | |
327 } | |
8528 | 328 |
22270 | 329 pthread_mutex_lock(&xmms_mutex); |
330 dp = new_demux_packet(XMMS_PACKETSIZE/2); | |
331 dp->pts = priv->spos / sh_audio->wf->nAvgBytesPerSec; | |
332 ds->pos = priv->spos; | |
8542
222c0a39c977
I cleaned up the source a bit, hopefully fixed hanging, also
arpi
parents:
8536
diff
changeset
|
333 |
22270 | 334 memcpy(dp->buffer,xmms_audiobuffer,XMMS_PACKETSIZE/2); |
22272 | 335 memcpy(xmms_audiobuffer,&xmms_audiobuffer[XMMS_PACKETSIZE/2], |
336 xmms_audiopos-XMMS_PACKETSIZE/2); | |
22270 | 337 xmms_audiopos-=XMMS_PACKETSIZE/2; |
338 pthread_mutex_unlock(&xmms_mutex); | |
8528 | 339 |
22270 | 340 ds_add_packet(ds,dp); |
341 | |
342 return 1; | |
8528 | 343 } |
344 | |
22272 | 345 static void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs, |
346 float audio_delay,int flags){ | |
22270 | 347 stream_t* s = demuxer->stream; |
348 sh_audio_t* sh_audio = demuxer->audio->sh; | |
349 xmms_priv_t *priv=demuxer->priv; | |
350 int32_t pos; | |
351 | |
352 if(priv->ip->get_time()<0) return; | |
8528 | 353 |
25883
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
354 pos = (flags & SEEK_ABSOLUTE) ? 0 : priv->spos / sh_audio->wf->nAvgBytesPerSec; |
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
355 if (flags & SEEK_FACTOR) |
22270 | 356 pos+= rel_seek_secs*xmms_length; |
22272 | 357 else |
358 pos+= rel_seek_secs; | |
8528 | 359 |
22270 | 360 if (pos<0) pos=0; |
361 if (pos>=xmms_length) pos=xmms_length-1; | |
8528 | 362 |
22270 | 363 priv->ip->seek((pos<0)?0:pos); |
364 priv->spos=pos * sh_audio->wf->nAvgBytesPerSec; | |
8528 | 365 } |
366 | |
16175 | 367 static void demux_close_xmms(demuxer_t* demuxer) { |
22270 | 368 xmms_priv_t *priv=demuxer->priv; |
369 xmms_playing=0; | |
370 xmms_audiopos=0; // xmp on exit waits until buffer is free enough | |
371 if (priv != NULL) { | |
372 if (priv->ip != NULL) | |
373 priv->ip->stop(); | |
374 free(priv); xmms_priv=demuxer->priv=NULL; | |
375 } | |
376 cleanup_plugins(); | |
8528 | 377 } |
378 | |
16175 | 379 static int demux_xmms_control(demuxer_t *demuxer,int cmd, void *arg){ |
8528 | 380 demux_stream_t *d_video=demuxer->video; |
381 sh_audio_t *sh_audio=demuxer->audio->sh; | |
382 xmms_priv_t *priv=demuxer->priv; | |
383 | |
384 switch(cmd) { | |
22270 | 385 case DEMUXER_CTRL_GET_TIME_LENGTH: |
386 if (xmms_length<=0) return DEMUXER_CTRL_DONTKNOW; | |
387 *((double *)arg)=(double)xmms_length/1000; | |
388 return DEMUXER_CTRL_GUESS; | |
8528 | 389 |
22270 | 390 case DEMUXER_CTRL_GET_PERCENT_POS: |
22272 | 391 if (xmms_length<=0) |
22270 | 392 return DEMUXER_CTRL_DONTKNOW; |
22272 | 393 *((int *)arg)=(int)( priv->spos / |
394 (float)(sh_audio->wf->nAvgBytesPerSec) / xmms_length ); | |
22270 | 395 return DEMUXER_CTRL_OK; |
8528 | 396 |
22270 | 397 default: |
398 return DEMUXER_CTRL_NOTIMPL; | |
8528 | 399 } |
400 } | |
16175 | 401 |
402 | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
22605
diff
changeset
|
403 const demuxer_desc_t demuxer_desc_xmms = { |
22270 | 404 "XMMS demuxer", |
405 "xmms", | |
406 "XMMS", | |
407 "Balatoni Denes, A'rpi", | |
408 "requires XMMS plugins", | |
409 DEMUXER_TYPE_XMMS, | |
410 0, // safe autodetect | |
411 demux_xmms_open, | |
412 demux_xmms_fill_buffer, | |
413 NULL, | |
414 demux_close_xmms, | |
415 demux_xmms_seek, | |
416 demux_xmms_control | |
16175 | 417 }; |