decoder/API: use ScopeLock
This commit is contained in:
parent
aa7694047b
commit
b9213df64b
@ -80,10 +80,9 @@ decoder_initialized(Decoder &decoder,
|
|||||||
decoder.error = std::move(error);
|
decoder.error = std::move(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.Lock();
|
const ScopeLock protect(dc.mutex);
|
||||||
dc.state = DecoderState::DECODE;
|
dc.state = DecoderState::DECODE;
|
||||||
dc.client_cond.signal();
|
dc.client_cond.signal();
|
||||||
dc.Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,6 +153,14 @@ decoder_get_virtual_command(Decoder &decoder)
|
|||||||
return dc.command;
|
return dc.command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
static DecoderCommand
|
||||||
|
decoder_lock_get_virtual_command(Decoder &decoder)
|
||||||
|
{
|
||||||
|
const ScopeLock protect(decoder.dc.mutex);
|
||||||
|
return decoder_get_virtual_command(decoder);
|
||||||
|
}
|
||||||
|
|
||||||
DecoderCommand
|
DecoderCommand
|
||||||
decoder_get_command(Decoder &decoder)
|
decoder_get_command(Decoder &decoder)
|
||||||
{
|
{
|
||||||
@ -165,7 +172,7 @@ decoder_command_finished(Decoder &decoder)
|
|||||||
{
|
{
|
||||||
DecoderControl &dc = decoder.dc;
|
DecoderControl &dc = decoder.dc;
|
||||||
|
|
||||||
dc.Lock();
|
const ScopeLock protect(dc.mutex);
|
||||||
|
|
||||||
assert(dc.command != DecoderCommand::NONE ||
|
assert(dc.command != DecoderCommand::NONE ||
|
||||||
decoder.initial_seek_running);
|
decoder.initial_seek_running);
|
||||||
@ -181,7 +188,6 @@ decoder_command_finished(Decoder &decoder)
|
|||||||
|
|
||||||
decoder.initial_seek_running = false;
|
decoder.initial_seek_running = false;
|
||||||
decoder.timestamp = dc.start_time.ToDoubleS();
|
decoder.timestamp = dc.start_time.ToDoubleS();
|
||||||
dc.Unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +208,6 @@ decoder_command_finished(Decoder &decoder)
|
|||||||
|
|
||||||
dc.command = DecoderCommand::NONE;
|
dc.command = DecoderCommand::NONE;
|
||||||
dc.client_cond.signal();
|
dc.client_cond.signal();
|
||||||
dc.Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SongTime
|
SongTime
|
||||||
@ -451,15 +456,12 @@ decoder_data(Decoder &decoder,
|
|||||||
uint16_t kbit_rate)
|
uint16_t kbit_rate)
|
||||||
{
|
{
|
||||||
DecoderControl &dc = decoder.dc;
|
DecoderControl &dc = decoder.dc;
|
||||||
DecoderCommand cmd;
|
|
||||||
|
|
||||||
assert(dc.state == DecoderState::DECODE);
|
assert(dc.state == DecoderState::DECODE);
|
||||||
assert(dc.pipe != nullptr);
|
assert(dc.pipe != nullptr);
|
||||||
assert(length % dc.in_audio_format.GetFrameSize() == 0);
|
assert(length % dc.in_audio_format.GetFrameSize() == 0);
|
||||||
|
|
||||||
dc.Lock();
|
DecoderCommand cmd = decoder_lock_get_virtual_command(decoder);
|
||||||
cmd = decoder_get_virtual_command(decoder);
|
|
||||||
dc.Unlock();
|
|
||||||
|
|
||||||
if (cmd == DecoderCommand::STOP || cmd == DecoderCommand::SEEK ||
|
if (cmd == DecoderCommand::STOP || cmd == DecoderCommand::SEEK ||
|
||||||
length == 0)
|
length == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user