1 // ****************************************************************************
5 // Implementation file for the CDarla driver class; this supports 20 bit
8 // Set editor tabs to 3 for your viewing pleasure.
10 // ----------------------------------------------------------------------------
12 // This file is part of Echo Digital Audio's generic driver library.
13 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
14 // All rights reserved
17 // This library is free software; you can redistribute it and/or
18 // modify it under the terms of the GNU Lesser General Public
19 // License as published by the Free Software Foundation; either
20 // version 2.1 of the License, or (at your option) any later version.
22 // This library is distributed in the hope that it will be useful,
23 // but WITHOUT ANY WARRANTY; without even the implied warranty of
24 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 // Lesser General Public License for more details.
27 // You should have received a copy of the GNU Lesser General Public
28 // License along with this library; if not, write to the Free Software
29 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 // ****************************************************************************
35 #define DARLA20_ANALOG_OUTPUT_LATENCY 137
36 #define DARLA20_ANALOG_INPUT_LATENCY 240
39 /****************************************************************************
41 Construction and destruction
43 ****************************************************************************/
45 //===========================================================================
47 // Overload new & delete so memory for this object is allocated
48 // from non-paged memory.
50 //===========================================================================
52 PVOID
CDarla::operator new( size_t Size
)
57 Status
= OsAllocateNonPaged(Size
,&pMemory
);
59 if ( (ECHOSTATUS_OK
!= Status
) || (NULL
== pMemory
))
61 ECHO_DEBUGPRINTF(("CDarla::operator new - memory allocation failed\n"));
67 memset( pMemory
, 0, Size
);
72 } // PVOID CDarla::operator new( size_t Size )
75 VOID
CDarla::operator delete( PVOID pVoid
)
77 if ( ECHOSTATUS_OK
!= OsFreeNonPaged( pVoid
) )
79 ECHO_DEBUGPRINTF(("CDarla::operator delete memory free failed\n"));
81 } // VOID CDarla::operator delete( PVOID pVoid )
84 //===========================================================================
86 // Constructor and destructor
88 //===========================================================================
90 CDarla::CDarla( PCOsSupport pOsSupport
)
91 : CEchoGals( pOsSupport
)
93 ECHO_DEBUGPRINTF( ( "CDarla::CDarla() is born!\n" ) );
95 m_wAnalogOutputLatency
= DARLA20_ANALOG_OUTPUT_LATENCY
;
96 m_wAnalogInputLatency
= DARLA20_ANALOG_INPUT_LATENCY
;
101 ECHO_DEBUGPRINTF( ( "CDarla::~CDarla() is toast!\n" ) );
107 /****************************************************************************
109 Setup and hardware initialization
111 ****************************************************************************/
113 //===========================================================================
115 // Every card has an InitHw method
117 //===========================================================================
119 ECHOSTATUS
CDarla::InitHw()
124 // Call the base InitHw method
126 if ( ECHOSTATUS_OK
!= ( Status
= CEchoGals::InitHw() ) )
130 // Create the DSP comm object
132 ECHO_ASSERT(NULL
== m_pDspCommObject
);
133 m_pDspCommObject
= new CDarlaDspCommObject( (PDWORD
) m_pvSharedMemory
,
135 if (NULL
== m_pDspCommObject
)
137 ECHO_DEBUGPRINTF(("CDarla::InitHw - could not create DSP comm object\n"));
138 return ECHOSTATUS_NO_MEM
;
144 GetDspCommObject()->LoadFirmware();
145 if ( GetDspCommObject()->IsBoardBad() )
146 return ECHOSTATUS_DSP_DEAD
;
149 // Clear the "bad board" flag
151 m_wFlags
&= ~ECHOGALS_FLAG_BADBOARD
;
154 // Must call this here *after* DSP is init
156 Status
= InitLineLevels();
159 // Get default sample rate from DSP
161 m_dwSampleRate
= GetDspCommObject()->GetSampleRate();
163 ECHO_DEBUGPRINTF( ( "CDarla::InitHw()\n" ) );
167 } // ECHOSTATUS CDarla::InitHw()
172 /****************************************************************************
174 Informational methods
176 ****************************************************************************/
178 //===========================================================================
180 // QueryAudioSampleRate is used to find out if this card can handle a
181 // given sample rate.
183 //===========================================================================
185 ECHOSTATUS
CDarla::QueryAudioSampleRate
190 if ( dwSampleRate
!= 44100 &&
191 dwSampleRate
!= 48000 )
194 ("CDarla::QueryAudioSampleRate() - rate %ld invalid\n",
196 return ECHOSTATUS_BAD_FORMAT
;
199 ECHO_DEBUGPRINTF( ( "CDarla::QueryAudioSampleRate()\n" ) );
200 return ECHOSTATUS_OK
;
202 } // ECHOSTATUS CDarla::QueryAudioSampleRate
205 void CDarla::QuerySampleRateRange(DWORD
&dwMinRate
,DWORD
&dwMaxRate
)
213 // *** CDarla.cpp ***