advanced.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. mpg123clr: MPEG Audio Decoder library Common Language Runtime version.
  3. copyright 2009 by Malcolm Boczek - free software under the terms of the LGPL 2.1
  4. mpg123clr.dll is a derivative work of libmpg123 - all original mpg123 licensing terms apply.
  5. All rights to this work freely assigned to the mpg123 project.
  6. */
  7. /*
  8. libmpg123: MPEG Audio Decoder library
  9. copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1
  10. see COPYING and AUTHORS files in distribution or http://mpg123.org
  11. */
  12. /*
  13. 1.8.1.0 04-Aug-09 Initial release.
  14. 1.9.0.0 24-Sep-09 Function names harmonized with libmpg123 (mb)
  15. 1.9.0.0 13-Oct-09 pin_ptr = nullptr on return (mb)
  16. 1.9.0.1 24-Nov-09 performance update - removed try/finally (mb)
  17. */
  18. #include "StdAfx.h"
  19. #include "advanced.h"
  20. mpg123clr::advpars::advpars(int% error)
  21. {
  22. pin_ptr<int> err = &error;
  23. mp = ::mpg123_new_pars(err);
  24. err = nullptr;
  25. }
  26. mpg123clr::advpars::~advpars(void)
  27. {
  28. // clean up code to release managed resources
  29. // ...
  30. // call Finalizer to clean up unmanaged resources
  31. this->!advpars();
  32. }
  33. mpg123clr::advpars::!advpars(void)
  34. {
  35. if (mp != NULL)
  36. {
  37. ::mpg123_delete_pars(mp);
  38. mp = NULL;
  39. }
  40. }
  41. mpg123clr::mpg::ErrorCode mpg123clr::advpars::mpg123_fmt_none(void)
  42. {
  43. return (mpg123clr::mpg::ErrorCode) ::mpg123_fmt_none(mp);
  44. }
  45. mpg123clr::mpg::ErrorCode mpg123clr::advpars::mpg123_fmt_all(void)
  46. {
  47. return (mpg123clr::mpg::ErrorCode) ::mpg123_fmt_all(mp);
  48. }
  49. mpg123clr::mpg::ErrorCode mpg123clr::advpars::mpg123_fmt(int rate, mpg123clr::mpg::channelcount channels, int encodings)
  50. {
  51. return (mpg123clr::mpg::ErrorCode) ::mpg123_fmt(mp, rate, (int)channels, encodings);
  52. }
  53. mpg123clr::mpg::channelcount mpg123clr::advpars::mpg123_fmt_support(int rate, int encodings)
  54. {
  55. return (mpg123clr::mpg::channelcount) ::mpg123_fmt_support(mp, rate, encodings);
  56. }
  57. mpg123clr::mpg::ErrorCode mpg123clr::advpars::mpg123_par(mpg123clr::mpg::parms type, int val, double fval)
  58. {
  59. return (mpg123clr::mpg::ErrorCode) ::mpg123_par(mp, (mpg123_parms) type, val, fval);
  60. }
  61. mpg123clr::mpg::ErrorCode mpg123clr::advpars::mpg123_getpar(mpg123clr::mpg::parms type, [Out] int% val, [Out] double% fval)
  62. {
  63. // Avoid need for local intermediary variables
  64. pin_ptr<int> _val = &val;
  65. pin_ptr<double> _fval = &fval;
  66. int ret = ::mpg123_getpar(mp, (mpg123_parms) type, (long*)_val, _fval);
  67. _fval = nullptr;
  68. _val = nullptr;
  69. return (mpg123clr::mpg::ErrorCode) ret;
  70. }