summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/wildmidi/Makefile.am2
-rw-r--r--plugins/wildmidi/src/wildmidi_lib.c40
-rw-r--r--plugins/wildmidi/wildmidiplug.c4
3 files changed, 27 insertions, 19 deletions
diff --git a/plugins/wildmidi/Makefile.am b/plugins/wildmidi/Makefile.am
index e12e95a7..4bab769d 100644
--- a/plugins/wildmidi/Makefile.am
+++ b/plugins/wildmidi/Makefile.am
@@ -5,7 +5,7 @@ EXTRA_DIST = $(wildmidipath)/README
pkglib_LTLIBRARIES = wildmidi.la
-wildmidi_la_SOURCES = wildmidiplug.c src/wildmidi.c src/wildmidi_lib.c include/wildmidi_lib.h
+wildmidi_la_SOURCES = wildmidiplug.c src/wildmidi_lib.c include/wildmidi_lib.h
wildmidi_la_LDFLAGS = -module
diff --git a/plugins/wildmidi/src/wildmidi_lib.c b/plugins/wildmidi/src/wildmidi_lib.c
index 315bf1a4..a5194f79 100644
--- a/plugins/wildmidi/src/wildmidi_lib.c
+++ b/plugins/wildmidi/src/wildmidi_lib.c
@@ -723,7 +723,7 @@ WM_FreePatches ( void ) {
}
int
-WM_LoadConfig (const char *config_file) {
+WM_LoadConfig (const char *config_file, const char *top_config_dir) {
unsigned long int config_size = 0;
unsigned char *config_buffer = NULL;
char * dir_end = NULL;
@@ -737,6 +737,10 @@ WM_LoadConfig (const char *config_file) {
char * new_config = NULL;
struct _patch * tmp_patch;
+ if (top_config_dir) {
+ config_dir = strdup (top_config_dir);
+ }
+
if ((config_buffer = WM_BufferFile(config_file, &config_size)) == NULL) {
return -1;
}
@@ -745,19 +749,21 @@ WM_LoadConfig (const char *config_file) {
return -1;
}
- dir_end = strrchr(config_file,'/');
- if (dir_end != NULL) {
- config_dir = malloc((dir_end - config_file + 2));
- if (config_dir == NULL) {
- WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, "to parse config", errno);
- WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0);
- WM_FreePatches();
- free (config_buffer);
- return -1;
- }
- strncpy(config_dir, config_file, (dir_end - config_file + 1));
- config_dir[dir_end - config_file + 1] = '\0';
- }
+ if (!config_dir) {
+ dir_end = strrchr(config_file,'/');
+ if (dir_end != NULL) {
+ config_dir = malloc((dir_end - config_file + 2));
+ if (config_dir == NULL) {
+ WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, "to parse config", errno);
+ WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_LOAD, config_file, 0);
+ WM_FreePatches();
+ free (config_buffer);
+ return -1;
+ }
+ strncpy(config_dir, config_file, (dir_end - config_file + 1));
+ config_dir[dir_end - config_file + 1] = '\0';
+ }
+ }
config_ptr = 0;
line_start_ptr = 0;
while (config_ptr < config_size) {
@@ -846,7 +852,7 @@ WM_LoadConfig (const char *config_file) {
printf ("wildmidi config_dir: %s\n", config_dir);
continue;
} else if (strncasecmp(line_buffer, "source ", 7) == 0) {
- if (config_dir != NULL, 0) {
+ if (config_dir != NULL && line_buffer[7] != '/') {
new_config = malloc(strlen(config_dir) + strlen(&line_buffer[7]) + 1);
if (new_config == NULL) {
WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, "to parse config", errno);
@@ -872,7 +878,7 @@ WM_LoadConfig (const char *config_file) {
strcpy(new_config, &line_buffer[7]);
}
printf ("wildmidi load new_config: %s\n", new_config);
- if (WM_LoadConfig(new_config) == -1) {
+ if (WM_LoadConfig(new_config, config_dir) == -1) {
free (new_config);
free (line_buffer);
free (config_buffer);
@@ -3716,7 +3722,7 @@ WildMidi_Init (const char * config_file, unsigned short int rate, unsigned short
return -1;
}
WM_InitPatches();
- if (WM_LoadConfig(config_file) == -1) {
+ if (WM_LoadConfig(config_file, NULL) == -1) {
return -1;
}
diff --git a/plugins/wildmidi/wildmidiplug.c b/plugins/wildmidi/wildmidiplug.c
index 3c5e4d81..7652b11f 100644
--- a/plugins/wildmidi/wildmidiplug.c
+++ b/plugins/wildmidi/wildmidiplug.c
@@ -92,6 +92,7 @@ wmidi_seek_sample (DB_fileinfo_t *_info, int sample) {
wmidi_info_t *info = (wmidi_info_t *)_info;
unsigned long int s = sample;
WildMidi_SampledSeek (info->m, &s);
+ _info->readpos = s/44100.0f;
return 0;
}
@@ -125,7 +126,8 @@ wmidi_insert (DB_playItem_t *after, const char *fname) {
int
wmidi_start (void) {
- WildMidi_Init ("/etc/timidity++/timidity-freepats.cfg", 44100, 0);
+ const char *config_file = deadbeef->conf_get_str ("wildmidi.config", "/etc/timidity++/timidity-freepats.cfg");
+ WildMidi_Init (config_file, 44100, 0);
return 0;
}