Mercurial > mplayer.hg
annotate libmpdemux/stream.c @ 9642:29694f961362
sync
author | gabucino |
---|---|
date | Sat, 22 Mar 2003 10:37:23 +0000 |
parents | 76c6d8f1ebf5 |
children | c3b63fb0e8db |
rev | line source |
---|---|
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
1 |
1430 | 2 #include <stdio.h> |
3 #include <stdlib.h> | |
4 #include <unistd.h> | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
5 |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
6 #include <sys/types.h> |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
7 #include <sys/stat.h> |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
8 #include <sys/ioctl.h> |
6814 | 9 #include <sys/wait.h> |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
10 #include <fcntl.h> |
2322 | 11 #include <signal.h> |
578 | 12 |
1430 | 13 #include "config.h" |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
14 #include "mp_msg.h" |
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
15 #include "help_mp.h" |
9380 | 16 #include "../osdep/shmem.h" |
578 | 17 |
18 #include "stream.h" | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
19 #include "demuxer.h" |
578 | 20 |
21 extern int verbose; // defined in mplayer.c | |
1 | 22 |
8812 | 23 #include "cue_read.h" |
24 | |
3261 | 25 #ifdef HAVE_VCD |
26 | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
692
diff
changeset
|
27 #ifdef __FreeBSD__ |
2310 | 28 #include "vcd_read_fbsd.h" |
5872 | 29 #elif defined(__NetBSD__) |
30 #include "vcd_read_nbsd.h" | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
692
diff
changeset
|
31 #else |
2310 | 32 #include "vcd_read.h" |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
692
diff
changeset
|
33 #endif |
1 | 34 |
3261 | 35 #endif |
36 | |
8812 | 37 //#include "vcd_read_bincue.h" |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
38 |
1595 | 39 #ifdef USE_DVDREAD |
8344 | 40 int dvd_read_sector(dvd_priv_t *d,unsigned char* data); |
41 void dvd_seek(dvd_priv_t *d,int pos); | |
6814 | 42 void dvd_close(dvd_priv_t *d); |
1595 | 43 #endif |
44 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
45 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
46 int read_cdda(stream_t* s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
47 void seek_cdda(stream_t* s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
48 void close_cdda(stream_t* s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
49 #endif |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
50 |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
51 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
52 #include "libsmbclient.h" |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
53 #endif |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
54 |
1 | 55 //=================== STREAMER ========================= |
56 | |
57 int stream_fill_buffer(stream_t *s){ | |
58 int len; | |
59 if(s->eof){ s->buf_pos=s->buf_len=0; return 0; } | |
60 switch(s->type){ | |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
61 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
62 case STREAMTYPE_SMB: |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
63 len=smbc_read(s->fd,s->buffer,STREAM_BUFFER_SIZE); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
64 break; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
65 #endif |
1 | 66 case STREAMTYPE_FILE: |
692 | 67 case STREAMTYPE_STREAM: |
4042
d651a7b5d213
STREAMTYPE_PLAYLIST introduced. similar to STREAMTYPE_STREAM but used for playlists. patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3291
diff
changeset
|
68 case STREAMTYPE_PLAYLIST: |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
69 #ifdef STREAMING |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
70 if( s->streaming_ctrl!=NULL ) { |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
71 len=s->streaming_ctrl->streaming_read(s->fd,s->buffer,STREAM_BUFFER_SIZE, s->streaming_ctrl);break; |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
72 } else { |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
73 len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break; |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
74 } |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
75 #else |
1 | 76 len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break; |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
77 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
78 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
79 case STREAMTYPE_CDDA: |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
80 len = read_cdda(s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
81 break; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
82 #endif |
3261 | 83 #ifdef HAVE_VCD |
1 | 84 case STREAMTYPE_VCD: |
85 len=vcd_read(s->fd,s->buffer);break; | |
86 #endif | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
87 case STREAMTYPE_VCDBINCUE: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
88 len=cue_vcd_read(s->buffer);break; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
89 #ifdef USE_DVDNAV |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
90 case STREAMTYPE_DVDNAV: { |
5472 | 91 dvdnav_stream_read((dvdnav_priv_t*)s->priv,s->buffer,&len); |
92 if (len==0) return 0; // this was an event, so repeat the read | |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
93 break; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
94 } |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
95 #endif |
1595 | 96 #ifdef USE_DVDREAD |
97 case STREAMTYPE_DVD: { | |
98 off_t pos=dvd_read_sector(s->priv,s->buffer); | |
99 if(pos>=0){ | |
100 len=2048; // full sector | |
101 s->pos=2048*pos-len; | |
102 } else len=-1; // error | |
103 break; | |
104 } | |
105 #endif | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
106 case STREAMTYPE_DS: |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
107 len = demux_read_data((demux_stream_t*)s->priv,s->buffer,STREAM_BUFFER_SIZE); |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
108 break; |
9610 | 109 |
110 #ifdef HAS_DVBIN_SUPPORT | |
111 case STREAMTYPE_DVB: | |
112 len = dvb_streaming_read(s->fd, s->buffer, STREAM_BUFFER_SIZE, s->priv); | |
113 break; | |
114 #endif | |
115 | |
116 | |
117 | |
1 | 118 default: len=0; |
119 } | |
120 if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; } | |
121 s->buf_pos=0; | |
122 s->buf_len=len; | |
123 s->pos+=len; | |
124 // printf("[%d]",len);fflush(stdout); | |
125 return len; | |
126 } | |
127 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
128 int stream_seek_long(stream_t *s,off_t pos){ |
6814 | 129 off_t newpos=0; |
1 | 130 |
2144 | 131 // if(verbose>=3) printf("seek_long to 0x%X\n",(unsigned int)pos); |
1 | 132 |
133 s->buf_pos=s->buf_len=0; | |
134 | |
135 switch(s->type){ | |
136 case STREAMTYPE_FILE: | |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
137 case STREAMTYPE_SMB: |
692 | 138 case STREAMTYPE_STREAM: |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
139 #ifdef _LARGEFILE_SOURCE |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
140 newpos=pos&(~((long long)STREAM_BUFFER_SIZE-1));break; |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
141 #else |
492 | 142 newpos=pos&(~(STREAM_BUFFER_SIZE-1));break; |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
143 #endif |
1 | 144 case STREAMTYPE_VCD: |
145 newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break; | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
146 case STREAMTYPE_VCDBINCUE: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
147 newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break; |
1595 | 148 case STREAMTYPE_DVD: |
149 newpos=pos/2048; newpos*=2048; break; | |
8524 | 150 #ifdef HAVE_CDDA |
151 case STREAMTYPE_CDDA: | |
152 newpos=(pos/VCD_SECTOR_SIZE)*VCD_SECTOR_SIZE;break; | |
153 #endif | |
1 | 154 } |
155 | |
2050 | 156 if(verbose>=3){ |
157 #ifdef _LARGEFILE_SOURCE | |
158 printf("s->pos=%llX newpos=%llX new_bufpos=%llX buflen=%X \n", | |
159 (long long)s->pos,(long long)newpos,(long long)pos,s->buf_len); | |
160 #else | |
161 printf("s->pos=%X newpos=%X new_bufpos=%X buflen=%X \n", | |
162 (unsigned int)s->pos,newpos,pos,s->buf_len); | |
163 #endif | |
164 } | |
165 | |
1 | 166 pos-=newpos; |
167 | |
168 if(newpos==0 || newpos!=s->pos){ | |
169 switch(s->type){ | |
170 case STREAMTYPE_FILE: | |
692 | 171 s->pos=newpos; // real seek |
1 | 172 if(lseek(s->fd,s->pos,SEEK_SET)<0) s->eof=1; |
173 break; | |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
174 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
175 case STREAMTYPE_SMB: |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
176 s->pos=newpos; // real seek |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
177 if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) s->eof=1; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
178 break; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
179 #endif |
3261 | 180 #ifdef HAVE_VCD |
1 | 181 case STREAMTYPE_VCD: |
692 | 182 s->pos=newpos; // real seek |
1 | 183 vcd_set_msf(s->pos/VCD_SECTOR_DATA); |
184 break; | |
3261 | 185 #endif |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
186 case STREAMTYPE_VCDBINCUE: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
187 s->pos=newpos; // real seek |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
188 cue_set_msf(s->pos/VCD_SECTOR_DATA); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
189 break; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
190 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
191 case STREAMTYPE_CDDA: { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
192 s->pos=newpos; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
193 seek_cdda(s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
194 break; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
195 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
196 #endif |
5472 | 197 #ifdef USE_DVDNAV |
198 case STREAMTYPE_DVDNAV: { | |
199 if (newpos==0) { | |
200 if (dvdnav_stream_reset((dvdnav_priv_t*)s->priv)) | |
201 s->pos=0; | |
202 } | |
203 if(newpos!=s->pos){ | |
204 mp_msg(MSGT_STREAM,MSGL_INFO,"Cannot seek in DVDNAV streams yet!\n"); | |
205 return 1; | |
206 } | |
207 break; | |
208 } | |
209 #endif | |
1595 | 210 #ifdef USE_DVDREAD |
211 case STREAMTYPE_DVD: | |
212 s->pos=newpos; // real seek | |
213 dvd_seek(s->priv,s->pos/2048); | |
214 break; | |
215 #endif | |
692 | 216 case STREAMTYPE_STREAM: |
217 //s->pos=newpos; // real seek | |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
218 // Some streaming protocol allow to seek backward and forward |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
219 // A function call that return -1 can tell that the protocol |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
220 // doesn't support seeking. |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
221 #ifdef STREAMING |
8929
c5ca1ae42555
check if seeking supported, otherwise fallback to null reading
arpi
parents:
8812
diff
changeset
|
222 if( s->streaming_ctrl!=NULL && s->streaming_ctrl->streaming_seek ) { |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
223 if( s->streaming_ctrl->streaming_seek( s->fd, pos, s->streaming_ctrl )<0 ) { |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
224 mp_msg(MSGT_STREAM,MSGL_INFO,"Stream not seekable!\n"); |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
225 return 1; |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
226 } |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
227 } |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
228 #else |
692 | 229 if(newpos<s->pos){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
230 mp_msg(MSGT_STREAM,MSGL_INFO,"Cannot seek backward in linear streams!\n"); |
692 | 231 return 1; |
232 } | |
233 while(s->pos<newpos){ | |
234 if(stream_fill_buffer(s)<=0) break; // EOF | |
235 } | |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
236 #endif |
692 | 237 break; |
7408 | 238 default: |
239 return 0; | |
1 | 240 } |
241 // putchar('.');fflush(stdout); | |
242 //} else { | |
243 // putchar('%');fflush(stdout); | |
244 } | |
245 | |
246 stream_fill_buffer(s); | |
1999 | 247 if(pos>=0 && pos<=s->buf_len){ |
1 | 248 s->buf_pos=pos; // byte position in sector |
249 return 1; | |
250 } | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
251 |
1999 | 252 // if(pos==s->buf_len) printf("XXX Seek to last byte of file -> EOF\n"); |
253 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
254 #ifdef _LARGEFILE_SOURCE |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
255 mp_msg(MSGT_STREAM,MSGL_V,"stream_seek: WARNING! Can't seek to 0x%llX !\n",(long long)(pos+newpos)); |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
256 #else |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
257 mp_msg(MSGT_STREAM,MSGL_V,"stream_seek: WARNING! Can't seek to 0x%X !\n",(pos+newpos)); |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
258 #endif |
1 | 259 return 0; |
260 } | |
261 | |
262 | |
263 void stream_reset(stream_t *s){ | |
264 if(s->eof){ | |
265 s->pos=0; //ftell(f); | |
266 // s->buf_pos=s->buf_len=0; | |
267 s->eof=0; | |
268 } | |
269 //stream_seek(s,0); | |
270 } | |
271 | |
2144 | 272 stream_t* new_memory_stream(unsigned char* data,int len){ |
273 stream_t *s=malloc(sizeof(stream_t)+len); | |
6892
b8e0b1c54940
10000l - didn't clear new stream struct, causing possible sig11 in cache layer
arpi
parents:
6814
diff
changeset
|
274 memset(s,0,sizeof(stream_t)); |
2144 | 275 s->fd=-1; |
276 s->type=STREAMTYPE_MEMORY; | |
277 s->buf_pos=0; s->buf_len=len; | |
278 s->start_pos=0; s->end_pos=len; | |
279 stream_reset(s); | |
280 s->pos=len; | |
281 memcpy(s->buffer,data,len); | |
282 return s; | |
283 } | |
284 | |
1 | 285 stream_t* new_stream(int fd,int type){ |
286 stream_t *s=malloc(sizeof(stream_t)); | |
3291 | 287 if(s==NULL) return NULL; |
288 memset(s,0,sizeof(stream_t)); | |
289 | |
1 | 290 s->fd=fd; |
291 s->type=type; | |
180 | 292 s->buf_pos=s->buf_len=0; |
598 | 293 s->start_pos=s->end_pos=0; |
1642 | 294 s->priv=NULL; |
7407 | 295 s->url=NULL; |
2322 | 296 s->cache_pid=0; |
1 | 297 stream_reset(s); |
298 return s; | |
299 } | |
300 | |
301 void free_stream(stream_t *s){ | |
6138
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5982
diff
changeset
|
302 // printf("\n*** free_stream() called ***\n"); |
4893 | 303 if(s->cache_pid) { |
5982 | 304 // kill(s->cache_pid,SIGTERM); |
305 kill(s->cache_pid,SIGKILL); | |
4893 | 306 waitpid(s->cache_pid,NULL,0); |
6810 | 307 shmem_free(s->cache_data); |
4893 | 308 } |
6300
c31d15532695
file descriptor leak - found by Marc Espie <espie@nerim.net>
arpi
parents:
6138
diff
changeset
|
309 if(s->fd>0) close(s->fd); |
6479 | 310 switch(s->type) { |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
311 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
312 case STREAMTYPE_SMB: |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
313 smbc_close(s->fd); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
314 break; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
315 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
316 #ifdef HAVE_CDDA |
6479 | 317 case STREAMTYPE_CDDA: |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
318 close_cdda(s); |
6479 | 319 break; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
320 #endif |
9610 | 321 #ifdef HAS_DVBIN_SUPPORT |
322 case STREAMTYPE_DVB: | |
323 dvbin_close(s->priv); | |
324 break; | |
325 #endif | |
326 | |
6479 | 327 #ifdef USE_DVDREAD |
328 case STREAMTYPE_DVD: | |
329 dvd_close(s->priv); | |
330 #endif | |
331 } | |
1642 | 332 if(s->priv) free(s->priv); |
1 | 333 free(s); |
334 } | |
335 | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
336 stream_t* new_ds_stream(demux_stream_t *ds) { |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
337 stream_t* s = new_stream(-1,STREAMTYPE_DS); |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
338 s->priv = ds; |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
339 return s; |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
340 } |