[ekiga] Do not reencode device names on Linux anymore



commit 18fc9d643b92fc4f97ff7246d14dfee44bba8dcc
Author: Eugen Dedu <Eugen Dedu pu-pm univ-fcomte fr>
Date:   Thu Feb 17 11:28:18 2011 +0100

    Do not reencode device names on Linux anymore
    
    Linux USB subsystem has been using utf-8 encoding for device name
    starting from 2.6.30 (10 June 2009).

 HACKING                                            |    5 ++---
 .../components/ptlib/audioinput-manager-ptlib.cpp  |   15 +++++++++++----
 .../components/ptlib/audiooutput-manager-ptlib.cpp |   15 +++++++++++----
 lib/engine/components/ptlib/utils.cpp              |   16 ++--------------
 lib/engine/components/ptlib/utils.h                |    8 ++++----
 .../components/ptlib/videoinput-manager-ptlib.cpp  |   17 +++++++++++++----
 6 files changed, 43 insertions(+), 33 deletions(-)
---
diff --git a/HACKING b/HACKING
index b3ff7e2..7171f26 100644
--- a/HACKING
+++ b/HACKING
@@ -24,8 +24,7 @@ Developers:
   keywords.  See the code for examples, such as
   lib/engine/videoinput/videinput-manager.h.
 - Encoding: Ekiga is completely UTF-8.  The only exception is that the
-  (audio/video) device names are in latin-1 for Linux <= 2.6.29, and
-  system codepage for Windows.  The latin2utf and utf2latin functions
-  take care of that.
+  (audio/video) device names are in system codepage for Windows.  The
+  latin2utf and utf2latin functions take care of that.
 - To find out which callbacks are called when o value in gconf
   changes, search gm_conf_notifier_add in ekiga code.
diff --git a/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp b/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
index 67bb14d..02b1e44 100644
--- a/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
@@ -77,9 +77,12 @@ void GMAudioInputManager_ptlib::get_devices(std::vector <Ekiga::AudioInputDevice
 
       for (PINDEX j = 0; devices_array[j] != NULL; j++) {
 
-        /* linux USB subsystem uses latin-1 encoding, Windows codepage,
-           while ekiga uses utf-8 */
-        device.name = latin2utf (devices_array[j]);
+#ifdef WIN32
+        /* Windows uses codepage encoding for device name, while ekiga uses utf-8 */
+        device.name = codepage2utf (devices_array[j]);
+#else
+        device.name = devices_array[j];
+#endif
         devices.push_back(device);
       }
       free (devices_array);
@@ -110,7 +113,11 @@ bool GMAudioInputManager_ptlib::open (unsigned channels, unsigned samplerate, un
   current_state.bits_per_sample = bits_per_sample;
 
   input_device = PSoundChannel::CreateOpenedChannel (current_state.device.source,
-                                                     utf2latin (current_state.device.name),  // reencode back to latin-1 or codepage
+#ifdef WIN32
+                                                     utf2codepage (current_state.device.name),  // reencode back to codepage
+#else
+                                                     current_state.device.name,
+#endif
                                                      PSoundChannel::Recorder,
                                                      channels,
                                                      samplerate,
diff --git a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
index f94d00a..297ab26 100644
--- a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
@@ -77,9 +77,12 @@ void GMAudioOutputManager_ptlib::get_devices(std::vector <Ekiga::AudioOutputDevi
 
       for (PINDEX j = 0; devices_array[j] != NULL; j++) {
 
-        /* linux USB subsystem uses latin-1 encoding, Windows codepage,
-           while ekiga uses utf-8 */
-        device.name = latin2utf (devices_array[j]);
+#ifdef WIN32
+        /* Windows uses codepage encoding for device name, while ekiga uses utf-8 */
+        device.name = codepage2utf (devices_array[j]);
+#else
+        device.name = devices_array[j];
+#endif
         devices.push_back(device);
       }
       free (devices_array);
@@ -110,7 +113,11 @@ bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPS ps, unsigned channel
   current_state[ps].bits_per_sample = bits_per_sample;
 
   output_device[ps] = PSoundChannel::CreateOpenedChannel (current_state[ps].device.source,
-                                                          utf2latin (current_state[ps].device.name),  // reencode back to latin-1 or codepage
+#ifdef WIN32
+                                                          utf2codepage (current_state[ps].device.name),  // reencode back to codepage
+#else
+                                                          current_state[ps].device.name,
+#endif
                                                           PSoundChannel::Player,
                                                           channels,
                                                           samplerate,
diff --git a/lib/engine/components/ptlib/utils.cpp b/lib/engine/components/ptlib/utils.cpp
index 4b16ba6..400e232 100644
--- a/lib/engine/components/ptlib/utils.cpp
+++ b/lib/engine/components/ptlib/utils.cpp
@@ -39,19 +39,13 @@
 #include "utils.h"
 
 const std::string
-latin2utf (const std::string str)
+codepage2utf (const std::string str)
 {
   gchar *utf8_str;
   std::string result;
 
-#ifdef WIN32
   utf8_str = g_locale_to_utf8 (str.c_str (), -1,
                                NULL, NULL, NULL);
-#else
-  utf8_str = g_convert (str.c_str (), -1,
-                        "UTF-8", "ISO-8859-1",
-                        NULL, NULL, NULL);
-#endif
   g_warn_if_fail (utf8_str != NULL);
   if (utf8_str == NULL)  /* conversion error */
     return "";
@@ -62,20 +56,14 @@ latin2utf (const std::string str)
 
 
 const std::string
-utf2latin (const std::string str)
+utf2codepage (const std::string str)
 {
   gchar *latin_str;
   std::string result;
 
   g_warn_if_fail (g_utf8_validate (str.c_str (), -1, NULL));
-#ifdef WIN32
   latin_str = g_locale_from_utf8 (str.c_str (), -1,
                                   NULL, NULL, NULL);
-#else
-  latin_str = g_convert (str.c_str (), -1,
-                         "ISO-8859-1", "UTF-8",
-                         NULL, NULL, NULL);
-#endif
   g_warn_if_fail (latin_str != NULL);
   if (latin_str == NULL)  /* conversion error */
     return "";
diff --git a/lib/engine/components/ptlib/utils.h b/lib/engine/components/ptlib/utils.h
index 1ff095a..5eba947 100644
--- a/lib/engine/components/ptlib/utils.h
+++ b/lib/engine/components/ptlib/utils.h
@@ -37,13 +37,13 @@
 #include <string>
 
 /* DESCRIPTION  :  /
- * BEHAVIOR     :  Change encoding from latin-1 to utf-8.
+ * BEHAVIOR     :  Change encoding from windows codepage to utf-8.
  * PRE          :  /
  */
-const std::string latin2utf (const std::string str);
+const std::string codepage2utf (const std::string str);
 
 /* DESCRIPTION  :  /
- * BEHAVIOR     :  Change encoding from utf-8 to latin-1.
+ * BEHAVIOR     :  Change encoding from utf-8 to windows codepage.
  * PRE          :  A validated utf-8 string.
  */
-const std::string utf2latin (const std::string str);
+const std::string utf2codepage (const std::string str);
diff --git a/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp b/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
index 580a1c2..b2ebe11 100644
--- a/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
@@ -79,9 +79,12 @@ void GMVideoInputManager_ptlib::get_devices(std::vector <Ekiga::VideoInputDevice
 
       for (PINDEX j = 0; devices_array[j] != NULL; j++) {
 
-        /* linux USB subsystem uses latin-1 encoding, Windows codepage,
-           while ekiga uses utf-8 */
-        device.name = latin2utf (devices_array[j]);
+#ifdef WIN32
+        /* Windows uses codepage encoding for device name, while ekiga uses utf-8 */
+        device.name = codepage2utf (devices_array[j]);
+#else
+        device.name = devices_array[j];
+#endif
         devices.push_back(device);
       }
       free (devices_array);
@@ -117,7 +120,13 @@ bool GMVideoInputManager_ptlib::open (unsigned width, unsigned height, unsigned
   expectedFrameSize = (width * height * 3) >> 1;
 
   pvideo_format = (PVideoDevice::VideoFormat)current_state.format;
-  input_device = PVideoInputDevice::CreateOpenedDevice (current_state.device.source, utf2latin (current_state.device.name), FALSE);  // reencode back to latin-1 or codepage
+  input_device = PVideoInputDevice::CreateOpenedDevice (current_state.device.source,
+#ifdef WIN32
+                 utf2codepage (current_state.device.name),  // reencode back to codepage
+#else
+                 current_state.device.name,
+#endif
+                 FALSE);
 
   Ekiga::VideoInputErrorCodes error_code = Ekiga::VI_ERROR_NONE;
   if (!input_device)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]