summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--junklib.c35
-rw-r--r--junklib.h9
-rw-r--r--main.c2
3 files changed, 42 insertions, 4 deletions
diff --git a/junklib.c b/junklib.c
index 7d552761..8bcd9c91 100644
--- a/junklib.c
+++ b/junklib.c
@@ -50,6 +50,10 @@ uint16_t sj_to_unicode[] = {
#include "playlist.h"
#include "utf8.h"
#include "plugins.h"
+#include "conf.h"
+
+int enable_cp1251_detection = 1;
+int enable_cp936_detection = 0;
#define MAX_TEXT_FRAME_SIZE 1024
#define MAX_CUESHEET_FRAME_SIZE 10000
@@ -651,6 +655,9 @@ static const char *junk_genretbl[] = {
static int
can_be_russian (const signed char *str) {
+ if (!enable_cp1251_detection) {
+ return 0;
+ }
int latin = 0;
int rus = 0;
int rus_in_row = 0;
@@ -677,6 +684,9 @@ can_be_russian (const signed char *str) {
static int
can_be_chinese (const signed char *str) {
+ if (!enable_cp936_detection) {
+ return 0;
+ }
for (; *str; str++) {
if (((unsigned char) *str >= 0x81 && (unsigned char) *str <= 0xFE )
&& ((unsigned char) *(str+1) >= 0x30 && (unsigned char) *(str+1) <= 0x39)
@@ -707,11 +717,11 @@ convstr_id3v2 (int version, uint8_t encoding, const unsigned char* str, int sz)
}
else if (encoding == 0) {
if (can_be_chinese (str)) {
- // hack to add cp936 support
+ // hack to add cp936 support
enc = "cp936";
- }
- else if (can_be_russian (str)) {
- // hack to add limited cp1251 recoding support
+ }
+ else if (can_be_russian (str)) {
+ // hack to add limited cp1251 recoding support
enc = "cp1251";
}
else {
@@ -3858,3 +3868,20 @@ error:
return err;
}
+void
+junk_enable_cp1251_detection (int enable) {
+ enable_cp1251_detection = enable;
+}
+
+void
+junk_enable_cp936_detection (int enable) {
+ enable_cp936_detection = enable;
+}
+
+void
+junk_configchanged (void) {
+ int cp1251 = conf_get_int ("junk.enable_cp1251_detection", 1);
+ int cp936 = conf_get_int ("junk.enable_cp936_detection", 0);
+ junk_enable_cp1251_detection (cp1251);
+ junk_enable_cp936_detection (cp936);
+}
diff --git a/junklib.h b/junklib.h
index 4212aa83..2cedfdd2 100644
--- a/junklib.h
+++ b/junklib.h
@@ -116,4 +116,13 @@ junk_recode (const char *in, int inlen, char *out, int outlen, const char *cs);
int
junk_rewrite_tags (struct playItem_s *it, uint32_t junk_flags, int id3v2_version, const char *id3v1_encoding);
+void
+junk_enable_cp1251_detection (int enable);
+
+void
+junk_configchanged (void);
+
+void
+junk_enable_cp936_detection (int enable);
+
#endif // __JUNKLIB_H
diff --git a/main.c b/main.c
index 6995d0c4..228e3ecb 100644
--- a/main.c
+++ b/main.c
@@ -55,6 +55,7 @@
#include "volume.h"
#include "plugins.h"
#include "common.h"
+#include "junklib.h"
#ifndef PREFIX
#error PREFIX must be defined
@@ -612,6 +613,7 @@ player_mainloop (void) {
case DB_EV_CONFIGCHANGED:
conf_save ();
streamer_configchanged ();
+ junk_configchanged ();
break;
case DB_EV_SEEK:
streamer_set_seek (p1 / 1000.f);