Skip to content

Commit 98a3ed2

Browse files
committed
retire manually installed ALSA
1 parent 7ce1029 commit 98a3ed2

File tree

4 files changed

+10
-256
lines changed

4 files changed

+10
-256
lines changed

Platform

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ uname := $(shell sh -c 'uname -s 2>/dev/null')
55

66
ifeq ($(uname),Linux)
77
PLATFORM := VSS_LINUX_UBUNTU
8-
# PLATFORM := VSS_LINUX_21ALSA
9-
# PLATFORM := VSS_LINUX_20ALSA
108
# To detect WSL, try uname -r.
119
endif
1210

Rules.common

+7-30
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,12 @@ endif
1818
ifeq "$(PLATFORM)" "VSS_IRIX_65"
1919
PLATFORMBASE := VSS_IRIX
2020
endif
21-
ifeq "$(PLATFORM)" "VSS_LINUX_20ALSA"
22-
PLATFORMBASE := VSS_LINUX
23-
endif
2421
ifeq "$(PLATFORM)" "VSS_REDHAT7"
2522
PLATFORMBASE := VSS_LINUX
2623
endif
2724
ifeq "$(PLATFORM)" "VSS_LINUX_UBUNTU"
2825
PLATFORMBASE := VSS_LINUX
2926
endif
30-
ifeq "$(PLATFORM)" "VSS_LINUX_21ALSA"
31-
PLATFORMBASE := VSS_LINUX
32-
endif
3327
ifeq "$(PLATFORM)" "VSS_CYGWIN32_NT40"
3428
PLATFORMBASE := VSS_WINDOWS
3529
endif
@@ -56,47 +50,29 @@ CcFLAGS := $(INC) -D$(PLATFORMBASE) -D$(PLATFORM) -Wall -Ofast
5650
LDFLAGS :=
5751

5852
ifeq "$(PLATFORM)" "VSS_IRIX_53"
59-
CcFLAGS += -I/usr/local/gnu/include/g++ -I/usr/local/gnu/mips-sgi-irix5.3/include
60-
CcFLAGS += -mips2
53+
CcFLAGS += -I/usr/local/gnu/include/g++ -I/usr/local/gnu/mips-sgi-irix5.3/include -mips2
6154
CFLAGS := $(CcFLAGS)
62-
cFLAGS := $(CcFLAGS)
6355
LDFLAGS += -L/usr/local/gnu/lib # to find libstdc++.a
6456
endif
6557
ifeq "$(PLATFORM)" "VSS_IRIX_62"
6658
CFLAGS := $(CcFLAGS)
67-
cFLAGS := $(CcFLAGS)
6859
endif
6960
ifeq "$(PLATFORM)" "VSS_IRIX_65"
7061
CcFLAGS += -DVSS_IRIX_63PLUS
7162
# -mips3 or -mips4 cause compile errors in STL.
7263
CFLAGS := $(CcFLAGS)
73-
cFLAGS := $(CcFLAGS)
7464
endif
7565
ifeq "$(PLATFORM)" "VSS_IRIX_63"
7666
CcFLAGS += -DVSS_IRIX_63PLUS
7767
# -mips3 or -mips4 cause compile errors in STL.
7868
CFLAGS := $(CcFLAGS)
79-
cFLAGS := $(CcFLAGS)
8069
endif
8170

82-
# -march=pentiumpro
83-
ifeq "$(PLATFORM)" "VSS_LINUX_20ALSA"
84-
#CcFLAGS += -DREDHAT52 -malign-double
85-
CFLAGS = $(CcFLAGS) -fno-exceptions
86-
cFLAGS = $(CcFLAGS)
87-
LDFLAGS := -lasound
88-
endif
8971
ifeq "$(PLATFORM)" "VSS_LINUX_UBUNTU"
90-
CFLAGS = $(CcFLAGS) -fno-exceptions
91-
cFLAGS = $(CcFLAGS)
92-
LDFLAGS := -lasound
93-
endif
94-
ifeq "$(PLATFORM)" "VSS_LINUX_21ALSA"
95-
#CcFLAGS += -g -DREDHAT52 -malign-double
96-
CFLAGS = $(CcFLAGS) -fno-exceptions
97-
cFLAGS = $(CcFLAGS)
98-
LDFLAGS := -lasound
72+
CFLAGS := $(CcFLAGS) -fno-exceptions
73+
LDFLAGS := -lasound
9974
endif
75+
10076
ifeq "$(PLATFORMBASE)" "VSS_WINDOWS"
10177
# VSS_CYGWIN32_NT40
10278
CcFLAGS += -malign-double
@@ -106,10 +82,11 @@ ifeq "$(PLATFORMBASE)" "VSS_WINDOWS"
10682
# maybe do a full build now. also remove -ldsound and -lwinmm.
10783
CYG=/cygdrive/d/cygwin
10884
LDFLAGS := -L $(CYG)/lib -L /usr/local/lib -ldsound -lwinmm -lole32
109-
CFLAGS = $(CcFLAGS) -fno-exceptions
110-
cFLAGS = $(CcFLAGS)
85+
CFLAGS := $(CcFLAGS) -fno-exceptions
11186
endif
11287

88+
cFLAGS := $(CcFLAGS)
89+
11390
# Optional file containing debugging options for CcFLAGS, LDFLAGS, etc.
11491
-include Rules.debug
11592

msg/messageGroup.c++

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const char MessageGroup::HandleDelim = '?';
2020
// construction
2121
//
2222
MessageGroup::MessageGroup() :
23-
#ifdef VSS_LINUX_20ALSA
23+
#ifdef VSS_MATH_HACK
2424
fMathHack(0),
2525
#endif
2626
recentHandle( hNil )

platform.c++

+2-223
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@
6868
#include "vssglobals.h"
6969
#include "VAlgorithm.h" // only for dBFromScalar()
7070

71-
#if defined VSS_LINUX_20ALSA || defined VSS_LINUX_21ALSA
72-
// VSS_LINUX_21ALSA is for ALSA 0.5.3+.
73-
#define VSS_LINUX_ALSA
74-
#endif
75-
7671
using std::cerr;
7772

7873
#ifdef VSS_LINUX_UBUNTU
@@ -206,28 +201,6 @@ static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams)
206201
}
207202
#endif // VSS_LINUX_UBUNTU
208203

209-
#ifdef VSS_LINUX_ALSA
210-
#ifdef VSS_LINUX_20ALSA
211-
#include <sys/soundlib.h>
212-
#include "/home/camilleg/audio_src/ALSA_0.1.4/ALSA/alsa-utils/include/config.h"
213-
#include "/home/camilleg/audio_src/ALSA_0.1.4/ALSA/alsa-utils/aplay/formats.h"
214-
void *pcm_handle_read = NULL;
215-
void *pcm_handle_write = NULL;
216-
struct snd_pcm_playback_info pinfo;
217-
struct snd_pcm_record_info rinfo;
218-
#define SND_PCM_OPEN_CAPTURE O_RDONLY
219-
#endif
220-
#ifdef VSS_LINUX_21ALSA
221-
#include <alsa/asoundlib.h> /* BS: changed 04/24/2006 -- although I didn't get the ALSA version working */
222-
snd_pcm_t *pcm_handle_read = NULL;
223-
snd_pcm_t *pcm_handle_write = NULL;
224-
#define snd_pcm_playback_info(a,b) snd_pcm_info(a,b)
225-
#define snd_pcm_record_info(a,b) snd_pcm_info(a,b)
226-
snd_pcm_info_t pinfo, rinfo;
227-
#endif
228-
snd_pcm_format_t pformat, rformat;
229-
#endif
230-
231204
#ifdef VSS_LINUX
232205

233206
#include <linux/soundcard.h>
@@ -482,176 +455,6 @@ int Initsynth(int /*udp_port*/, float srate, int nchans,
482455
#endif
483456
#endif // VSS_LINUX_UBUNTU
484457

485-
#ifdef VSS_LINUX_ALSA
486-
int err;
487-
488-
// O_RDWR O_WRONLY are actually SND_PCM_OPEN_DUPLEX SND_PCM_OPEN_PLAYBACK
489-
if ((err = snd_pcm_open( &pcm_handle_write, 0/*card*/, 0/*dev*/, SND_PCM_OPEN_PLAYBACK)) < 0)
490-
{
491-
fprintf(stderr, "vss error: can't open audio output port: %s\n", snd_strerror(err));
492-
liveaudio = 0;
493-
goto LContinue;
494-
}
495-
496-
{
497-
snd_pcm_channel_info_t info;
498-
memset(&info, 0, sizeof(info));
499-
if ((err = snd_pcm_channel_info(pcm_handle_write, &info)) < 0)
500-
{
501-
fprintf(stderr, "ALSA->open(): %s\n", snd_strerror(err));
502-
liveaudio = 0;
503-
goto LContinue;
504-
}
505-
}
506-
507-
{
508-
if (fSoundIn)
509-
{
510-
if ((err = snd_pcm_open( &pcm_handle_read, 0/*card*/, 0/*dev*/, SND_PCM_OPEN_CAPTURE)) < 0)
511-
{
512-
fSoundIn = 0;
513-
fprintf(stderr, "vss warning: can't open audio input port.\n");
514-
}
515-
}
516-
}
517-
518-
// can we play sounds ok?
519-
if ( (err = snd_pcm_playback_info(pcm_handle_write, &pinfo )) < 0 )
520-
{
521-
fprintf(stderr, "vss error: playback info error: %s\n",
522-
snd_strerror(err));
523-
liveaudio = 0;
524-
goto LContinue;
525-
}
526-
if (fSoundIn)
527-
{
528-
if ( (err = snd_pcm_record_info(pcm_handle_read, &rinfo )) < 0 )
529-
{
530-
fprintf(stderr, "vss error: record info error: %s\n",
531-
snd_strerror(err));
532-
}
533-
534-
/*
535-
printf("\n\nplayback info flags %x\n", pinfo.flags);
536-
printf("\n\nrecord info flags %x\n", rinfo.flags);
537-
*/
538-
/*
539-
printf("\n\nplayback frag bounds: %d %d, align %d\n\n",
540-
pinfo.min_fragment_size,
541-
pinfo.max_fragment_size,
542-
pinfo.fragment_align);;
543-
544-
printf("\n\nrecord frag bounds: %d %d, align %d\n\n",
545-
rinfo.min_fragment_size,
546-
rinfo.max_fragment_size,
547-
rinfo.fragment_align);;
548-
*/
549-
550-
}
551-
552-
// Set up playback format.
553-
#ifdef VSS_LINUX_20ALSA
554-
memset( &pformat, 0, sizeof( pformat ) );
555-
pformat.format = SND_PCM_SFMT_S16_LE;
556-
pformat.rate = (unsigned int)srate;
557-
pformat.channels = nchans;
558-
// printf("playing %i Hz, %i channels\n", pformat.rate, pformat.channels);
559-
if (snd_pcm_playback_format(pcm_handle_write, &pformat) < 0)
560-
{
561-
fprintf(stderr, "vss error: unable to set playback format %iHz, %i channels\n",
562-
pformat.rate, pformat.channels);
563-
}
564-
struct snd_pcm_playback_params pparams;
565-
memset( &pparams, 0, sizeof( pparams ) );
566-
pparams.fragment_size = 256; // 16-bit, mono.
567-
pparams.fragments_max = 8; //;; was 1, then was 3
568-
pparams.fragments_room = 8; //;; was 1, then was 3
569-
// we need 4 not 1 (well, maybe 3) to accommodate HidimMapper.
570-
if ( snd_pcm_playback_params(pcm_handle_write, &pparams ) < 0 )
571-
{
572-
fprintf(stderr, "vss error: unable to set playback params\n");
573-
liveaudio = 0;
574-
goto LContinue;
575-
}
576-
#else // VSS_LINUX_21ALSA
577-
snd_pcm_channel_params_t params;
578-
memset(&params, 0, sizeof(params));
579-
params.channel = SND_PCM_CHANNEL_PLAYBACK;
580-
params.buf.block.frag_size = 256; // 16-bit, mono.
581-
params.buf.block.frags_max = 3;
582-
params.buf.block.frags_min = 3;
583-
memset( &pformat, 0, sizeof( pformat ) );
584-
pformat.format = SND_PCM_SFMT_S16_LE;
585-
pformat.rate = (int)srate;
586-
pformat.voices = nchans;
587-
pformat.interleave = 1;
588-
memcpy(&params.format, &pformat, sizeof(pformat));
589-
590-
if ((err = snd_pcm_channel_params(pcm_handle_write, &params) < 0))
591-
{
592-
fprintf(stderr, "vss error: unable to set playback format %iHz, %i channels\n\t\"%s\"\n",
593-
pformat.rate, pformat.voices, snd_strerror(err));
594-
liveaudio = 0;
595-
goto LContinue;
596-
}
597-
printf("playing %i Hz, %i channels\n", pformat.rate, pformat.voices);
598-
#endif // VSS_LINUX_21ALSA
599-
600-
if (fSoundIn)
601-
{
602-
globs.nchansIn = nchansIn = nchansInArg;
603-
if (nchansIn == 0)
604-
fprintf(stderr, "vss warning: input has 0 channels.\n");
605-
#ifdef VSS_LINUX_20ALSA
606-
memset( &rformat, 0, sizeof( rformat ) );
607-
rformat.format = SND_PCM_SFMT_S16_LE;
608-
rformat.rate = (unsigned int)srate;
609-
rformat.channels = nchansIn;
610-
if (snd_pcm_record_format(pcm_handle_read, &rformat ) < 0 )
611-
{
612-
fprintf(stderr, "vss error: unable to set record format %i Hz, %i channels\n",
613-
rformat.rate, rformat.channels);
614-
liveaudio = 0;
615-
goto LContinue;
616-
}
617-
// printf("recording %i Hz, %i channels\n", rformat.rate, rformat.channels);
618-
struct snd_pcm_record_params rparams = {0};
619-
rparams.fragment_size = 256; // 16-bit, mono.
620-
rparams.fragments_min = 8; //;; was 1, then was 2.
621-
if (snd_pcm_record_params(pcm_handle_read, &rparams ) < 0 )
622-
fprintf(stderr, "vss error: unable to set record params\n");
623-
#else // VSS_LINUX_21ALSA
624-
snd_pcm_channel_params_t params;
625-
memset(&params, 0, sizeof(params));
626-
params.channel = SND_PCM_CHANNEL_CAPTURE;
627-
params.buf.block.frag_size = 256; // 16-bit, mono.
628-
params.buf.block.frags_max = 3;
629-
params.buf.block.frags_min = 3;
630-
memset( &rformat, 0, sizeof( rformat ) );
631-
rformat.format = SND_PCM_SFMT_S16_LE;
632-
rformat.rate = (int)srate;
633-
rformat.voices = nchansIn;
634-
rformat.interleave = 1;
635-
memcpy(&params.format, &rformat, sizeof(rformat));
636-
637-
if ((err = snd_pcm_channel_params(pcm_handle_read, &params) < 0))
638-
{
639-
fprintf(stderr, "vss error: unable to set record format %i Hz, %i channels\n",
640-
rformat.rate, rformat.voices);
641-
liveaudio = 0;
642-
goto LContinue;
643-
}
644-
printf("recording %i Hz, %i channels\n", rformat.rate, rformat.voices);
645-
646-
#endif // VSS_LINUX_21ALSA
647-
}
648-
#ifdef VSS_LINUX_20ALSA
649-
fdDAC = snd_pcm_file_descriptor(pcm_handle_write);
650-
#else
651-
fdDAC = snd_pcm_file_descriptor(pcm_handle_write, SND_PCM_CHANNEL_PLAYBACK);
652-
#endif
653-
#endif // VSS_LINUX_ALSA
654-
655458
#ifdef VSS_WINDOWS
656459
if (vfMMIO)
657460
{
@@ -798,28 +601,13 @@ void VSS_ResyncHardware()
798601
if (pcm_handle_write)
799602
snd_pcm_drain(pcm_handle_write);
800603
#endif
801-
#ifdef VSS_LINUX_ALSA
802-
#ifdef VSS_LINUX_20ALSA
803-
if (pcm_handle_read)
804-
snd_pcm_flush_record(pcm_handle_read);
805-
if (pcm_handle_write)
806-
snd_pcm_drain_playback(pcm_handle_write);
807-
#else // VSS_LINUX_21ALSA
808-
if (pcm_handle_read)
809-
snd_pcm_capture_flush(pcm_handle_read);
810-
if (pcm_handle_write)
811-
snd_pcm_playback_drain(pcm_handle_write);
812-
#endif // VSS_LINUX_21ALSA
813-
#endif // VSS_LINUX_ALSA
814604
}
815605

816606
// How many samples can we compute without getting too far ahead?
817607
int Scount()
818608
{
819609
#ifdef VSS_IRIX
820610
return alGetFilled(alp);
821-
#elif defined VSS_LINUX_ALSA
822-
return MaxSampsPerBuffer; // lie, always return MaxSampsPerBuffer, just to get it running!
823611
#elif defined VSS_LINUX_UBUNTU
824612
// # frames ready to capture or play (how far from xrun): snd_pcm_avail(), or cheap approximate snd_pcm_avail_update().
825613
return pcm_handle_write ? snd_pcm_avail_update(pcm_handle_write) : 0;
@@ -856,11 +644,6 @@ void Closesynth()
856644
snd_pcm_drain(pcm_handle_read);
857645
snd_pcm_close(pcm_handle_read);
858646
}
859-
#elif defined VSS_LINUX_ALSA
860-
if (pcm_handle_write)
861-
snd_pcm_close(pcm_handle_write);
862-
if (pcm_handle_read)
863-
snd_pcm_close(pcm_handle_read);
864647
#elif defined VSS_WINDOWS
865648
if (vfCalledback)
866649
{
@@ -937,9 +720,7 @@ int Synth(int n, int nchans)
937720
int i,j;
938721
if (liveaudio && fSoundIn)
939722
{
940-
#ifdef VSS_LINUX_ALSA
941-
(void)snd_pcm_read(pcm_handle_read, ibuf, n * nchansIn * sizeof(short));
942-
#elif defined VSS_LINUX_UBUNTU
723+
#ifdef VSS_LINUX_UBUNTU
943724
const int rc = snd_pcm_readi(pcm_handle_read, ibuf, n);
944725
if (rc == -EPIPE) {
945726
fprintf(stderr, "vss: input overrun.\n");
@@ -1134,9 +915,7 @@ int Synth(int n, int nchans)
1134915
int samps = ssp - sampbuff;
1135916
if (liveaudio)
1136917
{
1137-
#ifdef VSS_LINUX_ALSA
1138-
(void)snd_pcm_write(pcm_handle_write, sampbuff, samps*sizeof(short));
1139-
#elif defined VSS_IRIX
918+
#ifdef VSS_IRIX
1140919
alWriteFrames(alp, sampbuff, samps/nchans);
1141920
alSetFillPoint(alp, (long)(qsize-latency));
1142921
#elif defined VSS_WINDOWS

0 commit comments

Comments
 (0)