summaryrefslogtreecommitdiff
path: root/drivers/alsa
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-02-23 10:15:45 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-02-23 10:15:45 -0500
commitc758cdf4f6e959b92683f2dba6ce8617ac4f0a83 (patch)
tree36e2664048b4ba9d6925b33281afcab2a0aab53d /drivers/alsa
parent25786b77b700abbcce664e7e39504a2b0dd1f0c8 (diff)
downloadjack1-c758cdf4f6e959b92683f2dba6ce8617ac4f0a83.tar.gz
uncrustification of jack source code
Diffstat (limited to 'drivers/alsa')
-rw-r--r--drivers/alsa/alsa_driver.c1269
-rw-r--r--drivers/alsa/alsa_driver.h269
-rw-r--r--drivers/alsa/generic.h6
-rw-r--r--drivers/alsa/generic_hw.c10
-rw-r--r--drivers/alsa/hammerfall.c58
-rw-r--r--drivers/alsa/hammerfall.h18
-rw-r--r--drivers/alsa/hdsp.c117
-rw-r--r--drivers/alsa/hdsp.h8
-rw-r--r--drivers/alsa/ice1712.c94
-rw-r--r--drivers/alsa/ice1712.h48
-rw-r--r--drivers/alsa/memops.c312
-rw-r--r--drivers/alsa/usx2y.c339
-rw-r--r--drivers/alsa/usx2y.h18
13 files changed, 1296 insertions, 1270 deletions
diff --git a/drivers/alsa/alsa_driver.c b/drivers/alsa/alsa_driver.c
index c7dd724..2f42e31 100644
--- a/drivers/alsa/alsa_driver.c
+++ b/drivers/alsa/alsa_driver.c
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#include <math.h>
#include <stdio.h>
@@ -44,10 +44,10 @@
#include "usx2y.h"
#include "generic.h"
-extern void store_work_time (int);
-extern void store_wait_time (int);
-extern void show_wait_times ();
-extern void show_work_times ();
+extern void store_work_time(int);
+extern void store_wait_time(int);
+extern void show_wait_times();
+extern void show_work_times();
#undef DEBUG_WAKEUP
@@ -98,34 +98,34 @@ alsa_driver_check_capabilities (alsa_driver_t *driver)
}
static char*
-get_control_device_name(const char * device_name)
+get_control_device_name (const char * device_name)
{
- char * ctl_name;
- const char * comma;
-
- /* the user wants a hw or plughw device, the ctl name
- * should be hw:x where x is the card identification.
- * We skip the subdevice suffix that starts with comma */
-
- if (strncasecmp(device_name, "plughw:", 7) == 0) {
- /* skip the "plug" prefix" */
- device_name += 4;
- }
-
- comma = strchr(device_name, ',');
- if (comma == NULL) {
- ctl_name = strdup(device_name);
- if (ctl_name == NULL) {
- jack_error("strdup(\"%s\") failed.", device_name);
- }
- } else {
- ctl_name = strndup(device_name, comma - device_name);
- if (ctl_name == NULL) {
- jack_error("strndup(\"%s\", %u) failed.", device_name, (unsigned int)(comma - device_name));
- }
- }
-
- return ctl_name;
+ char * ctl_name;
+ const char * comma;
+
+ /* the user wants a hw or plughw device, the ctl name
+ * should be hw:x where x is the card identification.
+ * We skip the subdevice suffix that starts with comma */
+
+ if (strncasecmp (device_name, "plughw:", 7) == 0) {
+ /* skip the "plug" prefix" */
+ device_name += 4;
+ }
+
+ comma = strchr (device_name, ',');
+ if (comma == NULL) {
+ ctl_name = strdup (device_name);
+ if (ctl_name == NULL) {
+ jack_error ("strdup(\"%s\") failed.", device_name);
+ }
+ } else {
+ ctl_name = strndup (device_name, comma - device_name);
+ if (ctl_name == NULL) {
+ jack_error ("strndup(\"%s\", %u) failed.", device_name, (unsigned int)(comma - device_name));
+ }
+ }
+
+ return ctl_name;
}
static int
@@ -137,22 +137,22 @@ alsa_driver_check_card_type (alsa_driver_t *driver)
snd_ctl_card_info_alloca (&card_info);
- ctl_name = get_control_device_name(driver->alsa_name_playback);
+ ctl_name = get_control_device_name (driver->alsa_name_playback);
// XXX: I don't know the "right" way to do this. Which to use
// driver->alsa_name_playback or driver->alsa_name_capture.
if ((err = snd_ctl_open (&driver->ctl_handle, ctl_name, 0)) < 0) {
jack_error ("control open \"%s\" (%s)", ctl_name,
- snd_strerror(err));
- } else if ((err = snd_ctl_card_info(driver->ctl_handle, card_info)) < 0) {
+ snd_strerror (err));
+ } else if ((err = snd_ctl_card_info (driver->ctl_handle, card_info)) < 0) {
jack_error ("control hardware info \"%s\" (%s)",
driver->alsa_name_playback, snd_strerror (err));
snd_ctl_close (driver->ctl_handle);
}
- driver->alsa_driver = strdup(snd_ctl_card_info_get_driver (card_info));
+ driver->alsa_driver = strdup (snd_ctl_card_info_get_driver (card_info));
- free(ctl_name);
+ free (ctl_name);
return alsa_driver_check_capabilities (driver);
}
@@ -174,8 +174,8 @@ alsa_driver_hdsp_hardware (alsa_driver_t *driver)
static int
alsa_driver_ice1712_hardware (alsa_driver_t *driver)
{
- driver->hw = jack_alsa_ice1712_hw_new (driver);
- return 0;
+ driver->hw = jack_alsa_ice1712_hw_new (driver);
+ return 0;
}
static int
@@ -198,24 +198,24 @@ alsa_driver_hw_specific (alsa_driver_t *driver, int hw_monitoring,
{
int err;
- if (!strcmp(driver->alsa_driver, "RME9652")) {
+ if (!strcmp (driver->alsa_driver, "RME9652")) {
if ((err = alsa_driver_hammerfall_hardware (driver)) != 0) {
return err;
}
- } else if (!strcmp(driver->alsa_driver, "H-DSP")) {
- if ((err = alsa_driver_hdsp_hardware (driver)) !=0) {
- return err;
- }
- } else if (!strcmp(driver->alsa_driver, "ICE1712")) {
- if ((err = alsa_driver_ice1712_hardware (driver)) !=0) {
- return err;
- }
- } else if (!strcmp(driver->alsa_driver, "USB US-X2Y")) {
- if ((err = alsa_driver_usx2y_hardware (driver)) !=0) {
- return err;
+ } else if (!strcmp (driver->alsa_driver, "H-DSP")) {
+ if ((err = alsa_driver_hdsp_hardware (driver)) != 0) {
+ return err;
+ }
+ } else if (!strcmp (driver->alsa_driver, "ICE1712")) {
+ if ((err = alsa_driver_ice1712_hardware (driver)) != 0) {
+ return err;
+ }
+ } else if (!strcmp (driver->alsa_driver, "USB US-X2Y")) {
+ if ((err = alsa_driver_usx2y_hardware (driver)) != 0) {
+ return err;
}
} else {
- if ((err = alsa_driver_generic_hardware (driver)) != 0) {
+ if ((err = alsa_driver_generic_hardware (driver)) != 0) {
return err;
}
}
@@ -258,50 +258,50 @@ alsa_driver_setup_io_function_pointers (alsa_driver_t *driver)
case 2:
switch (driver->dither) {
case Rectangular:
- jack_info("Rectangular dithering at 16 bits");
- driver->write_via_copy = driver->quirk_bswap?
- sample_move_dither_rect_d16_sSs:
- sample_move_dither_rect_d16_sS;
+ jack_info ("Rectangular dithering at 16 bits");
+ driver->write_via_copy = driver->quirk_bswap ?
+ sample_move_dither_rect_d16_sSs :
+ sample_move_dither_rect_d16_sS;
break;
case Triangular:
- jack_info("Triangular dithering at 16 bits");
- driver->write_via_copy = driver->quirk_bswap?
- sample_move_dither_tri_d16_sSs:
- sample_move_dither_tri_d16_sS;
+ jack_info ("Triangular dithering at 16 bits");
+ driver->write_via_copy = driver->quirk_bswap ?
+ sample_move_dither_tri_d16_sSs :
+ sample_move_dither_tri_d16_sS;
break;
case Shaped:
- jack_info("Noise-shaped dithering at 16 bits");
- driver->write_via_copy = driver->quirk_bswap?
- sample_move_dither_shaped_d16_sSs:
- sample_move_dither_shaped_d16_sS;
+ jack_info ("Noise-shaped dithering at 16 bits");
+ driver->write_via_copy = driver->quirk_bswap ?
+ sample_move_dither_shaped_d16_sSs :
+ sample_move_dither_shaped_d16_sS;
break;
default:
- driver->write_via_copy = driver->quirk_bswap?
- sample_move_d16_sSs :
- sample_move_d16_sS;
+ driver->write_via_copy = driver->quirk_bswap ?
+ sample_move_d16_sSs :
+ sample_move_d16_sS;
break;
}
break;
case 3: /* NO DITHER */
- driver->write_via_copy = driver->quirk_bswap?
- sample_move_d24_sSs:
- sample_move_d24_sS;
+ driver->write_via_copy = driver->quirk_bswap ?
+ sample_move_d24_sSs :
+ sample_move_d24_sS;
break;
case 4: /* NO DITHER */
- driver->write_via_copy = driver->quirk_bswap?
- sample_move_d32u24_sSs:
- sample_move_d32u24_sS;
+ driver->write_via_copy = driver->quirk_bswap ?
+ sample_move_d32u24_sSs :
+ sample_move_d32u24_sS;
break;
default:
jack_error ("impossible sample width (%d) discovered!",
- driver->playback_sample_bytes);
+ driver->playback_sample_bytes);
exit (1);
}
}
@@ -313,19 +313,19 @@ alsa_driver_setup_io_function_pointers (alsa_driver_t *driver)
} else {
switch (driver->capture_sample_bytes) {
case 2:
- driver->read_via_copy = driver->quirk_bswap?
- sample_move_dS_s16s:
- sample_move_dS_s16;
+ driver->read_via_copy = driver->quirk_bswap ?
+ sample_move_dS_s16s :
+ sample_move_dS_s16;
break;
case 3:
- driver->read_via_copy = driver->quirk_bswap?
- sample_move_dS_s24s:
- sample_move_dS_s24;
+ driver->read_via_copy = driver->quirk_bswap ?
+ sample_move_dS_s24s :
+ sample_move_dS_s24;
break;
case 4:
- driver->read_via_copy = driver->quirk_bswap?
- sample_move_dS_s32u24s:
- sample_move_dS_s32u24;
+ driver->read_via_copy = driver->quirk_bswap ?
+ sample_move_dS_s32u24s :
+ sample_move_dS_s32u24;
break;
}
}
@@ -345,24 +345,25 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
int err, format;
unsigned int frame_rate;
snd_pcm_uframes_t stop_th;
+
static struct {
char Name[40];
snd_pcm_format_t format;
int swapped;
} formats[] = {
- {"32bit float little-endian", SND_PCM_FORMAT_FLOAT_LE, IS_LE},
- {"32bit integer little-endian", SND_PCM_FORMAT_S32_LE, IS_LE},
- {"32bit integer big-endian", SND_PCM_FORMAT_S32_BE, IS_BE},
- {"24bit little-endian in 3bytes format", SND_PCM_FORMAT_S24_3LE, IS_LE},
- {"24bit big-endian in 3bytes format", SND_PCM_FORMAT_S24_3BE, IS_BE},
- {"24bit little-endian", SND_PCM_FORMAT_S24_LE, IS_LE},
- {"24bit big-endian", SND_PCM_FORMAT_S24_BE, IS_BE},
- {"16bit little-endian", SND_PCM_FORMAT_S16_LE, IS_LE},
- {"16bit big-endian", SND_PCM_FORMAT_S16_BE, IS_BE},
+ { "32bit float little-endian", SND_PCM_FORMAT_FLOAT_LE, IS_LE },
+ { "32bit integer little-endian", SND_PCM_FORMAT_S32_LE, IS_LE },
+ { "32bit integer big-endian", SND_PCM_FORMAT_S32_BE, IS_BE },
+ { "24bit little-endian in 3bytes format", SND_PCM_FORMAT_S24_3LE, IS_LE },
+ { "24bit big-endian in 3bytes format", SND_PCM_FORMAT_S24_3BE, IS_BE },
+ { "24bit little-endian", SND_PCM_FORMAT_S24_LE, IS_LE },
+ { "24bit big-endian", SND_PCM_FORMAT_S24_BE, IS_BE },
+ { "16bit little-endian", SND_PCM_FORMAT_S16_LE, IS_LE },
+ { "16bit big-endian", SND_PCM_FORMAT_S16_BE, IS_BE },
};
-#define NUMFORMATS (sizeof(formats)/sizeof(formats[0]))
+#define NUMFORMATS (sizeof(formats) / sizeof(formats[0]))
- if ((err = snd_pcm_hw_params_any (handle, hw_params)) < 0) {
+ if ((err = snd_pcm_hw_params_any (handle, hw_params)) < 0) {
jack_error ("ALSA: no playback configurations available (%s)",
snd_strerror (err));
return -1;
@@ -416,10 +417,10 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
}
}
- frame_rate = driver->frame_rate ;
+ frame_rate = driver->frame_rate;
err = snd_pcm_hw_params_set_rate_near (handle, hw_params,
- &frame_rate, NULL) ;
- driver->frame_rate = frame_rate ;
+ &frame_rate, NULL);
+ driver->frame_rate = frame_rate;
if (err < 0) {
jack_error ("ALSA: cannot set sample/frame rate to %"
PRIu32 " for %s", driver->frame_rate,
@@ -429,10 +430,10 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
if (!*nchns) {
/*if not user-specified, try to find the maximum
* number of channels */
- unsigned int channels_max ;
+ unsigned int channels_max;
err = snd_pcm_hw_params_get_channels_max (hw_params,
&channels_max);
- *nchns = channels_max ;
+ *nchns = channels_max;
if (*nchns > 1024) {
@@ -442,14 +443,14 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
they can't be bothered to set up a proper
default device, limit the number of
channels for them to a sane default.
- */
+ */
jack_error (
-"You appear to be using the ALSA software \"plug\" layer, probably\n"
-"a result of using the \"default\" ALSA device. This is less\n"
-"efficient than it could be. Consider using a hardware device\n"
-"instead rather than using the plug layer. Usually the name of the\n"
-"hardware device that corresponds to the first sound card is hw:0\n"
+ "You appear to be using the ALSA software \"plug\" layer, probably\n"
+ "a result of using the \"default\" ALSA device. This is less\n"
+ "efficient than it could be. Consider using a hardware device\n"
+ "instead rather than using the plug layer. Usually the name of the\n"
+ "hardware device that corresponds to the first sound card is hw:0\n"
);
*nchns = 2;
}
@@ -474,8 +475,9 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
*nperiodsp = driver->user_nperiods;
snd_pcm_hw_params_set_periods_min (handle, hw_params, nperiodsp, NULL);
- if (*nperiodsp < driver->user_nperiods)
+ if (*nperiodsp < driver->user_nperiods) {
*nperiodsp = driver->user_nperiods;
+ }
if (snd_pcm_hw_params_set_periods_near (handle, hw_params,
nperiodsp, NULL) < 0) {
jack_error ("ALSA: cannot set number of periods to %u for %s",
@@ -485,15 +487,15 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
if (*nperiodsp < driver->user_nperiods) {
jack_error ("ALSA: got smaller periods %u than %u for %s",
- *nperiodsp, (unsigned int) driver->user_nperiods,
+ *nperiodsp, (unsigned int)driver->user_nperiods,
stream_name);
return -1;
}
jack_info ("ALSA: use %d periods for %s", *nperiodsp, stream_name);
#if 0
- if (!jack_power_of_two(driver->frames_per_cycle)) {
- jack_error("JACK: frames must be a power of two "
- "(64, 512, 1024, ...)\n");
+ 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;
}
#endif
@@ -544,8 +546,8 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
#if 0
jack_info ("set silence size to %lu * %lu = %lu",
- driver->frames_per_cycle, *nperiodsp,
- driver->frames_per_cycle * *nperiodsp);
+ driver->frames_per_cycle, *nperiodsp,
+ driver->frames_per_cycle * *nperiodsp);
if ((err = snd_pcm_sw_params_set_silence_size (
handle, sw_params,
@@ -556,14 +558,15 @@ alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
}
#endif
- if (handle == driver->playback_handle)
+ if (handle == driver->playback_handle) {
err = snd_pcm_sw_params_set_avail_min (
handle, sw_params,
driver->frames_per_cycle
* (*nperiodsp - driver->user_nperiods + 1));
- else
+ } else {
err = snd_pcm_sw_params_set_avail_min (
handle, sw_params, driver->frames_per_cycle);
+ }
if (err < 0) {
jack_error ("ALSA: cannot set avail min for %s", stream_name);
@@ -601,8 +604,8 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
driver->user_nperiods = user_nperiods;
jack_info ("configuring for %" PRIu32 "Hz, period = %"
- PRIu32 " frames (%.1f ms), buffer = %" PRIu32 " periods",
- rate, frames_per_cycle, (((float)frames_per_cycle / (float) rate) * 1000.0f), user_nperiods);
+ PRIu32 " frames (%.1f ms), buffer = %" PRIu32 " periods",
+ rate, frames_per_cycle, (((float)frames_per_cycle / (float)rate) * 1000.0f), user_nperiods);
if (driver->capture_handle) {
if (alsa_driver_configure_stream (
@@ -666,14 +669,12 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
driver->frame_rate = cr;
}
- }
- else if (driver->capture_handle && cr != driver->frame_rate) {
+ } else if (driver->capture_handle && cr != driver->frame_rate) {
jack_error ("capture sample rate in use (%d Hz) does not "
"match requested rate (%d Hz)",
cr, driver->frame_rate);
driver->frame_rate = cr;
- }
- else if (driver->playback_handle && pr != driver->frame_rate) {
+ } else if (driver->playback_handle && pr != driver->frame_rate) {
jack_error ("playback sample rate in use (%d Hz) does not "
"match requested rate (%d Hz)",
pr, driver->frame_rate);
@@ -684,28 +685,31 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
/* check the fragment size, since thats non-negotiable */
if (driver->playback_handle) {
- snd_pcm_access_t access;
+ snd_pcm_access_t access;
- err = snd_pcm_hw_params_get_period_size (
- driver->playback_hw_params, &p_period_size, &dir);
- if (err != 0)
+ err = snd_pcm_hw_params_get_period_size (
+ driver->playback_hw_params, &p_period_size, &dir);
+ if (err != 0) {
jack_error ("snd_pcm_hw_params_get_period_size (playback) : %s",
- snd_strerror (err));
+ snd_strerror (err));
+ }
- err = snd_pcm_hw_params_get_format (
- driver->playback_hw_params,
+ err = snd_pcm_hw_params_get_format (
+ driver->playback_hw_params,
&(driver->playback_sample_format));
- if (err != 0)
+ if (err != 0) {
jack_error ("snd_pcm_hw_params_get_format (playback) : %s",
- snd_strerror (err));
+ snd_strerror (err));
+ }
- err = snd_pcm_hw_params_get_access (driver->playback_hw_params,
+ err = snd_pcm_hw_params_get_access (driver->playback_hw_params,
&access);
- if (err != 0)
+ if (err != 0) {
jack_error ("snd_pcm_hw_params_get_access (playback) : %s",
- snd_strerror (err));
+ snd_strerror (err));
+ }
- driver->playback_interleaved =
+ driver->playback_interleaved =
(access == SND_PCM_ACCESS_MMAP_INTERLEAVED)
|| (access == SND_PCM_ACCESS_MMAP_COMPLEX);
@@ -719,28 +723,31 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
}
if (driver->capture_handle) {
- snd_pcm_access_t access;
+ snd_pcm_access_t access;
- err = snd_pcm_hw_params_get_period_size (
- driver->capture_hw_params, &c_period_size, &dir);
- if (err != 0)
+ err = snd_pcm_hw_params_get_period_size (
+ driver->capture_hw_params, &c_period_size, &dir);
+ if (err != 0) {
jack_error ("snd_pcm_hw_params_get_period_size (capture): %s",
- snd_strerror (err));
+ snd_strerror (err));
+ }
- err = snd_pcm_hw_params_get_format (
- driver->capture_hw_params,
+ err = snd_pcm_hw_params_get_format (
+ driver->capture_hw_params,
&(driver->capture_sample_format));
- if (err != 0)
+ if (err != 0) {
jack_error ("snd_pcm_hw_params_get_format (capture) : %s",
- snd_strerror (err));
+ snd_strerror (err));
+ }
- err = snd_pcm_hw_params_get_access (driver->capture_hw_params,
+ err = snd_pcm_hw_params_get_access (driver->capture_hw_params,
&access);
- if (err != 0)
+ if (err != 0) {
jack_error ("snd_pcm_hw_params_get_access (capture) : %s",
- snd_strerror (err));
+ snd_strerror (err));
+ }
- driver->capture_interleaved =
+ driver->capture_interleaved =
(access == SND_PCM_ACCESS_MMAP_INTERLEAVED)
|| (access == SND_PCM_ACCESS_MMAP_COMPLEX);
@@ -749,7 +756,7 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
PRIu32
" frames but got %uc frames for capture",
driver->frames_per_cycle, p_period_size);
- goto errout;
+ goto errout;
}
}
@@ -762,7 +769,7 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
if (driver->playback_handle) {
switch (driver->playback_sample_format) {
- case SND_PCM_FORMAT_FLOAT_LE:
+ case SND_PCM_FORMAT_FLOAT_LE:
case SND_PCM_FORMAT_S32_LE:
case SND_PCM_FORMAT_S24_3LE:
case SND_PCM_FORMAT_S24_3BE:
@@ -782,7 +789,7 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
if (driver->capture_handle) {
switch (driver->capture_sample_format) {
- case SND_PCM_FORMAT_FLOAT_LE:
+ case SND_PCM_FORMAT_FLOAT_LE:
case SND_PCM_FORMAT_S32_LE:
case SND_PCM_FORMAT_S24_3LE:
case SND_PCM_FORMAT_S24_3BE:
@@ -803,8 +810,8 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
if (driver->playback_interleaved) {
const snd_pcm_channel_area_t *my_areas;
snd_pcm_uframes_t offset, frames;
- if (snd_pcm_mmap_begin(driver->playback_handle,
- &my_areas, &offset, &frames) < 0) {
+ if (snd_pcm_mmap_begin (driver->playback_handle,
+ &my_areas, &offset, &frames) < 0) {
jack_error ("ALSA: %s: mmap areas info error",
driver->alsa_name_playback);
goto errout;
@@ -819,8 +826,8 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
if (driver->capture_interleaved) {
const snd_pcm_channel_area_t *my_areas;
snd_pcm_uframes_t offset, frames;
- if (snd_pcm_mmap_begin(driver->capture_handle,
- &my_areas, &offset, &frames) < 0) {
+ if (snd_pcm_mmap_begin (driver->capture_handle,
+ &my_areas, &offset, &frames) < 0) {
jack_error ("ALSA: %s: mmap areas info error",
driver->alsa_name_capture);
goto errout;
@@ -844,55 +851,53 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
channels require action on every cycle. any bits that are
not set after the engine's process() call indicate channels
that potentially need to be silenced.
- */
+ */
bitset_create (&driver->channels_done, driver->max_nchannels);
bitset_create (&driver->channels_not_done, driver->max_nchannels);
if (driver->playback_handle) {
- driver->playback_addr = (char **)
- malloc (sizeof (char *) * driver->playback_nchannels);
+ driver->playback_addr = (char**)
+ malloc (sizeof(char *) * driver->playback_nchannels);
memset (driver->playback_addr, 0,
- sizeof (char *) * driver->playback_nchannels);
- driver->playback_interleave_skip = (unsigned long *)
- malloc (sizeof (unsigned long *) * driver->playback_nchannels);
+ sizeof(char *) * driver->playback_nchannels);
+ driver->playback_interleave_skip = (unsigned long*)
+ malloc (sizeof(unsigned long *) * driver->playback_nchannels);
memset (driver->playback_interleave_skip, 0,
- sizeof (unsigned long *) * driver->playback_nchannels);
- driver->silent = (unsigned long *)
- malloc (sizeof (unsigned long)
- * driver->playback_nchannels);
+ sizeof(unsigned long *) * driver->playback_nchannels);
+ driver->silent = (unsigned long*)
+ malloc (sizeof(unsigned long)
+ * driver->playback_nchannels);
- for (chn = 0; chn < driver->playback_nchannels; chn++) {
+ for (chn = 0; chn < driver->playback_nchannels; chn++)
driver->silent[chn] = 0;
- }
- for (chn = 0; chn < driver->playback_nchannels; chn++) {
+ for (chn = 0; chn < driver->playback_nchannels; chn++)
bitset_add (driver->channels_done, chn);
- }
- driver->dither_state = (dither_state_t *)
- calloc ( driver->playback_nchannels,
- sizeof (dither_state_t));
+ driver->dither_state = (dither_state_t*)
+ calloc ( driver->playback_nchannels,
+ sizeof(dither_state_t));
}
if (driver->capture_handle) {
- driver->capture_addr = (char **)
- malloc (sizeof (char *) * driver->capture_nchannels);
+ driver->capture_addr = (char**)
+ malloc (sizeof(char *) * driver->capture_nchannels);
memset (driver->capture_addr, 0,
- sizeof (char *) * driver->capture_nchannels);
- driver->capture_interleave_skip = (unsigned long *)
- malloc (sizeof (unsigned long *) * driver->capture_nchannels);
+ sizeof(char *) * driver->capture_nchannels);
+ driver->capture_interleave_skip = (unsigned long*)
+ malloc (sizeof(unsigned long *) * driver->capture_nchannels);
memset (driver->capture_interleave_skip, 0,
- sizeof (unsigned long *) * driver->capture_nchannels);
+ sizeof(unsigned long *) * driver->capture_nchannels);
}
- driver->clock_sync_data = (ClockSyncStatus *)
- malloc (sizeof (ClockSyncStatus) * driver->max_nchannels);
+ driver->clock_sync_data = (ClockSyncStatus*)
+ malloc (sizeof(ClockSyncStatus) * driver->max_nchannels);
driver->period_usecs =
- (jack_time_t) floor ((((float) driver->frames_per_cycle) /
- driver->frame_rate) * 1000000.0f);
- driver->poll_timeout = (int) floor (1.5f * driver->period_usecs);
+ (jack_time_t)floor ((((float)driver->frames_per_cycle) /
+ driver->frame_rate) * 1000000.0f);
+ driver->poll_timeout = (int)floor (1.5f * driver->period_usecs);
if (driver->engine) {
if (driver->engine->set_buffer_size (driver->engine,
@@ -902,19 +907,19 @@ alsa_driver_set_parameters (alsa_driver_t *driver,
}
}
- driver->previously_successfully_configured = TRUE;
+ driver->previously_successfully_configured = TRUE;
return 0;
- errout:
- if (driver->previously_successfully_configured) {
- /* attempt to restore previous configuration */
- jack_info ("ALSA: falling back to old configuration");
- if (alsa_driver_set_parameters (driver, old_frames_per_cycle, old_user_nperiods, old_rate) == 0) {
- jack_error ("ALSA: reverted to previous parameters after failure");
- return 0;
- }
- }
- return -1;
+errout:
+ if (driver->previously_successfully_configured) {
+ /* attempt to restore previous configuration */
+ jack_info ("ALSA: falling back to old configuration");
+ if (alsa_driver_set_parameters (driver, old_frames_per_cycle, old_user_nperiods, old_rate) == 0) {
+ jack_error ("ALSA: reverted to previous parameters after failure");
+ return 0;
+ }
+ }
+ return -1;
}
static int
@@ -943,8 +948,8 @@ alsa_driver_get_channel_addresses (alsa_driver_t *driver,
if (capture_avail) {
if ((err = snd_pcm_mmap_begin (
driver->capture_handle, &driver->capture_areas,
- (snd_pcm_uframes_t *) capture_offset,
- (snd_pcm_uframes_t *) capture_avail)) < 0) {
+ (snd_pcm_uframes_t*)capture_offset,
+ (snd_pcm_uframes_t*)capture_avail)) < 0) {
jack_error ("ALSA: %s: mmap areas info error",
driver->alsa_name_capture);
return -1;
@@ -953,17 +958,17 @@ alsa_driver_get_channel_addresses (alsa_driver_t *driver,
for (chn = 0; chn < driver->capture_nchannels; chn++) {
const snd_pcm_channel_area_t *a =
&driver->capture_areas[chn];
- driver->capture_addr[chn] = (char *) a->addr
- + ((a->first + a->step * *capture_offset) / 8);
- driver->capture_interleave_skip[chn] = (unsigned long ) (a->step / 8);
+ driver->capture_addr[chn] = (char*)a->addr
+ + ((a->first + a->step * *capture_offset) / 8);
+ driver->capture_interleave_skip[chn] = (unsigned long )(a->step / 8);
}
}
if (playback_avail) {
if ((err = snd_pcm_mmap_begin (
driver->playback_handle, &driver->playback_areas,
- (snd_pcm_uframes_t *) playback_offset,
- (snd_pcm_uframes_t *) playback_avail)) < 0) {
+ (snd_pcm_uframes_t*)playback_offset,
+ (snd_pcm_uframes_t*)playback_avail)) < 0) {
jack_error ("ALSA: %s: mmap areas info error ",
driver->alsa_name_playback);
return -1;
@@ -972,9 +977,9 @@ alsa_driver_get_channel_addresses (alsa_driver_t *driver,
for (chn = 0; chn < driver->playback_nchannels; chn++) {
const snd_pcm_channel_area_t *a =
&driver->playback_areas[chn];
- driver->playback_addr[chn] = (char *) a->addr
- + ((a->first + a->step * *playback_offset) / 8);
- driver->playback_interleave_skip[chn] = (unsigned long ) (a->step / 8);
+ driver->playback_addr[chn] = (char*)a->addr
+ + ((a->first + a->step * *playback_offset) / 8);
+ driver->playback_interleave_skip[chn] = (unsigned long )(a->step / 8);
}
}
@@ -995,7 +1000,7 @@ alsa_driver_start (alsa_driver_t *driver)
if ((err = snd_pcm_prepare (driver->playback_handle)) < 0) {
jack_error ("ALSA: prepare error for playback on "
"\"%s\" (%s)", driver->alsa_name_playback,
- snd_strerror(err));
+ snd_strerror (err));
return -1;
}
}
@@ -1005,7 +1010,7 @@ alsa_driver_start (alsa_driver_t *driver)
if ((err = snd_pcm_prepare (driver->capture_handle)) < 0) {
jack_error ("ALSA: prepare error for capture on \"%s\""
" (%s)", driver->alsa_name_capture,
- snd_strerror(err));
+ snd_strerror (err));
return -1;
}
}
@@ -1042,14 +1047,14 @@ alsa_driver_start (alsa_driver_t *driver)
free (driver->pfd);
}
- driver->pfd = (struct pollfd *)
- malloc (sizeof (struct pollfd) *
- (driver->playback_nfds + driver->capture_nfds + 2));
+ driver->pfd = (struct pollfd*)
+ malloc (sizeof(struct pollfd) *
+ (driver->playback_nfds + driver->capture_nfds + 2));
if (driver->playback_handle) {
/* fill playback buffer with zeroes, and mark
all fragments as having data.
- */
+ */
pavail = snd_pcm_avail_update (driver->playback_handle);
@@ -1060,7 +1065,7 @@ alsa_driver_start (alsa_driver_t *driver)
}
if (alsa_driver_get_channel_addresses (driver,
- 0, &pavail, 0, &poffset)) {
+ 0, &pavail, 0, &poffset)) {
return -1;
}
@@ -1071,7 +1076,7 @@ alsa_driver_start (alsa_driver_t *driver)
alsa-lib may have a better function for doing this
here, where the goal is to silence the entire
buffer.
- */
+ */
for (chn = 0; chn < driver->playback_nchannels; chn++) {
alsa_driver_silence_on_channel (
@@ -1112,7 +1117,7 @@ alsa_driver_stop (alsa_driver_t *driver)
/* silence all capture port buffers, because we might
be entering offline mode.
- */
+ */
for (chn = 0, node = driver->capture_ports; node;
node = jack_slist_next (node), chn++) {
@@ -1121,9 +1126,9 @@ alsa_driver_stop (alsa_driver_t *driver)
char* buf;
jack_nframes_t nframes = driver->engine->control->buffer_size;
- port = (jack_port_t *) node->data;
+ port = (jack_port_t*)node->data;
buf = jack_port_get_buffer (port, nframes);
- memset (buf, 0, sizeof (jack_default_audio_sample_t) * nframes);
+ memset (buf, 0, sizeof(jack_default_audio_sample_t) * nframes);
}
if (driver->playback_handle) {
@@ -1159,8 +1164,9 @@ alsa_driver_restart (alsa_driver_t *driver)
int res;
driver->xrun_recovery = 1;
- if ((res = driver->nt_stop((struct _jack_driver_nt *) driver))==0)
- res = driver->nt_start((struct _jack_driver_nt *) driver);
+ if ((res = driver->nt_stop ((struct _jack_driver_nt*)driver)) == 0) {
+ res = driver->nt_start ((struct _jack_driver_nt*)driver);
+ }
driver->xrun_recovery = 0;
return res;
@@ -1172,47 +1178,46 @@ alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed_usecs)
snd_pcm_status_t *status;
int res;
- snd_pcm_status_alloca(&status);
+ snd_pcm_status_alloca (&status);
if (driver->capture_handle) {
- if ((res = snd_pcm_status(driver->capture_handle, status))
+ if ((res = snd_pcm_status (driver->capture_handle, status))
< 0) {
- jack_error("status error: %s", snd_strerror(res));
+ jack_error ("status error: %s", snd_strerror (res));
}
} else {
- if ((res = snd_pcm_status(driver->playback_handle, status))
+ if ((res = snd_pcm_status (driver->playback_handle, status))
< 0) {
- jack_error("status error: %s", snd_strerror(res));
+ jack_error ("status error: %s", snd_strerror (res));
}
}
- if (snd_pcm_status_get_state(status) == SND_PCM_STATE_SUSPENDED)
- {
- MESSAGE("\n\n**** alsa_pcm: pcm in suspended state, resuming it \n\n" );
+ if (snd_pcm_status_get_state (status) == SND_PCM_STATE_SUSPENDED) {
+ MESSAGE ("\n\n**** alsa_pcm: pcm in suspended state, resuming it \n\n" );
if (driver->capture_handle) {
- if ((res = snd_pcm_prepare(driver->capture_handle))
+ if ((res = snd_pcm_prepare (driver->capture_handle))
< 0) {
- jack_error("error preparing after suspend: %s", snd_strerror(res));
+ jack_error ("error preparing after suspend: %s", snd_strerror (res));
}
} else {
- if ((res = snd_pcm_prepare(driver->playback_handle))
+ if ((res = snd_pcm_prepare (driver->playback_handle))
< 0) {
- jack_error("error preparing after suspend: %s", snd_strerror(res));
+ jack_error ("error preparing after suspend: %s", snd_strerror (res));
}
}
}
- if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN
+ if (snd_pcm_status_get_state (status) == SND_PCM_STATE_XRUN
&& driver->process_count > XRUN_REPORT_DELAY) {
struct timeval now, diff, tstamp;
driver->xrun_count++;
- snd_pcm_status_get_tstamp(status,&now);
- snd_pcm_status_get_trigger_tstamp(status, &tstamp);
- timersub(&now, &tstamp, &diff);
+ snd_pcm_status_get_tstamp (status, &now);
+ snd_pcm_status_get_trigger_tstamp (status, &tstamp);
+ timersub (&now, &tstamp, &diff);
*delayed_usecs = diff.tv_sec * 1000000.0 + diff.tv_usec;
- MESSAGE("\n\n**** alsa_pcm: xrun of at least %.3f "
- "msecs\n\n",
- *delayed_usecs / 1000.0);
+ MESSAGE ("\n\n**** alsa_pcm: xrun of at least %.3f "
+ "msecs\n\n",
+ *delayed_usecs / 1000.0);
}
if (alsa_driver_restart (driver)) {
@@ -1275,7 +1280,7 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
need_playback = driver->playback_handle ? 1 : 0;
}
- again:
+again:
while (need_playback || need_capture) {
@@ -1303,14 +1308,13 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
/* ALSA doesn't set POLLERR in some versions of 0.9.X */
- for (i = 0; i < nfds; i++) {
+ for (i = 0; i < nfds; i++)
driver->pfd[i].events |= POLLERR;
- }
if (extra_fd >= 0) {
driver->pfd[nfds].fd = extra_fd;
driver->pfd[nfds].events =
- POLLIN|POLLERR|POLLHUP|POLLNVAL;
+ POLLIN | POLLERR | POLLHUP | POLLNVAL;
nfds++;
}
@@ -1370,7 +1374,7 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
if (extra_fd >= 0) {
- if (driver->pfd[nfds-1].revents == 0) {
+ if (driver->pfd[nfds - 1].revents == 0) {
/* we timed out on the extra fd */
*status = -4;
@@ -1380,13 +1384,13 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
/* if POLLIN was the only bit set, we're OK */
*status = 0;
- return (driver->pfd[nfds-1].revents == POLLIN) ? 0 : -1;
+ return (driver->pfd[nfds - 1].revents == POLLIN) ? 0 : -1;
}
if (need_playback) {
if (snd_pcm_poll_descriptors_revents
- (driver->playback_handle, &driver->pfd[0],
- driver->playback_nfds, &revents) < 0) {
+ (driver->playback_handle, &driver->pfd[0],
+ driver->playback_nfds, &revents) < 0) {
jack_error ("ALSA: playback revents failed");
*status = -6;
return 0;
@@ -1408,8 +1412,8 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
if (need_capture) {
if (snd_pcm_poll_descriptors_revents
- (driver->capture_handle, &driver->pfd[ci],
- driver->capture_nfds, &revents) < 0) {
+ (driver->capture_handle, &driver->pfd[ci],
+ driver->capture_nfds, &revents) < 0) {
jack_error ("ALSA: capture revents failed");
*status = -6;
return 0;
@@ -1491,7 +1495,7 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
/* constrain the available count to the nearest (round down) number of
periods.
- */
+ */
return avail - (avail % driver->frames_per_cycle);
}
@@ -1508,16 +1512,16 @@ alsa_driver_null_cycle (alsa_driver_t* driver, jack_nframes_t nframes)
return -1;
}
- if (driver->capture_handle) {
+ if (driver->capture_handle) {
nf = nframes;
offset = 0;
while (nf) {
contiguous = nf;
- if (alsa_driver_get_channel_addresses (driver,
- &contiguous, 0, &offset, 0)) {
- return -1;
- }
+ if (alsa_driver_get_channel_addresses (driver,
+ &contiguous, 0, &offset, 0)) {
+ return -1;
+ }
if (snd_pcm_mmap_commit (driver->capture_handle,
offset, contiguous) < 0) {
@@ -1534,15 +1538,14 @@ alsa_driver_null_cycle (alsa_driver_t* driver, jack_nframes_t nframes)
while (nf) {
contiguous = nf;
- if (alsa_driver_get_channel_addresses (driver,
- 0, &contiguous, 0, &offset)) {
- return -1;
- }
+ if (alsa_driver_get_channel_addresses (driver,
+ 0, &contiguous, 0, &offset)) {
+ return -1;
+ }
- for (chn = 0; chn < driver->playback_nchannels; chn++) {
+ for (chn = 0; chn < driver->playback_nchannels; chn++)
alsa_driver_silence_on_channel (driver, chn,
contiguous);
- }
if (snd_pcm_mmap_commit (driver->playback_handle,
offset, contiguous) < 0) {
@@ -1570,7 +1573,7 @@ alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
snd_pcm_sframes_t contiguous;
snd_pcm_sframes_t nread;
snd_pcm_uframes_t offset;
- jack_nframes_t orig_nframes;
+ jack_nframes_t orig_nframes;
jack_default_audio_sample_t* buf;
channel_t chn;
JSList *node;
@@ -1599,8 +1602,8 @@ alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
if (alsa_driver_get_channel_addresses (
driver,
- (snd_pcm_uframes_t *) &contiguous,
- (snd_pcm_uframes_t *) 0,
+ (snd_pcm_uframes_t*)&contiguous,
+ (snd_pcm_uframes_t*)0,
&offset, 0) < 0) {
return -1;
}
@@ -1608,7 +1611,7 @@ alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
for (chn = 0, node = driver->capture_ports; node;
node = jack_slist_next (node), chn++) {
- port = (jack_port_t *) node->data;
+ port = (jack_port_t*)node->data;
if (!jack_port_connected (port)) {
/* no-copy optimization */
@@ -1616,13 +1619,13 @@ alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
}
buf = jack_port_get_buffer (port, orig_nframes);
alsa_driver_read_from_channel (driver, chn,
- buf + nread, contiguous);
+ buf + nread, contiguous);
}
if ((err = snd_pcm_mmap_commit (driver->capture_handle,
- offset, contiguous)) < 0) {
+ offset, contiguous)) < 0) {
jack_error ("ALSA: could not complete read of %"
- PRIu32 " frames: error = %d", contiguous, err);
+ PRIu32 " frames: error = %d", contiguous, err);
return -1;
}
@@ -1667,8 +1670,8 @@ alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
for (chn = 0, node = driver->capture_ports; node;
node = jack_slist_next (node), chn++) {
- if (((jack_port_t *) node->data)->shared->monitor_requests) {
- driver->input_monitor_mask |= (1<<chn);
+ if (((jack_port_t*)node->data)->shared->monitor_requests) {
+ driver->input_monitor_mask |= (1 << chn);
}
}
@@ -1687,27 +1690,27 @@ alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
if (alsa_driver_get_channel_addresses (
driver,
- (snd_pcm_uframes_t *) 0,
- (snd_pcm_uframes_t *) &contiguous,
+ (snd_pcm_uframes_t*)0,
+ (snd_pcm_uframes_t*)&contiguous,
0, &offset) < 0) {
return -1;
}
- for (chn = 0, node = driver->playback_ports, mon_node=driver->monitor_ports;
+ for (chn = 0, node = driver->playback_ports, mon_node = driver->monitor_ports;
node;
node = jack_slist_next (node), chn++) {
- port = (jack_port_t *) node->data;
+ port = (jack_port_t*)node->data;
if (!jack_port_connected (port)) {
continue;
}
buf = jack_port_get_buffer (port, orig_nframes);
alsa_driver_write_to_channel (driver, chn,
- buf + nwritten, contiguous);
+ buf + nwritten, contiguous);
if (mon_node) {
- port = (jack_port_t *) mon_node->data;
+ port = (jack_port_t*)mon_node->data;
if (!jack_port_connected (port)) {
continue;
}
@@ -1724,11 +1727,12 @@ alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
}
if ((err = snd_pcm_mmap_commit (driver->playback_handle,
- offset, contiguous)) < 0) {
+ offset, contiguous)) < 0) {
jack_error ("ALSA: could not complete playback of %"
- PRIu32 " frames: error = %d", contiguous, err);
- if (err != -EPIPE && err != -ESTRPIPE)
+ PRIu32 " frames: error = %d", contiguous, err);
+ if (err != -EPIPE && err != -ESTRPIPE) {
return -1;
+ }
}
nframes -= contiguous;
@@ -1752,10 +1756,11 @@ alsa_driver_run_cycle (alsa_driver_t *driver)
DEBUG ("alsaback from wait, nframes = %lu", nframes);
- if (unlikely(wait_status < 0))
- return -1; /* driver failed */
+ if (unlikely (wait_status < 0)) {
+ return -1; /* driver failed */
- if (unlikely(nframes == 0)) {
+ }
+ if (unlikely (nframes == 0)) {
/* we detected an xrun and restarted: notify
* clients about the delay.
@@ -1770,20 +1775,19 @@ alsa_driver_run_cycle (alsa_driver_t *driver)
static void
alsa_driver_latency_callback (jack_latency_callback_mode_t mode, void* arg)
{
- alsa_driver_t* driver = (alsa_driver_t*) arg;
- jack_client_t* client = driver->client;
- jack_latency_range_t range;
- JSList* node;
-
- if (mode == JackPlaybackLatency) {
- range.min = range.max = driver->frames_per_cycle + driver->playback_frame_latency;
- } else {
- range.min = range.max = driver->frames_per_cycle + driver->capture_frame_latency;
- }
+ alsa_driver_t* driver = (alsa_driver_t*)arg;
+ jack_client_t* client = driver->client;
+ jack_latency_range_t range;
+ JSList* node;
- for (node = client->ports; node; node = jack_slist_next (node)) {
- jack_port_set_latency_range ((jack_port_t*) node->data, mode, &range);
+ if (mode == JackPlaybackLatency) {
+ range.min = range.max = driver->frames_per_cycle + driver->playback_frame_latency;
+ } else {
+ range.min = range.max = driver->frames_per_cycle + driver->capture_frame_latency;
}
+
+ for (node = client->ports; node; node = jack_slist_next (node))
+ jack_port_set_latency_range ((jack_port_t*)node->data, mode, &range);
}
static int
@@ -1801,7 +1805,7 @@ alsa_driver_attach (alsa_driver_t *driver)
}
driver->engine->set_sample_rate (driver->engine, driver->frame_rate);
- port_flags = JackPortIsOutput|JackPortIsPhysical|JackPortIsTerminal;
+ port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
if (driver->has_hw_monitoring) {
port_flags |= JackPortCanMonitor;
@@ -1809,7 +1813,7 @@ alsa_driver_attach (alsa_driver_t *driver)
for (chn = 0; chn < driver->capture_nchannels; chn++) {
- snprintf (buf, sizeof(buf), "capture_%lu", chn+1);
+ snprintf (buf, sizeof(buf), "capture_%lu", chn + 1);
if ((port = jack_port_register (driver->client, buf,
JACK_DEFAULT_AUDIO_TYPE,
@@ -1825,12 +1829,12 @@ alsa_driver_attach (alsa_driver_t *driver)
jack_slist_append (driver->capture_ports, port);
}
- port_flags = JackPortIsInput|JackPortIsPhysical|JackPortIsTerminal;
+ port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
for (chn = 0; chn < driver->playback_nchannels; chn++) {
jack_port_t *monitor_port;
- snprintf (buf, sizeof(buf) - 1, "playback_%lu", chn+1);
+ snprintf (buf, sizeof(buf) - 1, "playback_%lu", chn + 1);
if ((port = jack_port_register (driver->client, buf,
JACK_DEFAULT_AUDIO_TYPE,
@@ -1846,7 +1850,7 @@ alsa_driver_attach (alsa_driver_t *driver)
jack_slist_append (driver->playback_ports, port);
if (driver->with_monitor_ports) {
- snprintf (buf, sizeof(buf) - 1, "monitor_%lu", chn+1);
+ snprintf (buf, sizeof(buf) - 1, "monitor_%lu", chn + 1);
if ((monitor_port = jack_port_register (
driver->client, buf,
@@ -1878,307 +1882,302 @@ alsa_driver_detach (alsa_driver_t *driver)
return 0;
}
- for (node = driver->capture_ports; node;
- node = jack_slist_next (node)) {
- jack_port_unregister (driver->client,
- ((jack_port_t *) node->data));
- }
+ for (node = driver->capture_ports; node;
+ node = jack_slist_next (node))
+ jack_port_unregister (driver->client,
+ ((jack_port_t*)node->data));
- jack_slist_free (driver->capture_ports);
- driver->capture_ports = 0;
+ jack_slist_free (driver->capture_ports);
+ driver->capture_ports = 0;
- for (node = driver->playback_ports; node;
- node = jack_slist_next (node)) {
- jack_port_unregister (driver->client,
- ((jack_port_t *) node->data));
- }
+ for (node = driver->playback_ports; node;
+ node = jack_slist_next (node))
+ jack_port_unregister (driver->client,
+ ((jack_port_t*)node->data));
- jack_slist_free (driver->playback_ports);
- driver->playback_ports = 0;
+ jack_slist_free (driver->playback_ports);
+ driver->playback_ports = 0;
- if (driver->monitor_ports) {
- for (node = driver->monitor_ports; node;
- node = jack_slist_next (node)) {
- jack_port_unregister (driver->client,
- ((jack_port_t *) node->data));
- }
+ if (driver->monitor_ports) {
+ for (node = driver->monitor_ports; node;
+ node = jack_slist_next (node))
+ jack_port_unregister (driver->client,
+ ((jack_port_t*)node->data));
- jack_slist_free (driver->monitor_ports);
- driver->monitor_ports = 0;
- }
+ jack_slist_free (driver->monitor_ports);
+ driver->monitor_ports = 0;
+ }
- return 0;
- }
+ return 0;
+}
#if 0
- static int /* UNUSED */
- alsa_driver_change_sample_clock (alsa_driver_t *driver, SampleClockMode mode)
-
- {
- return driver->hw->change_sample_clock (driver->hw, mode);
- }
-
- static void /* UNUSED */
- alsa_driver_request_all_monitor_input (alsa_driver_t *driver, int yn)
-
- {
- if (driver->hw_monitoring) {
- if (yn) {
- driver->hw->set_input_monitor_mask (driver->hw, ~0U);
- } else {
- driver->hw->set_input_monitor_mask (
- driver->hw, driver->input_monitor_mask);
- }
- }
-
- driver->all_monitor_in = yn;
- }
-
- static void /* UNUSED */
- alsa_driver_set_hw_monitoring (alsa_driver_t *driver, int yn)
- {
- if (yn) {
- driver->hw_monitoring = TRUE;
-
- if (driver->all_monitor_in) {
- driver->hw->set_input_monitor_mask (driver->hw, ~0U);
- } else {
- driver->hw->set_input_monitor_mask (
- driver->hw, driver->input_monitor_mask);
- }
- } else {
- driver->hw_monitoring = FALSE;
- driver->hw->set_input_monitor_mask (driver->hw, 0);
- }
- }
-
- static ClockSyncStatus /* UNUSED */
- alsa_driver_clock_sync_status (channel_t chn)
- {
- return Lock;
- }
+static int /* UNUSED */
+alsa_driver_change_sample_clock (alsa_driver_t *driver, SampleClockMode mode)
+
+{
+ return driver->hw->change_sample_clock (driver->hw, mode);
+}
+
+static void /* UNUSED */
+alsa_driver_request_all_monitor_input (alsa_driver_t *driver, int yn)
+
+{
+ if (driver->hw_monitoring) {
+ if (yn) {
+ driver->hw->set_input_monitor_mask (driver->hw, ~0U);
+ } else {
+ driver->hw->set_input_monitor_mask (
+ driver->hw, driver->input_monitor_mask);
+ }
+ }
+
+ driver->all_monitor_in = yn;
+}
+
+static void /* UNUSED */
+alsa_driver_set_hw_monitoring (alsa_driver_t *driver, int yn)
+{
+ if (yn) {
+ driver->hw_monitoring = TRUE;
+
+ if (driver->all_monitor_in) {
+ driver->hw->set_input_monitor_mask (driver->hw, ~0U);
+ } else {
+ driver->hw->set_input_monitor_mask (
+ driver->hw, driver->input_monitor_mask);
+ }
+ } else {
+ driver->hw_monitoring = FALSE;
+ driver->hw->set_input_monitor_mask (driver->hw, 0);
+ }
+}
+
+static ClockSyncStatus /* UNUSED */
+alsa_driver_clock_sync_status (channel_t chn)
+{
+ return Lock;
+}
#endif
- static void
- alsa_driver_delete (alsa_driver_t *driver)
- {
- JSList *node;
+static void
+alsa_driver_delete (alsa_driver_t *driver)
+{
+ JSList *node;
- /*
- if (driver->midi)
- (driver->midi->destroy)((jack_driver_t*) driver->midi);
- */
+ /*
+ if (driver->midi)
+ (driver->midi->destroy)((jack_driver_t*) driver->midi);
+ */
- for (node = driver->clock_sync_listeners; node;
- node = jack_slist_next (node)) {
- free (node->data);
- }
- jack_slist_free (driver->clock_sync_listeners);
-
- if (driver->ctl_handle) {
- snd_ctl_close (driver->ctl_handle);
- driver->ctl_handle = 0;
- }
-
- if (driver->capture_handle) {
- snd_pcm_close (driver->capture_handle);
- driver->capture_handle = 0;
- }
-
- if (driver->playback_handle) {
- snd_pcm_close (driver->playback_handle);
- driver->capture_handle = 0;
- }
-
- if (driver->capture_hw_params) {
- snd_pcm_hw_params_free (driver->capture_hw_params);
- driver->capture_hw_params = 0;
- }
-
- if (driver->playback_hw_params) {
- snd_pcm_hw_params_free (driver->playback_hw_params);
- driver->playback_hw_params = 0;
- }
-
- if (driver->capture_sw_params) {
- snd_pcm_sw_params_free (driver->capture_sw_params);
- driver->capture_sw_params = 0;
- }
-
- if (driver->playback_sw_params) {
- snd_pcm_sw_params_free (driver->playback_sw_params);
- driver->playback_sw_params = 0;
- }
-
- if (driver->pfd) {
- free (driver->pfd);
- }
-
- if (driver->hw) {
- driver->hw->release (driver->hw);
- driver->hw = 0;
- }
- free(driver->alsa_name_playback);
- free(driver->alsa_name_capture);
- free(driver->alsa_driver);
-
- alsa_driver_release_channel_dependent_memory (driver);
- jack_driver_nt_finish ((jack_driver_nt_t *) driver);
- free (driver);
- }
-
- static char*
- discover_alsa_using_apps ()
- {
- char found[2048];
- char command[5192];
- char* path = getenv ("PATH");
- char* dir;
- size_t flen = 0;
- int card;
- int device;
- size_t cmdlen = 0;
-
- if (!path) {
- return NULL;
- }
-
- /* look for lsof and give up if its not in PATH */
-
- path = strdup (path);
- dir = strtok (path, ":");
- while (dir) {
- char maybe[PATH_MAX+1];
- snprintf (maybe, sizeof(maybe), "%s/lsof", dir);
- if (access (maybe, X_OK) == 0) {
- break;
- }
- dir = strtok (NULL, ":");
- }
- free (path);
-
- if (!dir) {
- return NULL;
- }
-
- snprintf (command, sizeof (command), "lsof -Fc0 ");
- cmdlen = strlen (command);
-
- for (card = 0; card < 8; ++card) {
- for (device = 0; device < 8; ++device) {
- char buf[32];
-
- snprintf (buf, sizeof (buf), "/dev/snd/pcmC%dD%dp", card, device);
- if (access (buf, F_OK) == 0) {
- snprintf (command+cmdlen, sizeof(command)-cmdlen, "%s ", buf);
- }
- cmdlen = strlen (command);
-
- snprintf (buf, sizeof (buf), "/dev/snd/pcmC%dD%dc", card, device);
- if (access (buf, F_OK) == 0) {
- snprintf (command+cmdlen, sizeof(command)-cmdlen, "%s ", buf);
- }
- cmdlen = strlen (command);
- }
- }
-
- FILE* f = popen (command, "r");
-
- if (!f) {
- return NULL;
- }
-
- while (!feof (f)) {
- char buf[1024]; /* lsof doesn't output much */
-
- if (!fgets (buf, sizeof (buf), f)) {
- break;
- }
-
- if (*buf != 'p') {
- return NULL;
- }
-
- /* buf contains NULL as a separator between the process field and the command field */
- char *pid = buf;
- ++pid; /* skip leading 'p' */
- char *cmd = pid;
-
- /* skip to NULL */
- while (*cmd) {
- ++cmd;
- }
- ++cmd; /* skip to 'c' */
- ++cmd; /* skip to first character of command */
-
- snprintf (found+flen, sizeof (found)-flen, "%s (process ID %s)\n", cmd, pid);
- flen = strlen (found);
-
- if (flen >= sizeof (found)) {
- break;
- }
- }
-
- pclose (f);
-
- if (flen) {
- return strdup (found);
- } else {
- return NULL;
- }
- }
-
-
- static jack_driver_t *
- alsa_driver_new (char *name, char *playback_alsa_device,
- char *capture_alsa_device,
- jack_client_t *client,
- jack_nframes_t frames_per_cycle,
- jack_nframes_t user_nperiods,
- jack_nframes_t rate,
- int hw_monitoring,
- int hw_metering,
- int capturing,
- int playing,
- DitherAlgorithm dither,
- int soft_mode,
- int monitor,
- int user_capture_nchnls,
- int user_playback_nchnls,
- int shorts_first,
- jack_nframes_t capture_latency,
- jack_nframes_t playback_latency
+ for (node = driver->clock_sync_listeners; node;
+ node = jack_slist_next (node))
+ free (node->data);
+ jack_slist_free (driver->clock_sync_listeners);
+
+ if (driver->ctl_handle) {
+ snd_ctl_close (driver->ctl_handle);
+ driver->ctl_handle = 0;
+ }
+
+ if (driver->capture_handle) {
+ snd_pcm_close (driver->capture_handle);
+ driver->capture_handle = 0;
+ }
+
+ if (driver->playback_handle) {
+ snd_pcm_close (driver->playback_handle);
+ driver->capture_handle = 0;
+ }
+
+ if (driver->capture_hw_params) {
+ snd_pcm_hw_params_free (driver->capture_hw_params);
+ driver->capture_hw_params = 0;
+ }
+
+ if (driver->playback_hw_params) {
+ snd_pcm_hw_params_free (driver->playback_hw_params);
+ driver->playback_hw_params = 0;
+ }
+
+ if (driver->capture_sw_params) {
+ snd_pcm_sw_params_free (driver->capture_sw_params);
+ driver->capture_sw_params = 0;
+ }
+
+ if (driver->playback_sw_params) {
+ snd_pcm_sw_params_free (driver->playback_sw_params);
+ driver->playback_sw_params = 0;
+ }
+
+ if (driver->pfd) {
+ free (driver->pfd);
+ }
+
+ if (driver->hw) {
+ driver->hw->release (driver->hw);
+ driver->hw = 0;
+ }
+ free (driver->alsa_name_playback);
+ free (driver->alsa_name_capture);
+ free (driver->alsa_driver);
+
+ alsa_driver_release_channel_dependent_memory (driver);
+ jack_driver_nt_finish ((jack_driver_nt_t*)driver);
+ free (driver);
+}
+
+static char*
+discover_alsa_using_apps ()
+{
+ char found[2048];
+ char command[5192];
+ char* path = getenv ("PATH");
+ char* dir;
+ size_t flen = 0;
+ int card;
+ int device;
+ size_t cmdlen = 0;
+
+ if (!path) {
+ return NULL;
+ }
+
+ /* look for lsof and give up if its not in PATH */
+
+ path = strdup (path);
+ dir = strtok (path, ":");
+ while (dir) {
+ char maybe[PATH_MAX + 1];
+ snprintf (maybe, sizeof(maybe), "%s/lsof", dir);
+ if (access (maybe, X_OK) == 0) {
+ break;
+ }
+ dir = strtok (NULL, ":");
+ }
+ free (path);
+
+ if (!dir) {
+ return NULL;
+ }
+
+ snprintf (command, sizeof(command), "lsof -Fc0 ");
+ cmdlen = strlen (command);
+
+ for (card = 0; card < 8; ++card) {
+ for (device = 0; device < 8; ++device) {
+ char buf[32];
+
+ snprintf (buf, sizeof(buf), "/dev/snd/pcmC%dD%dp", card, device);
+ if (access (buf, F_OK) == 0) {
+ snprintf (command + cmdlen, sizeof(command) - cmdlen, "%s ", buf);
+ }
+ cmdlen = strlen (command);
+
+ snprintf (buf, sizeof(buf), "/dev/snd/pcmC%dD%dc", card, device);
+ if (access (buf, F_OK) == 0) {
+ snprintf (command + cmdlen, sizeof(command) - cmdlen, "%s ", buf);
+ }
+ cmdlen = strlen (command);
+ }
+ }
+
+ FILE* f = popen (command, "r");
+
+ if (!f) {
+ return NULL;
+ }
+
+ while (!feof (f)) {
+ char buf[1024]; /* lsof doesn't output much */
+
+ if (!fgets (buf, sizeof(buf), f)) {
+ break;
+ }
+
+ if (*buf != 'p') {
+ return NULL;
+ }
+
+ /* buf contains NULL as a separator between the process field and the command field */
+ char *pid = buf;
+ ++pid; /* skip leading 'p' */
+ char *cmd = pid;
+
+ /* skip to NULL */
+ while (*cmd)
+ ++cmd;
+ ++cmd; /* skip to 'c' */
+ ++cmd; /* skip to first character of command */
+
+ snprintf (found + flen, sizeof(found) - flen, "%s (process ID %s)\n", cmd, pid);
+ flen = strlen (found);
+
+ if (flen >= sizeof(found)) {
+ break;
+ }
+ }
+
+ pclose (f);
+
+ if (flen) {
+ return strdup (found);
+ } else {
+ return NULL;
+ }
+}
+
+
+static jack_driver_t *
+alsa_driver_new (char *name, char *playback_alsa_device,
+ char *capture_alsa_device,
+ jack_client_t *client,
+ jack_nframes_t frames_per_cycle,
+ jack_nframes_t user_nperiods,
+ jack_nframes_t rate,
+ int hw_monitoring,
+ int hw_metering,
+ int capturing,
+ int playing,
+ DitherAlgorithm dither,
+ int soft_mode,
+ int monitor,
+ int user_capture_nchnls,
+ int user_playback_nchnls,
+ int shorts_first,
+ jack_nframes_t capture_latency,
+ jack_nframes_t playback_latency
)
{
int err;
- char* current_apps;
+ char* current_apps;
alsa_driver_t *driver;
jack_info ("creating alsa driver ... %s|%s|%" PRIu32 "|%" PRIu32
- "|%" PRIu32"|%" PRIu32"|%" PRIu32 "|%s|%s|%s|%s",
- playing ? playback_alsa_device : "-",
- capturing ? capture_alsa_device : "-",
- frames_per_cycle, user_nperiods, rate,
- user_capture_nchnls,user_playback_nchnls,
- hw_monitoring ? "hwmon": "nomon",
- hw_metering ? "hwmeter":"swmeter",
- soft_mode ? "soft-mode":"-",
- shorts_first ? "16bit":"32bit");
-
- driver = (alsa_driver_t *) calloc (1, sizeof (alsa_driver_t));
-
- jack_driver_nt_init ((jack_driver_nt_t *) driver);
-
- driver->nt_attach = (JackDriverNTAttachFunction) alsa_driver_attach;
- driver->nt_detach = (JackDriverNTDetachFunction) alsa_driver_detach;
- driver->read = (JackDriverReadFunction) alsa_driver_read;
- driver->write = (JackDriverReadFunction) alsa_driver_write;
+ "|%" PRIu32 "|%" PRIu32 "|%" PRIu32 "|%s|%s|%s|%s",
+ playing ? playback_alsa_device : "-",
+ capturing ? capture_alsa_device : "-",
+ frames_per_cycle, user_nperiods, rate,
+ user_capture_nchnls, user_playback_nchnls,
+ hw_monitoring ? "hwmon" : "nomon",
+ hw_metering ? "hwmeter" : "swmeter",
+ soft_mode ? "soft-mode" : "-",
+ shorts_first ? "16bit" : "32bit");
+
+ driver = (alsa_driver_t*)calloc (1, sizeof(alsa_driver_t));
+
+ jack_driver_nt_init ((jack_driver_nt_t*)driver);
+
+ driver->nt_attach = (JackDriverNTAttachFunction)alsa_driver_attach;
+ driver->nt_detach = (JackDriverNTDetachFunction)alsa_driver_detach;
+ driver->read = (JackDriverReadFunction)alsa_driver_read;
+ driver->write = (JackDriverReadFunction)alsa_driver_write;
driver->null_cycle =
- (JackDriverNullCycleFunction) alsa_driver_null_cycle;
- driver->nt_bufsize = (JackDriverNTBufSizeFunction) alsa_driver_bufsize;
- driver->nt_start = (JackDriverNTStartFunction) alsa_driver_start;
- driver->nt_stop = (JackDriverNTStopFunction) alsa_driver_stop;
- driver->nt_run_cycle = (JackDriverNTRunCycleFunction) alsa_driver_run_cycle;
+ (JackDriverNullCycleFunction)alsa_driver_null_cycle;
+ driver->nt_bufsize = (JackDriverNTBufSizeFunction)alsa_driver_bufsize;
+ driver->nt_start = (JackDriverNTStartFunction)alsa_driver_start;
+ driver->nt_stop = (JackDriverNTStopFunction)alsa_driver_stop;
+ driver->nt_run_cycle = (JackDriverNTRunCycleFunction)alsa_driver_run_cycle;
driver->playback_handle = NULL;
driver->capture_handle = NULL;
@@ -2189,8 +2188,8 @@ alsa_driver_detach (alsa_driver_t *driver)
driver->user_nchannels = 0;
driver->playback_nchannels = user_playback_nchnls;
driver->capture_nchannels = user_capture_nchnls;
- driver->playback_sample_bytes = (shorts_first ? 2:4);
- driver->capture_sample_bytes = (shorts_first ? 2:4);
+ driver->playback_sample_bytes = (shorts_first ? 2 : 4);
+ driver->capture_sample_bytes = (shorts_first ? 2 : 4);
driver->capture_frame_latency = capture_latency;
driver->playback_frame_latency = playback_latency;
@@ -2198,14 +2197,14 @@ alsa_driver_detach (alsa_driver_t *driver)
driver->capture_addr = 0;
driver->playback_interleave_skip = NULL;
driver->capture_interleave_skip = NULL;
- driver->previously_successfully_configured = FALSE;
+ driver->previously_successfully_configured = FALSE;
driver->silent = 0;
driver->all_monitor_in = FALSE;
driver->with_monitor_ports = monitor;
- driver->clock_mode = ClockMaster; /* XXX is it? */
- driver->input_monitor_mask = 0; /* XXX is it? */
+ driver->clock_mode = ClockMaster; /* XXX is it? */
+ driver->input_monitor_mask = 0; /* XXX is it? */
driver->capture_ports = 0;
driver->playback_ports = 0;
@@ -2246,23 +2245,23 @@ alsa_driver_detach (alsa_driver_t *driver)
SND_PCM_NONBLOCK) < 0) {
switch (errno) {
case EBUSY:
- current_apps = discover_alsa_using_apps ();
- if (current_apps) {
- jack_error ("\n\nATTENTION: The playback device \"%s\" is "
- "already in use. The following applications "
- " are using your soundcard(s) so you should "
- " check them and stop them as necessary before "
- " trying to start JACK again:\n\n%s",
- playback_alsa_device,
- current_apps);
- free (current_apps);
- } else {
- jack_error ("\n\nATTENTION: The playback device \"%s\" is "
- "already in use. Please stop the"
- " application using it and "
- "run JACK again",
- playback_alsa_device);
- }
+ current_apps = discover_alsa_using_apps ();
+ if (current_apps) {
+ jack_error ("\n\nATTENTION: The playback device \"%s\" is "
+ "already in use. The following applications "
+ " are using your soundcard(s) so you should "
+ " check them and stop them as necessary before "
+ " trying to start JACK again:\n\n%s",
+ playback_alsa_device,
+ current_apps);
+ free (current_apps);
+ } else {
+ jack_error ("\n\nATTENTION: The playback device \"%s\" is "
+ "already in use. Please stop the"
+ " application using it and "
+ "run JACK again",
+ playback_alsa_device);
+ }
alsa_driver_delete (driver);
return NULL;
break;
@@ -2291,23 +2290,23 @@ alsa_driver_detach (alsa_driver_t *driver)
SND_PCM_NONBLOCK) < 0) {
switch (errno) {
case EBUSY:
- current_apps = discover_alsa_using_apps ();
- if (current_apps) {
- jack_error ("\n\nATTENTION: The capture device \"%s\" is "
- "already in use. The following applications "
- " are using your soundcard(s) so you should "
- " check them and stop them as necessary before "
- " trying to start JACK again:\n\n%s",
- capture_alsa_device,
- current_apps);
- free (current_apps);
- } else {
- jack_error ("\n\nATTENTION: The capture (recording) device \"%s\" is "
- "already in use. Please stop the"
- " application using it and "
- "run JACK again",
- capture_alsa_device);
- }
+ current_apps = discover_alsa_using_apps ();
+ if (current_apps) {
+ jack_error ("\n\nATTENTION: The capture device \"%s\" is "
+ "already in use. The following applications "
+ " are using your soundcard(s) so you should "
+ " check them and stop them as necessary before "
+ " trying to start JACK again:\n\n%s",
+ capture_alsa_device,
+ current_apps);
+ free (current_apps);
+ } else {
+ jack_error ("\n\nATTENTION: The capture (recording) device \"%s\" is "
+ "already in use. Please stop the"
+ " application using it and "
+ "run JACK again",
+ capture_alsa_device);
+ }
alsa_driver_delete (driver);
return NULL;
break;
@@ -2423,11 +2422,11 @@ alsa_driver_detach (alsa_driver_t *driver)
}
}
- jack_set_latency_callback (client, alsa_driver_latency_callback, driver);
+ jack_set_latency_callback (client, alsa_driver_latency_callback, driver);
driver->client = client;
- return (jack_driver_t *) driver;
+ return (jack_driver_t*)driver;
}
int
@@ -2437,7 +2436,7 @@ alsa_driver_listen_for_clock_sync_status (alsa_driver_t *driver,
{
ClockSyncListener *csl;
- csl = (ClockSyncListener *) malloc (sizeof (ClockSyncListener));
+ csl = (ClockSyncListener*)malloc (sizeof(ClockSyncListener));
csl->function = func;
csl->arg = arg;
csl->id = driver->next_clock_sync_listener_id++;
@@ -2456,10 +2455,11 @@ alsa_driver_stop_listening_to_clock_sync_status (alsa_driver_t *driver,
{
JSList *node;
int ret = -1;
+
pthread_mutex_lock (&driver->clock_sync_lock);
for (node = driver->clock_sync_listeners; node;
node = jack_slist_next (node)) {
- if (((ClockSyncListener *) node->data)->id == which) {
+ if (((ClockSyncListener*)node->data)->id == which) {
driver->clock_sync_listeners =
jack_slist_remove_link (
driver->clock_sync_listeners, node);
@@ -2482,7 +2482,7 @@ alsa_driver_clock_sync_notify (alsa_driver_t *driver, channel_t chn,
pthread_mutex_lock (&driver->clock_sync_lock);
for (node = driver->clock_sync_listeners; node;
node = jack_slist_next (node)) {
- ClockSyncListener *csl = (ClockSyncListener *) node->data;
+ ClockSyncListener *csl = (ClockSyncListener*)node->data;
csl->function (chn, status, csl->arg);
}
pthread_mutex_unlock (&driver->clock_sync_lock);
@@ -2529,12 +2529,12 @@ driver_get_descriptor ()
jack_driver_param_desc_t * params;
unsigned int i;
- desc = calloc (1, sizeof (jack_driver_desc_t));
+ desc = calloc (1, sizeof(jack_driver_desc_t));
- strcpy (desc->name,"alsa");
+ strcpy (desc->name, "alsa");
desc->nparams = 18;
- params = calloc (desc->nparams, sizeof (jack_driver_param_desc_t));
+ params = calloc (desc->nparams, sizeof(jack_driver_param_desc_t));
i = 0;
strcpy (params[i].name, "capture");
@@ -2591,7 +2591,7 @@ driver_get_descriptor ()
params[i].character = 'H';
params[i].type = JackDriverParamBool;
params[i].value.i = 0;
- strcpy (params[i].short_desc,"Hardware monitoring, if available");
+ strcpy (params[i].short_desc, "Hardware monitoring, if available");
strcpy (params[i].long_desc, params[i].short_desc);
i++;
@@ -2614,7 +2614,7 @@ driver_get_descriptor ()
i++;
strcpy (params[i].name, "softmode");
params[i].character = 's';
- params[i].type = JackDriverParamBool;
+ params[i].type = JackDriverParamBool;
params[i].value.i = 0;
strcpy (params[i].short_desc, "Soft-mode, no xrun handling");
strcpy (params[i].long_desc, params[i].short_desc);
@@ -2699,7 +2699,7 @@ driver_get_descriptor ()
jack_driver_t *
driver_initialize (jack_client_t *client, const JSList * params)
{
- jack_nframes_t srate = 48000;
+ jack_nframes_t srate = 48000;
jack_nframes_t frames_per_interrupt = 1024;
unsigned long user_nperiods = 2;
char *playback_pcm_name = "hw:0";
@@ -2720,7 +2720,7 @@ driver_initialize (jack_client_t *client, const JSList * params)
const jack_driver_param_t * param;
for (node = params; node; node = jack_slist_next (node)) {
- param = (const jack_driver_param_t *) node->data;
+ param = (const jack_driver_param_t*)node->data;
switch (param->character) {
@@ -2761,9 +2761,9 @@ driver_initialize (jack_client_t *client, const JSList * params)
break;
case 'r':
- srate = param->value.ui;
+ srate = param->value.ui;
jack_info ("apparent rate = %d", srate);
- break;
+ break;
case 'p':
frames_per_interrupt = param->value.ui;
@@ -2771,8 +2771,9 @@ driver_initialize (jack_client_t *client, const JSList * params)
case 'n':
user_nperiods = param->value.ui;
- if (user_nperiods < 2) /* enforce minimum value */
+ if (user_nperiods < 2) { /* enforce minimum value */
user_nperiods = 2;
+ }
break;
case 's':
@@ -2781,7 +2782,7 @@ driver_initialize (jack_client_t *client, const JSList * params)
case 'z':
if (dither_opt (param->value.c, &dither)) {
- return NULL;
+ return NULL;
}
break;
@@ -2789,7 +2790,7 @@ driver_initialize (jack_client_t *client, const JSList * params)
user_capture_nchnls = param->value.ui;
break;
case 'o':
- user_playback_nchnls = param->value.ui;
+ user_playback_nchnls = param->value.ui;
break;
case 'S':
@@ -2805,7 +2806,7 @@ driver_initialize (jack_client_t *client, const JSList * params)
break;
case 'X':
- /* ignored, legacy option */
+ /* ignored, legacy option */
break;
}
@@ -2832,5 +2833,5 @@ driver_initialize (jack_client_t *client, const JSList * params)
void
driver_finish (jack_driver_t *driver)
{
- alsa_driver_delete ((alsa_driver_t *) driver);
+ alsa_driver_delete ((alsa_driver_t*)driver);
}
diff --git a/drivers/alsa/alsa_driver.h b/drivers/alsa/alsa_driver.h
index 074ac69..5066bcc 100644
--- a/drivers/alsa/alsa_driver.h
+++ b/drivers/alsa/alsa_driver.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2001 Paul Davis
+ Copyright (C) 2001 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#ifndef __jack_alsa_driver_h__
#define __jack_alsa_driver_h__
@@ -38,180 +38,183 @@
#include "driver.h"
#include "memops.h"
-typedef void (*ReadCopyFunction) (jack_default_audio_sample_t *dst, char *src,
- unsigned long src_bytes,
- unsigned long src_skip_bytes);
-typedef void (*WriteCopyFunction) (char *dst, jack_default_audio_sample_t *src,
- unsigned long src_bytes,
- unsigned long dst_skip_bytes,
- dither_state_t *state);
+typedef void (*ReadCopyFunction)(jack_default_audio_sample_t *dst, char *src,
+ unsigned long src_bytes,
+ unsigned long src_skip_bytes);
+typedef void (*WriteCopyFunction)(char *dst, jack_default_audio_sample_t *src,
+ unsigned long src_bytes,
+ unsigned long dst_skip_bytes,
+ dither_state_t *state);
typedef struct _alsa_driver {
- JACK_DRIVER_NT_DECL
-
- int poll_timeout;
- jack_time_t poll_last;
- jack_time_t poll_next;
- char **playback_addr;
- char **capture_addr;
- const snd_pcm_channel_area_t *capture_areas;
- const snd_pcm_channel_area_t *playback_areas;
- struct pollfd *pfd;
- unsigned int playback_nfds;
- unsigned int capture_nfds;
- unsigned long interleave_unit;
- unsigned long *capture_interleave_skip;
- unsigned long *playback_interleave_skip;
- channel_t max_nchannels;
- channel_t user_nchannels;
- channel_t playback_nchannels;
- channel_t capture_nchannels;
- unsigned long playback_sample_bytes;
- unsigned long capture_sample_bytes;
-
- jack_nframes_t frame_rate;
- jack_nframes_t frames_per_cycle;
- jack_nframes_t capture_frame_latency;
- jack_nframes_t playback_frame_latency;
-
- unsigned long *silent;
- char *alsa_name_playback;
- char *alsa_name_capture;
- char *alsa_driver;
- bitset_t channels_not_done;
- bitset_t channels_done;
- snd_pcm_format_t playback_sample_format;
- snd_pcm_format_t capture_sample_format;
- float max_sample_val;
- unsigned long user_nperiods;
- unsigned int playback_nperiods;
- unsigned int capture_nperiods;
- unsigned long last_mask;
- snd_ctl_t *ctl_handle;
- snd_pcm_t *playback_handle;
- snd_pcm_t *capture_handle;
- snd_pcm_hw_params_t *playback_hw_params;
- snd_pcm_sw_params_t *playback_sw_params;
- snd_pcm_hw_params_t *capture_hw_params;
- snd_pcm_sw_params_t *capture_sw_params;
- jack_hardware_t *hw;
- ClockSyncStatus *clock_sync_data;
- jack_client_t *client;
- JSList *capture_ports;
- JSList *playback_ports;
- JSList *monitor_ports;
-
- unsigned long input_monitor_mask;
-
- char soft_mode;
- char hw_monitoring;
- char hw_metering;
- char all_monitor_in;
- char capture_and_playback_not_synced;
- char playback_interleaved;
- char capture_interleaved;
- char with_monitor_ports;
- char has_clock_sync_reporting;
- char has_hw_monitoring;
- char has_hw_metering;
- char quirk_bswap;
-
- ReadCopyFunction read_via_copy;
- WriteCopyFunction write_via_copy;
-
- int dither;
- dither_state_t *dither_state;
-
- SampleClockMode clock_mode;
- JSList *clock_sync_listeners;
- pthread_mutex_t clock_sync_lock;
- unsigned long next_clock_sync_listener_id;
-
- int running;
- int run;
-
- int poll_late;
- int xrun_count;
- int process_count;
-
- int xrun_recovery;
- int previously_successfully_configured;
+ JACK_DRIVER_NT_DECL
+
+ int poll_timeout;
+ jack_time_t poll_last;
+ jack_time_t poll_next;
+ char **playback_addr;
+ char **capture_addr;
+ const snd_pcm_channel_area_t *capture_areas;
+ const snd_pcm_channel_area_t *playback_areas;
+ struct pollfd *pfd;
+ unsigned int playback_nfds;
+ unsigned int capture_nfds;
+ unsigned long interleave_unit;
+ unsigned long *capture_interleave_skip;
+ unsigned long *playback_interleave_skip;
+ channel_t max_nchannels;
+ channel_t user_nchannels;
+ channel_t playback_nchannels;
+ channel_t capture_nchannels;
+ unsigned long playback_sample_bytes;
+ unsigned long capture_sample_bytes;
+
+ jack_nframes_t frame_rate;
+ jack_nframes_t frames_per_cycle;
+ jack_nframes_t capture_frame_latency;
+ jack_nframes_t playback_frame_latency;
+
+ unsigned long *silent;
+ char *alsa_name_playback;
+ char *alsa_name_capture;
+ char *alsa_driver;
+ bitset_t channels_not_done;
+ bitset_t channels_done;
+ snd_pcm_format_t playback_sample_format;
+ snd_pcm_format_t capture_sample_format;
+ float max_sample_val;
+ unsigned long user_nperiods;
+ unsigned int playback_nperiods;
+ unsigned int capture_nperiods;
+ unsigned long last_mask;
+ snd_ctl_t *ctl_handle;
+ snd_pcm_t *playback_handle;
+ snd_pcm_t *capture_handle;
+ snd_pcm_hw_params_t *playback_hw_params;
+ snd_pcm_sw_params_t *playback_sw_params;
+ snd_pcm_hw_params_t *capture_hw_params;
+ snd_pcm_sw_params_t *capture_sw_params;
+ jack_hardware_t *hw;
+ ClockSyncStatus *clock_sync_data;
+ jack_client_t *client;
+ JSList *capture_ports;
+ JSList *playback_ports;
+ JSList *monitor_ports;
+
+ unsigned long input_monitor_mask;
+
+ char soft_mode;
+ char hw_monitoring;
+ char hw_metering;
+ char all_monitor_in;
+ char capture_and_playback_not_synced;
+ char playback_interleaved;
+ char capture_interleaved;
+ char with_monitor_ports;
+ char has_clock_sync_reporting;
+ char has_hw_monitoring;
+ char has_hw_metering;
+ char quirk_bswap;
+
+ ReadCopyFunction read_via_copy;
+ WriteCopyFunction write_via_copy;
+
+ int dither;
+ dither_state_t *dither_state;
+
+ SampleClockMode clock_mode;
+ JSList *clock_sync_listeners;
+ pthread_mutex_t clock_sync_lock;
+ unsigned long next_clock_sync_listener_id;
+
+ int running;
+ int run;
+
+ int poll_late;
+ int xrun_count;
+ int process_count;
+
+ int xrun_recovery;
+ int previously_successfully_configured;
} alsa_driver_t;
-static inline void
-alsa_driver_mark_channel_done (alsa_driver_t *driver, channel_t chn) {
+static inline void
+alsa_driver_mark_channel_done (alsa_driver_t *driver, channel_t chn)
+{
bitset_remove (driver->channels_not_done, chn);
driver->silent[chn] = 0;
}
-static inline void
+static inline void
alsa_driver_silence_on_channel (alsa_driver_t *driver, channel_t chn,
- jack_nframes_t nframes) {
+ jack_nframes_t nframes)
+{
if (driver->playback_interleaved) {
- memset_interleave
+ memset_interleave
(driver->playback_addr[chn],
- 0, nframes * driver->playback_sample_bytes,
- driver->interleave_unit,
- driver->playback_interleave_skip[chn]);
+ 0, nframes * driver->playback_sample_bytes,
+ driver->interleave_unit,
+ driver->playback_interleave_skip[chn]);
} else {
memset (driver->playback_addr[chn], 0,
nframes * driver->playback_sample_bytes);
}
- alsa_driver_mark_channel_done (driver,chn);
+ alsa_driver_mark_channel_done (driver, chn);
}
-static inline void
+static inline void
alsa_driver_silence_on_channel_no_mark (alsa_driver_t *driver, channel_t chn,
- jack_nframes_t nframes) {
+ jack_nframes_t nframes)
+{
if (driver->playback_interleaved) {
- memset_interleave
+ memset_interleave
(driver->playback_addr[chn],
- 0, nframes * driver->playback_sample_bytes,
- driver->interleave_unit,
- driver->playback_interleave_skip[chn]);
+ 0, nframes * driver->playback_sample_bytes,
+ driver->interleave_unit,
+ driver->playback_interleave_skip[chn]);
} else {
memset (driver->playback_addr[chn], 0,
nframes * driver->playback_sample_bytes);
}
}
-static inline void
+static inline void
alsa_driver_read_from_channel (alsa_driver_t *driver,
channel_t channel,
jack_default_audio_sample_t *buf,
jack_nframes_t nsamples)
{
- driver->read_via_copy (buf,
+ driver->read_via_copy (buf,
driver->capture_addr[channel],
- nsamples,
+ nsamples,
driver->capture_interleave_skip[channel]);
}
-static inline void
+static inline void
alsa_driver_write_to_channel (alsa_driver_t *driver,
- channel_t channel,
- jack_default_audio_sample_t *buf,
+ channel_t channel,
+ jack_default_audio_sample_t *buf,
jack_nframes_t nsamples)
{
driver->write_via_copy (driver->playback_addr[channel],
- buf,
- nsamples,
+ buf,
+ nsamples,
driver->playback_interleave_skip[channel],
- driver->dither_state+channel);
+ driver->dither_state + channel);
alsa_driver_mark_channel_done (driver, channel);
}
-void alsa_driver_silence_untouched_channels (alsa_driver_t *driver,
- jack_nframes_t nframes);
-void alsa_driver_set_clock_sync_status (alsa_driver_t *driver, channel_t chn,
- ClockSyncStatus status);
-int alsa_driver_listen_for_clock_sync_status (alsa_driver_t *,
- ClockSyncListenerFunction,
- void *arg);
-int alsa_driver_stop_listen_for_clock_sync_status (alsa_driver_t *,
- unsigned int);
-void alsa_driver_clock_sync_notify (alsa_driver_t *, channel_t chn,
- ClockSyncStatus);
+void alsa_driver_silence_untouched_channels(alsa_driver_t *driver,
+ jack_nframes_t nframes);
+void alsa_driver_set_clock_sync_status(alsa_driver_t *driver, channel_t chn,
+ ClockSyncStatus status);
+int alsa_driver_listen_for_clock_sync_status (alsa_driver_t *,
+ ClockSyncListenerFunction,
+ void *arg);
+int alsa_driver_stop_listen_for_clock_sync_status(alsa_driver_t *,
+ unsigned int);
+void alsa_driver_clock_sync_notify (alsa_driver_t *, channel_t chn,
+ ClockSyncStatus);
#endif /* __jack_alsa_driver_h__ */
diff --git a/drivers/alsa/generic.h b/drivers/alsa/generic.h
index 73dc593..434e610 100644
--- a/drivers/alsa/generic.h
+++ b/drivers/alsa/generic.h
@@ -1,6 +1,6 @@
/*
Copyright (C) 2001 Paul Davis
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -15,12 +15,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#ifndef __jack_generic_h__
#define __jack_generic_h__
jack_hardware_t *
-jack_alsa_generic_hw_new (alsa_driver_t *driver);
+jack_alsa_generic_hw_new(alsa_driver_t *driver);
#endif /* __jack_generic_h__*/
diff --git a/drivers/alsa/generic_hw.c b/drivers/alsa/generic_hw.c
index 69457e2..f65f00d 100644
--- a/drivers/alsa/generic_hw.c
+++ b/drivers/alsa/generic_hw.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2001 Paul Davis
+ Copyright (C) 2001 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#include "hardware.h"
#include "alsa_driver.h"
@@ -25,7 +25,7 @@ static int generic_set_input_monitor_mask (jack_hardware_t *hw, unsigned long ma
return -1;
}
-static int generic_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
+static int generic_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
{
return -1;
}
@@ -42,11 +42,11 @@ jack_alsa_generic_hw_new (alsa_driver_t *driver)
{
jack_hardware_t *hw;
- hw = (jack_hardware_t *) malloc (sizeof (jack_hardware_t));
+ hw = (jack_hardware_t*)malloc (sizeof(jack_hardware_t));
hw->capabilities = 0;
hw->input_monitor_mask = 0;
-
+
hw->set_input_monitor_mask = generic_set_input_monitor_mask;
hw->change_sample_clock = generic_change_sample_clock;
hw->release = generic_release;
diff --git a/drivers/alsa/hammerfall.c b/drivers/alsa/hammerfall.c
index fcb9add..531d73a 100644
--- a/drivers/alsa/hammerfall.c
+++ b/drivers/alsa/hammerfall.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2001 Paul Davis
+ Copyright (C) 2001 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#include "hardware.h"
#include "alsa_driver.h"
@@ -26,7 +26,7 @@
* warning: `hammerfall_monitor_controls' defined but not used */
#define HAMMERFALL_MONITOR_CONTROLS 0
-static void
+static void
set_control_id (snd_ctl_elem_id_t *ctl, const char *name)
{
snd_ctl_elem_id_set_name (ctl, name);
@@ -57,9 +57,8 @@ hammerfall_broadcast_channel_status_change (hammerfall_t *h, int lock, int sync,
status |= NoSync;
}
- for (chn = lowchn; chn < highchn; chn++) {
+ for (chn = lowchn; chn < highchn; chn++)
alsa_driver_set_clock_sync_status (h->driver, chn, status);
- }
}
static void
@@ -74,12 +73,12 @@ hammerfall_check_sync_state (hammerfall_t *h, int val, int adat_id)
XXX - maybe need to make sure that the rate matches our
idea of the current rate ?
- */
+ */
if (!h->said_that_spdif_is_fine) {
ClockSyncStatus status;
-
- status = Lock|Sync;
+
+ status = Lock | Sync;
/* XXX broken! fix for hammerfall light ! */
@@ -91,10 +90,10 @@ hammerfall_check_sync_state (hammerfall_t *h, int val, int adat_id)
lock = (val & 0x1) ? TRUE : FALSE;
sync = (val & 0x2) ? TRUE : FALSE;
-
+
if (h->lock_status[adat_id] != lock ||
h->sync_status[adat_id] != sync) {
- hammerfall_broadcast_channel_status_change (h, lock, sync, adat_id*8, (adat_id*8)+8);
+ hammerfall_broadcast_channel_status_change (h, lock, sync, adat_id * 8, (adat_id * 8) + 8);
}
h->lock_status[adat_id] = lock;
@@ -108,7 +107,7 @@ hammerfall_check_sync (hammerfall_t *h, snd_ctl_elem_value_t *ctl)
const char *name;
int val;
snd_ctl_elem_id_t *ctl_id;
-
+
jack_info ("check sync");
snd_ctl_elem_id_alloca (&ctl_id);
@@ -131,38 +130,37 @@ hammerfall_check_sync (hammerfall_t *h, snd_ctl_elem_value_t *ctl)
}
#endif /* HAMMERFALL_MONITOR_CONTROLS */
-static int
+static int
hammerfall_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask)
{
- hammerfall_t *h = (hammerfall_t *) hw->private;
+ hammerfall_t *h = (hammerfall_t*)hw->private;
snd_ctl_elem_value_t *ctl;
snd_ctl_elem_id_t *ctl_id;
int err;
int i;
-
+
snd_ctl_elem_value_alloca (&ctl);
snd_ctl_elem_id_alloca (&ctl_id);
set_control_id (ctl_id, "Channels Thru");
snd_ctl_elem_value_set_id (ctl, ctl_id);
-
- for (i = 0; i < 26; i++) {
- snd_ctl_elem_value_set_integer (ctl, i, (mask & (1<<i)) ? 1 : 0);
- }
-
+
+ for (i = 0; i < 26; i++)
+ snd_ctl_elem_value_set_integer (ctl, i, (mask & (1 << i)) ? 1 : 0);
+
if ((err = snd_ctl_elem_write (h->driver->ctl_handle, ctl)) != 0) {
jack_error ("ALSA/Hammerfall: cannot set input monitoring (%s)", snd_strerror (err));
return -1;
}
-
+
hw->input_monitor_mask = mask;
return 0;
}
-static int
-hammerfall_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
+static int
+hammerfall_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
{
- hammerfall_t *h = (hammerfall_t *) hw->private;
+ hammerfall_t *h = (hammerfall_t*)hw->private;
snd_ctl_elem_value_t *ctl;
snd_ctl_elem_id_t *ctl_id;
int err;
@@ -195,7 +193,7 @@ static void
hammerfall_release (jack_hardware_t *hw)
{
- hammerfall_t *h = (hammerfall_t *) hw->private;
+ hammerfall_t *h = (hammerfall_t*)hw->private;
void *status;
if (h == 0) {
@@ -212,8 +210,8 @@ hammerfall_release (jack_hardware_t *hw)
static void *
hammerfall_monitor_controls (void *arg)
{
- jack_hardware_t *hw = (jack_hardware_t *) arg;
- hammerfall_t *h = (hammerfall_t *) hw->private;
+ jack_hardware_t *hw = (jack_hardware_t*)arg;
+ hammerfall_t *h = (hammerfall_t*)hw->private;
snd_ctl_elem_id_t *switch_id[3];
snd_ctl_elem_value_t *sw[3];
@@ -250,7 +248,7 @@ hammerfall_monitor_controls (void *arg)
jack_error ("cannot read control switch 0 ...");
}
hammerfall_check_sync (h, sw[2]);
-
+
if (nanosleep (&h->monitor_interval, 0)) {
break;
}
@@ -267,9 +265,9 @@ jack_alsa_hammerfall_hw_new (alsa_driver_t *driver)
jack_hardware_t *hw;
hammerfall_t *h;
- hw = (jack_hardware_t *) malloc (sizeof (jack_hardware_t));
+ hw = (jack_hardware_t*)malloc (sizeof(jack_hardware_t));
- hw->capabilities = Cap_HardwareMonitoring|Cap_AutoSync|Cap_WordClock|Cap_ClockMaster|Cap_ClockLockReporting;
+ hw->capabilities = Cap_HardwareMonitoring | Cap_AutoSync | Cap_WordClock | Cap_ClockMaster | Cap_ClockLockReporting;
hw->input_monitor_mask = 0;
hw->private = 0;
@@ -277,7 +275,7 @@ jack_alsa_hammerfall_hw_new (alsa_driver_t *driver)
hw->change_sample_clock = hammerfall_change_sample_clock;
hw->release = hammerfall_release;
- h = (hammerfall_t *) malloc (sizeof (hammerfall_t));
+ h = (hammerfall_t*)malloc (sizeof(hammerfall_t));
h->lock_status[0] = FALSE;
h->sync_status[0] = FALSE;
diff --git a/drivers/alsa/hammerfall.h b/drivers/alsa/hammerfall.h
index b10ce6a..9077114 100644
--- a/drivers/alsa/hammerfall.h
+++ b/drivers/alsa/hammerfall.h
@@ -1,6 +1,6 @@
/*
Copyright (C) 2001 Paul Davis
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#ifndef __jack_hammerfall_h__
#define __jack_hammerfall_h__
@@ -23,14 +23,14 @@
#include <sys/time.h>
typedef struct {
- int lock_status[3];
- int sync_status[3];
- int said_that_spdif_is_fine;
- pthread_t monitor_thread;
- alsa_driver_t *driver;
- struct timespec monitor_interval;
+ int lock_status[3];
+ int sync_status[3];
+ int said_that_spdif_is_fine;
+ pthread_t monitor_thread;
+ alsa_driver_t *driver;
+ struct timespec monitor_interval;
} hammerfall_t;
-jack_hardware_t *jack_alsa_hammerfall_hw_new (alsa_driver_t *driver);
+jack_hardware_t *jack_alsa_hammerfall_hw_new(alsa_driver_t *driver);
#endif /* __jack_hammerfall_h__*/
diff --git a/drivers/alsa/hdsp.c b/drivers/alsa/hdsp.c
index cf28a91..bea357b 100644
--- a/drivers/alsa/hdsp.c
+++ b/drivers/alsa/hdsp.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2001 Paul Davis
+ Copyright (C) 2001 Paul Davis
Copyright (C) 2002 Dave LaRose
This program is free software; you can redistribute it and/or modify
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#include "hardware.h"
#include "alsa_driver.h"
@@ -29,45 +29,48 @@ static const int HDSP_UNITY_GAIN = 32768;
static const int HDSP_MAX_GAIN = 65535;
/*
- * Use these two arrays to choose the value of the input_channel
- * argument to hsdp_set_mixer_gain(). hdsp_physical_input_index[n]
- * selects the nth optical/analog input. audio_stream_index[n]
+ * Use these two arrays to choose the value of the input_channel
+ * argument to hsdp_set_mixer_gain(). hdsp_physical_input_index[n]
+ * selects the nth optical/analog input. audio_stream_index[n]
* selects the nth channel being received from the host via pci/pccard.
*/
static const int hdsp_num_input_channels = 52;
static const int hdsp_physical_input_index[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,24, 25
+};
static const int hdsp_audio_stream_index[] = {
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51};
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,50, 51
+};
/*
- * Use this array to choose the value of the output_channel
+ * Use this array to choose the value of the output_channel
* argument to hsdp_set_mixer_gain(). hdsp_physical_output_index[26]
* and hdsp_physical_output_index[27] refer to the two "line out"
* channels (1/4" phone jack on the front of digiface/multiface).
*/
static const int hdsp_num_output_channels = 28;
static const int hdsp_physical_output_index[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,24, 25, 26, 27
+};
/* Function for checking argument values */
-static int clamp_int(int value, int lower_bound, int upper_bound)
+static int clamp_int (int value, int lower_bound, int upper_bound)
{
- if(value < lower_bound) {
- return lower_bound;
- }
- if(value > upper_bound) {
- return upper_bound;
- }
- return value;
+ if (value < lower_bound) {
+ return lower_bound;
+ }
+ if (value > upper_bound) {
+ return upper_bound;
+ }
+ return value;
}
/* Note(XXX): Maybe should share this code with hammerfall.c? */
-static void
+static void
set_control_id (snd_ctl_elem_id_t *ctl, const char *name)
{
snd_ctl_elem_id_set_name (ctl, name);
@@ -86,18 +89,18 @@ set_control_id (snd_ctl_elem_id_t *ctl, const char *name)
/* gain is an int from 0 to 65535, with 0 being -inf gain, and */
/* 65535 being about +2dB. */
-static int hdsp_set_mixer_gain(jack_hardware_t *hw, int input_channel,
- int output_channel, int gain)
+static int hdsp_set_mixer_gain (jack_hardware_t *hw, int input_channel,
+ int output_channel, int gain)
{
- hdsp_t *h = (hdsp_t *) hw->private;
+ hdsp_t *h = (hdsp_t*)hw->private;
snd_ctl_elem_value_t *ctl;
snd_ctl_elem_id_t *ctl_id;
int err;
/* Check args */
- input_channel = clamp_int(input_channel, 0, hdsp_num_input_channels);
- output_channel = clamp_int(output_channel, 0, hdsp_num_output_channels);
- gain = clamp_int(gain, HDSP_MINUS_INFINITY_GAIN, HDSP_MAX_GAIN);
+ input_channel = clamp_int (input_channel, 0, hdsp_num_input_channels);
+ output_channel = clamp_int (output_channel, 0, hdsp_num_output_channels);
+ gain = clamp_int (gain, HDSP_MINUS_INFINITY_GAIN, HDSP_MAX_GAIN);
/* Allocate control element and select "Mixer" control */
snd_ctl_elem_value_alloca (&ctl);
@@ -106,15 +109,15 @@ static int hdsp_set_mixer_gain(jack_hardware_t *hw, int input_channel,
snd_ctl_elem_value_set_id (ctl, ctl_id);
/* Apparently non-standard and unstable interface for the */
- /* mixer control. */
+ /* mixer control. */
snd_ctl_elem_value_set_integer (ctl, 0, input_channel);
snd_ctl_elem_value_set_integer (ctl, 1, output_channel);
snd_ctl_elem_value_set_integer (ctl, 2, gain);
/* Commit the mixer value and check for errors */
if ((err = snd_ctl_elem_write (h->driver->ctl_handle, ctl)) != 0) {
- jack_error ("ALSA/HDSP: cannot set mixer gain (%s)", snd_strerror (err));
- return -1;
+ jack_error ("ALSA/HDSP: cannot set mixer gain (%s)", snd_strerror (err));
+ return -1;
}
/* Note (XXX): Perhaps we should maintain a cache of the current */
@@ -122,7 +125,7 @@ static int hdsp_set_mixer_gain(jack_hardware_t *hw, int input_channel,
/* hdsp hardware. We'll leave this out until a little later. */
return 0;
}
-
+
static int hdsp_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask)
{
int i;
@@ -130,40 +133,40 @@ static int hdsp_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask)
/* For each input channel */
for (i = 0; i < 26; i++) {
/* Monitoring requested for this channel? */
- if(mask & (1<<i)) {
+ if (mask & (1 << i)) {
/* Yes. Connect physical input to output */
- if(hdsp_set_mixer_gain (hw, hdsp_physical_input_index[i],
- hdsp_physical_output_index[i],
- HDSP_UNITY_GAIN) != 0) {
- return -1;
+ if (hdsp_set_mixer_gain (hw, hdsp_physical_input_index[i],
+ hdsp_physical_output_index[i],
+ HDSP_UNITY_GAIN) != 0) {
+ return -1;
}
#ifdef CANNOT_HEAR_SOFTWARE_STREAM_WHEN_MONITORING
/* ...and disconnect the corresponding software */
/* channel */
- if(hdsp_set_mixer_gain (hw, hdsp_audio_stream_index[i],
- hdsp_physical_output_index[i],
- HDSP_MINUS_INFINITY_GAIN) != 0) {
- return -1;
+ if (hdsp_set_mixer_gain (hw, hdsp_audio_stream_index[i],
+ hdsp_physical_output_index[i],
+ HDSP_MINUS_INFINITY_GAIN) != 0) {
+ return -1;
}
#endif
} else {
/* No. Disconnect physical input from output */
- if(hdsp_set_mixer_gain (hw, hdsp_physical_input_index[i],
- hdsp_physical_output_index[i],
- HDSP_MINUS_INFINITY_GAIN) != 0) {
- return -1;
+ if (hdsp_set_mixer_gain (hw, hdsp_physical_input_index[i],
+ hdsp_physical_output_index[i],
+ HDSP_MINUS_INFINITY_GAIN) != 0) {
+ return -1;
}
#ifdef CANNOT_HEAR_SOFTWARE_STREAM_WHEN_MONITORING
/* ...and connect the corresponding software */
/* channel */
- if(hdsp_set_mixer_gain (hw, hdsp_audio_stream_index[i],
- hdsp_physical_output_index[i],
- HDSP_UNITY_GAIN) != 0) {
- return -1;
+ if (hdsp_set_mixer_gain (hw, hdsp_audio_stream_index[i],
+ hdsp_physical_output_index[i],
+ HDSP_UNITY_GAIN) != 0) {
+ return -1;
}
#endif
}
@@ -174,11 +177,11 @@ static int hdsp_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask)
}
-static int hdsp_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
+static int hdsp_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
{
- // Empty for now, until Dave understands more about clock sync so
- // he can test.
- return -1;
+ // Empty for now, until Dave understands more about clock sync so
+ // he can test.
+ return -1;
}
static double hdsp_get_hardware_peak (jack_port_t *port, jack_nframes_t frame)
@@ -194,10 +197,10 @@ static double hdsp_get_hardware_power (jack_port_t *port, jack_nframes_t frame)
static void
hdsp_release (jack_hardware_t *hw)
{
- hdsp_t *h = (hdsp_t *) hw->private;
+ hdsp_t *h = (hdsp_t*)hw->private;
if (h != 0) {
- free (h);
+ free (h);
}
}
@@ -209,7 +212,7 @@ jack_alsa_hdsp_hw_new (alsa_driver_t *driver)
jack_hardware_t *hw;
hdsp_t *h;
- hw = (jack_hardware_t *) malloc (sizeof (jack_hardware_t));
+ hw = (jack_hardware_t*)malloc (sizeof(jack_hardware_t));
/* Not using clock lock-sync-whatever in home hardware setup */
/* yet. Will write this code when can test it. */
@@ -223,8 +226,8 @@ jack_alsa_hdsp_hw_new (alsa_driver_t *driver)
hw->release = hdsp_release;
hw->get_hardware_peak = hdsp_get_hardware_peak;
hw->get_hardware_power = hdsp_get_hardware_power;
-
- h = (hdsp_t *) malloc (sizeof (hdsp_t));
+
+ h = (hdsp_t*)malloc (sizeof(hdsp_t));
h->driver = driver;
hw->private = h;
diff --git a/drivers/alsa/hdsp.h b/drivers/alsa/hdsp.h
index cc2ad04..f62ac7d 100644
--- a/drivers/alsa/hdsp.h
+++ b/drivers/alsa/hdsp.h
@@ -1,6 +1,6 @@
/*
Copyright (C) 2001 Paul Davis
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#ifndef __jack_hdsp_h__
#define __jack_hdsp_h__
@@ -23,10 +23,10 @@
#include <sys/time.h>
typedef struct {
- alsa_driver_t *driver;
+ alsa_driver_t *driver;
} hdsp_t;
jack_hardware_t *
-jack_alsa_hdsp_hw_new (alsa_driver_t *driver);
+jack_alsa_hdsp_hw_new(alsa_driver_t *driver);
#endif /* __jack_hdsp_h__*/
diff --git a/drivers/alsa/ice1712.c b/drivers/alsa/ice1712.c
index 6c38364..9c96f96 100644
--- a/drivers/alsa/ice1712.c
+++ b/drivers/alsa/ice1712.c
@@ -1,7 +1,7 @@
/*
Copyright (C) 2002 Anthony Van Groningen
- Parts based on source code taken from the
+ Parts based on source code taken from the
"Env24 chipset (ICE1712) control utility" that is
Copyright (C) 2000 by Jaroslav Kysela <perex@suse.cz>
@@ -19,7 +19,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#include "hardware.h"
#include "alsa_driver.h"
@@ -27,13 +27,13 @@
#include "internal.h"
static int
-ice1712_hw_monitor_toggle(jack_hardware_t *hw, int idx, int onoff)
+ice1712_hw_monitor_toggle (jack_hardware_t *hw, int idx, int onoff)
{
- ice1712_t *h = (ice1712_t *) hw->private;
+ ice1712_t *h = (ice1712_t*)hw->private;
snd_ctl_elem_value_t *val;
int err;
-
+
snd_ctl_elem_value_alloca (&val);
snd_ctl_elem_value_set_interface (val, SND_CTL_ELEM_IFACE_MIXER);
if (idx >= 8) {
@@ -50,33 +50,33 @@ ice1712_hw_monitor_toggle(jack_hardware_t *hw, int idx, int onoff)
}
if ((err = snd_ctl_elem_write (h->driver->ctl_handle, val)) != 0) {
jack_error ("ALSA/ICE1712: (%d) cannot set input monitoring (%s)",
- idx,snd_strerror (err));
+ idx, snd_strerror (err));
return -1;
}
return 0;
}
-static int
+static int
ice1712_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask)
-
+
{
int idx;
- ice1712_t *h = (ice1712_t *) hw->private;
-
+ ice1712_t *h = (ice1712_t*)hw->private;
+
for (idx = 0; idx < 10; idx++) {
- if (h->active_channels & (1<<idx)) {
- ice1712_hw_monitor_toggle (hw, idx, mask & (1<<idx) ? 1 : 0);
+ if (h->active_channels & (1 << idx)) {
+ ice1712_hw_monitor_toggle (hw, idx, mask & (1 << idx) ? 1 : 0);
}
}
hw->input_monitor_mask = mask;
-
+
return 0;
}
-static int
-ice1712_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
-
+static int
+ice1712_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
+
{
return -1;
}
@@ -84,15 +84,17 @@ ice1712_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
static void
ice1712_release (jack_hardware_t *hw)
{
- ice1712_t *h = (ice1712_t *) hw->private;
-
- if (h == 0)
- return;
+ ice1712_t *h = (ice1712_t*)hw->private;
- if (h->eeprom)
- free(h->eeprom);
+ if (h == 0) {
+ return;
+ }
+
+ if (h->eeprom) {
+ free (h->eeprom);
+ }
- free(h);
+ free (h);
}
@@ -102,10 +104,10 @@ jack_alsa_ice1712_hw_new (alsa_driver_t *driver)
{
jack_hardware_t *hw;
ice1712_t *h;
- snd_ctl_elem_value_t *val;
+ snd_ctl_elem_value_t *val;
int err;
- hw = (jack_hardware_t *) malloc (sizeof (jack_hardware_t));
+ hw = (jack_hardware_t*)malloc (sizeof(jack_hardware_t));
hw->capabilities = Cap_HardwareMonitoring;
hw->input_monitor_mask = 0;
@@ -115,42 +117,42 @@ jack_alsa_ice1712_hw_new (alsa_driver_t *driver)
hw->change_sample_clock = ice1712_change_sample_clock;
hw->release = ice1712_release;
- h = (ice1712_t *) malloc (sizeof (ice1712_t));
+ h = (ice1712_t*)malloc (sizeof(ice1712_t));
h->driver = driver;
/* Get the EEPROM (adopted from envy24control) */
- h->eeprom = (ice1712_eeprom_t *) malloc (sizeof (ice1712_eeprom_t));
+ h->eeprom = (ice1712_eeprom_t*)malloc (sizeof(ice1712_eeprom_t));
snd_ctl_elem_value_alloca (&val);
snd_ctl_elem_value_set_interface (val, SND_CTL_ELEM_IFACE_CARD);
- snd_ctl_elem_value_set_name (val, "ICE1712 EEPROM");
- if ((err = snd_ctl_elem_read (driver->ctl_handle, val)) < 0) {
- jack_error( "ALSA/ICE1712: Unable to read EEPROM contents (%s)\n", snd_strerror (err));
- /* Recover? */
- }
- memcpy(h->eeprom, snd_ctl_elem_value_get_bytes(val), 32);
-
- /* determine number of pro ADC's. We're asumming that there is at least one stereo pair.
+ snd_ctl_elem_value_set_name (val, "ICE1712 EEPROM");
+ if ((err = snd_ctl_elem_read (driver->ctl_handle, val)) < 0) {
+ jack_error ( "ALSA/ICE1712: Unable to read EEPROM contents (%s)\n", snd_strerror (err));
+ /* Recover? */
+ }
+ memcpy (h->eeprom, snd_ctl_elem_value_get_bytes (val), 32);
+
+ /* determine number of pro ADC's. We're asumming that there is at least one stereo pair.
Should check this first, but how? */
- switch((h->eeprom->codec & 0xCU) >> 2) {
+ switch ((h->eeprom->codec & 0xCU) >> 2) {
case 0:
- h->active_channels = 0x3U;
- break;
+ h->active_channels = 0x3U;
+ break;
case 1:
- h->active_channels = 0xfU;
- break;
+ h->active_channels = 0xfU;
+ break;
case 2:
- h->active_channels = 0x3fU;
- break;
+ h->active_channels = 0x3fU;
+ break;
case 3:
- h->active_channels = 0xffU;
- break;
+ h->active_channels = 0xffU;
+ break;
}
/* check for SPDIF In's */
if (h->eeprom->spdif & 0x1U) {
- h->active_channels |= 0x300U;
+ h->active_channels |= 0x300U;
}
-
+
hw->private = h;
return hw;
diff --git a/drivers/alsa/ice1712.h b/drivers/alsa/ice1712.h
index 8dab29f..f68df57 100644
--- a/drivers/alsa/ice1712.h
+++ b/drivers/alsa/ice1712.h
@@ -1,11 +1,11 @@
/*
Copyright (C) 2002 Anthony Van Groningen
- Parts based on source code taken from the
+ Parts based on source code taken from the
"Env24 chipset (ICE1712) control utility" that is
Copyright (C) 2000 by Jaroslav Kysela <perex@suse.cz>
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -20,7 +20,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#ifndef __jack_ice1712_h__
#define __jack_ice1712_h__
@@ -36,31 +36,31 @@
#define MULTITRACK_PEAK_NAME "Multi Track Peak"
typedef struct {
- unsigned int subvendor; /* PCI[2c-2f] */
- unsigned char size; /* size of EEPROM image in bytes */
- unsigned char version; /* must be 1 */
- unsigned char codec; /* codec configuration PCI[60] */
- unsigned char aclink; /* ACLink configuration PCI[61] */
- unsigned char i2sID; /* PCI[62] */
- unsigned char spdif; /* S/PDIF configuration PCI[63] */
- unsigned char gpiomask; /* GPIO initial mask, 0 = write, 1 = don't */
- unsigned char gpiostate; /* GPIO initial state */
- unsigned char gpiodir; /* GPIO direction state */
- unsigned short ac97main;
- unsigned short ac97pcm;
- unsigned short ac97rec;
- unsigned char ac97recsrc;
- unsigned char dacID[4]; /* I2S IDs for DACs */
- unsigned char adcID[4]; /* I2S IDs for ADCs */
- unsigned char extra[4];
+ unsigned int subvendor; /* PCI[2c-2f] */
+ unsigned char size; /* size of EEPROM image in bytes */
+ unsigned char version; /* must be 1 */
+ unsigned char codec; /* codec configuration PCI[60] */
+ unsigned char aclink; /* ACLink configuration PCI[61] */
+ unsigned char i2sID; /* PCI[62] */
+ unsigned char spdif; /* S/PDIF configuration PCI[63] */
+ unsigned char gpiomask; /* GPIO initial mask, 0 = write, 1 = don't */
+ unsigned char gpiostate; /* GPIO initial state */
+ unsigned char gpiodir; /* GPIO direction state */
+ unsigned short ac97main;
+ unsigned short ac97pcm;
+ unsigned short ac97rec;
+ unsigned char ac97recsrc;
+ unsigned char dacID[4]; /* I2S IDs for DACs */
+ unsigned char adcID[4]; /* I2S IDs for ADCs */
+ unsigned char extra[4];
} ice1712_eeprom_t;
typedef struct {
- alsa_driver_t *driver;
- ice1712_eeprom_t *eeprom;
- unsigned long active_channels;
+ alsa_driver_t *driver;
+ ice1712_eeprom_t *eeprom;
+ unsigned long active_channels;
} ice1712_t;
-jack_hardware_t *jack_alsa_ice1712_hw_new (alsa_driver_t *driver);
+jack_hardware_t *jack_alsa_ice1712_hw_new(alsa_driver_t *driver);
#endif /* __jack_ice1712_h__*/
diff --git a/drivers/alsa/memops.c b/drivers/alsa/memops.c
index 090d7f4..24fd67b 100644
--- a/drivers/alsa/memops.c
+++ b/drivers/alsa/memops.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2000 Paul Davis
+ Copyright (C) 2000 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
@@ -39,7 +39,7 @@
the MAX_<N>BIT values are floating point. when multiplied by
a full-scale normalized floating point sample value (-1.0..+1.0)
they should give the maxium value representable with an integer
- sample type of N bits. Note that this is asymmetric. Sample ranges
+ sample type of N bits. Note that this is asymmetric. Sample ranges
for signed integer, 2's complement values are -(2^(N-1) to +(2^(N-1)-1)
Complications
@@ -59,20 +59,20 @@
use the right factor).
So, for now (October 2008) we use 2^(N-1)-1 as the scaling factor.
-*/
+ */
#define SAMPLE_24BIT_SCALING 8388607.0f
#define SAMPLE_16BIT_SCALING 32767.0f
/* these are just values to use if the floating point value was out of range
-
+
advice from Fons Adriaensen: make the limits symmetrical
*/
-#define SAMPLE_24BIT_MAX 8388607
-#define SAMPLE_24BIT_MIN -8388607
-#define SAMPLE_24BIT_MAX_F 8388607.0f
-#define SAMPLE_24BIT_MIN_F -8388607.0f
+#define SAMPLE_24BIT_MAX 8388607
+#define SAMPLE_24BIT_MIN -8388607
+#define SAMPLE_24BIT_MAX_F 8388607.0f
+#define SAMPLE_24BIT_MIN_F -8388607.0f
#define SAMPLE_16BIT_MAX 32767
#define SAMPLE_16BIT_MIN -32767
@@ -80,91 +80,93 @@
#define SAMPLE_16BIT_MIN_F -32767.0f
/* these mark the outer edges of the range considered "within" range
- for a floating point sample value. values outside (and on the boundaries)
- of this range will be clipped before conversion; values within this
+ for a floating point sample value. values outside (and on the boundaries)
+ of this range will be clipped before conversion; values within this
range will be scaled to appropriate values for the target sample
type.
-*/
+ */
#define NORMALIZED_FLOAT_MIN -1.0f
#define NORMALIZED_FLOAT_MAX 1.0f
/* define this in case we end up on a platform that is missing
the real lrintf functions
-*/
+ */
-#define f_round(f) lrintf(f)
+#define f_round(f) lrintf (f)
-#define float_16(s, d)\
- if ((s) <= NORMALIZED_FLOAT_MIN) {\
- (d) = SAMPLE_16BIT_MIN;\
- } else if ((s) >= NORMALIZED_FLOAT_MAX) {\
- (d) = SAMPLE_16BIT_MAX;\
- } else {\
- (d) = f_round ((s) * SAMPLE_16BIT_SCALING);\
+#define float_16(s, d) \
+ if ((s) <= NORMALIZED_FLOAT_MIN) { \
+ (d) = SAMPLE_16BIT_MIN; \
+ } else if ((s) >= NORMALIZED_FLOAT_MAX) { \
+ (d) = SAMPLE_16BIT_MAX; \
+ } else { \
+ (d) = f_round ((s) * SAMPLE_16BIT_SCALING); \
}
/* call this when "s" has already been scaled (e.g. when dithering)
*/
-#define float_16_scaled(s, d)\
- if ((s) <= SAMPLE_16BIT_MIN_F) {\
- (d) = SAMPLE_16BIT_MIN_F;\
+#define float_16_scaled(s, d) \
+ if ((s) <= SAMPLE_16BIT_MIN_F) { \
+ (d) = SAMPLE_16BIT_MIN_F; \
} else if ((s) >= SAMPLE_16BIT_MAX_F) { \
- (d) = SAMPLE_16BIT_MAX;\
- } else {\
- (d) = f_round ((s));\
+ (d) = SAMPLE_16BIT_MAX; \
+ } else { \
+ (d) = f_round ((s)); \
}
#define float_24u32(s, d) \
- if ((s) <= NORMALIZED_FLOAT_MIN) {\
- (d) = SAMPLE_24BIT_MIN << 8;\
- } else if ((s) >= NORMALIZED_FLOAT_MAX) {\
- (d) = SAMPLE_24BIT_MAX << 8;\
- } else {\
- (d) = f_round ((s) * SAMPLE_24BIT_SCALING) << 8;\
+ if ((s) <= NORMALIZED_FLOAT_MIN) { \
+ (d) = SAMPLE_24BIT_MIN << 8; \
+ } else if ((s) >= NORMALIZED_FLOAT_MAX) { \
+ (d) = SAMPLE_24BIT_MAX << 8; \
+ } else { \
+ (d) = f_round ((s) * SAMPLE_24BIT_SCALING) << 8; \
}
/* call this when "s" has already been scaled (e.g. when dithering)
*/
-#define float_24u32_scaled(s, d)\
- if ((s) <= SAMPLE_24BIT_MIN_F) {\
- (d) = SAMPLE_24BIT_MIN << 8;\
+#define float_24u32_scaled(s, d) \
+ if ((s) <= SAMPLE_24BIT_MIN_F) { \
+ (d) = SAMPLE_24BIT_MIN << 8; \
} else if ((s) >= SAMPLE_24BIT_MAX_F) { \
(d) = SAMPLE_24BIT_MAX << 8; \
- } else {\
+ } else { \
(d) = f_round ((s)) << 8; \
}
#define float_24(s, d) \
- if ((s) <= NORMALIZED_FLOAT_MIN) {\
- (d) = SAMPLE_24BIT_MIN;\
- } else if ((s) >= NORMALIZED_FLOAT_MAX) {\
- (d) = SAMPLE_24BIT_MAX;\
- } else {\
- (d) = f_round ((s) * SAMPLE_24BIT_SCALING);\
+ if ((s) <= NORMALIZED_FLOAT_MIN) { \
+ (d) = SAMPLE_24BIT_MIN; \
+ } else if ((s) >= NORMALIZED_FLOAT_MAX) { \
+ (d) = SAMPLE_24BIT_MAX; \
+ } else { \
+ (d) = f_round ((s) * SAMPLE_24BIT_SCALING); \
}
/* call this when "s" has already been scaled (e.g. when dithering)
*/
-#define float_24_scaled(s, d)\
- if ((s) <= SAMPLE_24BIT_MIN_F) {\
- (d) = SAMPLE_24BIT_MIN;\
+#define float_24_scaled(s, d) \
+ if ((s) <= SAMPLE_24BIT_MIN_F) { \
+ (d) = SAMPLE_24BIT_MIN; \
} else if ((s) >= SAMPLE_24BIT_MAX_F) { \
(d) = SAMPLE_24BIT_MAX; \
- } else {\
+ } else { \
(d) = f_round ((s)); \
}
/* Linear Congruential noise generator. From the music-dsp list
- * less random than rand(), but good enough and 10x faster
+ * less random than rand(), but good enough and 10x faster
*/
-static inline unsigned int fast_rand() {
+static inline unsigned int fast_rand ()
+{
static unsigned int seed = 22222;
+
seed = (seed * 96314165) + 907633515;
return seed;
@@ -173,17 +175,19 @@ static inline unsigned int fast_rand() {
/* functions for native float sample data */
-void sample_move_floatLE_sSs (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip) {
+void sample_move_floatLE_sSs (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
+{
while (nsamples--) {
- *dst = *((float *) src);
+ *dst = *((float*)src);
dst++;
src += src_skip;
}
}
-void sample_move_dS_floatLE (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state) {
+void sample_move_dS_floatLE (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+{
while (nsamples--) {
- *((float *) dst) = *src;
+ *((float*)dst) = *src;
dst += dst_skip;
src++;
}
@@ -197,7 +201,7 @@ void sample_move_dS_floatLE (char *dst, jack_default_audio_sample_t *src, unsign
the "s<TYPE>" component defines the source type for the operation
TYPE can be one of:
-
+
S - sample is a jack_default_audio_sample_t, currently (October 2008) a 32 bit floating point value
Ss - like S but reverse endian from the host CPU
32u24 - sample is an signed 32 bit integer value, but data is in upper 24 bits only
@@ -210,7 +214,7 @@ void sample_move_dS_floatLE (char *dst, jack_default_audio_sample_t *src, unsign
For obvious reasons, the reverse endian versions only show as source types.
This covers all known sample formats at 16 bits or larger.
-*/
+ */
/* functions for native integer sample data */
@@ -224,29 +228,29 @@ void sample_move_d32u24_sSs (char *dst, jack_default_audio_sample_t *src, unsign
#if __BYTE_ORDER == __LITTLE_ENDIAN
- dst[0]=(char)(z>>24);
- dst[1]=(char)(z>>16);
- dst[2]=(char)(z>>8);
- dst[3]=(char)(z);
+ dst[0] = (char)(z >> 24);
+ dst[1] = (char)(z >> 16);
+ dst[2] = (char)(z >> 8);
+ dst[3] = (char)(z);
#elif __BYTE_ORDER == __BIG_ENDIAN
- dst[0]=(char)(z);
- dst[1]=(char)(z>>8);
- dst[2]=(char)(z>>16);
- dst[3]=(char)(z>>24);
+ dst[0] = (char)(z);
+ dst[1] = (char)(z >> 8);
+ dst[2] = (char)(z >> 16);
+ dst[3] = (char)(z >> 24);
#endif
dst += dst_skip;
src++;
}
-}
+}
void sample_move_d32u24_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
while (nsamples--) {
- float_24u32 (*src, *((int32_t*) dst));
+ float_24u32 (*src, *((int32_t*)dst));
dst += dst_skip;
src++;
}
-}
+}
void sample_move_dS_s32u24s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
@@ -275,18 +279,18 @@ void sample_move_dS_s32u24s (jack_default_audio_sample_t *dst, char *src, unsign
dst++;
src += src_skip;
}
-}
+}
void sample_move_dS_s32u24 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
/* ALERT: signed sign-extension portability !!! */
while (nsamples--) {
- *dst = (*((int *) src) >> 8) / SAMPLE_24BIT_SCALING;
+ *dst = (*((int*)src) >> 8) / SAMPLE_24BIT_SCALING;
dst++;
src += src_skip;
}
-}
+}
void sample_move_d24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
@@ -295,34 +299,34 @@ void sample_move_d24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned
while (nsamples--) {
float_24 (*src, z);
#if __BYTE_ORDER == __LITTLE_ENDIAN
- dst[0]=(char)(z>>16);
- dst[1]=(char)(z>>8);
- dst[2]=(char)(z);
+ dst[0] = (char)(z >> 16);
+ dst[1] = (char)(z >> 8);
+ dst[2] = (char)(z);
#elif __BYTE_ORDER == __BIG_ENDIAN
- dst[0]=(char)(z);
- dst[1]=(char)(z>>8);
- dst[2]=(char)(z>>16);
+ dst[0] = (char)(z);
+ dst[1] = (char)(z >> 8);
+ dst[2] = (char)(z >> 16);
#endif
dst += dst_skip;
src++;
}
-}
+}
void sample_move_d24_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
- int32_t z;
-
+ int32_t z;
+
while (nsamples--) {
float_24 (*src, z);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy (dst, &z, 3);
#elif __BYTE_ORDER == __BIG_ENDIAN
- memcpy (dst, (char *)&z + 1, 3);
+ memcpy (dst, (char*)&z + 1, 3);
#endif
dst += dst_skip;
src++;
}
-}
+}
void sample_move_dS_s24s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
@@ -355,7 +359,7 @@ void sample_move_dS_s24s (jack_default_audio_sample_t *dst, char *src, unsigned
dst++;
src += src_skip;
}
-}
+}
void sample_move_dS_s24 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
@@ -364,19 +368,19 @@ void sample_move_dS_s24 (jack_default_audio_sample_t *dst, char *src, unsigned l
while (nsamples--) {
int x;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- memcpy((char*)&x + 1, src, 3);
+ memcpy ((char*)&x + 1, src, 3);
#elif __BYTE_ORDER == __BIG_ENDIAN
- memcpy(&x, src, 3);
+ memcpy (&x, src, 3);
#endif
x >>= 8;
*dst = x / SAMPLE_24BIT_SCALING;
dst++;
src += src_skip;
}
-}
+}
-void sample_move_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+void sample_move_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
int16_t tmp;
@@ -388,108 +392,108 @@ void sample_move_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned
} else if (*src >= NORMALIZED_FLOAT_MAX) {
tmp = SAMPLE_16BIT_MAX;
} else {
- tmp = (int16_t) f_round (*src * SAMPLE_16BIT_SCALING);
+ tmp = (int16_t)f_round (*src * SAMPLE_16BIT_SCALING);
}
#if __BYTE_ORDER == __LITTLE_ENDIAN
- dst[0]=(char)(tmp>>8);
- dst[1]=(char)(tmp);
+ dst[0] = (char)(tmp >> 8);
+ dst[1] = (char)(tmp);
#elif __BYTE_ORDER == __BIG_ENDIAN
- dst[0]=(char)(tmp);
- dst[1]=(char)(tmp>>8);
+ dst[0] = (char)(tmp);
+ dst[1] = (char)(tmp >> 8);
#endif
dst += dst_skip;
src++;
}
}
-void sample_move_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+void sample_move_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
while (nsamples--) {
- float_16 (*src, *((int16_t*) dst));
+ float_16 (*src, *((int16_t*)dst));
dst += dst_skip;
src++;
}
}
-void sample_move_dither_rect_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+void sample_move_dither_rect_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
jack_default_audio_sample_t val;
- int16_t tmp;
+ int16_t tmp;
while (nsamples--) {
- val = (*src * SAMPLE_16BIT_SCALING) + fast_rand() / (float) UINT_MAX - 0.5f;
+ val = (*src * SAMPLE_16BIT_SCALING) + fast_rand () / (float)UINT_MAX - 0.5f;
float_16_scaled (val, tmp);
#if __BYTE_ORDER == __LITTLE_ENDIAN
- dst[0]=(char)(tmp>>8);
- dst[1]=(char)(tmp);
+ dst[0] = (char)(tmp >> 8);
+ dst[1] = (char)(tmp);
#elif __BYTE_ORDER == __BIG_ENDIAN
- dst[0]=(char)(tmp);
- dst[1]=(char)(tmp>>8);
+ dst[0] = (char)(tmp);
+ dst[1] = (char)(tmp >> 8);
#endif
dst += dst_skip;
src++;
}
}
-void sample_move_dither_rect_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+void sample_move_dither_rect_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
jack_default_audio_sample_t val;
while (nsamples--) {
- val = (*src * SAMPLE_16BIT_SCALING) + fast_rand() / (float)UINT_MAX - 0.5f;
- float_16_scaled (val, *((int16_t*) dst));
+ val = (*src * SAMPLE_16BIT_SCALING) + fast_rand () / (float)UINT_MAX - 0.5f;
+ float_16_scaled (val, *((int16_t*)dst));
dst += dst_skip;
src++;
}
}
-void sample_move_dither_tri_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+void sample_move_dither_tri_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
jack_default_audio_sample_t val;
- int16_t tmp;
+ int16_t tmp;
while (nsamples--) {
- val = (*src * SAMPLE_16BIT_SCALING) + ((float)fast_rand() + (float)fast_rand()) / (float)UINT_MAX - 1.0f;
+ val = (*src * SAMPLE_16BIT_SCALING) + ((float)fast_rand () + (float)fast_rand ()) / (float)UINT_MAX - 1.0f;
float_16_scaled (val, tmp);
#if __BYTE_ORDER == __LITTLE_ENDIAN
- dst[0]=(char)(tmp>>8);
- dst[1]=(char)(tmp);
+ dst[0] = (char)(tmp >> 8);
+ dst[1] = (char)(tmp);
#elif __BYTE_ORDER == __BIG_ENDIAN
- dst[0]=(char)(tmp);
- dst[1]=(char)(tmp>>8);
+ dst[0] = (char)(tmp);
+ dst[1] = (char)(tmp >> 8);
#endif
dst += dst_skip;
src++;
}
}
-void sample_move_dither_tri_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+void sample_move_dither_tri_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
jack_default_audio_sample_t val;
while (nsamples--) {
- val = (*src * SAMPLE_16BIT_SCALING) + ((float)fast_rand() + (float)fast_rand()) / (float)UINT_MAX - 1.0f;
- float_16_scaled (val, *((int16_t*) dst));
+ val = (*src * SAMPLE_16BIT_SCALING) + ((float)fast_rand () + (float)fast_rand ()) / (float)UINT_MAX - 1.0f;
+ float_16_scaled (val, *((int16_t*)dst));
dst += dst_skip;
src++;
}
}
-void sample_move_dither_shaped_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+void sample_move_dither_shaped_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
- jack_default_audio_sample_t x;
- jack_default_audio_sample_t xe; /* the innput sample - filtered error */
- jack_default_audio_sample_t xp; /* x' */
- float r;
- float rm1 = state->rm1;
+ jack_default_audio_sample_t x;
+ jack_default_audio_sample_t xe; /* the innput sample - filtered error */
+ jack_default_audio_sample_t xp; /* x' */
+ float r;
+ float rm1 = state->rm1;
unsigned int idx = state->idx;
- int16_t tmp;
+ int16_t tmp;
while (nsamples--) {
x = *src * SAMPLE_16BIT_SCALING;
- r = ((float)fast_rand() + (float)fast_rand()) / (float)UINT_MAX - 1.0f;
+ r = ((float)fast_rand () + (float)fast_rand ()) / (float)UINT_MAX - 1.0f;
/* Filter the error with Lipshitz's minimally audible FIR:
[2.033 -2.165 1.959 -1.590 0.6149] */
xe = x
@@ -508,11 +512,11 @@ void sample_move_dither_shaped_d16_sSs (char *dst, jack_default_audio_sample_t
state->e[idx] = xp - xe;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- dst[0]=(char)(tmp>>8);
- dst[1]=(char)(tmp);
+ dst[0] = (char)(tmp >> 8);
+ dst[1] = (char)(tmp);
#elif __BYTE_ORDER == __BIG_ENDIAN
- dst[0]=(char)(tmp);
- dst[1]=(char)(tmp>>8);
+ dst[0] = (char)(tmp);
+ dst[1] = (char)(tmp >> 8);
#endif
dst += dst_skip;
src++;
@@ -521,18 +525,18 @@ void sample_move_dither_shaped_d16_sSs (char *dst, jack_default_audio_sample_t
state->idx = idx;
}
-void sample_move_dither_shaped_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
+void sample_move_dither_shaped_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
- jack_default_audio_sample_t x;
- jack_default_audio_sample_t xe; /* the innput sample - filtered error */
- jack_default_audio_sample_t xp; /* x' */
- float r;
- float rm1 = state->rm1;
+ jack_default_audio_sample_t x;
+ jack_default_audio_sample_t xe; /* the innput sample - filtered error */
+ jack_default_audio_sample_t xp; /* x' */
+ float r;
+ float rm1 = state->rm1;
unsigned int idx = state->idx;
while (nsamples--) {
x = *src * SAMPLE_16BIT_SCALING;
- r = ((float)fast_rand() + (float)fast_rand()) / (float)UINT_MAX - 1.0f;
+ r = ((float)fast_rand () + (float)fast_rand ()) / (float)UINT_MAX - 1.0f;
/* Filter the error with Lipshitz's minimally audible FIR:
[2.033 -2.165 1.959 -1.590 0.6149] */
xe = x
@@ -544,11 +548,11 @@ void sample_move_dither_shaped_d16_sS (char *dst, jack_default_audio_sample_t *
xp = xe + r - rm1;
rm1 = r;
- float_16_scaled (xp, *((int16_t*) dst));
+ float_16_scaled (xp, *((int16_t*)dst));
/* Intrinsic z^-1 delay */
idx = (idx + 1) & DITHER_BUF_MASK;
- state->e[idx] = *((int16_t*) dst) - xe;
+ state->e[idx] = *((int16_t*)dst) - xe;
dst += dst_skip;
src++;
@@ -557,7 +561,7 @@ void sample_move_dither_shaped_d16_sS (char *dst, jack_default_audio_sample_t *
state->idx = idx;
}
-void sample_move_dS_s16s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
+void sample_move_dS_s16s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
short z;
@@ -576,22 +580,22 @@ void sample_move_dS_s16s (jack_default_audio_sample_t *dst, char *src, unsigned
dst++;
src += src_skip;
}
-}
+}
+
+void sample_move_dS_s16 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
-void sample_move_dS_s16 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
-
{
/* ALERT: signed sign-extension portability !!! */
while (nsamples--) {
- *dst = (*((short *) src)) / SAMPLE_16BIT_SCALING;
+ *dst = (*((short*)src)) / SAMPLE_16BIT_SCALING;
dst++;
src += src_skip;
}
-}
+}
-void memset_interleave (char *dst, char val, unsigned long bytes,
- unsigned long unit_bytes,
- unsigned long skip_bytes)
+void memset_interleave (char *dst, char val, unsigned long bytes,
+ unsigned long unit_bytes,
+ unsigned long skip_bytes)
{
switch (unit_bytes) {
case 1:
@@ -602,21 +606,21 @@ void memset_interleave (char *dst, char val, unsigned long bytes,
break;
case 2:
while (bytes) {
- *((short *) dst) = (short) val;
+ *((short*)dst) = (short)val;
dst += skip_bytes;
bytes -= 2;
}
break;
- case 4:
+ case 4:
while (bytes) {
- *((int *) dst) = (int) val;
+ *((int*)dst) = (int)val;
dst += skip_bytes;
bytes -= 4;
}
break;
default:
while (bytes) {
- memset(dst, val, unit_bytes);
+ memset (dst, val, unit_bytes);
dst += skip_bytes;
bytes -= unit_bytes;
}
@@ -629,46 +633,46 @@ void memset_interleave (char *dst, char val, unsigned long bytes,
is the same for both channels. This is completely fine
unless the input and output were on different audio interfaces that
were interleaved differently. We don't try to handle that.
-*/
+ */
-void
+void
memcpy_fake (char *dst, char *src, unsigned long src_bytes, unsigned long foo, unsigned long bar)
{
memcpy (dst, src, src_bytes);
}
-void
+void
memcpy_interleave_d16_s16 (char *dst, char *src, unsigned long src_bytes,
unsigned long dst_skip_bytes, unsigned long src_skip_bytes)
{
while (src_bytes) {
- *((short *) dst) = *((short *) src);
+ *((short*)dst) = *((short*)src);
dst += dst_skip_bytes;
src += src_skip_bytes;
src_bytes -= 2;
}
}
-void
+void
memcpy_interleave_d24_s24 (char *dst, char *src, unsigned long src_bytes,
unsigned long dst_skip_bytes, unsigned long src_skip_bytes)
{
while (src_bytes) {
- memcpy(dst, src, 3);
+ memcpy (dst, src, 3);
dst += dst_skip_bytes;
src += src_skip_bytes;
src_bytes -= 3;
}
}
-void
+void
memcpy_interleave_d32_s32 (char *dst, char *src, unsigned long src_bytes,
unsigned long dst_skip_bytes, unsigned long src_skip_bytes)
{
while (src_bytes) {
- *((int *) dst) = *((int *) src);
+ *((int*)dst) = *((int*)src);
dst += dst_skip_bytes;
src += src_skip_bytes;
src_bytes -= 4;
diff --git a/drivers/alsa/usx2y.c b/drivers/alsa/usx2y.c
index 23efeb3..b0a6d12 100644
--- a/drivers/alsa/usx2y.c
+++ b/drivers/alsa/usx2y.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2001 Paul Davis
+ Copyright (C) 2001 Paul Davis
Copyright (C) 2005 Karsten Wiese, Rui Nuno Capela
This program is free software; you can redistribute it and/or modify
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#include "hardware.h"
#include "alsa_driver.h"
@@ -36,14 +36,14 @@
int dbg_offset;
char dbg_buffer[8096];
#endif
-static
+static
int usx2y_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask)
{
return -1;
}
static
-int usx2y_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
+int usx2y_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
{
return -1;
}
@@ -51,78 +51,85 @@ int usx2y_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
static void
usx2y_release (jack_hardware_t *hw)
{
- usx2y_t *h = (usx2y_t *) hw->private;
+ usx2y_t *h = (usx2y_t*)hw->private;
- if (h == 0)
+ if (h == 0) {
return;
-
- if (h->hwdep_handle)
- snd_hwdep_close(h->hwdep_handle);
+ }
+
+ if (h->hwdep_handle) {
+ snd_hwdep_close (h->hwdep_handle);
+ }
- free(h);
+ free (h);
}
static int
usx2y_driver_get_channel_addresses_playback (alsa_driver_t *driver,
- snd_pcm_uframes_t *playback_avail)
+ snd_pcm_uframes_t *playback_avail)
{
channel_t chn;
int iso;
snd_pcm_uframes_t playback_iso_avail;
char *playback;
- usx2y_t *h = (usx2y_t *) driver->hw->private;
+ usx2y_t *h = (usx2y_t*)driver->hw->private;
if (0 > h->playback_iso_start) {
int bytes = driver->playback_sample_bytes * 2 * driver->frames_per_cycle *
- driver->user_nperiods;
+ driver->user_nperiods;
iso = h->hwdep_pcm_shm->playback_iso_start;
- if (0 > iso)
+ if (0 > iso) {
return 0; /* FIXME: return -1; */
- if (++iso >= ARRAY_SIZE(h->hwdep_pcm_shm->captured_iso))
+ }
+ if (++iso >= ARRAY_SIZE (h->hwdep_pcm_shm->captured_iso)) {
iso = 0;
- while((bytes -= h->hwdep_pcm_shm->captured_iso[iso].length) > 0)
- if (++iso >= ARRAY_SIZE(h->hwdep_pcm_shm->captured_iso))
+ }
+ while ((bytes -= h->hwdep_pcm_shm->captured_iso[iso].length) > 0)
+ if (++iso >= ARRAY_SIZE (h->hwdep_pcm_shm->captured_iso)) {
iso = 0;
+ }
h->playback_iso_bytes_done = h->hwdep_pcm_shm->captured_iso[iso].length + bytes;
#ifdef DBGHWDEP
- dbg_offset = sprintf(dbg_buffer, "first iso = %i %i@%p:%i\n",
- iso, h->hwdep_pcm_shm->captured_iso[iso].length,
- h->hwdep_pcm_shm->playback,
- h->hwdep_pcm_shm->captured_iso[iso].offset);
+ dbg_offset = sprintf (dbg_buffer, "first iso = %i %i@%p:%i\n",
+ iso, h->hwdep_pcm_shm->captured_iso[iso].length,
+ h->hwdep_pcm_shm->playback,
+ h->hwdep_pcm_shm->captured_iso[iso].offset);
#endif
} else {
iso = h->playback_iso_start;
}
#ifdef DBGHWDEP
- dbg_offset += sprintf(dbg_buffer + dbg_offset, "iso = %i(%i;%i); ", iso,
- h->hwdep_pcm_shm->captured_iso[iso].offset,
- h->hwdep_pcm_shm->captured_iso[iso].frame);
+ dbg_offset += sprintf (dbg_buffer + dbg_offset, "iso = %i(%i;%i); ", iso,
+ h->hwdep_pcm_shm->captured_iso[iso].offset,
+ h->hwdep_pcm_shm->captured_iso[iso].frame);
#endif
playback = h->hwdep_pcm_shm->playback +
- h->hwdep_pcm_shm->captured_iso[iso].offset +
- h->playback_iso_bytes_done;
+ h->hwdep_pcm_shm->captured_iso[iso].offset +
+ h->playback_iso_bytes_done;
playback_iso_avail = (h->hwdep_pcm_shm->captured_iso[iso].length -
- h->playback_iso_bytes_done) /
- (driver->playback_sample_bytes * 2);
+ h->playback_iso_bytes_done) /
+ (driver->playback_sample_bytes * 2);
if (*playback_avail >= playback_iso_avail) {
*playback_avail = playback_iso_avail;
- if (++iso >= ARRAY_SIZE(h->hwdep_pcm_shm->captured_iso))
+ if (++iso >= ARRAY_SIZE (h->hwdep_pcm_shm->captured_iso)) {
iso = 0;
+ }
h->playback_iso_bytes_done = 0;
- } else
+ } else {
h->playback_iso_bytes_done =
*playback_avail * (driver->playback_sample_bytes * 2);
+ }
h->playback_iso_start = iso;
for (chn = 0; chn < driver->playback_nchannels; chn++) {
const snd_pcm_channel_area_t *a = &driver->playback_areas[chn];
driver->playback_addr[chn] = playback + a->first / 8;
}
#ifdef DBGHWDEP
- if (dbg_offset < (sizeof(dbg_buffer) - 256))
- dbg_offset += sprintf(dbg_buffer + dbg_offset, "avail %li@%p\n", *playback_avail, driver->playback_addr[0]);
- else {
- printf(dbg_buffer);
+ if (dbg_offset < (sizeof(dbg_buffer) - 256)) {
+ dbg_offset += sprintf (dbg_buffer + dbg_offset, "avail %li@%p\n", *playback_avail, driver->playback_addr[0]);
+ } else {
+ printf (dbg_buffer);
return -1;
}
#endif
@@ -132,48 +139,51 @@ usx2y_driver_get_channel_addresses_playback (alsa_driver_t *driver,
static int
usx2y_driver_get_channel_addresses_capture (alsa_driver_t *driver,
- snd_pcm_uframes_t *capture_avail)
+ snd_pcm_uframes_t *capture_avail)
{
channel_t chn;
int iso;
snd_pcm_uframes_t capture_iso_avail;
int capture_offset;
- usx2y_t *h = (usx2y_t *) driver->hw->private;
+ usx2y_t *h = (usx2y_t*)driver->hw->private;
if (0 > h->capture_iso_start) {
iso = h->hwdep_pcm_shm->capture_iso_start;
- if (0 > iso)
+ if (0 > iso) {
return 0; /* FIXME: return -1; */
+ }
h->capture_iso_bytes_done = 0;
#ifdef DBGHWDEP
- dbg_offset = sprintf(dbg_buffer, "cfirst iso = %i %i@%p:%i\n",
- iso, h->hwdep_pcm_shm->captured_iso[iso].length,
- h->hwdep_pcm_shm->capture0x8,
- h->hwdep_pcm_shm->captured_iso[iso].offset);
+ dbg_offset = sprintf (dbg_buffer, "cfirst iso = %i %i@%p:%i\n",
+ iso, h->hwdep_pcm_shm->captured_iso[iso].length,
+ h->hwdep_pcm_shm->capture0x8,
+ h->hwdep_pcm_shm->captured_iso[iso].offset);
#endif
} else {
iso = h->capture_iso_start;
}
#ifdef DBGHWDEP
- dbg_offset += sprintf(dbg_buffer + dbg_offset, "ciso = %i(%i;%i); ", iso,
- h->hwdep_pcm_shm->captured_iso[iso].offset,
- h->hwdep_pcm_shm->captured_iso[iso].frame);
+ dbg_offset += sprintf (dbg_buffer + dbg_offset, "ciso = %i(%i;%i); ", iso,
+ h->hwdep_pcm_shm->captured_iso[iso].offset,
+ h->hwdep_pcm_shm->captured_iso[iso].frame);
#endif
capture_offset =
h->hwdep_pcm_shm->captured_iso[iso].offset +
- h->capture_iso_bytes_done;
+ h->capture_iso_bytes_done;
capture_iso_avail = (h->hwdep_pcm_shm->captured_iso[iso].length -
- h->capture_iso_bytes_done) /
- (driver->capture_sample_bytes * 2);
+ h->capture_iso_bytes_done) /
+ (driver->capture_sample_bytes * 2);
if (*capture_avail >= capture_iso_avail) {
*capture_avail = capture_iso_avail;
- if (++iso >= ARRAY_SIZE(h->hwdep_pcm_shm->captured_iso))
+ if (++iso >= ARRAY_SIZE (h->hwdep_pcm_shm->captured_iso)) {
iso = 0;
+ }
h->capture_iso_bytes_done = 0;
- } else
+ } else {
h->capture_iso_bytes_done =
*capture_avail * (driver->capture_sample_bytes * 2);
+ }
h->capture_iso_start = iso;
for (chn = 0; chn < driver->capture_nchannels; chn++) {
driver->capture_addr[chn] =
@@ -182,21 +192,22 @@ usx2y_driver_get_channel_addresses_capture (alsa_driver_t *driver,
((chn & 1) ? driver->capture_sample_bytes : 0);
}
#ifdef DBGHWDEP
- {
- int f = 0;
- unsigned *u = driver->capture_addr[0];
- static unsigned last;
- dbg_offset += sprintf(dbg_buffer + dbg_offset, "\nvon %6u bis %6u\n", last, u[0]);
- while (f < *capture_avail && dbg_offset < (sizeof(dbg_buffer) - 256)) {
- if (u[f] != last + 1)
- dbg_offset += sprintf(dbg_buffer + dbg_offset, "\nooops %6u %6u\n", last, u[f]);
- last = u[f++];
- }
- }
- if (dbg_offset < (sizeof(dbg_buffer) - 256))
- dbg_offset += sprintf(dbg_buffer + dbg_offset, "avail %li@%p\n", *capture_avail, driver->capture_addr[0]);
- else {
- printf(dbg_buffer);
+ {
+ int f = 0;
+ unsigned *u = driver->capture_addr[0];
+ static unsigned last;
+ dbg_offset += sprintf (dbg_buffer + dbg_offset, "\nvon %6u bis %6u\n", last, u[0]);
+ while (f < *capture_avail && dbg_offset < (sizeof(dbg_buffer) - 256)) {
+ if (u[f] != last + 1) {
+ dbg_offset += sprintf (dbg_buffer + dbg_offset, "\nooops %6u %6u\n", last, u[f]);
+ }
+ last = u[f++];
+ }
+ }
+ if (dbg_offset < (sizeof(dbg_buffer) - 256)) {
+ dbg_offset += sprintf (dbg_buffer + dbg_offset, "avail %li@%p\n", *capture_avail, driver->capture_addr[0]);
+ } else {
+ printf (dbg_buffer);
return -1;
}
#endif
@@ -210,7 +221,7 @@ usx2y_driver_start (alsa_driver_t *driver)
int err, i;
snd_pcm_uframes_t poffset, pavail;
- usx2y_t *h = (usx2y_t *) driver->hw->private;
+ usx2y_t *h = (usx2y_t*)driver->hw->private;
for (i = 0; i < driver->capture_nchannels; i++)
// US428 channels 3+4 are on a seperate 2 channel stream.
@@ -225,40 +236,40 @@ usx2y_driver_start (alsa_driver_t *driver)
driver->poll_next = 0;
if ((err = snd_pcm_prepare (driver->playback_handle)) < 0) {
- jack_error ("ALSA/USX2Y: prepare error for playback: %s", snd_strerror(err));
+ jack_error ("ALSA/USX2Y: prepare error for playback: %s", snd_strerror (err));
return -1;
}
if (driver->playback_handle) {
-/* int i, j; */
-/* char buffer[2000]; */
+/* int i, j; */
+/* char buffer[2000]; */
h->playback_iso_start =
h->capture_iso_start = -1;
- snd_hwdep_poll_descriptors(h->hwdep_handle, &h->pfds, 1);
+ snd_hwdep_poll_descriptors (h->hwdep_handle, &h->pfds, 1);
h->hwdep_pcm_shm = (snd_usX2Y_hwdep_pcm_shm_t*)
- mmap(NULL, sizeof(snd_usX2Y_hwdep_pcm_shm_t),
- PROT_READ,
- MAP_SHARED, h->pfds.fd,
- 0);
+ mmap (NULL, sizeof(snd_usX2Y_hwdep_pcm_shm_t),
+ PROT_READ,
+ MAP_SHARED, h->pfds.fd,
+ 0);
if (MAP_FAILED == h->hwdep_pcm_shm) {
- perror("ALSA/USX2Y: mmap");
+ perror ("ALSA/USX2Y: mmap");
return -1;
}
- if (mprotect(h->hwdep_pcm_shm->playback,
- sizeof(h->hwdep_pcm_shm->playback),
- PROT_READ|PROT_WRITE)) {
- perror("ALSA/USX2Y: mprotect");
+ if (mprotect (h->hwdep_pcm_shm->playback,
+ sizeof(h->hwdep_pcm_shm->playback),
+ PROT_READ | PROT_WRITE)) {
+ perror ("ALSA/USX2Y: mprotect");
return -1;
}
- memset(h->hwdep_pcm_shm->playback, 0, sizeof(h->hwdep_pcm_shm->playback));
-/* for (i = 0, j = 0; i < 2000;) { */
-/* j += sprintf(buffer + j, "%04hX ", */
-/* *(unsigned short*)(h->hwdep_pcm_shm->capture + i)); */
-/* if (((i += 2) % 32) == 0) { */
-/* jack_error(buffer); */
-/* j = 0; */
-/* } */
-/* } */
+ memset (h->hwdep_pcm_shm->playback, 0, sizeof(h->hwdep_pcm_shm->playback));
+/* for (i = 0, j = 0; i < 2000;) { */
+/* j += sprintf(buffer + j, "%04hX ", */
+/* *(unsigned short*)(h->hwdep_pcm_shm->capture + i)); */
+/* if (((i += 2) % 32) == 0) { */
+/* jack_error(buffer); */
+/* j = 0; */
+/* } */
+/* } */
}
if (driver->hw_monitoring) {
@@ -269,7 +280,7 @@ usx2y_driver_start (alsa_driver_t *driver)
if (driver->playback_handle) {
/* fill playback buffer with zeroes, and mark
all fragments as having data.
- */
+ */
pavail = snd_pcm_avail_update (driver->playback_handle);
@@ -278,10 +289,10 @@ usx2y_driver_start (alsa_driver_t *driver)
return -1;
}
- if (snd_pcm_mmap_begin(
- driver->playback_handle,
- &driver->playback_areas,
- &poffset, &pavail) < 0) {
+ if (snd_pcm_mmap_begin (
+ driver->playback_handle,
+ &driver->playback_areas,
+ &poffset, &pavail) < 0) {
return -1;
}
@@ -292,22 +303,22 @@ usx2y_driver_start (alsa_driver_t *driver)
alsa-lib may have a better function for doing this
here, where the goal is to silence the entire
buffer.
- */
+ */
{
-/* snd_pcm_uframes_t frag, nframes = driver->buffer_frames; */
-/* while (nframes) { */
-/* frag = nframes; */
-/* if (usx2y_driver_get_channel_addresses_playback(driver, &frag) < 0) */
-/* return -1; */
-
-/* for (chn = 0; chn < driver->playback_nchannels; chn++) */
-/* alsa_driver_silence_on_channel (driver, chn, frag); */
-/* nframes -= frag; */
-/* } */
+/* snd_pcm_uframes_t frag, nframes = driver->buffer_frames; */
+/* while (nframes) { */
+/* frag = nframes; */
+/* if (usx2y_driver_get_channel_addresses_playback(driver, &frag) < 0) */
+/* return -1; */
+
+/* for (chn = 0; chn < driver->playback_nchannels; chn++) */
+/* alsa_driver_silence_on_channel (driver, chn, frag); */
+/* nframes -= frag; */
+/* } */
}
snd_pcm_mmap_commit (driver->playback_handle, poffset,
- driver->user_nperiods * driver->frames_per_cycle);
+ driver->user_nperiods * driver->frames_per_cycle);
if ((err = snd_pcm_start (driver->playback_handle)) < 0) {
jack_error ("ALSA/USX2Y: could not start playback (%s)",
@@ -326,16 +337,16 @@ usx2y_driver_start (alsa_driver_t *driver)
}
}
- driver->playback_nfds = snd_pcm_poll_descriptors_count (driver->playback_handle);
+ driver->playback_nfds = snd_pcm_poll_descriptors_count (driver->playback_handle);
driver->capture_nfds = snd_pcm_poll_descriptors_count (driver->capture_handle);
if (driver->pfd) {
free (driver->pfd);
}
- driver->pfd = (struct pollfd *)
- malloc (sizeof (struct pollfd) *
- (driver->playback_nfds + driver->capture_nfds + 2));
+ driver->pfd = (struct pollfd*)
+ malloc (sizeof(struct pollfd) *
+ (driver->playback_nfds + driver->capture_nfds + 2));
return 0;
}
@@ -347,28 +358,28 @@ usx2y_driver_stop (alsa_driver_t *driver)
JSList* node;
int chn;
- usx2y_t *h = (usx2y_t *) driver->hw->private;
+ usx2y_t *h = (usx2y_t*)driver->hw->private;
/* silence all capture port buffers, because we might
be entering offline mode.
- */
+ */
for (chn = 0, node = driver->capture_ports; node;
- node = jack_slist_next (node), chn++) {
+ node = jack_slist_next (node), chn++) {
jack_port_t* port;
char* buf;
jack_nframes_t nframes = driver->engine->control->buffer_size;
- port = (jack_port_t *) node->data;
+ port = (jack_port_t*)node->data;
buf = jack_port_get_buffer (port, nframes);
- memset (buf, 0, sizeof (jack_default_audio_sample_t) * nframes);
+ memset (buf, 0, sizeof(jack_default_audio_sample_t) * nframes);
}
if (driver->playback_handle) {
if ((err = snd_pcm_drop (driver->playback_handle)) < 0) {
jack_error ("ALSA/USX2Y: channel flush for playback "
- "failed (%s)", snd_strerror (err));
+ "failed (%s)", snd_strerror (err));
return -1;
}
}
@@ -377,7 +388,7 @@ usx2y_driver_stop (alsa_driver_t *driver)
driver->hw->set_input_monitor_mask (driver->hw, 0);
}
- munmap(h->hwdep_pcm_shm, sizeof(snd_usX2Y_hwdep_pcm_shm_t));
+ munmap (h->hwdep_pcm_shm, sizeof(snd_usX2Y_hwdep_pcm_shm_t));
return 0;
}
@@ -390,8 +401,8 @@ usx2y_driver_null_cycle (alsa_driver_t* driver, jack_nframes_t nframes)
snd_pcm_uframes_t contiguous, contiguous_;
int chn;
- VERBOSE(driver->engine,
- "usx2y_driver_null_cycle (%p, %i)", driver, nframes);
+ VERBOSE (driver->engine,
+ "usx2y_driver_null_cycle (%p, %i)", driver, nframes);
if (driver->capture_handle) {
nf = nframes;
@@ -399,25 +410,26 @@ usx2y_driver_null_cycle (alsa_driver_t* driver, jack_nframes_t nframes)
while (nf) {
contiguous = (nf > driver->frames_per_cycle) ?
- driver->frames_per_cycle : nf;
+ driver->frames_per_cycle : nf;
if (snd_pcm_mmap_begin (
- driver->capture_handle,
- &driver->capture_areas,
- (snd_pcm_uframes_t *) &offset,
- (snd_pcm_uframes_t *) &contiguous)) {
+ driver->capture_handle,
+ &driver->capture_areas,
+ (snd_pcm_uframes_t*)&offset,
+ (snd_pcm_uframes_t*)&contiguous)) {
return -1;
}
contiguous_ = contiguous;
while (contiguous_) {
snd_pcm_uframes_t frag = contiguous_;
- if (usx2y_driver_get_channel_addresses_capture(driver, &frag) < 0)
+ if (usx2y_driver_get_channel_addresses_capture (driver, &frag) < 0) {
return -1;
+ }
contiguous_ -= frag;
}
if (snd_pcm_mmap_commit (driver->capture_handle,
- offset, contiguous) < 0) {
+ offset, contiguous) < 0) {
return -1;
}
@@ -430,13 +442,13 @@ usx2y_driver_null_cycle (alsa_driver_t* driver, jack_nframes_t nframes)
offset = 0;
while (nf) {
contiguous = (nf > driver->frames_per_cycle) ?
- driver->frames_per_cycle : nf;
+ driver->frames_per_cycle : nf;
if (snd_pcm_mmap_begin (
driver->playback_handle,
&driver->playback_areas,
- (snd_pcm_uframes_t *) &offset,
- (snd_pcm_uframes_t *) &contiguous)) {
+ (snd_pcm_uframes_t*)&offset,
+ (snd_pcm_uframes_t*)&contiguous)) {
return -1;
}
@@ -444,8 +456,9 @@ usx2y_driver_null_cycle (alsa_driver_t* driver, jack_nframes_t nframes)
snd_pcm_uframes_t frag, nframes = contiguous;
while (nframes) {
frag = nframes;
- if (usx2y_driver_get_channel_addresses_playback(driver, &frag) < 0)
+ if (usx2y_driver_get_channel_addresses_playback (driver, &frag) < 0) {
return -1;
+ }
for (chn = 0; chn < driver->playback_nchannels; chn++)
alsa_driver_silence_on_channel (driver, chn, frag);
nframes -= frag;
@@ -453,7 +466,7 @@ usx2y_driver_null_cycle (alsa_driver_t* driver, jack_nframes_t nframes)
}
if (snd_pcm_mmap_commit (driver->playback_handle,
- offset, contiguous) < 0) {
+ offset, contiguous) < 0) {
return -1;
}
@@ -493,7 +506,7 @@ usx2y_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
for (chn = 0, node = driver->capture_ports;
node; node = jack_slist_next (node), chn++) {
- port = (jack_port_t *) node->data;
+ port = (jack_port_t*)node->data;
if (!jack_port_connected (port)) {
continue;
}
@@ -509,7 +522,7 @@ usx2y_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
}
for (chn = 0, node = driver->capture_ports;
node; node = jack_slist_next (node), chn++) {
- port = (jack_port_t *) node->data;
+ port = (jack_port_t*)node->data;
if (!jack_port_connected (port)) {
/* no-copy optimization */
continue;
@@ -517,10 +530,10 @@ usx2y_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
alsa_driver_read_from_channel (driver, chn,
buf[chn] + nread,
contiguous);
-/* sample_move_dS_s24(buf[chn] + nread, */
-/* driver->capture_addr[chn], */
-/* contiguous, */
-/* driver->capture_interleave_skip); */
+/* sample_move_dS_s24(buf[chn] + nread, */
+/* driver->capture_addr[chn], */
+/* contiguous, */
+/* driver->capture_interleave_skip); */
}
nread += contiguous;
nframes -= contiguous;
@@ -562,24 +575,24 @@ usx2y_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
driver->input_monitor_mask = 0;
for (chn = 0, node = driver->capture_ports; node;
- node = jack_slist_next (node), chn++) {
- if (((jack_port_t *) node->data)->shared->monitor_requests) {
- driver->input_monitor_mask |= (1<<chn);
+ node = jack_slist_next (node), chn++) {
+ if (((jack_port_t*)node->data)->shared->monitor_requests) {
+ driver->input_monitor_mask |= (1 << chn);
}
}
if (driver->hw_monitoring) {
if ((driver->hw->input_monitor_mask
- != driver->input_monitor_mask)
- && !driver->all_monitor_in) {
+ != driver->input_monitor_mask)
+ && !driver->all_monitor_in) {
driver->hw->set_input_monitor_mask (
driver->hw, driver->input_monitor_mask);
}
}
- if (snd_pcm_mmap_begin(driver->playback_handle,
- &driver->playback_areas,
- &offset, &nframes_) < 0) {
+ if (snd_pcm_mmap_begin (driver->playback_handle,
+ &driver->playback_areas,
+ &offset, &nframes_) < 0) {
jack_error ("ALSA/USX2Y: %s: mmap areas info error",
driver->alsa_name_capture);
return -1;
@@ -587,7 +600,7 @@ usx2y_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
for (chn = 0, node = driver->playback_ports;
node; node = jack_slist_next (node), chn++) {
- port = (jack_port_t *) node->data;
+ port = (jack_port_t*)node->data;
buf[chn] = jack_port_get_buffer (port, nframes_);
}
@@ -600,7 +613,7 @@ usx2y_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
}
for (chn = 0, node = driver->playback_ports;
node; node = jack_slist_next (node), chn++) {
- port = (jack_port_t *) node->data;
+ port = (jack_port_t*)node->data;
alsa_driver_write_to_channel (driver, chn,
buf[chn] + nwritten,
contiguous);
@@ -613,8 +626,9 @@ usx2y_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
offset, nframes_)) < 0) {
jack_error ("ALSA/USX2Y: could not complete playback of %"
PRIu32 " frames: error = %d", nframes_, err);
- if (err != EPIPE && err != ESTRPIPE)
+ if (err != EPIPE && err != ESTRPIPE) {
return -1;
+ }
}
return 0;
@@ -623,12 +637,12 @@ usx2y_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
static void
usx2y_driver_setup (alsa_driver_t *driver)
{
- driver->nt_start = (JackDriverNTStartFunction) usx2y_driver_start;
- driver->nt_stop = (JackDriverNTStopFunction) usx2y_driver_stop;
- driver->read = (JackDriverReadFunction) usx2y_driver_read;
- driver->write = (JackDriverReadFunction) usx2y_driver_write;
+ driver->nt_start = (JackDriverNTStartFunction)usx2y_driver_start;
+ driver->nt_stop = (JackDriverNTStopFunction)usx2y_driver_stop;
+ driver->read = (JackDriverReadFunction)usx2y_driver_read;
+ driver->write = (JackDriverReadFunction)usx2y_driver_write;
driver->null_cycle =
- (JackDriverNullCycleFunction) usx2y_driver_null_cycle;
+ (JackDriverNullCycleFunction)usx2y_driver_null_cycle;
}
@@ -638,13 +652,13 @@ jack_alsa_usx2y_hw_new (alsa_driver_t *driver)
jack_hardware_t *hw;
usx2y_t *h;
- int hwdep_cardno;
- int hwdep_devno;
+ int hwdep_cardno;
+ int hwdep_devno;
char *hwdep_colon;
- char hwdep_name[9];
+ char hwdep_name[9];
snd_hwdep_t *hwdep_handle;
- hw = (jack_hardware_t *) malloc (sizeof (jack_hardware_t));
+ hw = (jack_hardware_t*)malloc (sizeof(jack_hardware_t));
hw->capabilities = 0;
hw->input_monitor_mask = 0;
@@ -661,22 +675,23 @@ jack_alsa_usx2y_hw_new (alsa_driver_t *driver)
*/
hwdep_handle = NULL;
hwdep_cardno = hwdep_devno = 0;
- if ((hwdep_colon = strrchr(driver->alsa_name_playback, ':')) != NULL)
- sscanf(hwdep_colon, ":%d,%d", &hwdep_cardno, &hwdep_devno);
+ if ((hwdep_colon = strrchr (driver->alsa_name_playback, ':')) != NULL) {
+ sscanf (hwdep_colon, ":%d,%d", &hwdep_cardno, &hwdep_devno);
+ }
if (hwdep_devno == 2) {
- snprintf(hwdep_name, sizeof(hwdep_name), "hw:%d,1", hwdep_cardno);
+ snprintf (hwdep_name, sizeof(hwdep_name), "hw:%d,1", hwdep_cardno);
if (snd_hwdep_open (&hwdep_handle, hwdep_name, O_RDWR) < 0) {
jack_error ("ALSA/USX2Y: Cannot open hwdep device \"%s\"", hwdep_name);
} else {
/* Allocate specific USX2Y hwdep pcm struct. */
- h = (usx2y_t *) malloc (sizeof (usx2y_t));
+ h = (usx2y_t*)malloc (sizeof(usx2y_t));
h->driver = driver;
h->hwdep_handle = hwdep_handle;
hw->private = h;
/* Set our own operational function pointers. */
- usx2y_driver_setup(driver);
- jack_info("ALSA/USX2Y: EXPERIMENTAL hwdep pcm device %s"
- " (aka \"rawusb\")", driver->alsa_name_playback);
+ usx2y_driver_setup (driver);
+ jack_info ("ALSA/USX2Y: EXPERIMENTAL hwdep pcm device %s"
+ " (aka \"rawusb\")", driver->alsa_name_playback);
}
}
diff --git a/drivers/alsa/usx2y.h b/drivers/alsa/usx2y.h
index 8876d94..853f307 100644
--- a/drivers/alsa/usx2y.h
+++ b/drivers/alsa/usx2y.h
@@ -1,7 +1,7 @@
/*
Copyright (C) 2001 Paul Davis
Copyright (C) 2004 Karsten Wiese, Rui Nuno Capela
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -16,14 +16,14 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ */
#ifndef __jack_usx2y_h__
#define __jack_usx2y_h__
-#define USX2Y_MAXPACK 50
-#define USX2Y_MAXBUFFERMS 100
-#define USX2Y_MAXSTRIDE 3
+#define USX2Y_MAXPACK 50
+#define USX2Y_MAXBUFFERMS 100
+#define USX2Y_MAXSTRIDE 3
#define USX2Y_SSS (((USX2Y_MAXPACK * USX2Y_MAXBUFFERMS * USX2Y_MAXSTRIDE + 4096) / 4096) * 4096)
@@ -34,9 +34,9 @@ struct snd_usX2Y_hwdep_pcm_shm {
volatile int playback_iso_head;
int playback_iso_start;
struct {
- int frame,
- offset,
- length;
+ int frame,
+ offset,
+ length;
} captured_iso[128];
volatile int captured_iso_head;
volatile unsigned captured_iso_frames;
@@ -56,6 +56,6 @@ typedef struct {
} usx2y_t;
jack_hardware_t *
-jack_alsa_usx2y_hw_new (alsa_driver_t *driver);
+jack_alsa_usx2y_hw_new(alsa_driver_t *driver);
#endif /* __jack_usx2y_h__*/