mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 856562 - Fix decode race in gstreamer backend r=alessandro.d
This commit is contained in:
parent
99768370bd
commit
57bdc4503a
@ -423,34 +423,28 @@ void GStreamerReader::NotifyBytesConsumed()
|
||||
mLastReportedByteOffset = mByteOffset;
|
||||
}
|
||||
|
||||
bool GStreamerReader::WaitForDecodedData(int* aCounter)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mGstThreadsMonitor);
|
||||
|
||||
/* Report consumed bytes from here as we can't do it from gst threads */
|
||||
NotifyBytesConsumed();
|
||||
while(*aCounter == 0) {
|
||||
if (mReachedEos) {
|
||||
return false;
|
||||
}
|
||||
mon.Wait();
|
||||
NotifyBytesConsumed();
|
||||
}
|
||||
(*aCounter)--;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GStreamerReader::DecodeAudioData()
|
||||
{
|
||||
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
|
||||
|
||||
if (!WaitForDecodedData(&mAudioSinkBufferCount)) {
|
||||
GstBuffer *buffer = nullptr;
|
||||
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mGstThreadsMonitor);
|
||||
|
||||
if (mReachedEos) {
|
||||
mAudioQueue.Finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
GstBuffer* buffer = gst_app_sink_pull_buffer(mAudioAppSink);
|
||||
if (!mAudioSinkBufferCount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
buffer = gst_app_sink_pull_buffer(mAudioAppSink);
|
||||
mAudioSinkBufferCount--;
|
||||
}
|
||||
|
||||
int64_t timestamp = GST_BUFFER_TIMESTAMP(buffer);
|
||||
timestamp = gst_segment_to_stream_time(&mAudioSegment,
|
||||
GST_FORMAT_TIME, timestamp);
|
||||
@ -480,24 +474,32 @@ bool GStreamerReader::DecodeVideoFrame(bool &aKeyFrameSkip,
|
||||
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
|
||||
|
||||
GstBuffer *buffer = nullptr;
|
||||
int64_t timestamp, nextTimestamp;
|
||||
while (true)
|
||||
|
||||
{
|
||||
if (!WaitForDecodedData(&mVideoSinkBufferCount)) {
|
||||
ReentrantMonitorAutoEnter mon(mGstThreadsMonitor);
|
||||
|
||||
if (mReachedEos) {
|
||||
mVideoQueue.Finish();
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mVideoSinkBufferCount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mDecoder->NotifyDecodedFrames(0, 1);
|
||||
|
||||
buffer = gst_app_sink_pull_buffer(mVideoAppSink);
|
||||
mVideoSinkBufferCount--;
|
||||
}
|
||||
|
||||
bool isKeyframe = !GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DISCONT);
|
||||
if ((aKeyFrameSkip && !isKeyframe)) {
|
||||
gst_buffer_unref(buffer);
|
||||
buffer = nullptr;
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP(buffer);
|
||||
int64_t timestamp = GST_BUFFER_TIMESTAMP(buffer);
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mGstThreadsMonitor);
|
||||
timestamp = gst_segment_to_stream_time(&mVideoSegment,
|
||||
@ -505,7 +507,7 @@ bool GStreamerReader::DecodeVideoFrame(bool &aKeyFrameSkip,
|
||||
}
|
||||
NS_ASSERTION(GST_CLOCK_TIME_IS_VALID(timestamp),
|
||||
"frame has invalid timestamp");
|
||||
timestamp = nextTimestamp = GST_TIME_AS_USECONDS(timestamp);
|
||||
int64_t nextTimestamp = timestamp = GST_TIME_AS_USECONDS(timestamp);
|
||||
if (GST_CLOCK_TIME_IS_VALID(GST_BUFFER_DURATION(buffer)))
|
||||
nextTimestamp += GST_TIME_AS_USECONDS(GST_BUFFER_DURATION(buffer));
|
||||
else if (fpsNum && fpsDen)
|
||||
@ -517,11 +519,7 @@ bool GStreamerReader::DecodeVideoFrame(bool &aKeyFrameSkip,
|
||||
" threshold %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS(timestamp), GST_TIME_ARGS(aTimeThreshold)));
|
||||
gst_buffer_unref(buffer);
|
||||
buffer = nullptr;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!buffer)
|
||||
@ -570,8 +568,7 @@ bool GStreamerReader::DecodeVideoFrame(bool &aKeyFrameSkip,
|
||||
b.mPlanes[i].mSkip = 0;
|
||||
}
|
||||
|
||||
bool isKeyframe = !GST_BUFFER_FLAG_IS_SET(buffer,
|
||||
GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
isKeyframe = !GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
/* XXX ? */
|
||||
int64_t offset = 0;
|
||||
VideoData* video = VideoData::Create(mInfo, image, offset,
|
||||
|
@ -50,7 +50,6 @@ public:
|
||||
private:
|
||||
|
||||
void ReadAndPushData(guint aLength);
|
||||
bool WaitForDecodedData(int* counter);
|
||||
void NotifyBytesConsumed();
|
||||
int64_t QueryDuration();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user