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

« back to all changes in this revision

Viewing changes to tutorials/sndkit/tests/synctest.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: A program that demonstrates use of syncronization groups.
 
3
 * Copyright (C) 4Front Technologies, 2002-2004. Released under GPLv2/CDDL.
 
4
 *
 
5
 * Description:
 
6
 * This program opens three audio devices (hard coded in the program)
 
7
 * and creates a syncronization group using {!nlink SNDCTL_DSP_SYNCGROUP}.
 
8
 * 
 
9
 * Next it starts all the devices joined in the group simultaneously
 
10
 * by calling {!nlink SNDCTL_DSP_SYNCSTART}. Finally it will keep copying
 
11
 * audio input from the 3rd device to the other two ones.
 
12
 */
 
13
#include <stdio.h>
 
14
#include <stdlib.h>
 
15
#include <unistd.h>
 
16
#include <fcntl.h>
 
17
#include <sys/ioctl.h>
 
18
#include <soundcard.h>
 
19
 
 
20
#define MAX_DEV         10
 
21
 
 
22
int
 
23
main (int argc, char *argv[])
 
24
{
 
25
  int i, id, fd[MAX_DEV], ndevs = 0;
 
26
  char buf[32768] = { 0 };
 
27
 
 
28
  oss_syncgroup group;
 
29
 
 
30
  group.id = 0;
 
31
  group.mode = PCM_ENABLE_OUTPUT;
 
32
 
 
33
/*
 
34
 * Open the devices listed on command line
 
35
 */
 
36
  if (argc < 2)
 
37
    exit (-1);
 
38
 
 
39
  for (i = 1; i < argc; i++)
 
40
    {
 
41
      if ((fd[ndevs] = open (argv[i], O_WRONLY, 0)) == -1)
 
42
        {
 
43
          perror (argv[i]);
 
44
          exit (-1);
 
45
        }
 
46
 
 
47
      if (ioctl (fd[ndevs], SNDCTL_DSP_SYNCGROUP, &group) == -1)
 
48
        {
 
49
          perror ("SNDCTL_DSP_SYNCGROUP");
 
50
          exit (-1);
 
51
        }
 
52
/*
 
53
 * Note! It is very important to write some data to all output devices
 
54
 * between calling SNDCTL_DSP_SYNCGROUP and SNDCTL_DSP_SYNCSTART. Otherwise
 
55
 * playback will not start properly. However do not write more data than
 
56
 * there is room in device's DMA buffer. Recommended amount of prteload data
 
57
 * is one full fragment.
 
58
 *
 
59
 * In applications that record audio, process it and then play back it's
 
60
 * necessary to write two fragments of silence to the output device(s) before
 
61
 * starting the group. Otherwise output device(s) will run out of data before
 
62
 * the first read from the input device returns.
 
63
 */
 
64
 
 
65
      if (write (fd[ndevs], buf, sizeof (buf)) != sizeof (buf))
 
66
        {
 
67
          perror ("write");
 
68
          exit (-1);
 
69
        }
 
70
 
 
71
      ndevs++;
 
72
    }
 
73
 
 
74
  printf ("Sync group %x created with %d devices\n", group.id, ndevs);
 
75
 
 
76
 
 
77
  id = group.id;
 
78
 
 
79
  if (ioctl (fd[0], SNDCTL_DSP_SYNCSTART, &id) == -1)
 
80
    {
 
81
      perror ("SNDCTL_DSP_SYNCSTART");
 
82
      exit (-1);
 
83
    }
 
84
 
 
85
  while (1)
 
86
    {
 
87
      for (i = 0; i < ndevs; i++)
 
88
        if (write (fd[i], buf, sizeof (buf)) != sizeof (buf))
 
89
          {
 
90
            perror ("write2");
 
91
            exit (-1);
 
92
          }
 
93
    }
 
94
 
 
95
  exit (0);
 
96
}