CefMediaObserver.g.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // DO NOT MODIFY! THIS IS AUTOGENERATED FILE!
  3. //
  4. namespace Xilium.CefGlue
  5. {
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Diagnostics;
  9. using System.Runtime.InteropServices;
  10. using System.Threading;
  11. using Xilium.CefGlue.Interop;
  12. // Role: HANDLER
  13. public abstract unsafe partial class CefMediaObserver
  14. {
  15. private static Dictionary<IntPtr, CefMediaObserver> _roots = new Dictionary<IntPtr, CefMediaObserver>();
  16. private int _refct;
  17. private cef_media_observer_t* _self;
  18. private cef_media_observer_t.add_ref_delegate _ds0;
  19. private cef_media_observer_t.release_delegate _ds1;
  20. private cef_media_observer_t.has_one_ref_delegate _ds2;
  21. private cef_media_observer_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_media_observer_t.on_sinks_delegate _ds4;
  23. private cef_media_observer_t.on_routes_delegate _ds5;
  24. private cef_media_observer_t.on_route_state_changed_delegate _ds6;
  25. private cef_media_observer_t.on_route_message_received_delegate _ds7;
  26. protected CefMediaObserver()
  27. {
  28. _self = cef_media_observer_t.Alloc();
  29. _ds0 = new cef_media_observer_t.add_ref_delegate(add_ref);
  30. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  31. _ds1 = new cef_media_observer_t.release_delegate(release);
  32. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  33. _ds2 = new cef_media_observer_t.has_one_ref_delegate(has_one_ref);
  34. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  35. _ds3 = new cef_media_observer_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  36. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  37. _ds4 = new cef_media_observer_t.on_sinks_delegate(on_sinks);
  38. _self->_on_sinks = Marshal.GetFunctionPointerForDelegate(_ds4);
  39. _ds5 = new cef_media_observer_t.on_routes_delegate(on_routes);
  40. _self->_on_routes = Marshal.GetFunctionPointerForDelegate(_ds5);
  41. _ds6 = new cef_media_observer_t.on_route_state_changed_delegate(on_route_state_changed);
  42. _self->_on_route_state_changed = Marshal.GetFunctionPointerForDelegate(_ds6);
  43. _ds7 = new cef_media_observer_t.on_route_message_received_delegate(on_route_message_received);
  44. _self->_on_route_message_received = Marshal.GetFunctionPointerForDelegate(_ds7);
  45. }
  46. ~CefMediaObserver()
  47. {
  48. Dispose(false);
  49. }
  50. protected virtual void Dispose(bool disposing)
  51. {
  52. if (_self != null)
  53. {
  54. cef_media_observer_t.Free(_self);
  55. _self = null;
  56. }
  57. }
  58. private void add_ref(cef_media_observer_t* self)
  59. {
  60. if (Interlocked.Increment(ref _refct) == 1)
  61. {
  62. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  63. }
  64. }
  65. private int release(cef_media_observer_t* self)
  66. {
  67. if (Interlocked.Decrement(ref _refct) == 0)
  68. {
  69. lock (_roots) { _roots.Remove((IntPtr)_self); }
  70. return 1;
  71. }
  72. return 0;
  73. }
  74. private int has_one_ref(cef_media_observer_t* self)
  75. {
  76. return _refct == 1 ? 1 : 0;
  77. }
  78. private int has_at_least_one_ref(cef_media_observer_t* self)
  79. {
  80. return _refct != 0 ? 1 : 0;
  81. }
  82. internal cef_media_observer_t* ToNative()
  83. {
  84. add_ref(_self);
  85. return _self;
  86. }
  87. [Conditional("DEBUG")]
  88. private void CheckSelf(cef_media_observer_t* self)
  89. {
  90. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  91. }
  92. }
  93. }