~ubuntu-branches/ubuntu/vivid/oss4/vivid

« back to all changes in this revision

Viewing changes to tutorials/sndkit/tests/multich16.c

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis, Samuel Thibault, Romain Beauxis, Sebastien NOEL
  • Date: 2011-06-14 10:06:56 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110614100656-cx4oc7u426zn812z
Tags: 4.2-build2004-1
[ Samuel Thibault ]
* debian/control: Add liboss4-salsa2, liboss4-salsa-dev and
  liboss4-salsa-asound2 packages, equivalent to (and will replace) those from
  the oss-libsalsa package (Closes: #589127).
* debian/patches/liboss4-salsa.patch: New patch to rename libsalsa into
  liboss4-salsa to avoid conflicts in the archive for no good reason.
* debian/rules: Make in libOSSlib and libsalsa.
* debian/liboss4-salsa-dev.install, debian/liboss4-salsa2.install,
  debian/liboss4-salsa-asound2.links, debian/liboss4-salsa-dev.links:
  Install liboss4-salsa libraries like was done in the oss-libsalsa package.
* include-alsa: Add a copy of ALSA 1.0.5 headers: Cf ALSA_1.0.* symbols in
  libsalsa, this is the roughly supported version.
* debian/copyright: Update for new include-alsa files.
* alsa.pc: New file for compatibility with libasound-dev.
* debian/control:
  - Add Vcs-Browser and Vcs-Svn fields.
  - Use linux-any instead of the list of Linux archs (Closes: #604679).
  - Make dkms dependency linux-any only.
* debian/patches/hurd_iot.patch: New patch to fix soundcard.h usage in
  libsalsa on hurd-i386.
* debian/patches/libsalsa_fixes.patch: New patch to fix some printf usages
  and ioctl declaration in libsalsa.
* debian/patches/no_EBADE.patch: New patch to cope with hurd-i386 not having
  EBADE.
* debian/patches/CFLAGS.patch: New patch to make oss4 take debian/rules
  CFLAGS into account.
* debian/patches/snd_asoundlib_version.patch: New patch to add
  snd_asoundlib_version().
* debian/patches/generic_srccconf.patch: New patch to fix source
  configuration on unknown archs.

[ Romain Beauxis ]
* Fixed README.Debian to only mention dkms' modules.
* Switch to dpkg-source 3.0 (quilt) format
* Added DM-Upload-Allowed: yes

[ Sebastien NOEL ]
* New upstream release (Closes: #595298, #619272).
* Fix typo in initscript (Closes: #627149).
* debian/control: adjust linux-headers dependencies (Closes: #628879).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Multi channel audio test.
 
3
 *
 
4
 * This program is intended to test playback of 16 bit samples using 4 or more
 
5
 * channels at 48000 Hz. The program plays sine wave pulses sequentially on
 
6
 * channels 0 to N-1.
 
7
 *
 
8
 * Arguments:
 
9
 *
 
10
 * 1:   Number of channelts (default is 8).
 
11
 * 2:   Audio device (/dev/dsp by default).
 
12
 * 3-N: Options
 
13
 *        -b    Bypass virtual mixer
 
14
 *        -r    Raw mode (disables automatic sample rate/format conversions)
 
15
 */
 
16
#include <stdio.h>
 
17
#include <stdlib.h>
 
18
#include <unistd.h>
 
19
#include <fcntl.h>
 
20
#include <sys/ioctl.h>
 
21
#include <soundcard.h>
 
22
 
 
23
static int sinedata[48] = {
 
24
 
 
25
  0, 4276, 8480, 12539, 16383, 19947, 23169, 25995,
 
26
  28377, 30272, 31650, 32486, 32767, 32486, 31650, 30272,
 
27
  28377, 25995, 23169, 19947, 16383, 12539, 8480, 4276,
 
28
  0, -4276, -8480, -12539, -16383, -19947, -23169, -25995,
 
29
  -28377, -30272, -31650, -32486, -32767, -32486, -31650, -30272,
 
30
  -28377, -25995, -23169, -19947, -16383, -12539, -8480, -4276
 
31
};
 
32
 
 
33
int
 
34
main (int argc, char *argv[])
 
35
{
 
36
  char *dev = "/dev/dsp";
 
37
  int fd, l, i, n = 0, ch, p = 0, phase = 0, arg, channels, srate, thisch = 0;
 
38
  int tick = 0;
 
39
  int nch = 8;
 
40
  int bypass_vmix=0;
 
41
  int disable_format_conversions=0;
 
42
 
 
43
  short buf[1024];
 
44
 
 
45
  if (argc > 1)
 
46
    if (sscanf (argv[1], "%d", &nch) != 1)
 
47
      nch = 2;
 
48
 
 
49
  if (argc > 2)
 
50
    dev = argv[2];
 
51
 
 
52
  for (i=3;i<argc;i++)
 
53
  if (argv[i][0]=='-')
 
54
  switch (argv[i][1])
 
55
  {
 
56
  case 'b': /* Bypass virtual mixer */
 
57
          bypass_vmix = O_EXCL;
 
58
          break;
 
59
 
 
60
  case 'r': /* Use raw mode (disable automatic format conversions) */
 
61
          disable_format_conversions=1;
 
62
          break;
 
63
  }
 
64
 
 
65
  if ((fd = open (dev, O_WRONLY|bypass_vmix, 0)) == -1)
 
66
    {
 
67
      perror (dev);
 
68
      exit (-1);
 
69
    }
 
70
 
 
71
  if (disable_format_conversions)
 
72
     {
 
73
        arg=0;
 
74
        ioctl(fd, SNDCTL_DSP_COOKEDMODE, &arg);
 
75
     }
 
76
 
 
77
  arg = nch;
 
78
  if (ioctl (fd, SNDCTL_DSP_CHANNELS, &arg) == -1)
 
79
    perror ("SNDCTL_DSP_CHANNELS");
 
80
  channels = arg;
 
81
  fprintf (stderr, "Channels %d\n", arg);
 
82
 
 
83
  arg = AFMT_S16_NE;
 
84
  if (ioctl (fd, SNDCTL_DSP_SETFMT, &arg) == -1)
 
85
    perror ("SNDCTL_DSP_SETFMT");
 
86
  fprintf (stderr, "Format %x\n", arg);
 
87
 
 
88
  arg = 48000;
 
89
  if (ioctl (fd, SNDCTL_DSP_SPEED, &arg) == -1)
 
90
    perror ("SNDCTL_DSP_SPEED");
 
91
  printf ("Using sampling rate %d\n", arg);
 
92
  srate = arg;
 
93
 
 
94
  while (1)
 
95
    {
 
96
      for (ch = 0; ch < channels; ch++)
 
97
        {
 
98
          if (ch == thisch)
 
99
            {
 
100
              buf[p] = sinedata[phase];
 
101
              phase = (phase + 1 + (ch / 2)) % 48;
 
102
              if (phase == 0 && tick > 10 * channels)
 
103
                {
 
104
                  thisch = (thisch + 1) % channels;
 
105
                  tick = 0;
 
106
                }
 
107
            }
 
108
          else
 
109
            buf[p] = 0;
 
110
 
 
111
          p++;
 
112
 
 
113
          if (p >= sizeof (buf) / 2)
 
114
            {
 
115
              if (write (fd, buf, p * 2) != p * 2)
 
116
                perror ("write");
 
117
              p = 0;
 
118
              tick++;
 
119
 
 
120
            }
 
121
        }
 
122
      n++;
 
123
    }
 
124
 
 
125
  exit (0);
 
126
}