Commit e79380f8 authored by Christoph Berg's avatar Christoph Berg

Import Upstream version 3.5.0

parent 1372635e
2015-09-29 Kamil Ignacak
* bugfix: fixing code that resets tone queue on flushing. A bug
was found on FreeBSD: after pressing Ctrl+C, application that
wanted to stop and delete generator as part of SIGINT handling
procedure, got stuck in cw_tq_flush_internal() function, waiting
for tone queue to go idle. This never happened. Resetting all tone
queue state variables in flush function ensures that the function
completes and returns, and that client application can exit.
2015-09-12 Kamil Ignacak
* xcwcp: the application souce code files are now ported to
Qt5. Build system files have been modified to use Qt5 to build
xcwcp.
Discovery and adding -fPIC to compiler flags for xcwcp is right
now very naive, perhaps that will have to be improved in the
future.
2015-09-09 Kamil Ignacak
* alternative IPC: now that we have experimental branch, I decided
to remove "alternative IPC" code from master branch and leave that
just in "experimental" branch. master will be for small very
incremental, and only necessary changes. At this point libcw code
in master looks pretty much like it was in around commit
d02491ee32668d5f5ca3904193f306956e72468d, i.e. pre-semaphores.
2015-09-08 Kamil Ignacak
* git: created experimental_receiver branch, where all changes
related to new ideas for receiver will be developed. master branch
will be for boring, non-experimental code.
2015-09-03 Kamil Ignacak
* xcwcp: fixed handling of backspace key in keyboard mode. For
some time now the backspace key didn't remove yet-unplayed
characters from text area. Now the key works correctly.
2015-09-01 Kamil Ignacak
* xcwcp: simplifying class design in display.h. The file is now
called textarea.h, the class/widget derived from QTextEdit is now
called TextArea, and the change is reflected in few of xcwcp's
source files.
I hope to have less work in future thanks to this simplification.
A bit less code to maintain, a bit less logic to understand.
2015-08-31 Kamil Ignacak
* xcwcp: beginning of review of the the code, refactoring,
updating comments.
2015-08-30 Kamil Ignacak
* libcw/signals: improving signals code already existing in cw_gen
and cw_tq modules. In particular change in cw_gen (in
dequeue_and_play_internal()) greatly improves correctness of usage
of semaphores so far.
Fixing a FIXME in cw_tq_wait_for_tone_internal(): using new
semaphore deq_semaphore for another aspect of communication
between tq and generator makes the function fully ready for use of
alternative IPC mechanism (the function doesn't need signals
anymore).
* libcw/ipc: adding new header file for new libcw module:
libcw_ipc (Inter Process Communication). For now the module
consists only of a header file with a single macro.
* libcw/ipc: implementing cw_tq_wait_for_level_internal() using
semaphores. Improving the part of
cw_tq_wait_for_tone_queue_internal that used semaphores. This
means that tq module can work without signals, with semaphores
only.
* libcw/tests: adding test_cw_tq_wait_for_level_internal() unit
test function
2015-08-28 Kamil Ignacak
* libcw/signals: Initial commit of semaphores code. The code
enables communication between generator and tone queue using
semaphores instead of signals.
It may be desirable for libcw library to not to use signals, so
that client application can use them freely, without any
interference between application and libcw. This is the first step
to replace signals with other IPC mechanisms. This alternative
mechanism may be enabled with "--enable-signals-alternative"
passed to ./configure script.
2015-08-02 Kamil Ignacak
* tests: moving selected "make" test build targets from
src/libcw/Makefile.am to src/libcw/tests/Makefile.am. Updating
flags for some of the targets, so they may be built a bit
differently
* tests: libcw_test_public.c no longer tests "forever"
feature. Since this is a test of public API, it shouldn't use
LIBCW_UNIT_TESTS flag for compilation, nor should it use any
internal or test functions.
2015-07-31 Kamil Ignacak
* gen/tq: creating small client application that tests for
presence of the problem described on 2015-07-29 ("short space"
problem). The client application is located in src/libcw/tests/
and is executed as part of standard test suite ("make check").
2015-07-29 Kamil Ignacak
* gen/tq: one more attempt in cw_gen_play_eow_space_internal() to
ensure that eow spaces are enqueued so that client software can
have tq low level threshold set to 1.
It should be stressed in release notes that client software cannot
assume that eow space will be one tone. There may have been such
implicit assumption in the past, but it was only implicit, and it
became invalid some time ago.
2015-06-14 Kamil Ignacak
* pre-release: updating information in selected files before
release (updating version numbers, adding notes new releases etc.)
......
*** This file is no longer updated. ***
*** See NEWS file for description of changes. ***
This is HISTORY file for unixcw. It describes major changes in unixcw
releases. For detailed description of changes see NEWS file.
......@@ -93,3 +99,10 @@ generator, receiver, or key as an argument.
Improving unit tests code.
Testing unixcw on Alpine Linux (because of musl libc) and FreeBSD 10.0
(because this is *unix*cw).
*** This file is no longer updated. ***
*** See NEWS file for description of changes. ***
\ No newline at end of file
This is INSTALL file for unixcw 3.4.2.
This is INSTALL file for unixcw 3.5.0.
......@@ -22,7 +22,7 @@ Moreover, depending on platform and software/files installed on build
machine, the build system will configure and compile following
features:
- cwcp, if ncurses development files are available;
- xcwcp, if QT4 development files are available (xcwcp is an
- xcwcp, if QT5 development files are available (xcwcp is an
application written in C++);
libcw library, and cw and cwgen applications are built
......@@ -54,8 +54,8 @@ Build-time requirements for unixcw:
then install gmake package, and try running "gmake & gmake install"
instead of "make & make install".
- pkg-config to get configuration flags for QT4 application (xcwcp);
you can override pkg-config settings for QT4 using environment
- pkg-config to get configuration flags for QT5 application (xcwcp);
you can override pkg-config settings for QT5 using environment
variables, see output of "./configure --help" for details.
- audio library development files for including support for OSS, ALSA
......@@ -66,7 +66,7 @@ Build-time requirements for unixcw:
- ncurses development files for building cwcp;
- QT4 development files for building xcwcp;
- QT5 development files for building xcwcp;
......
......@@ -2,7 +2,7 @@ SUBDIRS=src
EXTRA_DIST = \
icon_unixcw.svg icon_unixcw.xpm \
unixcw-2.3.spec unixcw-3.4.2.lsm \
unixcw-2.3.spec unixcw-3.5.0.lsm \
po/UnixCW.po \
THANKS HISTORY \
debian
......@@ -264,8 +264,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
QT4_CFLAGS = @QT4_CFLAGS@
QT4_LIBS = @QT4_LIBS@
QT5_CFLAGS = @QT5_CFLAGS@
QT5_LIBS = @QT5_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
......@@ -329,7 +329,7 @@ top_srcdir = @top_srcdir@
SUBDIRS = src
EXTRA_DIST = \
icon_unixcw.svg icon_unixcw.xpm \
unixcw-2.3.spec unixcw-3.4.2.lsm \
unixcw-2.3.spec unixcw-3.5.0.lsm \
po/UnixCW.po \
THANKS HISTORY \
debian
......
......@@ -27,9 +27,9 @@ AC_LDCONFIG = @LDCONFIG@
AC_LIBS = @LIBS@
AC_AWK = @AWK@
AC_QT4_CFLAGS = @QT4_CFLAGS@
AC_QT4_LIBS = @QT4_LIBS@
AC_QT4_MOC = @MOC@
AC_QT5_CFLAGS = @QT5_CFLAGS@
AC_QT5_LIBS = @QT5_LIBS@
AC_QT5_MOC = @MOC@
AC_SRC_SUBDIRS = @SRC_SUBDIRS@
AC_CFLAG_PIC = @CFLAG_PIC@
......@@ -55,4 +55,5 @@ datarootdir = @datarootdir@
AM_CPPFLAGS = -I$(top_srcdir)/src/ \
-I$(top_srcdir)/src/libcw/ \
-I$(top_srcdir)/src/libcw/tests/ \
-I$(top_srcdir)/src/cwutils/
version 3.5.0 / 2015-10-06
libcw:
- adding few more small tests.
- trying to fix a problem of short space. The problem occurs when
client application has registered low-tone-queue callback, the
threshold for the callback is set to 1, and a single end-of-word
space has been enqueued by client application. When the eow space
is enqueued as a single tone-queue tone (or even as two tones)
("short space"), older versions of libcw may miss the event of
passing of tone queue level from 2 to 1 and will not call the
callback.
- Library soname/version changed from 6.4.1 to 6.5.1.
xcwcp
- porting the application from Qt4 to Qt5.
----------------------------------------------------------------------------
version 3.4.2 / 2015-06-17
libcw:
......
This is README file for unixcw project.
This is README file for unixcw project version 3.5.0.
unixcw is a project providing libcw library and a set of programs
using the library: cw, cwgen, cwcp and xcwcp. The programs are
......@@ -127,7 +127,9 @@ following:
3.3.1 6.1.1 2014-04-23
3.4.0 6.2.1 2014-11-11
3.4.1 6.3.1 2015-01-02
3.4.2 6.4.1 2015-06-XX
3.4.2 6.4.1 2015-06-17
3.5.0 6.5.1 2015-10-XX
......@@ -169,4 +171,4 @@ Website: unixcw.sf.net
Comments, questions, bug reports:
- create ticket: http://sourceforge.net/p/unixcw/tickets/, or
- write directly to acerion@wp.pl
I reserve a right to two months of delay to reply.
I reserve a right to a month of delay to reply.
This diff is collapsed.
......@@ -19,7 +19,7 @@
# General initializations.
AC_PREREQ(2.57)
AC_INIT([unixcw], [3.4.2])
AC_INIT([unixcw], [3.5.0])
AC_CONFIG_SRCDIR([src/libcw/libcw_gen.c])
AM_INIT_AUTOMAKE
......@@ -136,7 +136,7 @@ fi
# I'm defining it here so that it's available in config.h and can be
# used in libcw's cw_version() function that should return the
# numbers.
LIBCW_VERSION=\"6:4:1\"
LIBCW_VERSION=\"6:5:1\"
AC_DEFINE_UNQUOTED([LIBCW_VERSION], $LIBCW_VERSION, [Library version, libtool notation])
AC_SUBST(LIBCW_VERSION)
......@@ -218,7 +218,7 @@ fi
# Build xcwcp? Yes by default.
AC_ARG_ENABLE(xcwcp,
AS_HELP_STRING([--disable-xcwcp], [do not build xcwcp (application with Qt4 user interface)]),
AS_HELP_STRING([--disable-xcwcp], [do not build xcwcp (application with Qt5 user interface)]),
[],
[enable_xcwcp=yes])
......@@ -364,21 +364,21 @@ if test "$enable_xcwcp" = "no" ; then
WITH_XCWCP='no'
else
# http://stackoverflow.com/questions/5178511/integrate-qt-project-with-autotool
PKG_CHECK_MODULES(QT4, [QtCore QtGui >= 4.4.0], [
AC_PATH_PROGS(MOC, [moc-qt4 moc], moc,`eval $PKG_CONFIG --variable=exec_prefix QtCore`/bin)
PKG_CHECK_MODULES(QT5, [Qt5Widgets Qt5Gui Qt5Core >= 5.0.0], [
AC_PATH_PROGS(MOC, [moc-qt5 moc], moc,`eval $PKG_CONFIG --variable=host_bins Qt5Core`)
AC_MSG_RESULT([QT4 CLFAGS is $QT4_CFLAGS])
AC_MSG_RESULT([QT4 LIBS is $QT4_LIBS])
AC_MSG_RESULT([QT5 CLFAGS is $QT5_CFLAGS])
AC_MSG_RESULT([QT5 LIBS is $QT5_LIBS])
AC_SUBST(QT4_CFLAGS)
AC_SUBST(QT4_LIBS)
AC_SUBST(QT5_CFLAGS)
AC_SUBST(QT5_LIBS)
AC_SUBST(MOC)
WITH_XCWCP='yes'
], [
AC_MSG_WARN([Cannot find Qt4 files - unable to build xcwcp])
AC_MSG_WARN([Cannot find Qt5 files - unable to build xcwcp])
WITH_XCWCP='no'
......@@ -387,8 +387,6 @@ fi
# Development support tools.
AM_CONDITIONAL(LIBCW_WITH_DEV, test "$enable_dev" = "yes")
if test "$enable_dev" = "yes" ; then
......@@ -584,6 +582,7 @@ AC_CONFIG_FILES([Makefile.inc
Makefile
src/Makefile
src/libcw/Makefile
src/libcw/tests/Makefile
src/cwutils/Makefile
src/cw/Makefile
src/cwgen/Makefile])
......@@ -621,9 +620,9 @@ AC_MSG_NOTICE([build cwgen: ........................... yes])
AC_MSG_NOTICE([build cwcp: ............................ $WITH_CWCP])
AC_MSG_NOTICE([build xcwcp: ........................... $WITH_XCWCP])
if test "$WITH_XCWCP" = 'yes' ; then
AC_MSG_NOTICE([ Qt4 CFLAGS: $QT4_CFLAGS])
AC_MSG_NOTICE([ Qt4 LIBS: $QT4_LIBS])
AC_MSG_NOTICE([ Qt4 MOC: $MOC])
AC_MSG_NOTICE([ Qt5 CFLAGS: $QT5_CFLAGS])
AC_MSG_NOTICE([ Qt5 LIBS: $QT5_LIBS])
AC_MSG_NOTICE([ Qt5 MOC: $MOC])
fi
if test "$WITH_DEV" = 'yes' ; then
AC_MSG_NOTICE([enable dev support: ..................... yes])
......
......@@ -243,8 +243,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
QT4_CFLAGS = @QT4_CFLAGS@
QT4_LIBS = @QT4_LIBS@
QT5_CFLAGS = @QT5_CFLAGS@
QT5_LIBS = @QT5_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
......
......@@ -281,8 +281,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
QT4_CFLAGS = @QT4_CFLAGS@
QT4_LIBS = @QT4_LIBS@
QT5_CFLAGS = @QT5_CFLAGS@
QT5_LIBS = @QT5_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
......
......@@ -18,7 +18,7 @@
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\"
.TH CW 1 "CW Tutor Package" "cw ver. 3.4.2" \" -*- nroff -*-
.TH CW 1 "CW Tutor Package" "cw ver. 3.5.0" \" -*- nroff -*-
.SH NAME
.\"
cw \- sound characters as Morse code on the soundcard or console speaker
......
......@@ -281,8 +281,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
QT4_CFLAGS = @QT4_CFLAGS@
QT4_LIBS = @QT4_LIBS@
QT5_CFLAGS = @QT5_CFLAGS@
QT5_LIBS = @QT5_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
......
......@@ -18,7 +18,7 @@
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\"
.TH CWCP 1 "CW Tutor Package" "cwcp ver. 3.4.2" \" -*- nroff -*-
.TH CWCP 1 "CW Tutor Package" "cwcp ver. 3.5.0" \" -*- nroff -*-
.SH NAME
.\"
cwcp \- curses-based Morse tutor program
......
......@@ -925,7 +925,7 @@ bool mode_is_sending_active(void)
* character limit imposed by ISO C89 on string literal lengths.
*/
static const char *const INTRODUCTION = N_(
"UNIX/Linux Morse Tutor v3.4.2\n"
"UNIX/Linux Morse Tutor v3.5.0\n"
"Copyright (C) 1997-2006 Simon Baldwin\n"
"Copyright (C) 2011-2015 Kamil Ignacak\n"
"---------------------------------------------------------\n"
......
......@@ -281,8 +281,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
QT4_CFLAGS = @QT4_CFLAGS@
QT4_LIBS = @QT4_LIBS@
QT5_CFLAGS = @QT5_CFLAGS@
QT5_LIBS = @QT5_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
......
......@@ -18,7 +18,7 @@
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\"
.TH CWGEN 1 "CW Tutor Package" "cwgen ver. 3.4.2" \" -*- nroff -*-
.TH CWGEN 1 "CW Tutor Package" "cwgen ver. 3.5.0" \" -*- nroff -*-
.SH NAME
.\"
cwgen \- generate groups of random characters for Morse code practice
......
......@@ -491,8 +491,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
QT4_CFLAGS = @QT4_CFLAGS@
QT4_LIBS = @QT4_LIBS@
QT5_CFLAGS = @QT5_CFLAGS@
QT5_LIBS = @QT5_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
......
......@@ -16,11 +16,13 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
SUBDIRS=tests
-include $(top_builddir)/Makefile.inc
# targets to be built in this directory
lib_LTLIBRARIES=libcw.la
check_PROGRAMS=libcw_test_public libcw_test_internal libcw_test_simple_gen
check_PROGRAMS=libcw_test_internal
man_MANS=libcw.3 cw.7
pkgconfig_DATA=libcw.pc
......@@ -31,8 +33,7 @@ EXTRA_DIST=include.awk libdoc.awk libfuncs.awk libpc.awk libsigs.awk \
cw.7 \
libcw_gen.h libcw_rec.h \
libcw_tq.h libcw_data.h libcw_key.h libcw_utils.h libcw_signal.h \
libcw_null.h libcw_console.h libcw_oss.h libcw_alsa.h libcw_pa.h \
libcw_test.h
libcw_null.h libcw_console.h libcw_oss.h libcw_alsa.h libcw_pa.h
# These files are used to build two different targets - list them only
# once. I can't compile these files into an utility library because
......@@ -64,7 +65,6 @@ libcw_la_LDFLAGS = -version-number $(LIBCW_VERSION)
# target-specific compiler flags
libcw_la_CFLAGS = -rdynamic
# target-specific preprocessor flags (#defs and include dirs)
#
# $(LIBCW_NDEBUG) activates asserts in base libcw for dev builds, and
......@@ -72,27 +72,11 @@ libcw_la_CFLAGS = -rdynamic
libcw_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBCW_NDEBUG)
libcw_includedir=$(includedir)
libcw_include_HEADERS = libcw.h libcw_debug.h
# target: libcw_test_public: a test program testing only public API of libcw library;
# main() is defined in libcw_test_public.c
# Source code files used to build libcw_test_public program.
# This test tests library's public API, so the target should depend on
# a regular shared library file found in build directory. It shouldn't
# compile all *.c files that are used to create library, it should
# compile only test files and "link" them with this library file.
libcw_test_public_SOURCES = $(LIBCW_BASE_C_FILES) libcw_test_public.c libcw_test.c
# target-specific preprocessor flags (#defs and include dirs)
libcw_test_public_CPPFLAGS = $(AM_CPPFLAGS) -DLIBCW_UNIT_TESTS
# target-specific linker flags (objects to link)
libcw_test_public_LDADD = -lm -lpthread $(DL_LIB) -L./.libs -lcw
libcw_includedir=$(includedir)
libcw_include_HEADERS = libcw.h libcw_debug.h
......@@ -102,6 +86,12 @@ libcw_test_public_LDADD = -lm -lpthread $(DL_LIB) -L./.libs -lcw
# (internal) functions defined in libcw_xyz.c files;
# main() is defined in libcw_test_internal.c.
# For now I can't move this test to tests/ because the target refers
# to $(LIBCW_BASE_C_FILES) files residing in this directory, and not
# in tests/ directory. I could use
# "AM_INIT_AUTOMAKE([subdir-objects])" in configure.ac, but I don't
# know how portable it is.
# source code files used to build libcw_test_internal program
libcw_test_internal_SOURCES = $(LIBCW_BASE_C_FILES) libcw_test_internal.c
......@@ -118,24 +108,6 @@ libcw_test_internal_CFLAGS = -rdynamic
# target: libcw_test_simple_gen, yet another test program;
# main() is defined in libcw_test_simple_gen.c
# The file defines a very simple set of tests that make only a basic
# use of libcw's generator facilities.
# source code files used to build libcw_test_simple_gen program
libcw_test_simple_gen_SOURCES = libcw_test_simple_gen.c libcw_test.c
# target-specific linker flags (objects to link)
libcw_test_simple_gen_LDADD=-lm -lpthread $(DL_LIB) $(OSS_LIB) -L./.libs -lcw
# target-specific compiler flags
libcw_test_simple_gen_CFLAGS = -rdynamic
# target: libcw man page
libcw.3: libcw.3.m4
cat $(top_srcdir)/src/libcw/*.c | $(AC_AWK) -f $(top_srcdir)/src/libcw/libdoc.awk | $(AC_AWK) -f $(top_srcdir)/src/libcw/libsigs.awk > signatures
......@@ -162,11 +134,15 @@ CLEANFILES = libcw_test_internal.sh libcw.3
TESTS = $(check_SCRIPTS)
# run test programs (only libcw_test_internal unit tests suite)
check_SCRIPTS = libcw_test_internal.sh
# run test programs
check_SCRIPTS = libcw_test_internal.sh ./tests/libcw_test_tq_short_space.sh
libcw_test_internal.sh:
echo './libcw_test_internal | grep "test result: success"' > libcw_test_internal.sh
chmod +x libcw_test_internal.sh
./tests/libcw_test_tq_short_space.sh:
echo './tests/libcw_test_tq_short_space | grep "test result: success"' > ./tests/libcw_test_tq_short_space.sh
chmod +x ./tests/libcw_test_tq_short_space.sh
# sources, references
......
This diff is collapsed.
......@@ -18,7 +18,7 @@
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\"
.TH LIBCW 3 "CW Tutor Package" "libcw ver. 6.4.1" \" -*- nroff -*-
.TH LIBCW 3 "CW Tutor Package" "libcw ver. 6.5.1" \" -*- nroff -*-
.SH NAME
.\"
libcw \- general purpose Morse code functions library
......
......@@ -5,6 +5,6 @@ includedir=@includedir@
Name: libcw
Description: CW (Morse code) library
Version: 6.4.1
Version: 6.5.1
Libs: -L${libdir} -lcw
Cflags: -I${includedir}
......@@ -34,8 +34,8 @@
#define _BSD_SOURCE /* usleep() */
#define _POSIX_SOURCE /* sigaction() */
#define _POSIX_C_SOURCE 200112L /* pthread_sigmask() */
//#define _POSIX_SOURCE /* sigaction() */
//#define _POSIX_C_SOURCE 200112L /* pthread_sigmask() */
#include <stdio.h>
......
......@@ -80,9 +80,9 @@ uint32_t cw_get_debug_flags(void) __attribute__ ((deprecated));
#define cw_debug_msg(debug_object, flag, debug_level, ...) { \
if (debug_level >= debug_object->level) { \
if (debug_object->flags & flag) { \
fprintf(stderr, "%s:", debug_object->level_labels[debug_level]); \
if (debug_level >= (debug_object)->level) { \
if ((debug_object)->flags & flag) { \
fprintf(stderr, "%s:", (debug_object)->level_labels[debug_level]); \
if (debug_level == CW_DEBUG_DEBUG) { \
fprintf(stderr, "%s: %d: ", __func__, __LINE__); \
} \
......
......@@ -641,6 +641,8 @@ int cw_gen_stop_internal(cw_gen_t *gen)
return CW_FAILURE;
}
cw_debug_msg ((&cw_debug_object_dev), CW_DEBUG_GENERATOR, CW_DEBUG_INFO,
"libcw/gen: gen->do_dequeue_and_play = false");
gen->do_dequeue_and_play = false;
if (!gen->thread.running) {
......@@ -652,7 +654,11 @@ int cw_gen_stop_internal(cw_gen_t *gen)
return CW_SUCCESS;
}
/* This is to wake up cw_signal_wait_internal() function that
/* "while (gen->do_dequeue_and_play)" loop in thread function
may be in a state where dequeue() function returned IDLE
state, and the loop is waiting for new tone.
This is to wake up cw_signal_wait_internal() function that
may be waiting idle for signal in "while ()" loop in thread
function. */
pthread_kill(gen->thread.id, SIGALRM);
......@@ -682,7 +688,8 @@ int cw_gen_stop_internal(cw_gen_t *gen)
*/
#if 0 /* Old code using pthread_kill() instead of pthread_join(). */
#if 0 /* Old code using pthread_kill() instead of pthread_join().
This code is unused since before 2015-08-30. */
struct timespec req = { .tv_sec = 1, .tv_nsec = 0 };
cw_nanosleep_internal(&req);
......@@ -894,8 +901,10 @@ void *cw_gen_dequeue_and_play_internal(void *arg)
queue is "low/critical"; client code then can add more
characters to the queue; the observation is done using
cw_wait_for_tone_queue_critical();
- ...
- allows client code to observe any dequeue event
by waiting for signal in cw_wait_for_tone() /
cw_tq_wait_for_tone_internal()
*/
pthread_kill(gen->client.thread_id, SIGALRM);
......@@ -1977,18 +1986,58 @@ int cw_gen_play_eow_space_internal(cw_gen_t *gen)
this in this function), the tone queue manager can
recognize level dropping from 2 to 1. Then the passing of
critical level can be noticed, and "low level" callback can
be called. */
be called.
BUT: Sometimes the first tone is dequeued before/during the
second one is enqueued, and we can't recognize 2->1 event.
So, to be super-sure that there is a recognizable event of
passing tone queue level from 2 to 1, we split the eow
space into N parts and enqueue them. This way we have N + 1
tones per space, and client applications that rely on low
level threshold == 1 can correctly work when enqueueing
spaces.
At 60 wpm length of gen->eow_space_len is 100000 [us], so
it's large enough to safely divide it by small integer
value. */
int enqueued = 0;
cw_tone_t tone;
CW_TONE_INIT(&tone, 0, gen->eow_space_len, CW_SLOPE_MODE_NO_SLOPES);
int rv = cw_tq_enqueue_internal(gen->tq, &tone);
#if 0
/* This section is incorrect. Enable this section only for
tests. This section "implements" a bug that was present in
libcw until version 6.4.1 and that is now tested by
src/libcw/tests/libcw_test_tq_short_space.c */
int n = 1; /* No division. Old situation causing an error in
client applications. */
#else
int n = 2; /* "small integer value" - used to have more tones per eow space. */
#endif
CW_TONE_INIT(&tone, 0, gen->eow_space_len / n, CW_SLOPE_MODE_NO_SLOPES);
for (int i = 0; i < n; i++) {
int rv = cw_tq_enqueue_internal(gen->tq, &tone);
if (rv) {
enqueued++;
} else {
return CW_FAILURE;
}
}
if (rv == CW_SUCCESS) {
CW_TONE_INIT(&tone, 0, gen->adjustment_space_len, CW_SLOPE_MODE_NO_SLOPES);
rv = cw_tq_enqueue_internal(gen->tq, &tone);
CW_TONE_INIT(&tone, 0, gen->adjustment_space_len, CW_SLOPE_MODE_NO_SLOPES);
int rv = cw_tq_enqueue_internal(gen->tq, &tone);
if (rv) {
enqueued++;
} else {
return CW_FAILURE;
}
return rv;
cw_debug_msg ((&cw_debug_object), CW_DEBUG_GENERATOR, CW_DEBUG_DEBUG,
"libcw: enqueued %d tones per eow space, tq len = %d",
enqueued, cw_tq_length_internal(gen->tq));
return CW_SUCCESS;
}
......@@ -2536,9 +2585,8 @@ unsigned int test_cw_gen_new_delete_internal(void)
int n = 100;
/* new() + delete() */
fprintf(stderr, "libcw/gen: generator test 1/4\n");
for (int i = 0; i < n; i++) {
fprintf(stderr, "libcw/gen: generator test 1/4, loop #%d/%d\n", i, n);
cw_gen_t *gen = cw_gen_new_internal(CW_AUDIO_NULL, NULL);
cw_assert (gen, "failed to initialize generator (loop #%d)", i);
......@@ -2590,8 +2638,7 @@ unsigned int test_cw_gen_new_delete_internal(void)
}
/* Inner loop. */
/* Inner loop limit. */
int m = n;
......
......@@ -551,7 +551,11 @@ int cw_key_ik_update_graph_state_internal(volatile cw_key_t *key)
/* This function is called from generator thread. It
is perfectly valid situation that for some
applications a generator exists, but a keyer does
not exist. Silently accept this situation. */
not exist. Silently accept this situation.
TODO: move this check earlier in call stack, so
that less functions are called before silently
discovering that key doesn't exist.. */
cw_debug_msg ((&cw_debug_object_dev), CW_DEBUG_INTERNAL, CW_DEBUG_DEBUG,
"libcw/ik: NULL key, silently accepting");
return CW_SUCCESS;
......