ref: 19f9dc98ee0db66f87ab1043b739a6f0e0dc818f
parent: 96748cf309af5539eab85080408c9865746d720b
author: Peter Kirk <[email protected]>
date: Fri Jun 6 10:38:38 EDT 2008
Use EXPORT macro in a way compatible with win32
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,7 @@
AC_C_INLINE
AC_C_RESTRICT
+AC_DEFINE([CELT_BUILD], [], [This is a build of CELT])
AC_MSG_CHECKING(for C99 variable-size arrays)
AC_TRY_COMPILE( , [
@@ -62,7 +63,6 @@
has_alloca=no
)
AC_MSG_RESULT($has_alloca)
-
AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -79,7 +79,7 @@
#endif
};
-CELTEncoder EXPORT *celt_encoder_create(const CELTMode *mode)
+CELTEncoder *celt_encoder_create(const CELTMode *mode)
{
int N, C;
CELTEncoder *st;
@@ -115,7 +115,7 @@
return st;
}
-void EXPORT celt_encoder_destroy(CELTEncoder *st)
+void celt_encoder_destroy(CELTEncoder *st)
{
if (st == NULL)
{
@@ -225,7 +225,7 @@
}
}
-int EXPORT celt_encode(CELTEncoder * restrict st, celt_int16_t * restrict pcm, unsigned char *compressed, int nbCompressedBytes)
+int celt_encode(CELTEncoder * restrict st, celt_int16_t * restrict pcm, unsigned char *compressed, int nbCompressedBytes)
{
int i, c, N, N4;
int has_pitch;
@@ -453,7 +453,7 @@
int last_pitch_index;
};
-CELTDecoder EXPORT *celt_decoder_create(const CELTMode *mode)
+CELTDecoder *celt_decoder_create(const CELTMode *mode)
{
int N, C;
CELTDecoder *st;
@@ -480,7 +480,7 @@
return st;
}
-void EXPORT celt_decoder_destroy(CELTDecoder *st)
+void celt_decoder_destroy(CELTDecoder *st)
{
if (st == NULL)
{
@@ -552,7 +552,7 @@
RESTORE_STACK;
}
-int EXPORT celt_decode(CELTDecoder * restrict st, unsigned char *data, int len, celt_int16_t * restrict pcm)
+int celt_decode(CELTDecoder * restrict st, unsigned char *data, int len, celt_int16_t * restrict pcm)
{
int c, N, N4;
int has_pitch;
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -43,6 +43,14 @@
extern "C" {
#endif
+#if defined(__GNUC__) && defined(CELT_BUILD)
+#define EXPORT __attribute__ ((visibility ("default")))
+#elif defined(WIN32)
+#define EXPORT __declspec(dllexport)
+#else
+#define EXPORT
+#endif
+
/* Error codes */
/** No error */
#define CELT_OK 0
@@ -100,16 +108,16 @@
@param error Returned error code (if NULL, no error will be returned)
@return A newly created mode
*/
-CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int lookahead, int *error);
+EXPORT CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int lookahead, int *error);
/** Destroys a mode struct. Only call this after all encoders and decoders
using this mode are destroyed as well.
@param mode Mode to be destroyed
*/
-void celt_mode_destroy(CELTMode *mode);
+EXPORT void celt_mode_destroy(CELTMode *mode);
/** Query information from a mode */
-int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value);
+EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value);
/* Encoder stuff */
@@ -121,12 +129,12 @@
(must be the same characteristics as used for the decoder)
@return Newly created encoder state.
*/
-CELTEncoder *celt_encoder_create(const CELTMode *mode);
+EXPORT CELTEncoder *celt_encoder_create(const CELTMode *mode);
/** Destroys a an encoder state.
@param st Encoder state to be destroyed
*/
-void celt_encoder_destroy(CELTEncoder *st);
+EXPORT void celt_encoder_destroy(CELTEncoder *st);
/** Encodes a frame of audio.
@param st Encoder state
@@ -141,7 +149,7 @@
has occured (see error codes). It is IMPORTANT that the length returned
be somehow transmitted to the decoder. Otherwise, no decoding is possible.
*/
-int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, int nbCompressedBytes);
+EXPORT int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, int nbCompressedBytes);
/* Decoder stuff */
@@ -152,12 +160,12 @@
stream (must be the same characteristics as used for the encoder)
@return Newly created decoder state.
*/
-CELTDecoder *celt_decoder_create(const CELTMode *mode);
+EXPORT CELTDecoder *celt_decoder_create(const CELTMode *mode);
/** Destroys a a decoder state.
@param st Decoder state to be destroyed
*/
-void celt_decoder_destroy(CELTDecoder *st);
+EXPORT void celt_decoder_destroy(CELTDecoder *st);
/** Decodes a frame of audio.
@param st Decoder state
@@ -168,7 +176,7 @@
returned here.
@return Error code.
*/
-int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm);
+EXPORT int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm);
/* @} */
--- a/libcelt/celt_header.h
+++ b/libcelt/celt_header.h
@@ -56,11 +56,11 @@
} CELTHeader;
/** Creates a basic header struct */
-void celt_header_init(CELTHeader *header, const CELTMode *m);
+EXPORT void celt_header_init(CELTHeader *header, const CELTMode *m);
-int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size);
+EXPORT int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size);
-int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CELTHeader *header);
+EXPORT int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CELTHeader *header);
#ifdef __cplusplus
}
--- a/libcelt/header.c
+++ b/libcelt/header.c
@@ -62,7 +62,7 @@
return ret;
}
-void EXPORT celt_header_init(CELTHeader *header, const CELTMode *m)
+void celt_header_init(CELTHeader *header, const CELTMode *m)
{
CELT_COPY(header->codec_id, "CELT ", 8);
CELT_COPY(header->codec_version, "experimental ", 20);
@@ -77,7 +77,7 @@
header->extra_headers = 0;
}
-int EXPORT celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size)
+int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size)
{
celt_int32_t * h;
@@ -103,7 +103,7 @@
return sizeof(*header);
}
-int EXPORT celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CELTHeader *header)
+int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CELTHeader *header)
{
CELT_COPY((unsigned char*)header, packet, sizeof(*header));
return sizeof(*header);
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -52,7 +52,7 @@
#endif
-int EXPORT celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value)
+int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value)
{
switch (request)
{
@@ -270,7 +270,7 @@
mode->energy_alloc = alloc;
}
-CELTMode EXPORT *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int lookahead, int *error)
+CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int lookahead, int *error)
{
int i;
#ifdef STDIN_TUNING
@@ -391,7 +391,7 @@
return mode;
}
-void EXPORT celt_mode_destroy(CELTMode *mode)
+void celt_mode_destroy(CELTMode *mode)
{
#ifndef STATIC_MODES
int i;
--- a/libcelt/os_support.h
+++ b/libcelt/os_support.h
@@ -42,14 +42,6 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef __GNUC__
-#define EXPORT __attribute__ ((visibility ("default")))
-#elif defined(WIN32)
-#define EXPORT __declspec(dllexport)
-#else
-#define EXPORT
-#endif
-
/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, celt_realloc and celt_free
NOTE: celt_alloc needs to CLEAR THE MEMORY */
#ifndef OVERRIDE_CELT_ALLOC