Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
c32dceb4
Commit
c32dceb4
authored
Jul 08, 2022
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/CdioParanoia: remove loop from Read()
The Read() method is not required to fill the whole buffer. By returning as soon as at least one byte was read, we allow faster cancellation.
parent
5573e783
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
47 deletions
+38
-47
NEWS
NEWS
+1
-0
CdioParanoiaInputPlugin.cxx
src/input/plugins/CdioParanoiaInputPlugin.cxx
+37
-47
No files found.
NEWS
View file @
c32dceb4
...
@@ -3,6 +3,7 @@ ver 0.23.8 (not yet released)
...
@@ -3,6 +3,7 @@ ver 0.23.8 (not yet released)
- curl: fix crash if web server does not understand WebDAV
- curl: fix crash if web server does not understand WebDAV
* input
* input
- cdio_paranoia: fix crash if no drive was found
- cdio_paranoia: fix crash if no drive was found
- cdio_paranoia: faster cancellation
* output
* output
- pipewire: fix crash with PipeWire 0.3.53
- pipewire: fix crash with PipeWire 0.3.53
* mixer
* mixer
...
...
src/input/plugins/CdioParanoiaInputPlugin.cxx
View file @
c32dceb4
...
@@ -288,61 +288,51 @@ size_t
...
@@ -288,61 +288,51 @@ size_t
CdioParanoiaInputStream
::
Read
(
std
::
unique_lock
<
Mutex
>
&
,
CdioParanoiaInputStream
::
Read
(
std
::
unique_lock
<
Mutex
>
&
,
void
*
ptr
,
size_t
length
)
void
*
ptr
,
size_t
length
)
{
{
size_t
nbytes
=
0
;
/* end of track ? */
char
*
wptr
=
(
char
*
)
ptr
;
if
(
IsEOF
())
return
0
;
while
(
length
>
0
)
{
/* end of track ? */
//current sector was changed ?
if
(
IsEOF
())
const
int16_t
*
rbuf
;
break
;
const
int32_t
lsn_relofs
=
offset
/
CDIO_CD_FRAMESIZE_RAW
;
//current sector was changed ?
if
(
lsn_relofs
!=
buffer_lsn
)
{
const
int16_t
*
rbuf
;
const
ScopeUnlock
unlock
(
mutex
);
const
int32_t
lsn_relofs
=
offset
/
CDIO_CD_FRAMESIZE_RAW
;
try
{
if
(
lsn_relofs
!=
buffer_lsn
)
{
rbuf
=
para
.
Read
().
data
;
const
ScopeUnlock
unlock
(
mutex
);
}
catch
(...)
{
char
*
s_err
=
cdio_cddap_errors
(
drv
);
try
{
if
(
s_err
)
{
rbuf
=
para
.
Read
().
data
;
FmtError
(
cdio_domain
,
}
catch
(...)
{
"paranoia_read: {}"
,
s_err
);
char
*
s_err
=
cdio_cddap_errors
(
drv
);
cdio_cddap_free_messages
(
s_err
);
if
(
s_err
)
{
FmtError
(
cdio_domain
,
"paranoia_read: {}"
,
s_err
);
cdio_cddap_free_messages
(
s_err
);
}
throw
;
}
}
//store current buffer
throw
;
memcpy
(
buffer
,
rbuf
,
CDIO_CD_FRAMESIZE_RAW
);
buffer_lsn
=
lsn_relofs
;
}
else
{
//use cached sector
rbuf
=
(
const
int16_t
*
)
buffer
;
}
}
//correct offset
//store current buffer
const
int
diff
=
offset
-
lsn_relofs
*
CDIO_CD_FRAMESIZE_RAW
;
memcpy
(
buffer
,
rbuf
,
CDIO_CD_FRAMESIZE_RAW
);
buffer_lsn
=
lsn_relofs
;
}
else
{
//use cached sector
rbuf
=
(
const
int16_t
*
)
buffer
;
}
assert
(
diff
>=
0
&&
diff
<
CDIO_CD_FRAMESIZE_RAW
);
//correct offset
const
int
diff
=
offset
-
lsn_relofs
*
CDIO_CD_FRAMESIZE_RAW
;
const
size_t
maxwrite
=
CDIO_CD_FRAMESIZE_RAW
-
diff
;
//# of bytes pending in current buffer
assert
(
diff
>=
0
&&
diff
<
CDIO_CD_FRAMESIZE_RAW
);
const
size_t
len
=
std
::
min
(
length
,
maxwrite
);
//skip diff bytes from this lsn
const
size_t
maxwrite
=
CDIO_CD_FRAMESIZE_RAW
-
diff
;
//# of bytes pending in current buffer
memcpy
(
wptr
,
((
const
char
*
)
rbuf
)
+
diff
,
len
);
const
std
::
size_t
nbytes
=
std
::
min
(
length
,
maxwrite
);
//update pointer
wptr
+=
len
;
nbytes
+=
len
;
//update offset
//skip diff bytes from this lsn
offset
+=
len
;
memcpy
(
ptr
,
((
const
char
*
)
rbuf
)
+
diff
,
nbytes
)
;
//update length
length
-=
len
;
//update offset
}
offset
+=
nbytes
;
return
nbytes
;
return
nbytes
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment