Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #47

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

Windows support #47

wants to merge 21 commits into from

Conversation

dominikschnitzer
Copy link
Owner

@dominikschnitzer dominikschnitzer commented Sep 2, 2019

This PR addresses issue #15. It enables building with Visual studio.

(1) It adds a Travis Windows build, so we don't break it again. See the Windows build for this branch: https://travis-ci.org/dominikschnitzer/musly/builds/579697952
(2) bumps the Warning level to Wall (gcc/clang) and /W4 (VC++)
(3) compiles with with warnings as errors (Werror and /WX)
(4) Subsequently fixes all compiler warnings that broke the build due to (2) and (3)

We need to add getopt/dirent for MS Visual Studio
support.
Separate libmusly from kissfft and libsamplerate
Add explicit static_cast<>s where we implicitly
downcasted the value.
Adds #ifdefs for MSVC and missing headers
 - Unreachable code
 - Correct data type for varables
This fixes an annoying warning with MSVC++
As the macros are used/written they yield an
extra ";". This commit fixes the pedantic warning.
C code from external libraries uses a custom warning
level.
This is required because config.h is generated
in the binary dir of the cmake build.
The bit-flags in av_seek_frame() were logically
||'d instead of bitwise |'d
Copy link
Collaborator

@f0k f0k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I'm only halfway through, but thought I'd share the comments I have so far. You did a lot! 👍

script:
- mkdir -p build
- cd build
- cmake ..
- make -j
- cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=Release ${CARGS} ..
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the static build? Is it not working otherwise?

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

if (MSVC)
# Ninja uses those flags on Windows, MSBuild ignores them
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add a comment on what these flags are meant to do, similar to the next block?

@@ -36,6 +56,8 @@ else ()
set(BUILD_SHARED_LIBS ON)
endif ()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give a short explanation why setting this is a good idea? (Or add a one-line comment to the file?) According to the documentation, it's enabled by default for shared libraries, but not for executables.

@@ -16,6 +13,10 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external")
PROPERTIES COMPILE_FLAGS "-DLIBMUSLY_EXTERNAL ${LIBMUSLY_EXTERNAL_FLAGS}")
endif()

# configure libresample
find_file(HAVE_INTTYPES inttypes.h)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HAVE_INTTYPES_H?


target_link_libraries(libmusly
kissfft
libresample
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if that was included in one of the commit messages, but can you explain the implications of separating out kissfft and libresample into static libraries and linking them here, in case we're building a shared libmusly library for Linux? Any possible negative effects compared to compiling and linking all the objects at once?

excerpt_start * st->time_base.den / st->time_base.num,
AVSEEK_FLAG_BACKWARD || AVSEEK_FLAG_ANY) >= 0)) {
if ((excerpt_start > 0) && (av_seek_frame(fmtx, audio_stream_idx,
static_cast<int64_t>(static_cast<double>(excerpt_start) * st->time_base.den) / st->time_base.num,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you're doing the multiplication in double, convert to int64, and divide? Shouldn't we either do everything in int, or do everything in double if we fear an overflow? And do we want the code to look like that for 32-bit targets as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, we might adopt what the code for file_length = does.

@@ -471,14 +471,14 @@ libav::decodeto_22050hz_mono_float(
int skip_samples = 0;
if (excerpt_start < 0) {
// center excerpt, but start at -excerpt_start the latest
float file_length = decoded_pcm.size() / decx->sample_rate;
float file_length = static_cast<float>(decoded_pcm.size() / decx->sample_rate);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we'd want the division to happen in float?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants