mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 09:53:01 +08:00
libaiff
This commit is contained in:
parent
ad884fc296
commit
3cb9769d7b
32
ports/libaiff/CMakeLists.txt
Normal file
32
ports/libaiff/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
||||
cmake_minimum_required (VERSION 3.9)
|
||||
project (libaiff)
|
||||
set(SRC
|
||||
iff.c aifx.c lpcm.c g711.c
|
||||
float32.c libaiff.c
|
||||
extended.c pascal.c
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(/W4 -D_CRT_SECURE_NO_WARNINGS -DHAVE_INTTYPES_H -DHAVE_STDINT_H -DHAVE_STRING_H -DHAVE_STDLIB_H)
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
endif()
|
||||
|
||||
include_directories(.)
|
||||
|
||||
add_library(libaiff ${SRC})
|
||||
|
||||
|
||||
install(
|
||||
TARGETS libaiff
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
|
||||
if(NOT DISABLE_INSTALL_HEADERS)
|
||||
install(FILES libaiff/libaiff.h libaiff/config.h libaiff/endian.h DESTINATION include/libaiff)
|
||||
endif()
|
3
ports/libaiff/CONTROL
Normal file
3
ports/libaiff/CONTROL
Normal file
@ -0,0 +1,3 @@
|
||||
Source: libaiff
|
||||
Version: 5.0
|
||||
Description: LibAiff is an open-source library, providing C applications transparent read & write operations for Audio Interchange File Format (AIFF) files, with the goal of supporting all of its features
|
214
ports/libaiff/allow_utf_16_filename.patch
Normal file
214
ports/libaiff/allow_utf_16_filename.patch
Normal file
@ -0,0 +1,214 @@
|
||||
diff --git a/libaiff.c b/libaiff.c
|
||||
index d0ad40d..e266802 100644
|
||||
--- a/libaiff.c
|
||||
+++ b/libaiff.c
|
||||
@@ -44,6 +44,8 @@ static struct decoder* decoders[] = {
|
||||
|
||||
static AIFF_Ref AIFF_ReadOpen (const char *, int);
|
||||
static AIFF_Ref AIFF_WriteOpen (const char *, int);
|
||||
+static AIFF_Ref AIFF_ReadOpenW (const wchar_t*, int);
|
||||
+static AIFF_Ref AIFF_WriteOpenW (const wchar_t*, int);
|
||||
static void AIFF_ReadClose (AIFF_Ref);
|
||||
static int AIFF_WriteClose (AIFF_Ref);
|
||||
static void* InitBuffer (AIFF_Ref, size_t);
|
||||
@@ -53,6 +55,21 @@ static int Prepare (AIFF_Ref);
|
||||
static void Unprepare (AIFF_Ref);
|
||||
static struct decoder* FindDecoder (IFFType);
|
||||
|
||||
+#ifdef _WIN32
|
||||
+AIFF_Ref
|
||||
+AIFF_OpenFileW(const wchar_t *file, int flags)
|
||||
+{
|
||||
+ AIFF_Ref ref = NULL;
|
||||
+
|
||||
+ if (flags & F_RDONLY) {
|
||||
+ ref = AIFF_ReadOpenW(file, flags);
|
||||
+ } else if (flags & F_WRONLY) {
|
||||
+ ref = AIFF_WriteOpenW(file, flags);
|
||||
+ }
|
||||
+
|
||||
+ return ref;
|
||||
+}
|
||||
+#endif
|
||||
AIFF_Ref
|
||||
AIFF_OpenFile(const char *file, int flags)
|
||||
{
|
||||
@@ -86,6 +103,76 @@ AIFF_CloseFile(AIFF_Ref ref)
|
||||
return r;
|
||||
}
|
||||
|
||||
+#ifdef _WIN32
|
||||
+static AIFF_Ref
|
||||
+AIFF_ReadOpenW(const wchar_t *file, int flags)
|
||||
+{
|
||||
+ AIFF_Ref r;
|
||||
+ IFFHeader hdr;
|
||||
+
|
||||
+ r = malloc(kAIFFRefSize);
|
||||
+ if (!r) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ r->fd = _wfopen(file, L"rb");
|
||||
+ if (r->fd == NULL) {
|
||||
+ free(r);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ r->flags = F_RDONLY | flags;
|
||||
+ if (fread(&hdr, 1, 4, r->fd) < 4) {
|
||||
+ fclose(r->fd);
|
||||
+ free(r);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ switch (hdr.hid) {
|
||||
+ case AIFF_TYPE_IFF:
|
||||
+ /* Continue reading the IFF header */
|
||||
+ if (fread(&(hdr.len), 1, 8, r->fd) < 8) {
|
||||
+ fclose(r->fd);
|
||||
+ free(r);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ if (hdr.len == 0) {
|
||||
+ fclose(r->fd);
|
||||
+ free(r);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ /*
|
||||
+ * Check the format type (AIFF or AIFC)
|
||||
+ */
|
||||
+ r->format = hdr.fid;
|
||||
+ switch (r->format) {
|
||||
+ case AIFF_TYPE_AIFF:
|
||||
+ case AIFF_TYPE_AIFC:
|
||||
+ break;
|
||||
+ default:
|
||||
+ fclose(r->fd);
|
||||
+ free(r);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (init_aifx(r) < 1) {
|
||||
+ fclose(r->fd);
|
||||
+ free(r);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ break;
|
||||
+ default:
|
||||
+ fclose(r->fd);
|
||||
+ free(r);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ r->stat = 0;
|
||||
+ r->buffer = NULL;
|
||||
+ r->buflen = 0;
|
||||
+
|
||||
+ return r;
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
static AIFF_Ref
|
||||
AIFF_ReadOpen(const char *file, int flags)
|
||||
{
|
||||
@@ -450,6 +537,89 @@ AIFF_ReadClose(AIFF_Ref r)
|
||||
return;
|
||||
}
|
||||
|
||||
+#ifdef WIN32
|
||||
+static AIFF_Ref
|
||||
+AIFF_WriteOpenW(const wchar_t *file, int flags)
|
||||
+{
|
||||
+ AIFF_Ref w;
|
||||
+ IFFHeader hdr;
|
||||
+ ASSERT(sizeof(IFFHeader) == 12);
|
||||
+
|
||||
+ w = malloc(kAIFFRefSize);
|
||||
+ if (!w) {
|
||||
+err0:
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Simultaneous open for reading & writing
|
||||
+ */
|
||||
+ w->fd = _wfopen(file, L"w+b");
|
||||
+ if (w->fd == NULL) {
|
||||
+err1:
|
||||
+ free(w);
|
||||
+ goto err0;
|
||||
+ }
|
||||
+ hdr.hid = ARRANGE_BE32(AIFF_FORM);
|
||||
+ w->len = 4;
|
||||
+ hdr.len = ARRANGE_BE32(4);
|
||||
+ if (flags & F_AIFC)
|
||||
+ hdr.fid = ARRANGE_BE32(AIFF_AIFC);
|
||||
+ else
|
||||
+ hdr.fid = ARRANGE_BE32(AIFF_AIFF);
|
||||
+
|
||||
+ if (fwrite(&hdr, 1, 12, w->fd) < 12) {
|
||||
+err2:
|
||||
+ fclose(w->fd);
|
||||
+ goto err1;
|
||||
+ }
|
||||
+ w->stat = 0;
|
||||
+ w->segmentSize = 0;
|
||||
+ w->buffer = NULL;
|
||||
+ w->buflen = 0;
|
||||
+ w->tics = 0;
|
||||
+
|
||||
+ /*
|
||||
+ * If writing AIFF-C, write the required FVER chunk
|
||||
+ */
|
||||
+ if (flags & F_AIFC) {
|
||||
+ IFFChunk chk;
|
||||
+ uint32_t vers;
|
||||
+ ASSERT(sizeof(IFFChunk) == 8);
|
||||
+
|
||||
+ chk.id = ARRANGE_BE32(AIFF_FVER);
|
||||
+ chk.len = ARRANGE_BE32(4);
|
||||
+ vers = ARRANGE_BE32(AIFC_STD_DRAFT_082691);
|
||||
+
|
||||
+ if (fwrite(&chk, 1, 8, w->fd) < 8 ||
|
||||
+ fwrite(&vers, 1, 4, w->fd) < 4) {
|
||||
+ goto err2;
|
||||
+ }
|
||||
+
|
||||
+ w->len += 12;
|
||||
+
|
||||
+ /*
|
||||
+ * If no endianness specified for AIFF-C,
|
||||
+ * default to big endian
|
||||
+ */
|
||||
+ if (!(flags & (LPCM_LTE_ENDIAN | LPCM_BIG_ENDIAN))) {
|
||||
+ flags |= LPCM_BIG_ENDIAN;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /*
|
||||
+ * If writing regular AIFF, make sure we
|
||||
+ * write big-endian data
|
||||
+ */
|
||||
+ flags &= ~LPCM_LTE_ENDIAN;
|
||||
+ flags |= LPCM_BIG_ENDIAN;
|
||||
+ }
|
||||
+
|
||||
+ w->flags = F_WRONLY | flags;
|
||||
+
|
||||
+ return w;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static AIFF_Ref
|
||||
AIFF_WriteOpen(const char *file, int flags)
|
||||
{
|
||||
diff --git a/libaiff/libaiff.h b/libaiff/libaiff.h
|
||||
index 56fc77f..e1940a5 100644
|
||||
--- a/libaiff/libaiff.h
|
||||
+++ b/libaiff/libaiff.h
|
||||
@@ -165,6 +165,7 @@ typedef struct s_Instrument Instrument ;
|
||||
|
||||
/* == Function prototypes == */
|
||||
AIFF_Ref AIFF_OpenFile(const char *, int) ;
|
||||
+AIFF_Ref AIFF_OpenFile(const wchar_t *, int) ;
|
||||
int AIFF_CloseFile(AIFF_Ref) ;
|
||||
char* AIFF_GetAttribute(AIFF_Ref,IFFType) ;
|
||||
int AIFF_GetInstrumentData(AIFF_Ref,Instrument*) ;
|
12
ports/libaiff/config.h
Normal file
12
ports/libaiff/config.h
Normal file
@ -0,0 +1,12 @@
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "marcotrillo@gmail.com"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "LibAiff (MSVC)"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "LibAiff (MSVC) $Revision: 1.1 $"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "$Revision: 1.1 $"
|
||||
|
40
ports/libaiff/portfile.cmake
Normal file
40
ports/libaiff/portfile.cmake
Normal file
@ -0,0 +1,40 @@
|
||||
include(vcpkg_common_functions)
|
||||
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libaiff-5.0)
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "https://sourceforge.net/projects/aifftools/files/libaiff/LibAiff%205.0/libaiff-5.0-release.tar.gz"
|
||||
FILENAME "libaiff-5.0-release.tar.gz"
|
||||
SHA512 7800f9a3fbd0c5a17b8cc6c9b60181131d159ab5f5fb8e7de54e8f88c151717a988231de664a635e61940267c854a9ce83d58b12e322dcdda3aa8080c7b15f66
|
||||
)
|
||||
vcpkg_extract_source_archive(${ARCHIVE})
|
||||
|
||||
|
||||
vcpkg_apply_patches(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PATCHES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/allow_utf_16_filename.patch"
|
||||
)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/config.h DESTINATION ${SOURCE_PATH}/libaiff)
|
||||
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
||||
file(GLOB HEADERS "${CURRENT_PACKAGES_DIR}/include/libaiff/*.h")
|
||||
foreach(HEADER ${HEADERS})
|
||||
file(READ "${HEADER}" _contents)
|
||||
string(REPLACE "#ifdef HAVE_STDINT_H" "#if 1" _contents "${_contents}")
|
||||
string(REPLACE "#ifdef HAVE_STRING_H" "#if 1" _contents "${_contents}")
|
||||
string(REPLACE "#ifdef HAVE_STDLIB_H" "#if 1" _contents "${_contents}")
|
||||
string(REPLACE "#ifdef HAVE_INTTYPES_H" "#if 1" _contents "${_contents}")
|
||||
file(WRITE "${HEADER}" "${_contents}")
|
||||
endforeach()
|
||||
|
||||
# Handle copyright
|
||||
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libaiff RENAME copyright)
|
Loading…
Reference in New Issue
Block a user