aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Soulier <asoulier@google.com>2024-03-19 15:09:51 -0700
committerAntoine SOULIER <103120622+asoulier@users.noreply.github.com>2024-03-27 10:31:14 -0700
commitbfea2c04c16040038c9abde331d58ea85af50f95 (patch)
tree7815fc7cedec7abc92c12827b31756d940571f80
parentae0fb3757f72fd25ff9586a4f04e1bb780709ee7 (diff)
downloadliblc3-bfea2c04c16040038c9abde331d58ea85af50f95.tar.gz
msvc: Fix MSVC compilation and CI
-rw-r--r--.github/workflows/ci.yaml15
-rw-r--r--include/lc3.h50
-rw-r--r--include/lc3_private.h11
-rw-r--r--meson.build4
-rw-r--r--src/common.h8
5 files changed, 56 insertions, 32 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index bf39f0b..1ced2c2 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -29,6 +29,21 @@ jobs:
CC: gcc
- run: meson compile -C builddir/
+ build-msvc-meson:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ cache: 'pip'
+ - run: pip install meson ninja
+ - uses: TheMrMilchmann/setup-msvc-dev@v3
+ with:
+ arch: x64
+ - run: meson setup builddir
+ - run: meson compile -C builddir
+
build-wasm:
runs-on: ubuntu-latest
steps:
diff --git a/include/lc3.h b/include/lc3.h
index 9745d64..98022f3 100644
--- a/include/lc3.h
+++ b/include/lc3.h
@@ -262,9 +262,9 @@ typedef LC3_DECODER_MEM_T(10000, 48000) lc3_decoder_mem_48k_t;
* sr_hz Sample rate in Hz, 8000, 16000, 24000, 32000, 48000 or 96000
* return Number of PCM samples, -1 on bad parameters
*/
-int lc3_hr_frame_samples(bool hrmode, int dt_us, int sr_hz);
+LC3_EXPORT int lc3_hr_frame_samples(bool hrmode, int dt_us, int sr_hz);
-int lc3_frame_samples(int dt_us, int sr_hz);
+LC3_EXPORT int lc3_frame_samples(int dt_us, int sr_hz);
/**
* Return the size of frames, from bitrate
@@ -275,9 +275,10 @@ int lc3_frame_samples(int dt_us, int sr_hz);
* respectively the minimum and maximum allowed size.
* return The floor size in bytes of the frames, -1 on bad parameters
*/
-int lc3_hr_frame_bytes(bool hrmode, int dt_us, int sr_hz, int bitrate);
+LC3_EXPORT int lc3_hr_frame_bytes(
+ bool hrmode, int dt_us, int sr_hz, int bitrate);
-int lc3_frame_bytes(int dt_us, int bitrate);
+LC3_EXPORT int lc3_frame_bytes(int dt_us, int bitrate);
/**
* Return the size of frame blocks, from bitrate
@@ -290,10 +291,10 @@ int lc3_frame_bytes(int dt_us, int bitrate);
* respectively the minimum and maximum allowed size.
* return The floor size in bytes of the frames, -1 on bad parameters
*/
-int lc3_hr_frame_block_bytes(bool hrmode,
- int dt_us, int sr_hz, int nchannels, int bitrate);
+LC3_EXPORT int lc3_hr_frame_block_bytes(
+ bool hrmode, int dt_us, int sr_hz, int nchannels, int bitrate);
-int lc3_frame_block_bytes(int dt_us, int nframes, int bitrate);
+LC3_EXPORT int lc3_frame_block_bytes(int dt_us, int nframes, int bitrate);
/**
* Resolve the bitrate, from the size of frames
@@ -303,9 +304,10 @@ int lc3_frame_block_bytes(int dt_us, int nframes, int bitrate);
* nbytes Size in bytes of the frames or frame blocks
* return The ceiled bitrate in bps, -1 on bad parameters
*/
-int lc3_hr_resolve_bitrate(bool hrmode, int dt_us, int sr_hz, int nbytes);
+LC3_EXPORT int lc3_hr_resolve_bitrate(
+ bool hrmode, int dt_us, int sr_hz, int nbytes);
-int lc3_resolve_bitrate(int dt_us, int nbytes);
+LC3_EXPORT int lc3_resolve_bitrate(int dt_us, int nbytes);
/**
* Return algorithmic delay, as a number of samples
@@ -314,9 +316,9 @@ int lc3_resolve_bitrate(int dt_us, int nbytes);
* sr_hz Sample rate in Hz, 8000, 16000, 24000, 32000, 48000 or 96000
* return Number of algorithmic delay samples, -1 on bad parameters
*/
-int lc3_hr_delay_samples(bool hrmode, int dt_us, int sr_hz);
+LC3_EXPORT int lc3_hr_delay_samples(bool hrmode, int dt_us, int sr_hz);
-int lc3_delay_samples(int dt_us, int sr_hz);
+LC3_EXPORT int lc3_delay_samples(int dt_us, int sr_hz);
/**
* Return size needed for an encoder
@@ -328,9 +330,9 @@ int lc3_delay_samples(int dt_us, int sr_hz);
* The `sr_hz` parameter is the sample rate of the PCM input stream,
* and will match `sr_pcm_hz` of `lc3_hr_setup_encoder()`.
*/
-unsigned lc3_hr_encoder_size(bool hrmode, int dt_us, int sr_hz);
+LC3_EXPORT unsigned lc3_hr_encoder_size(bool hrmode, int dt_us, int sr_hz);
-unsigned lc3_encoder_size(int dt_us, int sr_hz);
+LC3_EXPORT unsigned lc3_encoder_size(int dt_us, int sr_hz);
/**
* Setup encoder
@@ -347,10 +349,10 @@ unsigned lc3_encoder_size(int dt_us, int sr_hz);
* sample rate `sr_hz`. The size of the context needed, given by
* `lc3_hr_encoder_size()` will be set accordingly to `sr_pcm_hz`.
*/
-lc3_encoder_t lc3_hr_setup_encoder(bool hrmode,
- int dt_us, int sr_hz, int sr_pcm_hz, void *mem);
+LC3_EXPORT lc3_encoder_t lc3_hr_setup_encoder(
+ bool hrmode, int dt_us, int sr_hz, int sr_pcm_hz, void *mem);
-lc3_encoder_t lc3_setup_encoder(
+LC3_EXPORT lc3_encoder_t lc3_setup_encoder(
int dt_us, int sr_hz, int sr_pcm_hz, void *mem);
/**
@@ -362,7 +364,8 @@ lc3_encoder_t lc3_setup_encoder(
* out Output buffer of `nbytes` size
* return 0: On success -1: Wrong parameters
*/
-int lc3_encode(lc3_encoder_t encoder, enum lc3_pcm_format fmt,
+LC3_EXPORT int lc3_encode(
+ lc3_encoder_t encoder, enum lc3_pcm_format fmt,
const void *pcm, int stride, int nbytes, void *out);
/**
@@ -375,9 +378,9 @@ int lc3_encode(lc3_encoder_t encoder, enum lc3_pcm_format fmt,
* The `sr_hz` parameter is the sample rate of the PCM output stream,
* and will match `sr_pcm_hz` of `lc3_hr_setup_decoder()`.
*/
-unsigned lc3_hr_decoder_size(bool hrmode, int dt_us, int sr_hz);
+LC3_EXPORT unsigned lc3_hr_decoder_size(bool hrmode, int dt_us, int sr_hz);
-unsigned lc3_decoder_size(int dt_us, int sr_hz);
+LC3_EXPORT unsigned lc3_decoder_size(int dt_us, int sr_hz);
/**
* Setup decoder
@@ -394,10 +397,10 @@ unsigned lc3_decoder_size(int dt_us, int sr_hz);
* sample rate `sr_hz`. The size of the context needed, given by
* `lc3_hr_decoder_size()` will be set accordingly to `sr_pcm_hz`.
*/
-lc3_decoder_t lc3_hr_setup_decoder(bool hrmode,
- int dt_us, int sr_hz, int sr_pcm_hz, void *mem);
+LC3_EXPORT lc3_decoder_t lc3_hr_setup_decoder(
+ bool hrmode, int dt_us, int sr_hz, int sr_pcm_hz, void *mem);
-lc3_decoder_t lc3_setup_decoder(
+LC3_EXPORT lc3_decoder_t lc3_setup_decoder(
int dt_us, int sr_hz, int sr_pcm_hz, void *mem);
/**
@@ -408,7 +411,8 @@ lc3_decoder_t lc3_setup_decoder(
* pcm, stride Output PCM samples, and count between two consecutives
* return 0: On success 1: PLC operated -1: Wrong parameters
*/
-int lc3_decode(lc3_decoder_t decoder, const void *in, int nbytes,
+LC3_EXPORT int lc3_decode(
+ lc3_decoder_t decoder, const void *in, int nbytes,
enum lc3_pcm_format fmt, void *pcm, int stride);
diff --git a/include/lc3_private.h b/include/lc3_private.h
index d7e93fd..4f5f657 100644
--- a/include/lc3_private.h
+++ b/include/lc3_private.h
@@ -173,4 +173,15 @@ struct lc3_decoder {
}
+/**
+ * Change the visibility of interface functions
+ */
+
+#ifdef _WIN32
+#define LC3_EXPORT __declspec(dllexport)
+#else
+#define LC3_EXPORT __attribute__((visibility ("default")))
+#endif
+
+
#endif /* __LC3_PRIVATE_H */
diff --git a/meson.build b/meson.build
index 4d4f1d7..60f38b3 100644
--- a/meson.build
+++ b/meson.build
@@ -20,7 +20,9 @@ project('lc3', 'c',
cc = meson.get_compiler('c')
-if cc.get_id() != 'msvc'
+if cc.get_id() == 'msvc'
+ add_project_arguments(['/wd4244', '/wd4305', '/fp:fast'], language: 'c')
+else
add_project_arguments('-ffast-math', language: 'c')
endif
diff --git a/src/common.h b/src/common.h
index 2f6cd1f..3d907b9 100644
--- a/src/common.h
+++ b/src/common.h
@@ -83,14 +83,6 @@
/**
- * Change the visibility of interface functions
- */
-
-#define LC3_EXPORT \
- __attribute__((visibility ("default")))
-
-
-/**
* Macros
* MIN/MAX Minimum and maximum between 2 values
* CLIP Clip a value between low and high limits