From 425dc4bf697e7465e3d41f9e5d198222c0bce448 Mon Sep 17 00:00:00 2001 From: Corey Powell Date: Thu, 30 Jun 2016 10:45:08 -0500 Subject: [PATCH 1/6] Allow overriding static lib name This helps alleviate cases where compilers will choose to link against the dynamic library instead of the static based on name alone (in which you don't have much control, or don't wish to tinker too much with the compiler args) --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb645a8..09b48d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ set(LIBSOUNDIO_VERSION_PATCH 0) set(LIBSOUNDIO_VERSION "${LIBSOUNDIO_VERSION_MAJOR}.${LIBSOUNDIO_VERSION_MINOR}.${LIBSOUNDIO_VERSION_PATCH}") message("Configuring libsoundio version ${LIBSOUNDIO_VERSION}") +if(NOT SOUNDIO_STATIC_LIBNAME) + set(SOUNDIO_STATIC_LIBNAME soundio) +endif() + option(BUILD_STATIC_LIBS "Build static libraries" ON) option(BUILD_EXAMPLE_PROGRAMS "Build example programs" ON) option(BUILD_TESTS "Build tests" ON) @@ -233,7 +237,7 @@ install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(BUILD_STATIC_LIBS) add_library(libsoundio_static STATIC ${LIBSOUNDIO_SOURCES}) set_target_properties(libsoundio_static PROPERTIES - OUTPUT_NAME soundio + OUTPUT_NAME ${SOUNDIO_STATIC_LIBNAME} COMPILE_FLAGS ${LIB_CFLAGS} LINKER_LANGUAGE C ) From 3e1033cd30fa9e23adbe467af2850845aa55f74a Mon Sep 17 00:00:00 2001 From: Corey Powell Date: Thu, 30 Jun 2016 10:45:55 -0500 Subject: [PATCH 2/6] Added flag to building the dynamic libraries BUILD_DYNAMIC_LIBS Some libs (glfw comes to mind), offer the option to build both or either the static and dynamic libs --- CMakeLists.txt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09b48d2..e47a46d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ if(NOT SOUNDIO_STATIC_LIBNAME) endif() option(BUILD_STATIC_LIBS "Build static libraries" ON) +option(BUILD_DYNAMIC_LIBS "Build dynamic libraries" ON) option(BUILD_EXAMPLE_PROGRAMS "Build example programs" ON) option(BUILD_TESTS "Build tests" ON) option(ENABLE_JACK "Enable JACK backend" ON) @@ -222,17 +223,18 @@ configure_file( ${DOXYGEN_CONF_FILE} ) -add_library(libsoundio_shared SHARED ${LIBSOUNDIO_SOURCES}) -set_target_properties(libsoundio_shared PROPERTIES - OUTPUT_NAME soundio - SOVERSION ${LIBSOUNDIO_VERSION_MAJOR} - VERSION ${LIBSOUNDIO_VERSION} - COMPILE_FLAGS ${LIB_CFLAGS} - LINKER_LANGUAGE C -) -target_link_libraries(libsoundio_shared LINK_PUBLIC ${LIBSOUNDIO_LIBS}) -install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - +if(BUILD_DYNAMIC_LIBS) + add_library(libsoundio_shared SHARED ${LIBSOUNDIO_SOURCES}) + set_target_properties(libsoundio_shared PROPERTIES + OUTPUT_NAME soundio + SOVERSION ${LIBSOUNDIO_VERSION_MAJOR} + VERSION ${LIBSOUNDIO_VERSION} + COMPILE_FLAGS ${LIB_CFLAGS} + LINKER_LANGUAGE C + ) + target_link_libraries(libsoundio_shared LINK_PUBLIC ${LIBSOUNDIO_LIBS}) + install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() if(BUILD_STATIC_LIBS) add_library(libsoundio_static STATIC ${LIBSOUNDIO_SOURCES}) From 81cd9e54e92e40a283f2b5da29b025fc49cad789 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 20 Jul 2016 16:47:44 -0700 Subject: [PATCH 3/6] WASAPI: Remove useless statement in CMake module AUDIOCLIENT_H, as declared here, is not an external cached variable, so calling mark_as_advanced() has no apparent effect (does not enable user to modify value, even in advanced mode). Even if it were cached, its value (success/failure at finding audioclient.h) should not be edited by the user. Also modified whitespace to be more consistent with that found in CMakeLists.txt. --- cmake/FindWASAPI.cmake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmake/FindWASAPI.cmake b/cmake/FindWASAPI.cmake index 88bb9a6..2207589 100644 --- a/cmake/FindWASAPI.cmake +++ b/cmake/FindWASAPI.cmake @@ -5,11 +5,10 @@ # WASAPI_FOUND # AUDIOCLIENT_H -if (WIN32) - include(CheckIncludeFile) - check_include_file(audioclient.h AUDIOCLIENT_H) +if(WIN32) + include(CheckIncludeFile) + check_include_file(audioclient.h AUDIOCLIENT_H) endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(WASAPI DEFAULT_MSG AUDIOCLIENT_H) -mark_as_advanced(AUDIOCLIENT_H) From bba007f0a7865ddd3ff552e4c0db0f6c3e3731aa Mon Sep 17 00:00:00 2001 From: Joshua Olson <0joshua.olson1@gmail.com> Date: Sat, 23 Jul 2016 19:15:26 -0600 Subject: [PATCH 4/6] Remove duplicate documented SoundIoError --- soundio/soundio.h | 1 - 1 file changed, 1 deletion(-) diff --git a/soundio/soundio.h b/soundio/soundio.h index 1f1ab10..6aa8359 100644 --- a/soundio/soundio.h +++ b/soundio/soundio.h @@ -946,7 +946,6 @@ SOUNDIO_EXPORT void soundio_outstream_destroy(struct SoundIoOutStream *outstream /// * #SoundIoErrorBackendDisconnected /// * #SoundIoErrorSystemResources /// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient` -/// * #SoundIoErrorOpeningDevice /// * #SoundIoErrorIncompatibleBackend - SoundIoOutStream::channel_count is /// greater than the number of channels the backend can handle. /// * #SoundIoErrorIncompatibleDevice - stream parameters requested are not From 9defcda7f4671d1042c5d08a04e2e0224510c052 Mon Sep 17 00:00:00 2001 From: 0joshuaolson1 <0joshua.olson1@gmail.com> Date: Tue, 26 Jul 2016 16:23:05 -0600 Subject: [PATCH 5/6] Add packed/3bytes format to ALSA,dummy --- example/sio_microphone.c | 4 ++ example/sio_record.c | 4 ++ soundio/soundio.h | 48 +++++++++++++++--------- src/alsa.c | 14 ++++++- src/dummy.c | 22 ++++++----- src/soundio.c | 80 ++++++++++++++++++++++------------------ test/overflow.c | 4 ++ 7 files changed, 112 insertions(+), 64 deletions(-) diff --git a/example/sio_microphone.c b/example/sio_microphone.c index 0e3d3d4..c95e106 100644 --- a/example/sio_microphone.c +++ b/example/sio_microphone.c @@ -22,6 +22,8 @@ static enum SoundIoFormat prioritized_formats[] = { SoundIoFormatS32FE, SoundIoFormatS24NE, SoundIoFormatS24FE, + SoundIoFormatS24PackedNE, + SoundIoFormatS24PackedFE, SoundIoFormatS16NE, SoundIoFormatS16FE, SoundIoFormatFloat64NE, @@ -30,6 +32,8 @@ static enum SoundIoFormat prioritized_formats[] = { SoundIoFormatU32FE, SoundIoFormatU24NE, SoundIoFormatU24FE, + SoundIoFormatU24PackedNE, + SoundIoFormatU24PackedFE, SoundIoFormatU16NE, SoundIoFormatU16FE, SoundIoFormatS8, diff --git a/example/sio_record.c b/example/sio_record.c index 29c07ef..82ec635 100644 --- a/example/sio_record.c +++ b/example/sio_record.c @@ -25,6 +25,8 @@ static enum SoundIoFormat prioritized_formats[] = { SoundIoFormatS32FE, SoundIoFormatS24NE, SoundIoFormatS24FE, + SoundIoFormatS24PackedNE, + SoundIoFormatS24PackedFE, SoundIoFormatS16NE, SoundIoFormatS16FE, SoundIoFormatFloat64NE, @@ -33,6 +35,8 @@ static enum SoundIoFormat prioritized_formats[] = { SoundIoFormatU32FE, SoundIoFormatU24NE, SoundIoFormatU24FE, + SoundIoFormatU24PackedNE, + SoundIoFormatU24PackedFE, SoundIoFormatU16NE, SoundIoFormatU16FE, SoundIoFormatS8, diff --git a/soundio/soundio.h b/soundio/soundio.h index 6aa8359..3d7a0fb 100644 --- a/soundio/soundio.h +++ b/soundio/soundio.h @@ -234,24 +234,28 @@ enum SoundIoDeviceAim { /// which point to the respective SoundIoFormat values. enum SoundIoFormat { SoundIoFormatInvalid, - SoundIoFormatS8, ///< Signed 8 bit - SoundIoFormatU8, ///< Unsigned 8 bit - SoundIoFormatS16LE, ///< Signed 16 bit Little Endian - SoundIoFormatS16BE, ///< Signed 16 bit Big Endian - SoundIoFormatU16LE, ///< Unsigned 16 bit Little Endian - SoundIoFormatU16BE, ///< Unsigned 16 bit Little Endian - SoundIoFormatS24LE, ///< Signed 24 bit Little Endian using low three bytes in 32-bit word - SoundIoFormatS24BE, ///< Signed 24 bit Big Endian using low three bytes in 32-bit word - SoundIoFormatU24LE, ///< Unsigned 24 bit Little Endian using low three bytes in 32-bit word - SoundIoFormatU24BE, ///< Unsigned 24 bit Big Endian using low three bytes in 32-bit word - SoundIoFormatS32LE, ///< Signed 32 bit Little Endian - SoundIoFormatS32BE, ///< Signed 32 bit Big Endian - SoundIoFormatU32LE, ///< Unsigned 32 bit Little Endian - SoundIoFormatU32BE, ///< Unsigned 32 bit Big Endian - SoundIoFormatFloat32LE, ///< Float 32 bit Little Endian, Range -1.0 to 1.0 - SoundIoFormatFloat32BE, ///< Float 32 bit Big Endian, Range -1.0 to 1.0 - SoundIoFormatFloat64LE, ///< Float 64 bit Little Endian, Range -1.0 to 1.0 - SoundIoFormatFloat64BE, ///< Float 64 bit Big Endian, Range -1.0 to 1.0 + SoundIoFormatS8, ///< Signed 8 bit + SoundIoFormatU8, ///< Unsigned 8 bit + SoundIoFormatS16LE, ///< Signed 16 bit Little Endian + SoundIoFormatS16BE, ///< Signed 16 bit Big Endian + SoundIoFormatU16LE, ///< Unsigned 16 bit Little Endian + SoundIoFormatU16BE, ///< Unsigned 16 bit Little Endian + SoundIoFormatS24LE, ///< Signed 24 bit Little Endian using low three bytes in 32-bit word + SoundIoFormatS24BE, ///< Signed 24 bit Big Endian using low three bytes in 32-bit word + SoundIoFormatU24LE, ///< Unsigned 24 bit Little Endian using low three bytes in 32-bit word + SoundIoFormatU24BE, ///< Unsigned 24 bit Big Endian using low three bytes in 32-bit word + SoundIoFormatS24PackedLE, ///< Signed 24 bit Little Endian using three bytes + SoundIoFormatS24PackedBE, ///< Signed 24 bit Big Endian using three bytes + SoundIoFormatU24PackedLE, ///< Unsigned 24 bit Little Endian using three bytes + SoundIoFormatU24PackedBE, ///< Unsigned 24 bit Big Endian using three bytes + SoundIoFormatS32LE, ///< Signed 32 bit Little Endian + SoundIoFormatS32BE, ///< Signed 32 bit Big Endian + SoundIoFormatU32LE, ///< Unsigned 32 bit Little Endian + SoundIoFormatU32BE, ///< Unsigned 32 bit Big Endian + SoundIoFormatFloat32LE, ///< Float 32 bit Little Endian, Range -1.0 to 1.0 + SoundIoFormatFloat32BE, ///< Float 32 bit Big Endian, Range -1.0 to 1.0 + SoundIoFormatFloat64LE, ///< Float 64 bit Little Endian, Range -1.0 to 1.0 + SoundIoFormatFloat64BE, ///< Float 64 bit Big Endian, Range -1.0 to 1.0 }; #if defined(SOUNDIO_OS_BIG_ENDIAN) @@ -259,6 +263,8 @@ enum SoundIoFormat { #define SoundIoFormatU16NE SoundIoFormatU16BE #define SoundIoFormatS24NE SoundIoFormatS24BE #define SoundIoFormatU24NE SoundIoFormatU24BE +#define SoundIoFormatS24PackedNE SoundIoFormatS24PackedBE +#define SoundIoFormatU24PackedNE SoundIoFormatU24PackedBE #define SoundIoFormatS32NE SoundIoFormatS32BE #define SoundIoFormatU32NE SoundIoFormatU32BE #define SoundIoFormatFloat32NE SoundIoFormatFloat32BE @@ -268,6 +274,8 @@ enum SoundIoFormat { #define SoundIoFormatU16FE SoundIoFormatU16LE #define SoundIoFormatS24FE SoundIoFormatS24LE #define SoundIoFormatU24FE SoundIoFormatU24LE +#define SoundIoFormatS24PackedFE SoundIoFormatS24PackedLE +#define SoundIoFormatU24PackedFE SoundIoFormatU24PackedLE #define SoundIoFormatS32FE SoundIoFormatS32LE #define SoundIoFormatU32FE SoundIoFormatU32LE #define SoundIoFormatFloat32FE SoundIoFormatFloat32LE @@ -283,6 +291,8 @@ enum SoundIoFormat { #define SoundIoFormatU16NE SoundIoFormatU16LE #define SoundIoFormatS24NE SoundIoFormatS24LE #define SoundIoFormatU24NE SoundIoFormatU24LE +#define SoundIoFormatS24PackedNE SoundIoFormatS24PackedLE +#define SoundIoFormatU24PackedNE SoundIoFormatU24PackedLE #define SoundIoFormatS32NE SoundIoFormatS32LE #define SoundIoFormatU32NE SoundIoFormatU32LE #define SoundIoFormatFloat32NE SoundIoFormatFloat32LE @@ -292,6 +302,8 @@ enum SoundIoFormat { #define SoundIoFormatU16FE SoundIoFormatU16BE #define SoundIoFormatS24FE SoundIoFormatS24BE #define SoundIoFormatU24FE SoundIoFormatU24BE +#define SoundIoFormatS24PackedFE SoundIoFormatS24PackedBE +#define SoundIoFormatU24PackedFE SoundIoFormatU24PackedBE #define SoundIoFormatS32FE SoundIoFormatS32BE #define SoundIoFormatU32FE SoundIoFormatU32BE #define SoundIoFormatFloat32FE SoundIoFormatFloat32BE diff --git a/src/alsa.c b/src/alsa.c index 5a1e541..81a2fda 100644 --- a/src/alsa.c +++ b/src/alsa.c @@ -236,6 +236,10 @@ static snd_pcm_format_t to_alsa_fmt(enum SoundIoFormat fmt) { case SoundIoFormatS24BE: return SND_PCM_FORMAT_S24_BE; case SoundIoFormatU24LE: return SND_PCM_FORMAT_U24_LE; case SoundIoFormatU24BE: return SND_PCM_FORMAT_U24_BE; + case SoundIoFormatS24PackedLE: return SND_PCM_FORMAT_S24_3LE; + case SoundIoFormatS24PackedBE: return SND_PCM_FORMAT_S24_3BE; + case SoundIoFormatU24PackedLE: return SND_PCM_FORMAT_U24_3LE; + case SoundIoFormatU24PackedBE: return SND_PCM_FORMAT_U24_3BE; case SoundIoFormatS32LE: return SND_PCM_FORMAT_S32_LE; case SoundIoFormatS32BE: return SND_PCM_FORMAT_S32_BE; case SoundIoFormatU32LE: return SND_PCM_FORMAT_U32_LE; @@ -350,6 +354,10 @@ static int probe_open_device(struct SoundIoDevice *device, snd_pcm_t *handle, in snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_S24_BE); snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_U24_LE); snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_U24_BE); + snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_S24_3LE); + snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_S24_3BE); + snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_U24_3LE); + snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_U24_3BE); snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_S32_LE); snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_S32_BE); snd_pcm_format_mask_set(fmt_mask, SND_PCM_FORMAT_U32_LE); @@ -364,7 +372,7 @@ static int probe_open_device(struct SoundIoDevice *device, snd_pcm_t *handle, in if (!device->formats) { snd_pcm_hw_params_get_format_mask(hwparams, fmt_mask); - device->formats = ALLOCATE(enum SoundIoFormat, 18); + device->formats = ALLOCATE(enum SoundIoFormat, 22); if (!device->formats) return SoundIoErrorNoMem; @@ -379,6 +387,10 @@ static int probe_open_device(struct SoundIoDevice *device, snd_pcm_t *handle, in test_fmt_mask(device, fmt_mask, SoundIoFormatS24BE); test_fmt_mask(device, fmt_mask, SoundIoFormatU24LE); test_fmt_mask(device, fmt_mask, SoundIoFormatU24BE); + test_fmt_mask(device, fmt_mask, SoundIoFormatS24PackedLE); + test_fmt_mask(device, fmt_mask, SoundIoFormatS24PackedBE); + test_fmt_mask(device, fmt_mask, SoundIoFormatU24PackedLE); + test_fmt_mask(device, fmt_mask, SoundIoFormatU24PackedBE); test_fmt_mask(device, fmt_mask, SoundIoFormatS32LE); test_fmt_mask(device, fmt_mask, SoundIoFormatS32BE); test_fmt_mask(device, fmt_mask, SoundIoFormatU32LE); diff --git a/src/dummy.c b/src/dummy.c index f1a3828..5e0ff61 100644 --- a/src/dummy.c +++ b/src/dummy.c @@ -380,7 +380,7 @@ static int instream_get_latency_dummy(struct SoundIoPrivate *si, struct SoundIoI } static int set_all_device_formats(struct SoundIoDevice *device) { - device->format_count = 18; + device->format_count = 22; device->formats = ALLOCATE(enum SoundIoFormat, device->format_count); if (!device->formats) return SoundIoErrorNoMem; @@ -395,14 +395,18 @@ static int set_all_device_formats(struct SoundIoDevice *device) { device->formats[7] = SoundIoFormatS24FE; device->formats[8] = SoundIoFormatU24NE; device->formats[9] = SoundIoFormatU24FE; - device->formats[10] = SoundIoFormatFloat64NE; - device->formats[11] = SoundIoFormatFloat64FE; - device->formats[12] = SoundIoFormatS16NE; - device->formats[13] = SoundIoFormatS16FE; - device->formats[14] = SoundIoFormatU16NE; - device->formats[15] = SoundIoFormatU16FE; - device->formats[16] = SoundIoFormatS8; - device->formats[17] = SoundIoFormatU8; + device->formats[10] = SoundIoFormatS24PackedNE; + device->formats[11] = SoundIoFormatS24PackedFE; + device->formats[12] = SoundIoFormatU24PackedNE; + device->formats[13] = SoundIoFormatU24PackedFE; + device->formats[14] = SoundIoFormatFloat64NE; + device->formats[15] = SoundIoFormatFloat64FE; + device->formats[16] = SoundIoFormatS16NE; + device->formats[17] = SoundIoFormatS16FE; + device->formats[18] = SoundIoFormatU16NE; + device->formats[19] = SoundIoFormatU16FE; + device->formats[20] = SoundIoFormatS8; + device->formats[21] = SoundIoFormatU8; return 0; } diff --git a/src/soundio.c b/src/soundio.c index 32d3455..4f5dc6f 100644 --- a/src/soundio.c +++ b/src/soundio.c @@ -97,24 +97,28 @@ const char *soundio_strerror(int error) { int soundio_get_bytes_per_sample(enum SoundIoFormat format) { switch (format) { - case SoundIoFormatU8: return 1; - case SoundIoFormatS8: return 1; - case SoundIoFormatS16LE: return 2; - case SoundIoFormatS16BE: return 2; - case SoundIoFormatU16LE: return 2; - case SoundIoFormatU16BE: return 2; - case SoundIoFormatS24LE: return 4; - case SoundIoFormatS24BE: return 4; - case SoundIoFormatU24LE: return 4; - case SoundIoFormatU24BE: return 4; - case SoundIoFormatS32LE: return 4; - case SoundIoFormatS32BE: return 4; - case SoundIoFormatU32LE: return 4; - case SoundIoFormatU32BE: return 4; - case SoundIoFormatFloat32LE: return 4; - case SoundIoFormatFloat32BE: return 4; - case SoundIoFormatFloat64LE: return 8; - case SoundIoFormatFloat64BE: return 8; + case SoundIoFormatU8: return 1; + case SoundIoFormatS8: return 1; + case SoundIoFormatS16LE: return 2; + case SoundIoFormatS16BE: return 2; + case SoundIoFormatU16LE: return 2; + case SoundIoFormatU16BE: return 2; + case SoundIoFormatS24LE: return 4; + case SoundIoFormatS24BE: return 4; + case SoundIoFormatU24LE: return 4; + case SoundIoFormatU24BE: return 4; + case SoundIoFormatS24PackedLE: return 3; + case SoundIoFormatS24PackedBE: return 3; + case SoundIoFormatU24PackedLE: return 3; + case SoundIoFormatU24PackedBE: return 3; + case SoundIoFormatS32LE: return 4; + case SoundIoFormatS32BE: return 4; + case SoundIoFormatU32LE: return 4; + case SoundIoFormatU32BE: return 4; + case SoundIoFormatFloat32LE: return 4; + case SoundIoFormatFloat32BE: return 4; + case SoundIoFormatFloat64LE: return 8; + case SoundIoFormatFloat64BE: return 8; case SoundIoFormatInvalid: return -1; } @@ -123,24 +127,28 @@ int soundio_get_bytes_per_sample(enum SoundIoFormat format) { const char * soundio_format_string(enum SoundIoFormat format) { switch (format) { - case SoundIoFormatS8: return "signed 8-bit"; - case SoundIoFormatU8: return "unsigned 8-bit"; - case SoundIoFormatS16LE: return "signed 16-bit LE"; - case SoundIoFormatS16BE: return "signed 16-bit BE"; - case SoundIoFormatU16LE: return "unsigned 16-bit LE"; - case SoundIoFormatU16BE: return "unsigned 16-bit LE"; - case SoundIoFormatS24LE: return "signed 24-bit LE"; - case SoundIoFormatS24BE: return "signed 24-bit BE"; - case SoundIoFormatU24LE: return "unsigned 24-bit LE"; - case SoundIoFormatU24BE: return "unsigned 24-bit BE"; - case SoundIoFormatS32LE: return "signed 32-bit LE"; - case SoundIoFormatS32BE: return "signed 32-bit BE"; - case SoundIoFormatU32LE: return "unsigned 32-bit LE"; - case SoundIoFormatU32BE: return "unsigned 32-bit BE"; - case SoundIoFormatFloat32LE: return "float 32-bit LE"; - case SoundIoFormatFloat32BE: return "float 32-bit BE"; - case SoundIoFormatFloat64LE: return "float 64-bit LE"; - case SoundIoFormatFloat64BE: return "float 64-bit BE"; + case SoundIoFormatS8: return "signed 8-bit"; + case SoundIoFormatU8: return "unsigned 8-bit"; + case SoundIoFormatS16LE: return "signed 16-bit LE"; + case SoundIoFormatS16BE: return "signed 16-bit BE"; + case SoundIoFormatU16LE: return "unsigned 16-bit LE"; + case SoundIoFormatU16BE: return "unsigned 16-bit LE"; + case SoundIoFormatS24LE: return "signed 24-bit LE"; + case SoundIoFormatS24BE: return "signed 24-bit BE"; + case SoundIoFormatU24LE: return "unsigned 24-bit LE"; + case SoundIoFormatU24BE: return "unsigned 24-bit BE"; + case SoundIoFormatS24PackedLE: return "signed 24-bit packed LE"; + case SoundIoFormatS24PackedBE: return "signed 24-bit packed BE"; + case SoundIoFormatU24PackedLE: return "unsigned 24-bit packed LE"; + case SoundIoFormatU24PackedBE: return "unsigned 24-bit packed BE"; + case SoundIoFormatS32LE: return "signed 32-bit LE"; + case SoundIoFormatS32BE: return "signed 32-bit BE"; + case SoundIoFormatU32LE: return "unsigned 32-bit LE"; + case SoundIoFormatU32BE: return "unsigned 32-bit BE"; + case SoundIoFormatFloat32LE: return "float 32-bit LE"; + case SoundIoFormatFloat32BE: return "float 32-bit BE"; + case SoundIoFormatFloat64LE: return "float 64-bit LE"; + case SoundIoFormatFloat64BE: return "float 64-bit BE"; case SoundIoFormatInvalid: return "(invalid sample format)"; diff --git a/test/overflow.c b/test/overflow.c index 43b6d22..dcff2e9 100644 --- a/test/overflow.c +++ b/test/overflow.c @@ -21,6 +21,8 @@ static enum SoundIoFormat prioritized_formats[] = { SoundIoFormatS32FE, SoundIoFormatS24NE, SoundIoFormatS24FE, + SoundIoFormatS24PackedNE, + SoundIoFormatS24PackedFE, SoundIoFormatS16NE, SoundIoFormatS16FE, SoundIoFormatFloat64NE, @@ -29,6 +31,8 @@ static enum SoundIoFormat prioritized_formats[] = { SoundIoFormatU32FE, SoundIoFormatU24NE, SoundIoFormatU24FE, + SoundIoFormatU24PackedNE, + SoundIoFormatU24PackedFE, SoundIoFormatU16NE, SoundIoFormatU16FE, SoundIoFormatS8, From 662286a3120c17fe8adca585dbe23a6ababc395e Mon Sep 17 00:00:00 2001 From: 0joshuaolson1 <0joshua.olson1@gmail.com> Date: Sat, 30 Jul 2016 14:45:28 -0600 Subject: [PATCH 6/6] Add PulseAudio signed 24bit packed formats --- src/pulseaudio.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/pulseaudio.c b/src/pulseaudio.c index d594c3b..3f1bb6a 100644 --- a/src/pulseaudio.c +++ b/src/pulseaudio.c @@ -101,13 +101,13 @@ static enum SoundIoFormat from_pulseaudio_format(pa_sample_spec sample_spec) { case PA_SAMPLE_S32BE: return SoundIoFormatS32BE; case PA_SAMPLE_S24_32LE: return SoundIoFormatS24LE; case PA_SAMPLE_S24_32BE: return SoundIoFormatS24BE; + case PA_SAMPLE_S24LE: return SoundIoFormatS24PackedLE; + case PA_SAMPLE_S24BE: return SoundIoFormatS24PackedBE; case PA_SAMPLE_MAX: case PA_SAMPLE_INVALID: case PA_SAMPLE_ALAW: case PA_SAMPLE_ULAW: - case PA_SAMPLE_S24LE: - case PA_SAMPLE_S24BE: return SoundIoFormatInvalid; } return SoundIoFormatInvalid; @@ -183,7 +183,7 @@ static int set_all_device_channel_layouts(struct SoundIoDevice *device) { } static int set_all_device_formats(struct SoundIoDevice *device) { - device->format_count = 9; + device->format_count = 11; device->formats = ALLOCATE(enum SoundIoFormat, device->format_count); if (!device->formats) return SoundIoErrorNoMem; @@ -196,6 +196,8 @@ static int set_all_device_formats(struct SoundIoDevice *device) { device->formats[6] = SoundIoFormatS32BE; device->formats[7] = SoundIoFormatS24LE; device->formats[8] = SoundIoFormatS24BE; + device->formats[9] = SoundIoFormatS24PackedLE; + device->formats[10] = SoundIoFormatS24PackedBE; return 0; } @@ -513,15 +515,17 @@ static void force_device_scan_pa(struct SoundIoPrivate *si) { static pa_sample_format_t to_pulseaudio_format(enum SoundIoFormat format) { switch (format) { - case SoundIoFormatU8: return PA_SAMPLE_U8; - case SoundIoFormatS16LE: return PA_SAMPLE_S16LE; - case SoundIoFormatS16BE: return PA_SAMPLE_S16BE; - case SoundIoFormatS24LE: return PA_SAMPLE_S24_32LE; - case SoundIoFormatS24BE: return PA_SAMPLE_S24_32BE; - case SoundIoFormatS32LE: return PA_SAMPLE_S32LE; - case SoundIoFormatS32BE: return PA_SAMPLE_S32BE; - case SoundIoFormatFloat32LE: return PA_SAMPLE_FLOAT32LE; - case SoundIoFormatFloat32BE: return PA_SAMPLE_FLOAT32BE; + case SoundIoFormatU8: return PA_SAMPLE_U8; + case SoundIoFormatS16LE: return PA_SAMPLE_S16LE; + case SoundIoFormatS16BE: return PA_SAMPLE_S16BE; + case SoundIoFormatS24LE: return PA_SAMPLE_S24_32LE; + case SoundIoFormatS24BE: return PA_SAMPLE_S24_32BE; + case SoundIoFormatS24PackedLE: return PA_SAMPLE_S24LE; + case SoundIoFormatS24PackedBE: return PA_SAMPLE_S24BE; + case SoundIoFormatS32LE: return PA_SAMPLE_S32LE; + case SoundIoFormatS32BE: return PA_SAMPLE_S32BE; + case SoundIoFormatFloat32LE: return PA_SAMPLE_FLOAT32LE; + case SoundIoFormatFloat32BE: return PA_SAMPLE_FLOAT32BE; case SoundIoFormatInvalid: case SoundIoFormatS8: @@ -529,6 +533,8 @@ static pa_sample_format_t to_pulseaudio_format(enum SoundIoFormat format) { case SoundIoFormatU16BE: case SoundIoFormatU24LE: case SoundIoFormatU24BE: + case SoundIoFormatU24PackedLE: + case SoundIoFormatU24PackedBE: case SoundIoFormatU32LE: case SoundIoFormatU32BE: case SoundIoFormatFloat64LE: