@@ -415,41 +415,44 @@ def __audiorender_thread(self):
415415
416416 while self .status in [PLAYING ,PAUSED ]:
417417 # Retrieve audiochunk
418- if self .status == PLAYING and new_audioframe is None :
419- # Get a new frame from the audiostream, skip to the next one
420- # if the current one gives a problem
421- try :
422- start = self .audio_times .pop (0 )
423- stop = self .audio_times [0 ]
424- except IndexError :
425- logger .debug ("Audio times could not be obtained" )
426- time .sleep (0.02 )
427- continue
428-
429- # Get the frame numbers to extract from the audio stream.
430- chunk = (1.0 / self .audioformat ['fps' ])* np .arange (start , stop )
431-
432- try :
433- # Extract the frames from the audio stream. Does not always,
434- # succeed (e.g. with bad streams missing frames), so make
435- # sure this doesn't crash the whole program.
436- new_audioframe = self .clip .audio .to_soundarray (
437- tt = chunk ,
438- buffersize = self .frame_interval * self .clip .audio .fps ,
439- quantize = True
440- )
441- except OSError as e :
442- logger .warning ("Sound decoding error: {}" .format (e ))
443- new_audioframe = None
444- # Put audioframe in buffer/queue for soundrenderer to pick up. If
445- # the queue is full, try again after a timeout (this allows to check
446- # if the status is still PLAYING after a pause.)
447- if not new_audioframe is None :
448- try :
449- self .audioqueue .put (new_audioframe , timeout = .05 )
450- new_audioframe = None
451- except Full :
452- pass
418+ if self .status == PLAYING :
419+ if new_audioframe is None :
420+ # Get a new frame from the audiostream, skip to the next one
421+ # if the current one gives a problem
422+ try :
423+ start = self .audio_times .pop (0 )
424+ stop = self .audio_times [0 ]
425+ except IndexError :
426+ logger .debug ("Audio times could not be obtained" )
427+ time .sleep (0.02 )
428+ continue
429+
430+ # Get the frame numbers to extract from the audio stream.
431+ chunk = (1.0 / self .audioformat ['fps' ])* np .arange (start , stop )
432+
433+ try :
434+ # Extract the frames from the audio stream. Does not always,
435+ # succeed (e.g. with bad streams missing frames), so make
436+ # sure this doesn't crash the whole program.
437+ new_audioframe = self .clip .audio .to_soundarray (
438+ tt = chunk ,
439+ buffersize = self .frame_interval * self .clip .audio .fps ,
440+ quantize = True
441+ )
442+ except OSError as e :
443+ logger .warning ("Sound decoding error: {}" .format (e ))
444+ new_audioframe = None
445+ # Put audioframe in buffer/queue for soundrenderer to pick up. If
446+ # the queue is full, try again after a timeout (this allows to check
447+ # if the status is still PLAYING after a pause.)
448+ if not new_audioframe is None :
449+ try :
450+ self .audioqueue .put (new_audioframe , timeout = .05 )
451+ new_audioframe = None
452+ except Full :
453+ pass
454+
455+ time .sleep (0.005 )
453456
454457 logger .debug ("Stopped audio rendering thread." )
455458
0 commit comments