Mercurial > mplayer.hg
comparison libmpdemux/vcd_read_fbsd.h @ 7406:1394aebaa838
removed obsolete VCD_CACHE hack
author | arpi |
---|---|
date | Sun, 15 Sep 2002 18:48:16 +0000 |
parents | 9e059416eea6 |
children | d862231858d5 |
comparison
equal
deleted
inserted
replaced
7405:c1d517db8d95 | 7406:1394aebaa838 |
---|---|
94 } | 94 } |
95 memcpy(mem,vcd_buf.data,VCD_SECTOR_DATA); | 95 memcpy(mem,vcd_buf.data,VCD_SECTOR_DATA); |
96 return VCD_SECTOR_DATA; | 96 return VCD_SECTOR_DATA; |
97 } | 97 } |
98 | 98 |
99 //================== VCD CACHE ======================= | |
100 #ifdef VCD_CACHE | |
101 | |
102 static int vcd_cache_size=0; | |
103 static char *vcd_cache_data=NULL; | |
104 static int *vcd_cache_sectors=NULL; | |
105 static int vcd_cache_index=0; // index to first free (or oldest) cache sector | |
106 static int vcd_cache_current=-1; | |
107 | |
108 void vcd_cache_init(int s){ | |
109 vcd_cache_size=s; | |
110 vcd_cache_sectors=malloc(s*sizeof(int)); | |
111 vcd_cache_data=malloc(s*VCD_SECTOR_SIZE); | |
112 memset(vcd_cache_sectors,255,s*sizeof(int)); | |
113 } | |
114 | |
115 static inline void vcd_cache_seek(int sect){ | |
116 vcd_cache_current=sect; | |
117 } | |
118 | |
119 int vcd_cache_read(int fd,char* mem){ | |
120 int i; | |
121 char* vcd_buf; | |
122 for(i=0;i<vcd_cache_size;i++) | |
123 if(vcd_cache_sectors[i]==vcd_cache_current){ | |
124 // found in the cache! :) | |
125 vcd_buf=&vcd_cache_data[i*VCD_SECTOR_SIZE]; | |
126 ++vcd_cache_current; | |
127 memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA); | |
128 return VCD_SECTOR_DATA; | |
129 } | |
130 // NEW cache entry: | |
131 vcd_buf=&vcd_cache_data[vcd_cache_index*VCD_SECTOR_SIZE]; | |
132 vcd_cache_sectors[vcd_cache_index]=vcd_cache_current; | |
133 ++vcd_cache_index;if(vcd_cache_index>=vcd_cache_size)vcd_cache_index=0; | |
134 // read data! | |
135 vcd_set_msf(vcd_cache_current); | |
136 memcpy(vcd_buf,&vcd_entry.entry.addr.msf,sizeof(struct cdrom_msf)); | |
137 /* if(ioctl(fd,CDROMREADRAW,vcd_buf)==-1) return 0; */ // EOF? | |
138 ++vcd_cache_current; | |
139 memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA); | |
140 return VCD_SECTOR_DATA; | |
141 } | |
142 | |
143 #endif |