root/trunk/libffado/src/libavc/avc_definitions.cpp

Revision 445, 3.2 kB (checked in by pieterpalmers, 15 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #include "avc_definitions.h"
25
26
27 int
28 convertESamplingFrequency(ESamplingFrequency freq)
29 {
30     int value = 0;
31
32     switch ( freq ) {
33     case eSF_22050Hz:
34         value = 22050;
35         break;
36     case eSF_24000Hz:
37         value = 24000;
38         break;
39     case eSF_32000Hz:
40         value = 32000;
41         break;
42     case eSF_44100Hz:
43         value = 44100;
44         break;
45     case eSF_48000Hz:
46         value = 48000;
47         break;
48     case eSF_88200Hz:
49         value = 88200;
50         break;
51     case eSF_96000Hz:
52         value = 96000;
53         break;
54     case eSF_176400Hz:
55         value = 176400;
56         break;
57     case eSF_192000Hz:
58         value = 192000;
59         break;
60     case eSF_AnyLow:
61         value = 48000;
62         break;
63     case eSF_AnyMid:
64         value = 96000;
65         break;
66     case eSF_AnyHigh:
67         value = 192000;
68         break;
69     default:
70         value = 0;
71     }
72
73
74     return value;
75 }
76
77 ESamplingFrequency
78 parseSampleRate( int sampleRate )
79 {
80     ESamplingFrequency efreq;
81     switch ( sampleRate ) {
82     case 22050:
83         efreq = eSF_22050Hz;
84         break;
85     case 24000:
86         efreq = eSF_24000Hz;
87         break;
88     case 32000:
89         efreq = eSF_32000Hz;
90         break;
91     case 44100:
92         efreq = eSF_44100Hz;
93         break;
94     case 48000:
95         efreq = eSF_48000Hz;
96         break;
97     case 88200:
98         efreq = eSF_88200Hz;
99         break;
100     case 96000:
101         efreq = eSF_96000Hz;
102         break;
103     case 176400:
104         efreq = eSF_176400Hz;
105         break;
106     case 192000:
107         efreq = eSF_192000Hz;
108         break;
109     default:
110         efreq = eSF_DontCare;
111     }
112
113     return efreq;
114 }
115
116 std::ostream& operator<<( std::ostream& stream, ESamplingFrequency samplingFrequency )
117 {
118     char* str;
119     switch ( samplingFrequency ) {
120     case eSF_22050Hz:
121         str = "22050";
122         break;
123     case eSF_24000Hz:
124         str = "24000";
125         break;
126     case eSF_32000Hz:
127         str = "32000";
128         break;
129     case eSF_44100Hz:
130         str = "44100";
131         break;
132     case eSF_48000Hz:
133         str = "48000";
134         break;
135     case eSF_88200Hz:
136         str = "88200";
137         break;
138     case eSF_96000Hz:
139         str = "96000";
140         break;
141     case eSF_176400Hz:
142         str = "176400";
143         break;
144     case eSF_192000Hz:
145         str = "192000";
146         break;
147     case eSF_DontCare:
148     default:
149         str = "unknown";
150     }
151     return stream << str;
152 };
Note: See TracBrowser for help on using the browser.