forked from mia/Aegisub
Fix a bug that would occasionally cause opening audio using the ffms2 audio provider to fail with error "out of bounds track number selected".
Originally committed to SVN as r3818.
This commit is contained in:
parent
653427fbad
commit
e720bba41c
1 changed files with 11 additions and 2 deletions
|
@ -156,14 +156,19 @@ void FFmpegSourceAudioProvider::LoadAudio(wxString filename) {
|
||||||
Index = NULL;
|
Index = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no valid index exists and the file only has one audio track, index all tracks
|
// no valid index exists and the file only has one audio track, index it
|
||||||
else if (TrackNumber < 0)
|
else if (TrackNumber < 0)
|
||||||
TrackNumber = FFMS_TRACKMASK_ALL;
|
TrackNumber = FFMS_TRACKMASK_ALL;
|
||||||
// else: do nothing (keep track mask as it is)
|
// else: do nothing (keep track mask as it is)
|
||||||
|
|
||||||
// moment of truth
|
// moment of truth
|
||||||
if (!IndexIsValid) {
|
if (!IndexIsValid) {
|
||||||
int TrackMask = Options.AsBool(_T("FFmpegSource always index all tracks")) ? FFMS_TRACKMASK_ALL : 1 << TrackNumber;
|
int TrackMask;
|
||||||
|
if (Options.AsBool(_T("FFmpegSource always index all tracks")) || TrackNumber == FFMS_TRACKMASK_ALL)
|
||||||
|
TrackMask = FFMS_TRACKMASK_ALL;
|
||||||
|
else
|
||||||
|
TrackMask = (1 << TrackNumber);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Index = DoIndexing(Indexer, CacheName, TrackMask, false);
|
Index = DoIndexing(Indexer, CacheName, TrackMask, false);
|
||||||
} catch (wxString temp) {
|
} catch (wxString temp) {
|
||||||
|
@ -172,6 +177,10 @@ void FFmpegSourceAudioProvider::LoadAudio(wxString filename) {
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if tracknumber still isn't set we need to set it now
|
||||||
|
if (TrackNumber == FFMS_TRACKMASK_ALL)
|
||||||
|
TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, &ErrInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update access time of index file so it won't get cleaned away
|
// update access time of index file so it won't get cleaned away
|
||||||
|
|
Loading…
Reference in a new issue