Skip to content

Commit ca157d8

Browse files
author
Clement Champetier
committed
pyTest: fix seg fault in the readers tests
* Force to call the reader destructor before the inputFile destructor (which cannot happen in C++). * This is a new problem since the decoder has a link to the stream, which is needed to access the codec to close it. So the file, which handles the streams, should not be destroyed before the decoders.
1 parent aa9387e commit ca157d8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

test/pyTest/testAudioReader.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,18 @@ def testAudioReaderChannelsExtraction():
5555

5656
assert_equals( sizeOfFrameWithAllChannels / nbChannels, sizeOfFrameWithOneChannels )
5757

58+
# Force to call the readers destructor before the inputFile destructor (which cannot happen in C++)
59+
readerOfAllChannels = None
60+
readerOfOneChannel = None
61+
5862

5963
def testAudioReaderWithGenerator():
6064
"""
6165
Read an audio stream with the AudioReader.
6266
When there is no more data to decode, switch to a generator and process some frames.
6367
"""
6468
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
65-
inputFile = av.InputFile(inputFileName)
66-
reader = av.AudioReader(inputFile)
69+
reader = av.AudioReader(inputFileName)
6770

6871
# read all frames and check their size
6972
while True:

test/pyTest/testVideoReader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def testVideoReaderCreateNewInputFile():
2525
assert_equals( frame.getDataSize(), reader.getOutputWidth() * reader.getOutputHeight() * bytesPerPixel )
2626

2727
# check if there is no next frame
28-
frame = reader.readNextFrame()
2928
assert_equals( reader.readNextFrame(), None )
3029

3130

@@ -47,6 +46,9 @@ def testVideoReaderReferenceInputFile():
4746
# check if there is no next frame
4847
assert_equals( reader.readNextFrame(), None )
4948

49+
# Force to call the reader destructor before the inputFile destructor (which cannot happen in C++)
50+
reader = None
51+
5052

5153
def testVideoReaderWithGenerator():
5254
"""

0 commit comments

Comments
 (0)