public void deallocate() {
        if(state == REALIZED || state == UNREALIZED) return;
        if(state == CLOSED) throw new IllegalStateException();
        if(state == STARTED ){
            try{
                stop();
            }
            catch(MediaException e){
            }
        }
        deallocateImpl();
        state = REALIZED;
    }