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

« back to all changes in this revision

Viewing changes to tutorials/sndkit/samples/playtgt.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 sample program for play target selection
 
3
 * Copyright (C) 4Front Technologies, 2002-2007. Released under GPLv2/CDDL.
 
4
 *
 
5
 * Description:
 
6
 * This program demonstrates the new ioctl call interface used to
 
7
 * control the play target selection.
 
8
 *
 
9
 * The first command line argument is the audio device (/dev/dsp#). If there 
 
10
 * are no other arguments then the available choices will be printed. If the 
 
11
 * second argument is "-" then the current setting will be printed.
 
12
 * Finally the source can be changed by giving it's name as the
 
13
 * second argument.
 
14
 *
 
15
 * {!notice Please not that the change may stay in effect even after closing
 
16
 * the device. However equally well it's possible that the device returns back
 
17
 * to some default source. There is no way to predict how the device will
 
18
 * behave and the application must not expect any particular behaviour.}
 
19
 */
 
20
#include <stdio.h>
 
21
#include <unistd.h>
 
22
#include <stdlib.h>
 
23
#include <string.h>
 
24
#include <fcntl.h>
 
25
#include <soundcard.h>
 
26
#include <time.h>
 
27
 
 
28
int
 
29
main (int argc, char *argv[])
 
30
{
 
31
  int fd, i, src;
 
32
  oss_mixer_enuminfo ei;
 
33
 
 
34
  if (argc < 2)
 
35
    {
 
36
      fprintf (stderr, "Usage: %s dspdev\n", argv[0]);
 
37
      exit (-1);
 
38
    }
 
39
 
 
40
  if ((fd = open (argv[1], O_WRONLY, 0)) == -1)
 
41
    {
 
42
      perror (argv[1]);
 
43
      exit (-1);
 
44
    }
 
45
 
 
46
  if (ioctl (fd, SNDCTL_DSP_GET_PLAYTGT_NAMES, &ei) == -1)
 
47
    {
 
48
      perror ("SNDCTL_DSP_GET_PLAYTGT_NAMES");
 
49
      exit (-1);
 
50
    }
 
51
 
 
52
  if (argc == 2)
 
53
    {
 
54
      for (i = 0; i < ei.nvalues; i++)
 
55
        printf ("Play target #%d = '%s'\n", i, ei.strings + ei.strindex[i]);
 
56
      exit (0);
 
57
    }
 
58
 
 
59
  if (strcmp (argv[2], "?") == 0 || strcmp (argv[2], "-") == 0)
 
60
    {
 
61
      if (ioctl (fd, SNDCTL_DSP_GET_PLAYTGT, &src) == -1)
 
62
        {
 
63
          perror ("SNDCTL_DSP_GET_PLAYTGT");
 
64
          exit (-1);
 
65
        }
 
66
 
 
67
      printf ("Current play target is #%d\n", src);
 
68
      printf ("Current play target is #%d (%s)\n",
 
69
              src, ei.strings + ei.strindex[src]);
 
70
      exit (0);
 
71
    }
 
72
 
 
73
  src = 0;
 
74
 
 
75
  for (i = 0; i < ei.nvalues; i++)
 
76
    {
 
77
      if (strcmp (argv[2], ei.strings + ei.strindex[i]) == 0)
 
78
        {
 
79
          if (ioctl (fd, SNDCTL_DSP_SET_PLAYTGT, &src) == -1)
 
80
            {
 
81
              perror ("SNDCTL_DSP_SET_PLAYTGT");
 
82
              exit (-1);
 
83
            }
 
84
 
 
85
          exit (0);
 
86
        }
 
87
 
 
88
      src++;
 
89
    }
 
90
 
 
91
  fprintf (stderr, "What?\n");
 
92
  exit (-1);
 
93
}