decoder/API: move part of decoder_check_cancel_read() into class DecoderBridge
This commit is contained in:
parent
8c342a764b
commit
2718f4c333
@ -43,6 +43,26 @@ DecoderBridge::~DecoderBridge()
|
||||
delete decoder_tag;
|
||||
}
|
||||
|
||||
bool
|
||||
DecoderBridge::CheckCancelRead() const
|
||||
{
|
||||
if (error)
|
||||
/* this translates to DecoderCommand::STOP */
|
||||
return true;
|
||||
|
||||
if (dc.command == DecoderCommand::NONE)
|
||||
return false;
|
||||
|
||||
/* ignore the SEEK command during initialization, the plugin
|
||||
should handle that after it has initialized successfully */
|
||||
if (dc.command == DecoderCommand::SEEK &&
|
||||
(dc.state == DecoderState::START || seeking ||
|
||||
initial_seek_running))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* All chunks are full of decoded data; wait for the player to free
|
||||
* one.
|
||||
|
@ -107,6 +107,15 @@ public:
|
||||
|
||||
~DecoderBridge();
|
||||
|
||||
/**
|
||||
* Should be read operation be cancelled? That is the case when the
|
||||
* player thread has sent a command such as "STOP".
|
||||
*
|
||||
* Caller must lock the #DecoderControl object.
|
||||
*/
|
||||
gcc_pure
|
||||
bool CheckCancelRead() const;
|
||||
|
||||
/**
|
||||
* Returns the current chunk the decoder writes to, or allocates a new
|
||||
* chunk if there is none.
|
||||
|
@ -264,25 +264,7 @@ gcc_pure
|
||||
static inline bool
|
||||
decoder_check_cancel_read(const DecoderBridge *bridge)
|
||||
{
|
||||
if (bridge == nullptr)
|
||||
return false;
|
||||
|
||||
if (bridge->error)
|
||||
/* this translates to DecoderCommand::STOP */
|
||||
return true;
|
||||
|
||||
const DecoderControl &dc = bridge->dc;
|
||||
if (dc.command == DecoderCommand::NONE)
|
||||
return false;
|
||||
|
||||
/* ignore the SEEK command during initialization, the plugin
|
||||
should handle that after it has initialized successfully */
|
||||
if (dc.command == DecoderCommand::SEEK &&
|
||||
(dc.state == DecoderState::START || bridge->seeking ||
|
||||
bridge->initial_seek_running))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return bridge != nullptr && bridge->CheckCancelRead();
|
||||
}
|
||||
|
||||
size_t
|
||||
|
Loading…
Reference in New Issue
Block a user