input/CdioParanoia: make variables more local

This commit is contained in:
Max Kellermann 2019-01-20 21:59:57 +01:00
parent 2cc2bab309
commit 10a6c5c57d
1 changed files with 6 additions and 11 deletions

View File

@ -285,32 +285,27 @@ size_t
CdioParanoiaInputStream::Read(void *ptr, size_t length) CdioParanoiaInputStream::Read(void *ptr, size_t length)
{ {
size_t nbytes = 0; size_t nbytes = 0;
int diff;
size_t len, maxwrite;
int16_t *rbuf;
char *s_err, *s_mess;
char *wptr = (char *) ptr; char *wptr = (char *) ptr;
while (length > 0) { while (length > 0) {
/* end of track ? */ /* end of track ? */
if (lsn_from + lsn_relofs > lsn_to) if (lsn_from + lsn_relofs > lsn_to)
break; break;
//current sector was changed ? //current sector was changed ?
int16_t *rbuf;
if (lsn_relofs != buffer_lsn) { if (lsn_relofs != buffer_lsn) {
const ScopeUnlock unlock(mutex); const ScopeUnlock unlock(mutex);
rbuf = cdio_paranoia_read(para, nullptr); rbuf = cdio_paranoia_read(para, nullptr);
s_err = cdda_errors(drv); char *s_err = cdda_errors(drv);
if (s_err) { if (s_err) {
FormatError(cdio_domain, FormatError(cdio_domain,
"paranoia_read: %s", s_err); "paranoia_read: %s", s_err);
free(s_err); free(s_err);
} }
s_mess = cdda_messages(drv); char *s_mess = cdda_messages(drv);
if (s_mess) { if (s_mess) {
free(s_mess); free(s_mess);
} }
@ -326,12 +321,12 @@ CdioParanoiaInputStream::Read(void *ptr, size_t length)
} }
//correct offset //correct offset
diff = offset - lsn_relofs * CDIO_CD_FRAMESIZE_RAW; const int diff = offset - lsn_relofs * CDIO_CD_FRAMESIZE_RAW;
assert(diff >= 0 && diff < CDIO_CD_FRAMESIZE_RAW); assert(diff >= 0 && diff < CDIO_CD_FRAMESIZE_RAW);
maxwrite = CDIO_CD_FRAMESIZE_RAW - diff; //# of bytes pending in current buffer const size_t maxwrite = CDIO_CD_FRAMESIZE_RAW - diff; //# of bytes pending in current buffer
len = (length < maxwrite? length : maxwrite); const size_t len = (length < maxwrite? length : maxwrite);
//skip diff bytes from this lsn //skip diff bytes from this lsn
memcpy(wptr, ((char*)rbuf) + diff, len); memcpy(wptr, ((char*)rbuf) + diff, len);