Revert Gst initialization on Windows since it didn't have any impact on crashes.

This commit is contained in:
esaunders 2020-03-11 12:08:56 -04:00
parent 219bb5b2e0
commit 92a3667a14

View File

@ -74,7 +74,6 @@ import org.freedesktop.gstreamer.Format;
import org.freedesktop.gstreamer.GstException;
import org.freedesktop.gstreamer.event.SeekFlags;
import org.freedesktop.gstreamer.event.SeekType;
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
/**
* This is a video player that is part of the Media View layered pane. It uses
@ -222,14 +221,6 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
//True for fairness. In other words,
//acquire() calls are processed in order of invocation.
sliderLock = new Semaphore(1, true);
/**
* See JIRA-5888 for details. Initializing gstreamer here is more stable
* on Windows.
*/
if (PlatformUtil.isWindowsOS()) {
Gst.init();
}
}
private void customizeComponents() {
@ -278,6 +269,7 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
}
previousState = State.NULL;
}
@Override
public void mouseClicked(MouseEvent e) {
}
@ -389,6 +381,7 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
gstPlayBin.getBus().disconnect(endOfStreamListener);
gstPlayBin.getBus().disconnect(stateChangeListener);
gstPlayBin.getBus().disconnect(errorListener);
gstPlayBin.getBus().dispose();
gstPlayBin.dispose();
fxAppSink.clear();
gstPlayBin = null;
@ -548,10 +541,8 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
// Initialize Gstreamer. It is safe to call this for every file.
// It was moved here from the constructor because having it happen
// earlier resulted in conflicts on Linux. See JIRA-5888.
if (!PlatformUtil.isWindowsOS()) {
// earlier resulted in crashes on Linux. See JIRA-5888.
Gst.init();
}
//Video is ready for playback. Create new components
gstPlayBin = new PlayBin("VideoPlayer", tempFile.toURI());
@ -599,13 +590,15 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
@Override
public void actionPerformed(ActionEvent e) {
if (!progressSlider.getValueIsAdjusting()) {
try {
sliderLock.acquireUninterruptibly();
long position = gstPlayBin.queryPosition(TimeUnit.NANOSECONDS);
long duration = gstPlayBin.queryDuration(TimeUnit.NANOSECONDS);
/**
* Duration may not be known until there is video data in the
* pipeline. We start this updater when data-flow has just been
* initiated so buffering may still be in progress.
* Duration may not be known until there is video data in
* the pipeline. We start this updater when data-flow has
* just been initiated so buffering may still be in
* progress.
*/
if (duration >= 0 && position >= 0) {
double relativePosition = (double) position / duration;
@ -615,10 +608,12 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
SwingUtilities.invokeLater(() -> {
updateTimeLabel(position, duration);
});
} finally {
sliderLock.release();
}
}
}
}
/**
* Custom view for the JSlider.
@ -655,8 +650,8 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
}
/**
* Modifies the View to be an oval rather than the underlying
* rectangle Controller.
* Modifies the View to be an oval rather than the underlying rectangle
* Controller.
*/
@Override
public void paintThumb(Graphics graphic) {
@ -705,11 +700,12 @@ public class MediaPlayerPanel extends JPanel implements MediaFileViewer.MediaVie
@Override
protected TrackListener createTrackListener(JSlider slider) {
/**
* This track listener will force the thumb to be snapped to the mouse
* location. This makes grabbing and dragging the JSlider much easier.
* Using the default track listener, the user would have to click
* exactly on the slider thumb to drag it. Now the thumb positions
* itself under the mouse so that it can always be dragged.
* This track listener will force the thumb to be snapped to the
* mouse location. This makes grabbing and dragging the JSlider much
* easier. Using the default track listener, the user would have to
* click exactly on the slider thumb to drag it. Now the thumb
* positions itself under the mouse so that it can always be
* dragged.
*/
return new TrackListener() {
@Override