MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / do_read

Function do_read

src/blkdev_cdimage.cpp:161–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161static int do_read (struct cdunit *cdu, struct cdtoc *t, uae_u8 *data, int sector, int offset, int size, bool audio)
162{
163 if (t->enctype == ENC_CHD) {
164#ifdef WITH_CHD
165 int type = CD_TRACK_MODE1_RAW;
166 uae_u8 tmpbuf[2352];
167 if (size > 2352)
168 return 0;
169 switch (size)
170 {
171 case 2352:
172 type = CD_TRACK_MODE1_RAW;
173 offset = 0;
174 break;
175 case 2336:
176 type = CD_TRACK_MODE2;
177 offset = 0;
178 break;
179 case 2048:
180 type = CD_TRACK_MODE1;
181 offset = 0;
182 break;
183 }
184 if (audio && size == 2352)
185 type = CD_TRACK_AUDIO;
186 if (cdrom_read_data(cdu->chd_cdf, sector + (uint32_t)t->offset, tmpbuf, type, false)) {
187 memcpy(data, tmpbuf + offset, size);
188 return 1;
189 }
190 return 0;
191#endif
192 } else if (t->handle) {
193 int ssize = t->size + t->skipsize;
194 zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + offset, SEEK_SET);
195 return zfile_fread (data, 1, size, t->handle) == size;
196 }
197 return 0;
198}
199
200#if CHD_FLAC_USE_DRFLAC
201struct flac_zfile_stream

Callers 3

cdda_play_func2Function · 0.85
command_rawreadFunction · 0.85
command_readFunction · 0.85

Calls 3

cdrom_read_dataFunction · 0.85
zfile_fseekFunction · 0.85
zfile_freadFunction · 0.85

Tested by

no test coverage detected