diff options
author | sanine <sanine.not@pm.me> | 2022-08-26 12:42:30 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-08-26 12:42:30 -0500 |
commit | bde3e4f1bb7b8f8abca0884a7d994ee1c17a66b1 (patch) | |
tree | 825ff3669a38ec247bcc9b575a4a4ceb81534d35 | |
parent | 8ec3f8e82acd70410515550fd1790ee5827aafdb (diff) |
refactor: move mossrose.h to include/ dir
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | include/mossrose.h (renamed from src/mossrose.h) | 0 | ||||
-rw-r--r-- | src/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/channel.c (renamed from src/mossrose-channel.c) | 4 | ||||
-rw-r--r-- | src/channel.h (renamed from src/mossrose-channel.h) | 2 | ||||
-rw-r--r-- | src/mossrose.c | 15 | ||||
-rw-r--r-- | src/mutex.c (renamed from src/mossrose-mutex.c) | 2 | ||||
-rw-r--r-- | src/mutex.h (renamed from src/mossrose-mutex.h) | 0 |
8 files changed, 23 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d86dc60..b51a63f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,16 +5,14 @@ project( ) +include_directories(${CMAKE_SOURCE_DIR}/include) option(MOSSROSE_BUILD_EXAMPLES "Build the example programs" OFF) add_subdirectory(${CMAKE_SOURCE_DIR}/portaudio EXCLUDE_FROM_ALL) -add_library(mossrose - ${CMAKE_SOURCE_DIR}/src/mossrose.c - ${CMAKE_SOURCE_DIR}/src/mossrose-mutex.c - ${CMAKE_SOURCE_DIR}/src/mossrose-channel.c -) +add_library(mossrose) +add_subdirectory(${CMAKE_SOURCE_DIR}/src) set_target_properties(mossrose PROPERTIES C_STANDARD 99 CMAKE_C_FLAGS "-Wall -Wextra -Werror -Wfatal-errors -Wpedantic" @@ -28,7 +26,6 @@ endif() if (MOSSROSE_BUILD_EXAMPLES) - include_directories(${CMAKE_SOURCE_DIR}/src) add_custom_target(examples) add_subdirectory(${CMAKE_SOURCE_DIR}/examples) endif() diff --git a/src/mossrose.h b/include/mossrose.h index fb7d088..fb7d088 100644 --- a/src/mossrose.h +++ b/include/mossrose.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..069d00a --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,7 @@ +project(mossrose) + +target_sources(mossrose PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/mossrose.c + ${CMAKE_CURRENT_LIST_DIR}/mutex.c + ${CMAKE_CURRENT_LIST_DIR}/channel.c +) diff --git a/src/mossrose-channel.c b/src/channel.c index 7232417..169b245 100644 --- a/src/mossrose-channel.c +++ b/src/channel.c @@ -1,7 +1,7 @@ #include <stdlib.h> #include <string.h> -#include "mossrose-mutex.h" -#include "mossrose-channel.h" +#include "mutex.h" +#include "channel.h" void mossrose_channel_init(struct mossrose_channel_t *chan) diff --git a/src/mossrose-channel.h b/src/channel.h index e1db89d..23c11d6 100644 --- a/src/mossrose-channel.h +++ b/src/channel.h @@ -2,7 +2,7 @@ #define MOSSROSE_CHANNEL_H #include <stddef.h> -#include "mossrose-mutex.h" +#include "mutex.h" struct mossrose_channel_t { mossrose_mutex_t mutex; diff --git a/src/mossrose.c b/src/mossrose.c index 02f063a..4f31711 100644 --- a/src/mossrose.c +++ b/src/mossrose.c @@ -1,9 +1,9 @@ #include <stdio.h> #include <stdlib.h> #include <portaudio.h> -#include "mossrose.h" -#include "mossrose-mutex.h" -#include "mossrose-channel.h" +#include <mossrose.h> +#include "mutex.h" +#include "channel.h" /* ~~~~~~~~~~~~~~~~ type definitions ~~~~~~~~~~~~~~~~ */ @@ -124,15 +124,18 @@ int mossrose_init(double sample_rate, int n_channels) int mossrose_play(float *left, float *right, size_t len, int channel) { if (channel > 0) { - return mossrose_channel_set(mossrose_global.channels+channel, left, right, len, 1); + if (mossrose_channel_set(mossrose_global.channels+channel, left, right, len, 1) == 0) + return channel; + else + return -1; } else { struct mossrose_channel_t *chan; for (int i=0; i<mossrose_global.n_channels; i++) { chan = mossrose_global.channels + i; - if (mossrose_channel_set(chan, left, right, len, 0) == 0) return 0; + if (mossrose_channel_set(chan, left, right, len, 0) == 0) return i; } - return 1; + return -1; } } diff --git a/src/mossrose-mutex.c b/src/mutex.c index b6865f8..4a51fa8 100644 --- a/src/mossrose-mutex.c +++ b/src/mutex.c @@ -1,4 +1,4 @@ -#include "mossrose-mutex.h" +#include "mutex.h" #ifdef WIN32 #include <windows.h> diff --git a/src/mossrose-mutex.h b/src/mutex.h index 84d1f63..84d1f63 100644 --- a/src/mossrose-mutex.h +++ b/src/mutex.h |