~ubuntu-branches/ubuntu/oneiric/oss4/oneiric-proposed

« back to all changes in this revision

Viewing changes to kernel/framework/vmix_core/outexport_int.inc

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera
  • Date: 2011-06-16 20:37:48 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110616203748-jbrxik6ql33z54co
Tags: 4.2-build2004-1ubuntu1
* Merge from Debian unstable.
  - Supports our current kernel (LP: #746048)
  Remaining changes:
  - debian/oss4-dkms.dkms.in: s/source/build/ in Kernel headers paths.
* ld-as-needed.patch: Re-order CC arguments to enable building with ld
  --as-needed (LP: #770972)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Purpose: Local output buffer to device export routine for vmix (int)
 
3
 */
 
4
/*
 
5
 *
 
6
 * This file is part of Open Sound System.
 
7
 *
 
8
 * Copyright (C) 4Front Technologies 1996-2008.
 
9
 *
 
10
 * This this source file is released under GPL v2 license (no other versions).
 
11
 * See the COPYING file included in the main directory of this source
 
12
 * distribution for the license terms and conditions.
 
13
 *
 
14
 */
 
15
 
 
16
int i, ch, och;
 
17
int vol;
 
18
 
 
19
#define RANGE_MAX       ((1<<24)-1)
 
20
#define RANGE_MIN       -(1<<24)
 
21
 
 
22
vol = vmix_db_table[eng->outvol / 5];
 
23
 
 
24
for (ch = 0; ch < channels; ch++)
 
25
  {
 
26
    int vu;
 
27
    int *chbuf;
 
28
 
 
29
    och = eng->channel_order[ch];
 
30
    op = (SAMPLE_TYPE *) outbuf;
 
31
    op += och;
 
32
 
 
33
    chbuf = chbufs[ch];
 
34
 
 
35
    vu = eng->vu[och % 2];
 
36
    vu = vu * 65536;
 
37
 
 
38
    for (i = 0; i < samples; i++)
 
39
      {
 
40
        int tmp;
 
41
 
 
42
        tmp = *chbuf++;
 
43
 
 
44
        tmp = (tmp * vol) / VMIX_VOL_SCALE;
 
45
 
 
46
/*
 
47
 * Check for clipping. Decrease volume if necessary.
 
48
 */
 
49
        if (tmp<RANGE_MIN)
 
50
           {
 
51
                tmp=RANGE_MIN;
 
52
                eng->outvol -= 1;
 
53
                vol /= 2;
 
54
           }
 
55
        else
 
56
           if (tmp>RANGE_MAX)
 
57
              {
 
58
                tmp=RANGE_MAX;
 
59
                eng->outvol -= 1;
 
60
                vol /= 2;
 
61
              }
 
62
        
 
63
        *op = VMIX_BYTESWAP(INT_EXPORT(tmp));
 
64
        op += channels;
 
65
 
 
66
        /* VU meter */
 
67
        if (tmp < 0)
 
68
          tmp = -tmp;
 
69
        if (tmp > vu)
 
70
          vu = tmp;
 
71
      }
 
72
 
 
73
    if (och < 2)
 
74
      {
 
75
        vu = vu / 65536;
 
76
        eng->vu[och] = vu;
 
77
      }
 
78
  }