summaryrefslogtreecommitdiff
path: root/plugins/ao/eng_psf/eng_psf.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ao/eng_psf/eng_psf.c')
-rw-r--r--plugins/ao/eng_psf/eng_psf.c45
1 files changed, 19 insertions, 26 deletions
diff --git a/plugins/ao/eng_psf/eng_psf.c b/plugins/ao/eng_psf/eng_psf.c
index 8b12c777..268c8968 100644
--- a/plugins/ao/eng_psf/eng_psf.c
+++ b/plugins/ao/eng_psf/eng_psf.c
@@ -64,6 +64,23 @@ static void spu_update (unsigned char* pSound,long lBytes,void *data)
memcpy(s->spu_pOutput, pSound, lBytes);
}
+void
+ao_getlibpath (const char *path, const char *libname, char *libpath, int size) {
+ const char *e = strrchr (path, ':');
+ if (!e) {
+ e = strrchr (path, '/');
+ }
+ if (e) {
+ e++;
+ memcpy (libpath, path, e-path);
+ libpath[e-path] = 0;
+ strcat (libpath, libname);
+ }
+ else {
+ strcpy (libpath, libname);
+ }
+}
+
void *psf_start(const char *path, uint8 *buffer, uint32 length)
{
psf_synth_t *s = malloc (sizeof (psf_synth_t));
@@ -126,19 +143,7 @@ void *psf_start(const char *path, uint8 *buffer, uint32 length)
{
uint64 tmp_length;
char libpath[PATH_MAX];
- const char *e = path + strlen(path);
- while (e > path && *e != '/') {
- e--;
- }
- if (*e == '/') {
- e++;
- memcpy (libpath, path, e-path);
- libpath[e-path] = 0;
- strcat (libpath, s->c->lib);
- }
- else {
- strcpy (libpath, s->c->lib);
- }
+ ao_getlibpath (path, s->c->lib, libpath, sizeof (libpath));
if (ao_get_lib(libpath, &lib_raw_file, &tmp_length) != AO_SUCCESS)
{
@@ -228,19 +233,7 @@ void *psf_start(const char *path, uint8 *buffer, uint32 length)
{
uint64 tmp_length;
char libpath[PATH_MAX];
- const char *e = path + strlen(path);
- while (e > path && *e != '/') {
- e--;
- }
- if (*e == '/') {
- e++;
- memcpy (libpath, path, e-path);
- libpath[e-path] = 0;
- strcat (libpath, s->c->libaux[i]);
- }
- else {
- strcpy (libpath, s->c->libaux[i]);
- }
+ ao_getlibpath (path, s->c->libaux[i], libpath, sizeof (libpath));
if (ao_get_lib(libpath, &lib_raw_file, &tmp_length) != AO_SUCCESS)
{