Permalink
Browse files

remove all the ALSA code

git-svn-id: http://svn.metadecks.org/libremix/trunk@320 e2d53364-18fc-0310-981e-b60a84739af0
  • Loading branch information...
1 parent 560968b commit 95205ee8ba32663762c6a05ab7ddf9966ab21d14 conrad committed Jan 25, 2006
Showing with 10 additions and 276 deletions.
  1. +0 −6 config.h.in
  2. +0 −12 configure.ac
  3. +1 −1 remix.pc.in
  4. +3 −3 src/examples/Makefile.am
  5. +6 −248 src/libremix/remix_monitor.c
  6. +0 −6 src/libremix/remix_private.h
View
@@ -3,12 +3,6 @@
/* Define to build experimental code */
#undef ANX_CONFIG_EXPERIMENTAL
-/* Set to 1 if using ALSA for sound output. */
-#undef HAVE_ALSA
-
-/* Define to 1 if you have the <alsa/asoundlib.h> header file. */
-#undef HAVE_ALSA_ASOUNDLIB_H
-
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
View
@@ -88,18 +88,6 @@ AC_CHECK_HEADERS(sys/soundcard.h)
AC_SUBST(BUILD_MONITOR)
AM_CONDITIONAL(BUILD_MONITOR, test -n "$BUILD_MONITOR")
-dnl Test for ALSA.
-
-HAVE_ALSA=0
-AC_CHECK_HEADERS(alsa/asoundlib.h)
- if test "x${ac_cv_header_alsa_asoundlib_h}" = xyes ; then
- HAVE_ALSA=1
- ALSA_LIBS="-lasound"
- AC_SUBST(ALSA_LIBS)
- fi
-
-AC_DEFINE_UNQUOTED([HAVE_ALSA],${HAVE_ALSA}, [Set to 1 if using ALSA for sound output.])
-
dnl
dnl Set PACKAGE_PLUGIN_DIR in Makefiles and config.h.
dnl
View
@@ -7,5 +7,5 @@ Name: remix
Description: An audio rendering library
Requires: ctxdata sndfile
Version: @VERSION@
-Libs: -L${libdir} -lremix -ldl @ALSA_LIBS@
+Libs: -L${libdir} -lremix -ldl
Cflags: -I${includedir}
View
@@ -15,10 +15,10 @@ cd_list_test_SOURCES = cd_list_test.c
cd_list_test_LDADD = ../ctxdata/libctxdata.la
noisedemo_SOURCES = noisedemo.c
-noisedemo_LDADD = $(REMIX_LIBS) @ALSA_LIBS@
+noisedemo_LDADD = $(REMIX_LIBS)
squaredemo_SOURCES = squaredemo.c
-squaredemo_LDADD = $(REMIX_LIBS) @ALSA_LIBS@
+squaredemo_LDADD = $(REMIX_LIBS)
sndfiledemo_SOURCES = sndfiledemo.c
-sndfiledemo_LDADD = $(REMIX_LIBS) @SNDFILE_LIBS@ @ALSA_LIBS@
+sndfiledemo_LDADD = $(REMIX_LIBS) @SNDFILE_LIBS@
@@ -40,13 +40,6 @@
#include <config.h>
-#if (HAVE_ALSA == 1)
-#define ALSA_PCM_OLD_HW_PARAMS_API
-#include <alsa/asoundlib.h>
-#else
-typedef void snd_pcm_t;
-#endif
-
#define __REMIX__
#include "remix.h"
@@ -70,19 +63,6 @@ typedef void snd_pcm_t;
static RemixMonitor * remix_monitor_optimise (RemixEnv * env, RemixMonitor * monitor);
static RemixBase *
-alsa_reset_device (RemixEnv * env, RemixBase * base, snd_pcm_t * alsa_dev,
- int channels, int samplerate);
-
-static snd_pcm_t * alsa_open_device (RemixEnv * env, RemixBase * base);
-
-static RemixCount
-alsa_write_float (RemixEnv * env, snd_pcm_t * alsa_dev, RemixPCM *data,
- RemixCount playcount);
-
-static void alsa_close_device (RemixMonitor * monitor);
-
-
-static RemixBase *
remix_monitor_reset_device (RemixEnv * env, RemixBase * base)
{
RemixMonitor * monitor = (RemixMonitor *)base;
@@ -109,11 +89,6 @@ remix_monitor_reset_device (RemixEnv * env, RemixBase * base)
return base;
}
- if (monitor->alsa_dev != NULL) {
- alsa_reset_device (env, base, monitor->alsa_dev, nr_channels, monitor->frequency);
- return base;
- }
-
if (ioctl (monitor->dev_dsp_fd, SNDCTL_DSP_GETFMTS, &monitor->mask) == -1) {
remix_set_error (env, REMIX_ERROR_SYSTEM);
return RemixNone;
@@ -171,19 +146,12 @@ remix_monitor_init (RemixEnv * env, RemixBase * base)
RemixMonitor * monitor = (RemixMonitor *)base;
monitor->dev_dsp_fd = -1;
- monitor->alsa_dev = NULL;
- if (HAVE_ALSA == 1) {
- monitor->alsa_dev = alsa_open_device (env, base);
- }
-
- if (monitor->alsa_dev == NULL) {
- monitor->dev_dsp_fd = open (FILENAME, O_WRONLY, 0);
- if (monitor->dev_dsp_fd == -1) {
- printf ("Couldn't open any output device.\n");
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
+ monitor->dev_dsp_fd = open (FILENAME, O_WRONLY, 0);
+ if (monitor->dev_dsp_fd == -1) {
+ printf ("Couldn't open any output device.\n");
+ remix_set_error (env, REMIX_ERROR_SYSTEM);
+ return RemixNone;
}
remix_monitor_reset_device (env, base);
@@ -216,9 +184,7 @@ remix_monitor_destroy (RemixEnv * env, RemixBase * base)
{
RemixMonitor * monitor = (RemixMonitor *)base;
- if (monitor->alsa_dev != NULL) {
- alsa_close_device (monitor);
- } else if (monitor->dev_dsp_fd != -1) {
+ if (monitor->dev_dsp_fd != -1) {
close (monitor->dev_dsp_fd);
}
remix_free (monitor);
@@ -255,11 +221,6 @@ remix_monitor_write_short (RemixEnv * env, RemixMonitor * monitor, RemixCount co
RemixCount n = 0;
fd_set fds;
- if (monitor->alsa_dev != NULL) {
- printf ("1 ######## Should not be here if using ALSA.\n");
- return count;
- }
-
if (!(monitor->format & AFMT_S16_LE)) {
printf ("###### device cannot play AFMT_S16_LE nicely\n");
return count;
@@ -297,13 +258,6 @@ remix_monitor_playbuffer (RemixEnv * env, RemixMonitor * monitor, RemixPCM * dat
RemixPCM value;
const RemixPCM max_value = (RemixPCM)SHRT_MAX / 2;
- if (monitor->alsa_dev != NULL) {
- /* Assuming here that we have two channels. */
- i = alsa_write_float (env, monitor->alsa_dev, data, count / 2) * 2;
-
- return i;
- }
-
for (i = 0; i < count; i++) {
value = *data++ * max_value;
monitor->playbuffer[i] = (short)value;
@@ -323,23 +277,6 @@ remix_monitor_chunk (RemixEnv * env, RemixChunk * chunk, RemixCount offset,
RemixCount remaining = count, written = 0, n, playcount;
RemixPCM * d;
- if (monitor->alsa_dev != NULL) {
- while (remaining > 0) {
- playcount = MIN (remaining, REMIX_MONITOR_BUFFERLEN);
- d = &chunk->data[offset];
- n = alsa_write_float (env, monitor->alsa_dev, d, playcount);
-
- if (n == -1) {
- return -1;
- }
-
- offset += n;
- written += n;
- remaining -= n;
- }
- return written;
- }
-
if (monitor->dev_dsp_fd == -1) {
remix_dprintf ("[remix_monitor_chunk] no file\n");
remix_set_error (env, REMIX_ERROR_NOENTITY); /* XXX: different error ? */
@@ -445,182 +382,3 @@ remix_monitor_optimise (RemixEnv * env, RemixMonitor * monitor)
_remix_set_methods (env, (RemixBase *)monitor, &_remix_monitor_methods);
return monitor;
}
-
-#if (HAVE_ALSA == 0)
-
-static snd_pcm_t *
-alsa_open_device (RemixEnv * env, RemixBase * base)
-{
- env = env;
- base = base;
- return NULL;
-}
-
-static RemixBase *
-alsa_reset_device (RemixEnv * env, RemixBase * base, snd_pcm_t * alsa_dev, int channels, int samplerate)
-{
- env = env;
- alsa_dev = alsa_dev;
- channels = channels;
- samplerate = samplerate;
- return base;
-}
-
-static RemixCount
-alsa_write_float (RemixEnv * env, snd_pcm_t * alsa_dev, RemixPCM *data,
- RemixCount playcount)
-{
- env = env;
- alsa_dev = alsa_dev;
- data = data;
- return playcount;
-}
-
-static void
-alsa_close_device (RemixMonitor * monitor)
-{
- monitor = monitor;
-}
-
-#else
-
-static snd_pcm_t *
-alsa_open_device (RemixEnv * env, RemixBase * base)
-{
- snd_pcm_t *alsa_device = NULL;
- char *device_name = "default";
- int error;
-
- if ((error = snd_pcm_open (&alsa_device, device_name, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
- return NULL;
- }
-
- return alsa_device;
-}
-
-static RemixBase *
-alsa_reset_device (RemixEnv * env, RemixBase * base, snd_pcm_t * alsa_dev,
- int channels, int samplerate)
-{
- snd_pcm_hw_params_t *hw_params;
- int periods;
- int error;
-
- if ((error = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- if ((error = snd_pcm_hw_params_any (alsa_dev, hw_params)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- if ((error = snd_pcm_hw_params_set_access (alsa_dev, hw_params,
- SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- if ((error = snd_pcm_hw_params_set_format (alsa_dev, hw_params,
- SND_PCM_FORMAT_FLOAT)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- if ((error = snd_pcm_hw_params_set_rate_near (alsa_dev, hw_params,
- samplerate, 0)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- if ((error = snd_pcm_hw_params_set_channels (alsa_dev, hw_params, channels)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- if ((error = snd_pcm_hw_params_set_period_size (alsa_dev, hw_params,
- REMIX_MONITOR_BUFFERLEN/channels, 0)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- periods = MIN (4, snd_pcm_hw_params_get_periods_max (hw_params, 0));
- periods =
- MAX (periods, snd_pcm_hw_params_get_periods_min (hw_params, 0));
-
- if ((error = snd_pcm_hw_params_set_periods (alsa_dev, hw_params,
- periods, 0)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- if ((error = snd_pcm_hw_params (alsa_dev, hw_params)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- snd_pcm_hw_params_free (hw_params);
-
- if ((error = snd_pcm_prepare (alsa_dev)) < 0) {
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return RemixNone;
- }
-
- return base;
-}
-
-static RemixCount
-alsa_write_float (RemixEnv * env, snd_pcm_t * alsa_dev, RemixPCM *data,
- RemixCount playcount /* frames */)
-{
- snd_pcm_status_t * status;
- int err;
-
- /*printf ("want to write %ld thingies\n", playcount);*/
-
- if (snd_pcm_wait (alsa_dev, 1000) < 0) {
- printf ("snd_pcm_wait error\n");
- remix_set_error (env, REMIX_ERROR_SYSTEM);
- return -1;
- }
-
- err = snd_pcm_writei (alsa_dev, data, playcount);
-
- if (err == -EPIPE) {
- snd_pcm_status_alloca(&status);
- if ((err = snd_pcm_status(alsa_dev, status))<0) {
- fprintf(stderr, "Remix: alsa_write: xrun. can't determine length\n");
- } else {
- if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
- struct timeval now, diff, tstamp;
- gettimeofday(&now, 0);
- snd_pcm_status_get_trigger_tstamp(status, &tstamp);
- timersub(&now, &tstamp, &diff);
- fprintf(stderr, "Remix: alsa_write: xrun of at least %.3f msecs. "
- "resetting stream\n", diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
- } else {
- fprintf(stderr, "Remix: alsa_write: xrun. can't determine length\n");
- }
- }
- snd_pcm_prepare(alsa_dev);
- err = snd_pcm_writei(alsa_dev, data, playcount);
- if (err != playcount) {
- fprintf(stderr, "Remix: alsa_write: %s\n", snd_strerror(err));
- return 0;
- } else if (err < 0) {
- fprintf(stderr, "Remix: alsa_write: %s\n", snd_strerror(err));
- return 0;
- }
- }
-
- return err;
-}
-
-static void
-alsa_close_device (RemixMonitor * monitor)
-{
- snd_pcm_close (monitor->alsa_dev);
- monitor->alsa_dev = NULL;
-}
-#endif
@@ -169,11 +169,6 @@ typedef struct _RemixMonitor RemixMonitor;
#define REMIX_MONITOR_BUFFERLEN 2048
-/* Opaque type from <alsa/pcm.h> */
-#ifndef __ALSA_PCM_H
-typedef struct _snd_pcm snd_pcm_t;
-#endif
-
struct _RemixMonitor {
RemixBase base;
RemixPCM databuffer[REMIX_MONITOR_BUFFERLEN];
@@ -186,7 +181,6 @@ struct _RemixMonitor {
int frequency;
int numfrags;
int fragsize;
- snd_pcm_t *alsa_dev;
};
#define _remix_time_zero(t) (RemixTime)\

0 comments on commit 95205ee

Please sign in to comment.