diff --git a/CMakeLists.txt b/CMakeLists.txt index e0392fc..ce69bb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,8 @@ project(dingusppc) set(CMAKE_CXX_STANDARD 11) set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) +#set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) if (NOT WIN32) @@ -20,7 +21,8 @@ add_subdirectory("${PROJECT_SOURCE_DIR}/thirdparty/loguru/") set(BUILD_EXAMPLE_PROGRAMS OFF CACHE BOOL "Build libsoundio example programs") set(BUILD_TESTS OFF CACHE BOOL "Build libsoundio tests") -set(BUILD_DYNAMIC_LIBS OFF CACHE BOOL "Build libsoundio dynamic libs") +set(BUILD_DYNAMIC_LIBS ON CACHE BOOL "Build libsoundio dynamic libs") +set(BUILD_STATIC_LIBS ON CACHE BOOL "Build libsoundio static libs") add_subdirectory("${PROJECT_SOURCE_DIR}/thirdparty/libsoundio") @@ -48,7 +50,8 @@ add_executable(dingusppc ${SOURCES} $ if (WIN32) target_link_libraries(dingusppc "${PROJECT_SOURCE_DIR}/thirdparty/SDL2/lib/x64/SDL2.lib" - "${PROJECT_SOURCE_DIR}/thirdparty/SDL2/lib/x64/SDL2main.lib") + "${PROJECT_SOURCE_DIR}/thirdparty/SDL2/lib/x64/SDL2main.lib" + libsoundio_static ${LIBSOUNDIO_LIBS}) else() target_link_libraries(dingusppc libsoundio_static ${LIBSOUNDIO_LIBS} ${SDL2_LIBRARIES}) endif() @@ -62,7 +65,8 @@ add_executable(testppc ${TEST_SOURCES} $ if (WIN32) target_link_libraries(testppc "${PROJECT_SOURCE_DIR}/thirdparty/SDL2/lib/x64/SDL2.lib" - "${PROJECT_SOURCE_DIR}/thirdparty/SDL2/lib/x64/SDL2main.lib") + "${PROJECT_SOURCE_DIR}/thirdparty/SDL2/lib/x64/SDL2main.lib" + libsoundio_static ${LIBSOUNDIO_LIBS}) else() target_link_libraries(testppc libsoundio_static ${LIBSOUNDIO_LIBS} ${SDL2_LIBRARIES}) endif() diff --git a/devices/awacs.cpp b/devices/awacs.cpp index 8c8bda4..437fabe 100644 --- a/devices/awacs.cpp +++ b/devices/awacs.cpp @@ -144,10 +144,23 @@ static void sound_out_callback(struct SoundIoOutStream *outstream, struct SoundIoChannelArea *areas; DMAChannel *dma_ch = (DMAChannel *)outstream->userdata; /* C API baby! */ int n_channels = outstream->layout.channel_count; - bool stop = false; + //bool stop = false; - buf_len = (frame_count_max * n_channels) << 1; - frame_count = frame_count_max; + if (!dma_ch->is_active()) { + LOG_F(INFO, "pausing result: %s", + soundio_strerror(soundio_outstream_pause(outstream, true))); + return; + } + + if (frame_count_max > 512) { + frame_count = 512; + } + else { + frame_count = frame_count_max; + } + + buf_len = (frame_count * n_channels) << 1; + //frame_count = frame_count_max; //LOG_F(INFO, "frame_count_min=%d", frame_count_min); //LOG_F(INFO, "frame_count_max=%d", frame_count_max); @@ -171,7 +184,7 @@ static void sound_out_callback(struct SoundIoOutStream *outstream, /* fill the buffer with silence */ //LOG_F(ERROR, "rem_len=%d", rem_len); insert_silence(areas, rem_len >> 2); - stop = true; + //stop = true; break; } } @@ -181,10 +194,10 @@ static void sound_out_callback(struct SoundIoOutStream *outstream, return; } - if (stop) { - LOG_F(INFO, "pausing result: %s", - soundio_strerror(soundio_outstream_pause(outstream, true))); - } + //if (stop) { + // LOG_F(INFO, "pausing result: %s", + // soundio_strerror(soundio_outstream_pause(outstream, true))); + //} } void AWACDevice::open_stream(int sample_rate) diff --git a/devices/dbdma.cpp b/devices/dbdma.cpp index 79026aa..8e57d3a 100644 --- a/devices/dbdma.cpp +++ b/devices/dbdma.cpp @@ -220,6 +220,16 @@ int DMAChannel::get_data(uint32_t req_len, uint32_t *avail_len, uint8_t **p_data return -1; /* tell the caller there is no more data */ } +bool DMAChannel::is_active() +{ + if (this->ch_stat & CH_STAT_DEAD || !(this->ch_stat & CH_STAT_ACTIVE)) { + return false; + } + else { + return true; + } +} + void DMAChannel::start() { if (this->ch_stat & CH_STAT_PAUSE) { diff --git a/devices/dbdma.h b/devices/dbdma.h index 79023d6..a4660d6 100644 --- a/devices/dbdma.h +++ b/devices/dbdma.h @@ -76,6 +76,7 @@ public: void reg_write(uint32_t offset, uint32_t value, int size); int get_data(uint32_t req_len, uint32_t *avail_len, uint8_t **p_data); + bool is_active(); protected: void get_next_cmd(uint32_t cmd_addr, DMACmd *p_cmd);