Make ThreadedFrameSource never lock jobMutex and fileMutex at the same time. Moderately improves responsiveness of the audio display while video is loaded.

Originally committed to SVN as r5070.
This commit is contained in:
Thomas Goyne 2010-12-30 22:19:36 +00:00
parent ca8b6d8525
commit 5370f3fa04
2 changed files with 10 additions and 8 deletions

View file

@ -125,6 +125,7 @@ void *ThreadedFrameSource::Entry() {
while (!TestDestroy() && run) { while (!TestDestroy() && run) {
double time; double time;
int frameNum; int frameNum;
std::auto_ptr<AssFile> newSubs;
{ {
wxMutexLocker jobLocker(jobMutex); wxMutexLocker jobLocker(jobMutex);
@ -133,15 +134,16 @@ void *ThreadedFrameSource::Entry() {
continue; continue;
} }
if (nextSubs.get()) {
wxMutexLocker fileLocker(fileMutex);
subs = nextSubs;
singleFrame = -1;
}
time = nextTime; time = nextTime;
frameNum = nextFrame; frameNum = nextFrame;
nextTime = -1.; nextTime = -1.;
newSubs = nextSubs;
}
if (newSubs.get()) {
wxMutexLocker fileLocker(fileMutex);
subs = newSubs;
singleFrame = -1;
} }
try { try {

View file

@ -69,8 +69,8 @@ class ThreadedFrameSource : public wxThread {
/// it was last sent to the subtitle provider /// it was last sent to the subtitle provider
int singleFrame; int singleFrame;
wxMutex fileMutex; ///< Mutex for subtitle file usage wxMutex fileMutex; ///< Mutex for subs and singleFrame
wxMutex jobMutex; ///< Mutex for nextFrame/nextTime wxMutex jobMutex; ///< Mutex for nextFrame, nextTime and nextSubs
wxMutex providerMutex; ///< Mutex for video provider wxMutex providerMutex; ///< Mutex for video provider
wxMutex evtMutex; ///< Mutex for FrameReadyEvents associated with this wxMutex evtMutex; ///< Mutex for FrameReadyEvents associated with this