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
73013a3c
Commit
73013a3c
authored
Mar 15, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/thread: move code to Stop()
Fixes crash due to "pure virtual method called" in the "mms" input plugin. Closes #253
parent
e8099f01
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
3 deletions
+30
-3
NEWS
NEWS
+1
-1
ThreadInputStream.cxx
src/input/ThreadInputStream.cxx
+6
-1
ThreadInputStream.hxx
src/input/ThreadInputStream.hxx
+19
-1
MmsInputPlugin.cxx
src/input/plugins/MmsInputPlugin.cxx
+4
-0
No files found.
NEWS
View file @
73013a3c
...
...
@@ -2,7 +2,7 @@ ver 0.20.19 (not yet released)
* protocol
- validate absolute seek time, reject negative values
* input
- mms: fix lockup bug
- mms: fix lockup bug
and a crash bug
* macOS: fix crash bug
ver 0.20.18 (2018/02/24)
...
...
src/input/ThreadInputStream.cxx
View file @
73013a3c
...
...
@@ -26,8 +26,12 @@
#include <assert.h>
#include <string.h>
ThreadInputStream
::~
ThreadInputStream
()
void
ThreadInputStream
::
Stop
()
noexcept
{
if
(
!
thread
.
IsDefined
())
return
;
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
close
=
true
;
...
...
@@ -42,6 +46,7 @@ ThreadInputStream::~ThreadInputStream()
buffer
->
Clear
();
HugeFree
(
buffer
->
Write
().
data
,
buffer_size
);
delete
buffer
;
buffer
=
nullptr
;
}
}
...
...
src/input/ThreadInputStream.hxx
View file @
73013a3c
...
...
@@ -27,6 +27,7 @@
#include <exception>
#include <assert.h>
#include <stdint.h>
template
<
typename
T
>
class
CircularBuffer
;
...
...
@@ -39,6 +40,11 @@ template<typename T> class CircularBuffer;
* manages the thread and the buffer.
*
* This works only for "streams": unknown length, no seeking, no tags.
*
* The implementation must call Stop() before its destruction
* completes. This cannot be done in ~ThreadInputStream() because at
* this point, the class has been morphed back to #ThreadInputStream
* and the still-running thread will crash due to pure method call.
*/
class
ThreadInputStream
:
public
InputStream
{
const
char
*
const
plugin
;
...
...
@@ -76,7 +82,13 @@ public:
thread
(
BIND_THIS_METHOD
(
ThreadFunc
)),
buffer_size
(
_buffer_size
)
{}
virtual
~
ThreadInputStream
();
#ifndef NDEBUG
~
ThreadInputStream
()
override
{
/* Stop() must have been called already */
assert
(
!
thread
.
IsDefined
());
assert
(
buffer
==
nullptr
);
}
#endif
/**
* Initialize the object and start the thread.
...
...
@@ -90,6 +102,12 @@ public:
size_t
Read
(
void
*
ptr
,
size_t
size
)
override
final
;
protected
:
/**
* Stop the thread and free the buffer. This must be called
* before destruction of this object completes.
*/
void
Stop
()
noexcept
;
void
SetMimeType
(
const
char
*
_mime
)
{
assert
(
thread
.
IsInside
());
...
...
src/input/plugins/MmsInputPlugin.cxx
View file @
73013a3c
...
...
@@ -39,6 +39,10 @@ public:
MMS_BUFFER_SIZE
)
{
}
~
MmsInputStream
()
noexcept
override
{
Stop
();
}
protected
:
virtual
void
Open
()
override
;
virtual
size_t
ThreadRead
(
void
*
ptr
,
size_t
size
)
override
;
...
...
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