TimeshiftWindowClient is not released on failing to start buffering.
In BufferingRequestImpl.startBuffering(), it gets a TimeShiftWindowClient by calling the method TimeShiftManager.getTSWByDuration(). During the execution of this method a new tswc is created and added to the tsw. Also NI resource usages are updated properly. If the tswc is in the state TSWSTATE_READY_TO_BUFFER/TSWSTATE_BUFFERING it calls tswc.attachFor(). This method can throw IllelgalStateException/IllegalArgumentException. These exceptions are not handled properly. attachFor() itself catches these excepitons, updates the constraints and throws it again. But tswc is not released anywhere.
These are the points which needs clarification:
1) From BufferingRequestImpl.startBuffering() when attachFor(TimeShiftManager.TSWUSE_BUFFERING) is called, on getting IllegalstateException/IllegalArgumentException, the tswc is not released. In the same file, in WFTunedState.tswChanged(), on getting IllegalStateException it is releasing tswc and changing the state to m_retryStateImpl.
2) In BufferingRequestImpl.startBuffering(), IllegalStateException is caught and does not do any action. IllegalArgumentException is not caught and hence it is propagated to applicaiton.
3) In WFTunedState.tswChanged(), it is catching IllegalStateException and handles properly. But it does not handle IllegalArgumentException.
Also, TimeShiftWindowClient.attachFor() is called from multiple places and at all the places other than from BufferingRequestImpl, exceptions are caught and not done any action.