From 67229c0d276b9cc11efdfd4319619336e7bd78d4 Mon Sep 17 00:00:00 2001 From: trutkin Date: Fri, 29 Aug 2003 00:06:30 +0000 Subject: [PATCH] Enforce power of two size frames. Moved alsa headers to alsa directory. git-svn-id: svn+ssh://jackaudio.org/trunk/jack@483 0c269be4-1314-0410-8aa9-9f06e86f4224 --- AUTHORS | 1 + TODO | 6 +++--- drivers/Makefile.am | 3 +-- drivers/alsa/Makefile.am | 8 ++++++++ drivers/alsa/alsa_driver.c | 16 +++++++++++----- {jack => drivers/alsa}/alsa_driver.h | 2 +- {jack => drivers/alsa}/generic.h | 0 drivers/alsa/generic_hw.c | 2 +- drivers/alsa/hammerfall.c | 4 ++-- {jack => drivers/alsa}/hammerfall.h | 0 drivers/alsa/hdsp.c | 4 ++-- {jack => drivers/alsa}/hdsp.h | 0 drivers/alsa/ice1712.c | 4 ++-- {jack => drivers/alsa}/ice1712.h | 0 drivers/alsa/memops.c | 2 +- {jack => drivers/alsa}/memops.h | 0 drivers/portaudio/portaudio_driver.c | 6 ++++++ jack/Makefile.am | 6 ------ jack/engine.h | 5 +++++ 19 files changed, 44 insertions(+), 25 deletions(-) rename {jack => drivers/alsa}/alsa_driver.h (99%) rename {jack => drivers/alsa}/generic.h (100%) rename {jack => drivers/alsa}/hammerfall.h (100%) rename {jack => drivers/alsa}/hdsp.h (100%) rename {jack => drivers/alsa}/ice1712.h (100%) rename {jack => drivers/alsa}/memops.h (100%) diff --git a/AUTHORS b/AUTHORS index 4348893..1d83338 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,5 +16,6 @@ many small patches and documentation. Fernando Pablo Lopez-Lezcano contributed the capabilities-based code. Jeremy Hall, Steve Harris, and Martin Boer contributed sample clients and utilities. Jack O'Quin contributed new transport interfaces and documentation. +Taybin Rutkin helps with patch management and releases. Many others have contributed patches and/or test results. diff --git a/TODO b/TODO index 5543a38..a7a44a7 100644 --- a/TODO +++ b/TODO @@ -12,7 +12,6 @@ send a change request to Kai Vehmanen (mailto:k_at_eca.cx). TO BE DECIDED (owner) - dropping the use of CAP_RESOURCE (nando) -- whether to default to triangular dithering the at 16bit (swh) - support for on-the-fly sampling rate change TODO for 1.0 (owner) @@ -21,14 +20,13 @@ TODO for 1.0 (owner) - API to change buffer size (joq) TODO post-1.0 - +- jack session handling (taybin) - TBD TODO general (owner) - don't build static libraries of drivers and ip-clients (kaiv) - add explanation of protocol versioning to README.developers (kaiv) -- add code to enforce the 'bufsize==2^x' rule (kaiv) - proper handling of client return values in libjack (kaiv) - pool based malloc for rt client-local mem allocation (paul, moved back here) @@ -43,6 +41,8 @@ TO THINK ABOUT CLOSED (date,who,comment) +- added code to enforce the 'bufsize==2^x' rule (taybin) (2003/8/28) +- whether to default to triangular dithering the at 16bit. This was decided to leave off. (taybin) (2003/8/28) - make sure that process callbacks always have nframes equal to buffersize (2003/08/27,done,kaiv) - add Paul's graph/subgraph explanation to the design doc (2003/08/27,done,kaiv) - add support for custom jackd --tmpdir in libjack (2003/05/06,done,jesse) diff --git a/drivers/Makefile.am b/drivers/Makefile.am index 124e3e9..33299cb 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -1,4 +1,4 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in if HAVE_ALSA ALSA_DIR = alsa @@ -9,4 +9,3 @@ endif SUBDIRS = dummy $(ALSA_DIR) DIST_SUBDIRS = dummy alsa - diff --git a/drivers/alsa/Makefile.am b/drivers/alsa/Makefile.am index 6478581..6961d4a 100644 --- a/drivers/alsa/Makefile.am +++ b/drivers/alsa/Makefile.am @@ -9,4 +9,12 @@ plugin_LTLIBRARIES = jack_alsa.la jack_alsa_la_LDFLAGS = -module -avoid-version jack_alsa_la_SOURCES = alsa_driver.c generic_hw.c memops.c \ hammerfall.c hdsp.c ice1712.c + +noinst_HEADERS = alsa_driver.h \ + generic.h \ + hammerfall.h \ + hdsp.h \ + ice1712.h \ + memops.h + jack_alsa_la_LIBADD = $(ALSA_LIBS) diff --git a/drivers/alsa/alsa_driver.c b/drivers/alsa/alsa_driver.c index b405038..51b3e77 100644 --- a/drivers/alsa/alsa_driver.c +++ b/drivers/alsa/alsa_driver.c @@ -27,14 +27,14 @@ #include #include -#include +#include "alsa_driver.h" #include #include #include -#include -#include -#include -#include +#include "hammerfall.h" +#include "hdsp.h" +#include "ice1712.h" +#include "generic.h" #include extern void store_work_time (int); @@ -346,6 +346,11 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name, return -1; } + if (!jack_power_of_two(driver->frames_per_cycle)) { + jack_error("JACK: frames must be a power of two (64, 512, 1024, ...)\n"); + return -1; + } + if ((err = snd_pcm_hw_params_set_buffer_size (handle, hw_params, driver->user_nperiods * driver->frames_per_cycle)) < 0) { jack_error ("ALSA: cannot set buffer length to %" PRIu32 " for %s", @@ -1984,3 +1989,4 @@ driver_finish (jack_driver_t *driver) { alsa_driver_delete ((alsa_driver_t *) driver); } + diff --git a/jack/alsa_driver.h b/drivers/alsa/alsa_driver.h similarity index 99% rename from jack/alsa_driver.h rename to drivers/alsa/alsa_driver.h index cddf424..9f44951 100644 --- a/jack/alsa_driver.h +++ b/drivers/alsa/alsa_driver.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include "memops.h" #include typedef void (*ReadCopyFunction) (jack_default_audio_sample_t *dst, char *src, diff --git a/jack/generic.h b/drivers/alsa/generic.h similarity index 100% rename from jack/generic.h rename to drivers/alsa/generic.h diff --git a/drivers/alsa/generic_hw.c b/drivers/alsa/generic_hw.c index 75287cd..80b6d46 100644 --- a/drivers/alsa/generic_hw.c +++ b/drivers/alsa/generic_hw.c @@ -19,7 +19,7 @@ */ #include -#include +#include "alsa_driver.h" static int generic_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask) { diff --git a/drivers/alsa/hammerfall.c b/drivers/alsa/hammerfall.c index 680dcd8..f8d3e0f 100644 --- a/drivers/alsa/hammerfall.c +++ b/drivers/alsa/hammerfall.c @@ -19,8 +19,8 @@ */ #include -#include -#include +#include "alsa_driver.h" +#include "hammerfall.h" #include /* Set this to 1 if you want this compile error: diff --git a/jack/hammerfall.h b/drivers/alsa/hammerfall.h similarity index 100% rename from jack/hammerfall.h rename to drivers/alsa/hammerfall.h diff --git a/drivers/alsa/hdsp.c b/drivers/alsa/hdsp.c index b83f228..899c95f 100644 --- a/drivers/alsa/hdsp.c +++ b/drivers/alsa/hdsp.c @@ -20,8 +20,8 @@ */ #include -#include -#include +#include "alsa_driver.h" +#include "hdsp.h" #include /* Constants to make working with the hdsp matrix mixer easier */ diff --git a/jack/hdsp.h b/drivers/alsa/hdsp.h similarity index 100% rename from jack/hdsp.h rename to drivers/alsa/hdsp.h diff --git a/drivers/alsa/ice1712.c b/drivers/alsa/ice1712.c index 15284f5..24e39c0 100644 --- a/drivers/alsa/ice1712.c +++ b/drivers/alsa/ice1712.c @@ -22,8 +22,8 @@ */ #include -#include -#include +#include "alsa_driver.h" +#include "ice1712.h" #include static int diff --git a/jack/ice1712.h b/drivers/alsa/ice1712.h similarity index 100% rename from jack/ice1712.h rename to drivers/alsa/ice1712.h diff --git a/drivers/alsa/memops.c b/drivers/alsa/memops.c index 55407fa..abb3509 100644 --- a/drivers/alsa/memops.c +++ b/drivers/alsa/memops.c @@ -31,7 +31,7 @@ #include #include -#include +#include "memops.h" #define SAMPLE_MAX_24BIT 8388607.0f #define SAMPLE_MAX_16BIT 32767.0f diff --git a/jack/memops.h b/drivers/alsa/memops.h similarity index 100% rename from jack/memops.h rename to drivers/alsa/memops.h diff --git a/drivers/portaudio/portaudio_driver.c b/drivers/portaudio/portaudio_driver.c index cbd5048..0bdbc11 100644 --- a/drivers/portaudio/portaudio_driver.c +++ b/drivers/portaudio/portaudio_driver.c @@ -239,6 +239,12 @@ portaudio_driver_new (char *name, jack_driver_init ((jack_driver_t *) driver); driver->frame_rate = rate; + + if (!jack_power_of_two(frames_per_cycle)) { + printf("JACK: frames must be a power of two (64, 512, 1024, ...)\n"); + goto error; + } + driver->frames_per_cycle = frames_per_cycle; driver->attach = (JackDriverAttachFunction) portaudio_driver_attach; diff --git a/jack/Makefile.am b/jack/Makefile.am index 331a2b8..bbd36d5 100644 --- a/jack/Makefile.am +++ b/jack/Makefile.am @@ -9,18 +9,12 @@ libjackinclude_HEADERS = \ types.h noinst_HEADERS = \ - alsa_driver.h \ cycles.h \ driver.h \ engine.h \ - generic.h \ - hammerfall.h \ hardware.h \ - hdsp.h \ - ice1712.h \ internal.h \ jslist.h \ - memops.h \ pool.h \ port.h \ shm.h \ diff --git a/jack/engine.h b/jack/engine.h index e8f9dab..0db6295 100644 --- a/jack/engine.h +++ b/jack/engine.h @@ -136,4 +136,9 @@ static inline void jack_unlock_graph (jack_engine_t* engine) pthread_mutex_unlock (&engine->client_lock); } +static inline unsigned int jack_power_of_two (unsigned int n) +{ + return !(n & (n - 1)); +} + #endif /* __jack_engine_h__ */