Skip to content
Browse files

remove audio track which failed to init codec

git-svn-id: http://movist.googlecode.com/svn/trunk@264 9988c26d-9134-0410-b5bb-5778289bb252
  • Loading branch information...
1 parent fe8b743 commit 5c437b656a469ce20b9dff735cb2d15c255fb544 moosoy committed May 17, 2009
Showing with 10 additions and 8 deletions.
  1. +10 −8 MMovie_FFMPEG.m
View
18 MMovie_FFMPEG.m
@@ -187,7 +187,7 @@ - (BOOL)initAVCodec:(int*)errorCode digitalAudioOut:(BOOL)digitalAudioOut
TRACE(@"%s", __PRETTY_FUNCTION__);
_trackMutex = [[NSLock alloc] init];
bool needPtsAdjust = strstr(_formatContext->iformat->name, "matroska");
-
+
MTrack* track;
FFVideoTrack* vTrack;
NSEnumerator* enumerator = [_videoTracks objectEnumerator];
@@ -206,25 +206,27 @@ - (BOOL)initAVCodec:(int*)errorCode digitalAudioOut:(BOOL)digitalAudioOut
[vTrack setMovie:self];
[track setMovie:self];
}
+ NSMutableIndexSet* removeTracks = [NSMutableIndexSet indexSet];
BOOL passThrough = FALSE;
FFAudioTrack* aTrack;
enumerator = [_audioTracks objectEnumerator];
while (track = (MTrack*)[enumerator nextObject]) {
aTrack = (FFAudioTrack*)[track impl];
passThrough = digitalAudioOut && [aTrack isAc3Dts];
- if ([aTrack initTrack:errorCode passThrough:passThrough]) {
- if (!_mainAudioTrack) {
- _mainAudioTrack = aTrack;
- }
- [track setEnabled:aTrack == _mainAudioTrack];
- }
- else {
+ if (![aTrack initTrack:errorCode passThrough:passThrough]) {
[track setEnabled:FALSE];
+ [removeTracks addIndex:[_audioTracks indexOfObject:track]];
+ continue;
+ }
+ if (!_mainAudioTrack) {
+ _mainAudioTrack = aTrack;
}
+ [track setEnabled:aTrack == _mainAudioTrack];
[aTrack setSpeakerCount:2]; // FIXME
[aTrack setMovie:self];
[track setMovie:self];
}
+ [_audioTracks removeObjectsAtIndexes:removeTracks];
return (0 != _mainVideoTrack);
}

0 comments on commit 5c437b6

Please sign in to comment.
Something went wrong with that request. Please try again.