Partially fixes a memory leak which used to retain CallDialog and just about anything related to a Call because MediaControl#sourceProcessor wasn't closed, it was just stopped. The fix works for calls with no video. Video calls though, at least on Linux, still leak the same objects but the cause is different (and I suspect civil to be erroneously not breaking a reference).

cusax-fix
Lyubomir Marinov 17 years ago
parent de3361a81b
commit 372ab97ca0

@ -91,7 +91,7 @@ public class MediaControl
* The processor that will be handling content coming from our capture data
* sources.
*/
public Processor sourceProcessor = null;
private Processor sourceProcessor = null;
/**
* The list of readers currently using our processor.
@ -200,8 +200,7 @@ public void propertyChange(PropertyChangeEvent evt)
private void initCaptureDevices()
throws MediaException
{
if (avDataSource != null)
avDataSource.disconnect();
disposeBeforeInitCaptureDevices();
// Init audio device
CaptureDeviceInfo audioDeviceInfo
@ -286,6 +285,33 @@ else if (videoDataSource != null)
sourceProcessor = null;
}
/**
* Allows this instance to dispose of any state which is to reinitialized by
* {@link #initCaptureDevices()}. For example, a vital requirement is to
* invoke {@link Controller#close()} on <code>sourceProcessor</code>
* regardless of the fact that it is soon to not be referenced at all or it
* will keep unnecessary threads alive and they will in turn keep just about
* anything created to an associated <code>Call</code>.
*/
private void disposeBeforeInitCaptureDevices()
{
if (avDataSource != null)
avDataSource.disconnect();
if (sourceProcessor != null)
{
sourceProcessor.stop();
if (sourceProcessor.getState() == Processor.Realized)
{
DataSource dataOutput = sourceProcessor.getDataOutput();
if (dataOutput != null)
dataOutput.disconnect();
}
sourceProcessor.deallocate();
sourceProcessor.close();
}
}
/**
* Opens the source pointed to by the <tt>debugMediaSource</tt> URL and
* prepares to use it instead of capture devices.
@ -973,9 +999,6 @@ public void stopProcessingMedia(Object reader)
if( sourceProcessor.getState() == Processor.Started )
{
avDataSource.disconnect();
sourceProcessor.stop();
try
{
initCaptureDevices();
@ -1158,19 +1181,6 @@ public void setLocalVideoAllowed(boolean allowed)
{
localVideoAllowed = allowed;
if (sourceProcessor != null)
{
sourceProcessor.stop();
if (sourceProcessor.getState() == Processor.Realized)
{
DataSource dataOutput = sourceProcessor.getDataOutput();
if (dataOutput != null)
dataOutput.disconnect();
}
sourceProcessor.deallocate();
sourceProcessor.close();
}
initCaptureDevices();
}
}

Loading…
Cancel
Save