LibCecSharp: set the callback methods in libcec to NULL before closing the connection...
[deb_libcec.git] / src / LibCecSharp / LibCecSharp.cpp
index 6cdc6ab0a72b14e2cafb86215bef5094ec222f23..4e76ead7a6ab264252ef97040448e9909fb93729 100644 (file)
@@ -136,6 +136,8 @@ namespace CecSharp
 
                void Close(void)
                {
+                       // delete the callbacks, since these might already have been destroyed in .NET
+                       m_libCec->EnableCallbacks(NULL, NULL);
                        m_libCec->Close();
                }
 
@@ -226,7 +228,7 @@ namespace CecSharp
                        return m_libCec->SetLogicalAddress((cec_logical_address) logicalAddress);
                }
 
-               bool SetPhysicalAddress(int16_t physicalAddress)
+               bool SetPhysicalAddress(uint16_t physicalAddress)
                {
                        return m_libCec->SetPhysicalAddress(physicalAddress);
                }
@@ -388,9 +390,31 @@ namespace CecSharp
                        return m_libCec->GetDevicePhysicalAddress((cec_logical_address)iAddress);
                }
 
+               bool SetStreamPath(CecLogicalAddress iAddress)
+               {
+                       return m_libCec->SetStreamPath((cec_logical_address)iAddress);
+               }
+
+               bool SetStreamPath(uint16_t iPhysicalAddress)
+               {
+                       return m_libCec->SetStreamPath(iPhysicalAddress);
+               }
+
+               CecLogicalAddresses ^GetLogicalAddresses(void)
+               {
+                       CecLogicalAddresses ^addr = gcnew CecLogicalAddresses();
+                       cec_logical_addresses libAddr = m_libCec->GetLogicalAddresses();
+                       for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+                               addr->Addresses[iPtr] = (CecLogicalAddress)libAddr.addresses[iPtr];
+                       addr->Primary = (CecLogicalAddress)libAddr.primary;
+                       return addr;
+               }
+
                bool GetCurrentConfiguration(LibCECConfiguration ^configuration)
                {
                        libcec_configuration config;
+                       config.Clear();
+
                        if (m_libCec->GetCurrentConfiguration(&config))
                        {
                                configuration->BaseDevice = (CecLogicalAddress)config.baseDevice;