close.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. function vw = close(vw)
  2. %VW=CLOSE(VW)
  3. % Closes video VW and releases any system resources necessary to access it
  4. % (e.g. threads, file handles, etc.). Do NOT just clear a videoWriter
  5. % object without first closing its handle:
  6. %
  7. % % BAD code--typically will leak system resources
  8. % vw = videoWriter(...);
  9. % ...
  10. % clear vw; % leaks resources, probably results in a corrupted file
  11. %
  12. % % GOOD code
  13. % vw = videoWriter(...);
  14. % ...
  15. % vw = close(vw);
  16. % clear vw; % okay, but not needed
  17. %
  18. % After calling CLOSE, VW should not be used any more.
  19. % vw = videoWriter(...);
  20. % vw = close(vr);
  21. % next(vw); % BAD
  22. % vw = videoWriter(...);
  23. % close(vw); % BAD: should reassign result to vw to be safe
  24. % next(vw); % BAD
  25. %
  26. %SEE ALSO
  27. % videoWriter
  28. %
  29. %Copyright (c) 2007 Gerald Dalley
  30. %See "MIT.txt" in the installation directory for licensing details (especially
  31. %when using this library on GNU/Linux).
  32. feval(vw.plugin, 'close', vw.handle);
  33. vw.handle = nan;