-/*
- * Copyright (C) 2009 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2009 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
/** \file wma_afh.c The audio format handler for WMA files. */
size_t ct_size = 250;
int ret, count = 0, num_frames, num_superframes;
- afhi->chunk_table = para_malloc(ct_size * sizeof(uint32_t));
+ afhi->chunk_table = arr_alloc(ct_size, sizeof(uint32_t));
afhi->chunk_table[0] = 0;
afhi->chunk_table[1] = afhi->header_len;
int ret;
if (!src || !*src) {
- *dst = para_calloc(2);
+ *dst = zalloc(2);
return 0;
}
/*
/* even though src is in UTF-8, strlen() should DTRT */
inbytes = inbytesleft = strlen(src);
outbytes = outbytesleft = 4 * inbytes + 2; /* hope that's enough */
- *dst = outbuf = para_malloc(outbytes);
+ *dst = outbuf = alloc(outbytes);
sz = iconv(cd, ICONV_CAST &inbuf, &inbytesleft, &outbuf, &outbytesleft);
if (sz == (size_t)-1) {
ret = -ERRNO_TO_PARA_ERROR(errno);
ret = convert_utf8_to_utf16(tags->artist, &artist);
if (ret < 0)
return ret;
+ assert(artist);
artist_bytes = ret;
ret = convert_utf8_to_utf16(tags->title, &title);
if (ret < 0)
goto out;
+ assert(title);
title_bytes = ret;
ret = convert_utf8_to_utf16(tags->comment, &comment);
if (ret < 0)
goto out;
+ assert(comment);
comment_bytes = ret;
if (cdo) {
result->size = 16 + 8 + 5 * 2 + title_bytes + artist_bytes
+ orig_cr_bytes + comment_bytes + orig_rating_bytes;
PARA_DEBUG_LOG("cdo is %zu bytes\n", (size_t)result->size);
- p = result->ptr = para_malloc(result->size);
+ p = result->ptr = alloc(result->size);
memcpy(p, content_description_header, 16);
p += 16;
write_u64(p, result->size);
ret = convert_utf8_to_utf16(tags->album, &album);
if (ret < 0)
return ret;
+ assert(album);
album_bytes = ret;
ret = convert_utf8_to_utf16(tags->year, &year);
if (ret < 0)
goto out;
+ assert(year);
year_bytes = ret;
result->size = 16 + 8 + 2; /* GUID, size, count */
/* name_length + name + null + data type + val length + val */
result->size += 2 + sizeof(album_tag_header) + 2 + 2 + 2 + album_bytes;
result->size += 2 + sizeof(year_tag_header) + 2 + 2 + 2 + year_bytes;
- p = result->ptr = para_malloc(result->size);
+ p = result->ptr = alloc(result->size);
memcpy(p, extended_content_header, 16);
p += 16;
write_u64(p, result->size);
if (top.reserved2 != 2)
return -E_NO_WMA;
p++; /* objects start at p */
- top.objects = para_malloc(top.num_objects * sizeof(struct asf_object));
+ top.objects = arr_alloc(top.num_objects, sizeof(struct asf_object));
ret = read_asf_objects(p, top.size - (p - map), top.num_objects,
top.objects, &ton);
if (ret < 0)
static const char * const wma_suffixes[] = {"wma", NULL};
/**
- * The init function of the wma audio format handler.
+ * The audio format handler for Windows Media Audio.
*
- * \param afh Pointer to the struct to initialize.
+ * Only WMA version 2 is supported. This audio format handler does not depend
+ * on any third party libraries and is therefore always compiled in.
*/
-void wma_afh_init(struct audio_format_handler *afh)
-{
- afh->get_file_info = wma_get_file_info;
- afh->suffixes = wma_suffixes;
- afh->rewrite_tags = wma_rewrite_tags;
-}
+const struct audio_format_handler wma_afh = {
+ .get_file_info = wma_get_file_info,
+ .suffixes = wma_suffixes,
+ .rewrite_tags = wma_rewrite_tags,
+};