Commit 36f712b9 authored by Max Kellermann's avatar Max Kellermann

tag/{riff,aiff}: convert to C++

parent a446775d
...@@ -441,8 +441,8 @@ if HAVE_ID3TAG ...@@ -441,8 +441,8 @@ if HAVE_ID3TAG
libtag_a_SOURCES += \ libtag_a_SOURCES += \
src/tag/TagId3.cxx src/tag/TagId3.hxx \ src/tag/TagId3.cxx src/tag/TagId3.hxx \
src/tag/TagRva2.cxx src/tag/TagRva2.hxx \ src/tag/TagRva2.cxx src/tag/TagRva2.hxx \
src/tag/riff.c src/tag/riff.h \ src/tag/Riff.cxx src/tag/Riff.hxx \
src/tag/aiff.c src/tag/aiff.h src/tag/Aiff.cxx src/tag/Aiff.hxx
endif endif
# decoder plugins # decoder plugins
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
#include "config.h" /* must be first for large file support */ #include "config.h" /* must be first for large file support */
#include "aiff.h" #include "Aiff.hxx"
#include <glib.h> #include <glib.h>
...@@ -46,16 +46,10 @@ struct aiff_chunk_header { ...@@ -46,16 +46,10 @@ struct aiff_chunk_header {
size_t size_t
aiff_seek_id3(FILE *file) aiff_seek_id3(FILE *file)
{ {
int ret;
struct stat st;
struct aiff_header header;
struct aiff_chunk_header chunk;
size_t size;
/* determine the file size */ /* determine the file size */
ret = fstat(fileno(file), &st); struct stat st;
if (ret < 0) { if (fstat(fileno(file), &st) < 0) {
g_warning("Failed to stat file descriptor: %s", g_warning("Failed to stat file descriptor: %s",
g_strerror(errno)); g_strerror(errno));
return 0; return 0;
...@@ -63,13 +57,13 @@ aiff_seek_id3(FILE *file) ...@@ -63,13 +57,13 @@ aiff_seek_id3(FILE *file)
/* seek to the beginning and read the AIFF header */ /* seek to the beginning and read the AIFF header */
ret = fseek(file, 0, SEEK_SET); if (fseek(file, 0, SEEK_SET) != 0) {
if (ret != 0) {
g_warning("Failed to seek: %s", g_strerror(errno)); g_warning("Failed to seek: %s", g_strerror(errno));
return 0; return 0;
} }
size = fread(&header, sizeof(header), 1, file); aiff_header header;
size_t size = fread(&header, sizeof(header), 1, file);
if (size != 1 || if (size != 1 ||
memcmp(header.id, "FORM", 4) != 0 || memcmp(header.id, "FORM", 4) != 0 ||
GUINT32_FROM_BE(header.size) > (uint32_t)st.st_size || GUINT32_FROM_BE(header.size) > (uint32_t)st.st_size ||
...@@ -81,6 +75,7 @@ aiff_seek_id3(FILE *file) ...@@ -81,6 +75,7 @@ aiff_seek_id3(FILE *file)
while (true) { while (true) {
/* read the chunk header */ /* read the chunk header */
aiff_chunk_header chunk;
size = fread(&chunk, sizeof(chunk), 1, file); size = fread(&chunk, sizeof(chunk), 1, file);
if (size != 1) if (size != 1)
return 0; return 0;
...@@ -99,8 +94,7 @@ aiff_seek_id3(FILE *file) ...@@ -99,8 +94,7 @@ aiff_seek_id3(FILE *file)
/* found it! */ /* found it! */
return size; return size;
ret = fseek(file, size, SEEK_CUR); if (fseek(file, size, SEEK_CUR) != 0)
if (ret != 0)
return 0; return 0;
} }
} }
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -22,10 +22,9 @@ ...@@ -22,10 +22,9 @@
* A parser for the AIFF file format. * A parser for the AIFF file format.
*/ */
#ifndef MPD_AIFF_H #ifndef MPD_AIFF_HXX
#define MPD_AIFF_H #define MPD_AIFF_HXX
#include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
#include "config.h" /* must be first for large file support */ #include "config.h" /* must be first for large file support */
#include "riff.h" #include "Riff.hxx"
#include <glib.h> #include <glib.h>
...@@ -46,16 +46,10 @@ struct riff_chunk_header { ...@@ -46,16 +46,10 @@ struct riff_chunk_header {
size_t size_t
riff_seek_id3(FILE *file) riff_seek_id3(FILE *file)
{ {
int ret;
struct stat st;
struct riff_header header;
struct riff_chunk_header chunk;
size_t size;
/* determine the file size */ /* determine the file size */
ret = fstat(fileno(file), &st); struct stat st;
if (ret < 0) { if (fstat(fileno(file), &st) < 0) {
g_warning("Failed to stat file descriptor: %s", g_warning("Failed to stat file descriptor: %s",
g_strerror(errno)); g_strerror(errno));
return 0; return 0;
...@@ -63,13 +57,13 @@ riff_seek_id3(FILE *file) ...@@ -63,13 +57,13 @@ riff_seek_id3(FILE *file)
/* seek to the beginning and read the RIFF header */ /* seek to the beginning and read the RIFF header */
ret = fseek(file, 0, SEEK_SET); if (fseek(file, 0, SEEK_SET) != 0) {
if (ret != 0) {
g_warning("Failed to seek: %s", g_strerror(errno)); g_warning("Failed to seek: %s", g_strerror(errno));
return 0; return 0;
} }
size = fread(&header, sizeof(header), 1, file); riff_header header;
size_t size = fread(&header, sizeof(header), 1, file);
if (size != 1 || if (size != 1 ||
memcmp(header.id, "RIFF", 4) != 0 || memcmp(header.id, "RIFF", 4) != 0 ||
GUINT32_FROM_LE(header.size) > (uint32_t)st.st_size) GUINT32_FROM_LE(header.size) > (uint32_t)st.st_size)
...@@ -79,6 +73,7 @@ riff_seek_id3(FILE *file) ...@@ -79,6 +73,7 @@ riff_seek_id3(FILE *file)
while (true) { while (true) {
/* read the chunk header */ /* read the chunk header */
riff_chunk_header chunk;
size = fread(&chunk, sizeof(chunk), 1, file); size = fread(&chunk, sizeof(chunk), 1, file);
if (size != 1) if (size != 1)
return 0; return 0;
...@@ -97,8 +92,7 @@ riff_seek_id3(FILE *file) ...@@ -97,8 +92,7 @@ riff_seek_id3(FILE *file)
/* found it! */ /* found it! */
return size; return size;
ret = fseek(file, size, SEEK_CUR); if (fseek(file, size, SEEK_CUR) != 0)
if (ret != 0)
return 0; return 0;
} }
} }
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -22,10 +22,9 @@ ...@@ -22,10 +22,9 @@
* A parser for the RIFF file format (e.g. WAV). * A parser for the RIFF file format (e.g. WAV).
*/ */
#ifndef MPD_RIFF_H #ifndef MPD_RIFF_HXX
#define MPD_RIFF_H #define MPD_RIFF_HXX
#include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
#include "TagBuilder.hxx" #include "TagBuilder.hxx"
#include "util/Error.hxx" #include "util/Error.hxx"
#include "ConfigGlobal.hxx" #include "ConfigGlobal.hxx"
#include "Riff.hxx"
extern "C" { #include "Aiff.hxx"
#include "riff.h"
#include "aiff.h"
}
#include <glib.h> #include <glib.h>
#include <id3tag.h> #include <id3tag.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment