wavpack: use GLib instead of utils.h / log.h

Replace deprecated code with GLib.
This commit is contained in:
Max Kellermann 2008-11-04 17:10:10 +01:00
parent 097bccd4ae
commit 946e69b2f6

View File

@ -19,11 +19,10 @@
*/ */
#include "../decoder_api.h" #include "../decoder_api.h"
#include "../utils.h"
#include "../log.h"
#include "../path.h" #include "../path.h"
#include <wavpack/wavpack.h> #include <wavpack/wavpack.h>
#include <glib.h>
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */ /* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
#define CHUNK_SIZE 1020 #define CHUNK_SIZE 1020
@ -218,9 +217,7 @@ static char *wavpack_tag(WavpackContext *wpc, char *key)
size = WavpackGetTagItem(wpc, key, NULL, 0); size = WavpackGetTagItem(wpc, key, NULL, 0);
if (size > 0) { if (size > 0) {
size++; size++;
value = xmalloc(size); value = g_malloc(size);
if (!value)
return NULL;
WavpackGetTagItem(wpc, key, value, size); WavpackGetTagItem(wpc, key, value, size);
} }
@ -290,7 +287,8 @@ static struct tag *wavpack_tagdup(const char *fname)
wpc = WavpackOpenFileInput(fname, error, OPEN_TAGS, 0); wpc = WavpackOpenFileInput(fname, error, OPEN_TAGS, 0);
if (wpc == NULL) { if (wpc == NULL) {
ERROR("failed to open WavPack file \"%s\": %s\n", fname, error); g_warning("failed to open WavPack file \"%s\": %s\n",
fname, error);
return NULL; return NULL;
} }
@ -307,12 +305,10 @@ static struct tag *wavpack_tagdup(const char *fname)
++j; ++j;
if (s == NULL) { if (s == NULL) {
s = xmalloc(j); s = g_malloc(j);
if (s == NULL) break;
ssize = j; ssize = j;
} else if (j > ssize) { } else if (j > ssize) {
char *t = (char *)xrealloc(s, j); char *t = (char *)g_realloc(s, j);
if (t == NULL) break;
ssize = j; ssize = j;
s = t; s = t;
} }
@ -322,8 +318,7 @@ static struct tag *wavpack_tagdup(const char *fname)
} }
} }
if (s != NULL) g_free(s);
free(s);
WavpackCloseFile(wpc); WavpackCloseFile(wpc);
@ -436,7 +431,6 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc,
{ {
char tmp[MPD_PATH_MAX]; char tmp[MPD_PATH_MAX];
const char *utf8url; const char *utf8url;
size_t len;
char *wvc_url = NULL; char *wvc_url = NULL;
bool ret; bool ret;
char first_byte; char first_byte;
@ -450,20 +444,9 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc,
if (utf8url == NULL) if (utf8url == NULL)
return false; return false;
len = strlen(utf8url); wvc_url = g_strconcat(utf8url, "c", NULL);
if (!len)
return false;
wvc_url = (char *)xmalloc(len + 2); /* +2: 'c' and EOS */
if (wvc_url == NULL)
return false;
memcpy(wvc_url, utf8url, len);
wvc_url[len] = 'c';
wvc_url[len + 1] = '\0';
ret = input_stream_open(is_wvc, wvc_url); ret = input_stream_open(is_wvc, wvc_url);
free(wvc_url); g_free(wvc_url);
if (!ret) if (!ret)
return false; return false;
@ -503,7 +486,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
open_flags, 15); open_flags, 15);
if (wpc == NULL) { if (wpc == NULL) {
ERROR("failed to open WavPack stream: %s\n", error); g_warning("failed to open WavPack stream: %s\n", error);
return false; return false;
} }
@ -531,7 +514,8 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
OPEN_TAGS | OPEN_WVC | OPEN_TAGS | OPEN_WVC |
OPEN_2CH_MAX | OPEN_NORMALIZE, 15); OPEN_2CH_MAX | OPEN_NORMALIZE, 15);
if (wpc == NULL) { if (wpc == NULL) {
ERROR("failed to open WavPack file \"%s\": %s\n", fname, error); g_warning("failed to open WavPack file \"%s\": %s\n",
fname, error);
return false; return false;
} }