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

« back to all changes in this revision

Viewing changes to tutorials/sndkit/tests/seltest2.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
  Purpose: This program has been used to verify that the select() call works
 
3
 * Copyright (C) 4Front Technologies, 2002-2004. Released under GPLv2/CDDL.
 
4
 *
 
5
 * Description:
 
6
 * This program opens an audio device and then just
 
7
 * copies input to output. Select is used for flow control.
 
8
 */
 
9
#include <stdio.h>
 
10
#include <unistd.h>
 
11
#include <stdlib.h>
 
12
#include <sys/time.h>
 
13
#include <sys/types.h>
 
14
#include <fcntl.h>
 
15
#include <soundcard.h>
 
16
#ifdef _AIX
 
17
#include <sys/select.h>
 
18
#endif
 
19
 
 
20
int
 
21
main (int agrc, char *argv[])
 
22
{
 
23
  int fd;
 
24
 
 
25
  int tmp;
 
26
 
 
27
  char buf[128 * 1024];
 
28
 
 
29
  int have_data = 0;
 
30
  int n, l;
 
31
 
 
32
  int frag = 0x00200008;        /* 32 fragments of 2^8=256 bytes */
 
33
 
 
34
  fd_set reads, writes;
 
35
 
 
36
  close (0);
 
37
 
 
38
  if ((fd = open ("/dev/dsp", O_RDWR, 0)) == -1)
 
39
    {
 
40
      perror ("/dev/dsp open");
 
41
      exit (-1);
 
42
    }
 
43
 
 
44
  ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &frag);
 
45
 
 
46
/*
 
47
 * Set just the sampling tahe. Use the default format. We do not do any
 
48
 * error checking (maybe not so good idea) because we don't care what
 
49
 * the sampling rate really is.
 
50
 */
 
51
  tmp = 48000;
 
52
  ioctl (fd, SNDCTL_DSP_SPEED, &tmp);
 
53
 
 
54
  while (1)
 
55
    {
 
56
      struct timeval time;
 
57
 
 
58
      FD_ZERO (&reads);
 
59
      FD_ZERO (&writes);
 
60
 
 
61
      if (have_data)
 
62
        FD_SET (fd, &writes);
 
63
      else
 
64
        FD_SET (fd, &reads);
 
65
 
 
66
      time.tv_sec = 1;
 
67
      time.tv_usec = 0;
 
68
      if (select (fd + 1, &reads, &writes, NULL, &time) == -1)
 
69
        {
 
70
          perror ("select");
 
71
          exit (-1);
 
72
        }
 
73
 
 
74
      if (FD_ISSET (fd, &reads))
 
75
        {
 
76
          struct audio_buf_info info;
 
77
 
 
78
          if (ioctl (fd, SNDCTL_DSP_GETISPACE, &info) == -1)
 
79
            {
 
80
              perror ("select");
 
81
              exit (-1);
 
82
            }
 
83
 
 
84
          n = info.bytes;
 
85
 
 
86
          l = read (fd, buf, n);
 
87
          if (l > 0)
 
88
            have_data = 1;
 
89
        }
 
90
 
 
91
      if (FD_ISSET (fd, &writes))
 
92
        {
 
93
          int i;
 
94
 
 
95
          struct audio_buf_info info;
 
96
 
 
97
          if (ioctl (fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
 
98
            {
 
99
              perror ("select");
 
100
              exit (-1);
 
101
            }
 
102
 
 
103
          n = info.bytes;
 
104
 
 
105
          printf ("Write %d\n", l);
 
106
          write (fd, buf, l);
 
107
          printf ("OK");
 
108
          have_data = 0;
 
109
        }
 
110
    }
 
111
 
 
112
  exit (0);
 
113
}