ReactOS 0.4.16-dev-336-gb667d82
rate.c
Go to the documentation of this file.
1/*
2 ReactOS Sound System
3 Sound Blaster DSP support
4 Sample rate routines
5
6 Author:
7 Andrew Greenwood (silverblade@reactos.org)
8
9 History:
10 2 July 2008 - Created (split from sbdsp.c)
11
12 Notes:
13 Functions documented in sbdsp.h
14*/
15
16#include "precomp.h"
17
22 IN USHORT Rate,
23 IN BOOLEAN Stereo)
24{
25 if ( MajorVersion == 1 )
26 {
27 if ( Stereo )
28 return FALSE;
29
30 return ( ( Rate >= 4000 ) && ( Rate <= 13000 ) );
31 }
32 else if ( MajorVersion == 2 )
33 {
34 if ( Stereo )
35 return FALSE;
36
37 if ( MinorVersion == 0 )
38 return ( ( Rate >= 4000 ) && ( Rate <= 15000 ) );
39 else
40 return ( ( Rate >= 4000 ) && ( Rate <= 44100 ) );
41 }
42 else if ( MajorVersion == 3 )
43 {
44 if ( Stereo )
45 return FALSE;
46
47 return ( ( Rate >= 4000 ) && ( Rate <= 13000 ) );
48 }
49 else /* 4.00 and above */
50 {
51 return ( ( Rate >= 5000 ) && ( Rate <= 44100 ) );
52 }
53}
54
59 IN USHORT Rate,
60 IN BOOLEAN Stereo)
61{
62 if ( MajorVersion == 1 )
63 {
64 if ( Stereo )
65 return FALSE;
66
67 return ( ( Rate >= 4000 ) && ( Rate <= 23000 ) );
68 }
69 else if ( MajorVersion == 2 )
70 {
71 if ( Stereo )
72 return FALSE;
73
74 if ( MinorVersion == 0 )
75 return ( ( Rate >= 4000 ) && ( Rate <= 23000 ) );
76 else
77 return ( ( Rate >= 4000 ) && ( Rate <= 44100 ) );
78 }
79 else if ( MajorVersion == 3 )
80 {
81 if ( ! Stereo )
82 return ( ( Rate >= 4000 ) && ( Rate <= 44100 ) );
83 else
84 return ( ( Rate >= 11025 ) && ( Rate <= 22050 ) );
85 }
86 else /* 4.00 and above */
87 {
88 return ( ( Rate >= 5000 ) && ( Rate <= 44100 ) );
89 }
90}
91
92/* Internal routine - call only after submitting one of the rate commands */
95 IN PUCHAR BasePort,
96 IN USHORT Rate,
98{
100
101 /* NOTE - No check for validity of rate! */
102
103 /* Write high byte */
104 Status = SbDspWrite(BasePort, (Rate & 0xff00) >> 8, Timeout);
105 if ( Status != STATUS_SUCCESS )
106 return Status;
107
108 /* Write low byte */
109 Status = SbDspWrite(BasePort, Rate & 0xff, Timeout);
110 if ( Status != STATUS_SUCCESS )
111 return Status;
112
113 return Status;
114}
115
118 IN PUCHAR BasePort,
119 IN USHORT Rate,
121{
123
124 /* NOTE - No check for validity of rate! */
125
126 /* Prepare to write the output rate */
127 Status = SbDspWrite(BasePort, SB_DSP_OUTPUT_RATE, (Rate & 0xff00) >> 8);
128 if ( Status != STATUS_SUCCESS )
129 return Status;
130
131 return SbDsp4WriteRate(BasePort, Rate, Timeout);
132}
133
136 IN PUCHAR BasePort,
137 IN USHORT Rate,
139{
141
142 /* NOTE - No check for validity of rate! */
143
144 /* Prepare to write the input rate */
145 Status = SbDspWrite(BasePort, SB_DSP_OUTPUT_RATE, (Rate & 0xff00) >> 8);
146 if ( Status != STATUS_SUCCESS )
147 return Status;
148
149 return SbDsp4WriteRate(BasePort, Rate, Timeout);
150}
151
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
ULONG MajorVersion
Definition: ros_glue.cpp:4
ULONG MinorVersion
Definition: ros_glue.cpp:5
Status
Definition: gdiplustypes.h:25
unsigned short USHORT
Definition: pedump.c:61
static ULONG Timeout
Definition: ping.c:61
BOOLEAN SbDspIsValidOutputRate(IN UCHAR MajorVersion, IN UCHAR MinorVersion, IN USHORT Rate, IN BOOLEAN Stereo)
Definition: rate.c:56
NTSTATUS SbDsp4SetOutputRate(IN PUCHAR BasePort, IN USHORT Rate, IN ULONG Timeout)
Definition: rate.c:117
NTSTATUS SbDsp4WriteRate(IN PUCHAR BasePort, IN USHORT Rate, IN ULONG Timeout)
Definition: rate.c:94
BOOLEAN SbDspIsValidInputRate(IN UCHAR MajorVersion, IN UCHAR MinorVersion, IN USHORT Rate, IN BOOLEAN Stereo)
Definition: rate.c:19
NTSTATUS SbDsp4SetInputRate(IN PUCHAR BasePort, IN USHORT Rate, IN ULONG Timeout)
Definition: rate.c:135
NTSTATUS SbDspWrite(IN PUCHAR BasePort, IN UCHAR DataByte, IN ULONG Timeout)
Definition: dsp_io.c:99
#define SB_DSP_OUTPUT_RATE
Definition: sbdsp.h:72
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: xmlstorage.h:181