|
68 | 68 | #include "vssglobals.h"
|
69 | 69 | #include "VAlgorithm.h" // only for dBFromScalar()
|
70 | 70 |
|
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 |
| - |
76 | 71 | using std::cerr;
|
77 | 72 |
|
78 | 73 | #ifdef VSS_LINUX_UBUNTU
|
@@ -206,28 +201,6 @@ static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams)
|
206 | 201 | }
|
207 | 202 | #endif // VSS_LINUX_UBUNTU
|
208 | 203 |
|
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 |
| - |
231 | 204 | #ifdef VSS_LINUX
|
232 | 205 |
|
233 | 206 | #include <linux/soundcard.h>
|
@@ -482,176 +455,6 @@ int Initsynth(int /*udp_port*/, float srate, int nchans,
|
482 | 455 | #endif
|
483 | 456 | #endif // VSS_LINUX_UBUNTU
|
484 | 457 |
|
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(¶ms, 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(¶ms.format, &pformat, sizeof(pformat)); |
589 |
| - |
590 |
| - if ((err = snd_pcm_channel_params(pcm_handle_write, ¶ms) < 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(¶ms, 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(¶ms.format, &rformat, sizeof(rformat)); |
636 |
| - |
637 |
| - if ((err = snd_pcm_channel_params(pcm_handle_read, ¶ms) < 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 |
| - |
655 | 458 | #ifdef VSS_WINDOWS
|
656 | 459 | if (vfMMIO)
|
657 | 460 | {
|
@@ -798,28 +601,13 @@ void VSS_ResyncHardware()
|
798 | 601 | if (pcm_handle_write)
|
799 | 602 | snd_pcm_drain(pcm_handle_write);
|
800 | 603 | #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 |
814 | 604 | }
|
815 | 605 |
|
816 | 606 | // How many samples can we compute without getting too far ahead?
|
817 | 607 | int Scount()
|
818 | 608 | {
|
819 | 609 | #ifdef VSS_IRIX
|
820 | 610 | return alGetFilled(alp);
|
821 |
| -#elif defined VSS_LINUX_ALSA |
822 |
| - return MaxSampsPerBuffer; // lie, always return MaxSampsPerBuffer, just to get it running! |
823 | 611 | #elif defined VSS_LINUX_UBUNTU
|
824 | 612 | // # frames ready to capture or play (how far from xrun): snd_pcm_avail(), or cheap approximate snd_pcm_avail_update().
|
825 | 613 | return pcm_handle_write ? snd_pcm_avail_update(pcm_handle_write) : 0;
|
@@ -856,11 +644,6 @@ void Closesynth()
|
856 | 644 | snd_pcm_drain(pcm_handle_read);
|
857 | 645 | snd_pcm_close(pcm_handle_read);
|
858 | 646 | }
|
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); |
864 | 647 | #elif defined VSS_WINDOWS
|
865 | 648 | if (vfCalledback)
|
866 | 649 | {
|
@@ -937,9 +720,7 @@ int Synth(int n, int nchans)
|
937 | 720 | int i,j;
|
938 | 721 | if (liveaudio && fSoundIn)
|
939 | 722 | {
|
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 |
943 | 724 | const int rc = snd_pcm_readi(pcm_handle_read, ibuf, n);
|
944 | 725 | if (rc == -EPIPE) {
|
945 | 726 | fprintf(stderr, "vss: input overrun.\n");
|
@@ -1134,9 +915,7 @@ int Synth(int n, int nchans)
|
1134 | 915 | int samps = ssp - sampbuff;
|
1135 | 916 | if (liveaudio)
|
1136 | 917 | {
|
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 |
1140 | 919 | alWriteFrames(alp, sampbuff, samps/nchans);
|
1141 | 920 | alSetFillPoint(alp, (long)(qsize-latency));
|
1142 | 921 | #elif defined VSS_WINDOWS
|
|
0 commit comments