ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

rate.c
Go to the documentation of this file.
00001 /*
00002     ReactOS Sound System
00003     Sound Blaster DSP support
00004     Sample rate routines
00005 
00006     Author:
00007         Andrew Greenwood (silverblade@reactos.org)
00008 
00009     History:
00010         2 July 2008 - Created (split from sbdsp.c)
00011 
00012     Notes:
00013         Functions documented in sbdsp.h
00014 */
00015 
00016 #include "precomp.h"
00017 
00018 BOOLEAN
00019 SbDspIsValidInputRate(
00020     IN  UCHAR MajorVersion,
00021     IN  UCHAR MinorVersion,
00022     IN  USHORT Rate,
00023     IN  BOOLEAN Stereo)
00024 {
00025     if ( MajorVersion == 1 )
00026     {
00027         if ( Stereo )
00028             return FALSE;
00029 
00030         return ( ( Rate >= 4000 ) && ( Rate <= 13000 ) );
00031     }
00032     else if ( MajorVersion == 2 )
00033     {
00034         if ( Stereo )
00035             return FALSE;
00036 
00037         if ( MinorVersion == 0 )
00038             return ( ( Rate >= 4000 ) && ( Rate <= 15000 ) );
00039         else
00040             return ( ( Rate >= 4000 ) && ( Rate <= 44100 ) );
00041     }
00042     else if ( MajorVersion == 3 )
00043     {
00044         if ( Stereo )
00045             return FALSE;
00046 
00047         return ( ( Rate >= 4000 ) && ( Rate <= 13000 ) );
00048     }
00049     else /* 4.00 and above */
00050     {
00051         return ( ( Rate >= 5000 ) && ( Rate <= 44100 ) );
00052     }
00053 }
00054 
00055 BOOLEAN
00056 SbDspIsValidOutputRate(
00057     IN  UCHAR MajorVersion,
00058     IN  UCHAR MinorVersion,
00059     IN  USHORT Rate,
00060     IN  BOOLEAN Stereo)
00061 {
00062     if ( MajorVersion == 1 )
00063     {
00064         if ( Stereo )
00065             return FALSE;
00066 
00067         return ( ( Rate >= 4000 ) && ( Rate <= 23000 ) );
00068     }
00069     else if ( MajorVersion == 2 )
00070     {
00071         if ( Stereo )
00072             return FALSE;
00073 
00074         if ( MinorVersion == 0 )
00075             return ( ( Rate >= 4000 ) && ( Rate <= 23000 ) );
00076         else
00077             return ( ( Rate >= 4000 ) && ( Rate <= 44100 ) );
00078     }
00079     else if ( MajorVersion == 3 )
00080     {
00081         if ( ! Stereo )
00082             return ( ( Rate >= 4000 ) && ( Rate <= 44100 ) );
00083         else
00084             return ( ( Rate >= 11025 ) && ( Rate <= 22050 ) );
00085     }
00086     else /* 4.00 and above */
00087     {
00088         return ( ( Rate >= 5000 ) && ( Rate <= 44100 ) );
00089     }
00090 }
00091 
00092 /* Internal routine - call only after submitting one of the rate commands */
00093 NTSTATUS
00094 SbDsp4WriteRate(
00095     IN  PUCHAR BasePort,
00096     IN  USHORT Rate,
00097     IN  ULONG Timeout)
00098 {
00099     NTSTATUS Status;
00100 
00101     /* NOTE - No check for validity of rate! */
00102 
00103     /* Write high byte */
00104     Status = SbDspWrite(BasePort, (Rate & 0xff00) >> 8, Timeout);
00105     if ( Status != STATUS_SUCCESS )
00106         return Status;
00107 
00108     /* Write low byte */
00109     Status = SbDspWrite(BasePort, Rate & 0xff, Timeout);
00110     if ( Status != STATUS_SUCCESS )
00111         return Status;
00112 
00113     return Status;
00114 }
00115 
00116 NTSTATUS
00117 SbDsp4SetOutputRate(
00118     IN  PUCHAR BasePort,
00119     IN  USHORT Rate,
00120     IN  ULONG Timeout)
00121 {
00122     NTSTATUS Status;
00123 
00124     /* NOTE - No check for validity of rate! */
00125 
00126     /* Prepare to write the output rate */
00127     Status = SbDspWrite(BasePort, SB_DSP_OUTPUT_RATE, (Rate & 0xff00) >> 8);
00128     if ( Status != STATUS_SUCCESS )
00129         return Status;
00130 
00131     return SbDsp4WriteRate(BasePort, Rate, Timeout);
00132 }
00133 
00134 NTSTATUS
00135 SbDsp4SetInputRate(
00136     IN  PUCHAR BasePort,
00137     IN  USHORT Rate,
00138     IN  ULONG Timeout)
00139 {
00140     NTSTATUS Status;
00141 
00142     /* NOTE - No check for validity of rate! */
00143 
00144     /* Prepare to write the input rate */
00145     Status = SbDspWrite(BasePort, SB_DSP_OUTPUT_RATE, (Rate & 0xff00) >> 8);
00146     if ( Status != STATUS_SUCCESS )
00147         return Status;
00148 
00149     return SbDsp4WriteRate(BasePort, Rate, Timeout);
00150 }
00151  

Generated on Fri May 25 2012 04:34:39 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.