1 // ****************************************************************************
5 // Implementation file for the CIndigoIO driver class.
6 // Set editor tabs to 3 for your viewing pleasure.
8 // ----------------------------------------------------------------------------
10 // This file is part of Echo Digital Audio's generic driver library.
11 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
12 // All rights reserved
15 // This library is free software; you can redistribute it and/or
16 // modify it under the terms of the GNU Lesser General Public
17 // License as published by the Free Software Foundation; either
18 // version 2.1 of the License, or (at your option) any later version.
20 // This library is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 // Lesser General Public License for more details.
25 // You should have received a copy of the GNU Lesser General Public
26 // License along with this library; if not, write to the Free Software
27 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 // ****************************************************************************
31 #include "CIndigoIO.h"
32 #include "CIndigoDJ.h"
34 #define INDIGO_IO_OUTPUT_LATENCY_SINGLE_SPEED 44
35 #define INDIGO_IO_OUTPUT_LATENCY_DOUBLE_SPEED 37
36 #define INDIGO_IO_INPUT_LATENCY_SINGLE_SPEED 44
37 #define INDIGO_IO_INPUT_LATENCY_DOUBLE_SPEED 41
40 /****************************************************************************
42 Construction and destruction
44 ****************************************************************************/
46 //===========================================================================
48 // Overload new & delete so memory for this object is allocated
49 // from non-paged memory.
51 //===========================================================================
53 PVOID
CIndigoIO::operator new( size_t Size
)
58 Status
= OsAllocateNonPaged(Size
,&pMemory
);
60 if ( (ECHOSTATUS_OK
!= Status
) || (NULL
== pMemory
))
62 ECHO_DEBUGPRINTF(("CIndigoIO::operator new - memory allocation failed\n"));
68 memset( pMemory
, 0, Size
);
73 } // PVOID CIndigoIO::operator new( size_t Size )
76 VOID
CIndigoIO::operator delete( PVOID pVoid
)
78 if ( ECHOSTATUS_OK
!= OsFreeNonPaged( pVoid
) )
80 ECHO_DEBUGPRINTF(("CIndigoIO::operator delete memory free failed\n"));
82 } // VOID CIndigoIO::operator delete( PVOID pVoid )
86 //===========================================================================
88 // Constructor and destructor
90 //===========================================================================
92 CIndigoIO::CIndigoIO( PCOsSupport pOsSupport
)
93 : CEchoGalsVmixer( pOsSupport
)
95 ECHO_DEBUGPRINTF( ( "CIndigoIO::CIndigoIO() is born!\n" ) );
98 CIndigoIO::~CIndigoIO()
100 ECHO_DEBUGPRINTF( ( "CIndigoIO::~CIndigoIO() is toast!\n" ) );
106 /****************************************************************************
108 Setup and hardware initialization
110 ****************************************************************************/
112 //===========================================================================
114 // Every card has an InitHw method
116 //===========================================================================
118 ECHOSTATUS
CIndigoIO::InitHw()
123 // Call the base method
125 if ( ECHOSTATUS_OK
!= ( Status
= CEchoGals::InitHw() ) )
129 // Create the DSP comm object
131 ECHO_ASSERT(NULL
== m_pDspCommObject
);
132 m_pDspCommObject
= new CIndigoIODspCommObject( (PDWORD
) m_pvSharedMemory
,
134 if (NULL
== m_pDspCommObject
)
136 ECHO_DEBUGPRINTF(("CIndigoIO::InitHw - could not create DSP comm object\n"));
137 return ECHOSTATUS_NO_MEM
;
143 GetDspCommObject()->LoadFirmware();
144 if ( GetDspCommObject()->IsBoardBad() )
145 return ECHOSTATUS_DSP_DEAD
;
150 m_wFlags
&= ~ECHOGALS_FLAG_BADBOARD
;
151 m_wFlags
|= ECHOGALS_ROFLAG_SUPER_INTERLEAVE_OK
;
154 // Must call this here after DSP is init to
155 // init gains and mutes
157 Status
= InitLineLevels();
158 if ( ECHOSTATUS_OK
!= Status
)
162 // Get default sample rate from DSP
164 m_dwSampleRate
= GetDspCommObject()->GetSampleRate();
166 ECHO_DEBUGPRINTF( ( "CIndigoIO::InitHw() complete\n" ) );
169 } // ECHOSTATUS CIndigoIO::InitHw()
174 /****************************************************************************
176 Informational methods
178 ****************************************************************************/
180 //===========================================================================
182 // Override GetCapabilities to enumerate unique capabilties for this card
184 //===========================================================================
186 ECHOSTATUS
CIndigoIO::GetCapabilities
188 PECHOGALS_CAPS pCapabilities
193 Status
= GetBaseCapabilities(pCapabilities
);
194 if ( ECHOSTATUS_OK
!= Status
)
197 pCapabilities
->dwOutClockTypes
= 0;
201 } // ECHOSTATUS CIndigoIO::GetCapabilities
204 //===========================================================================
206 // QueryAudioSampleRate is used to find out if this card can handle a
207 // given sample rate.
209 //===========================================================================
211 ECHOSTATUS
CIndigoIO::QueryAudioSampleRate
216 if ( dwSampleRate
!= 32000 &&
217 dwSampleRate
!= 44100 &&
218 dwSampleRate
!= 48000 &&
219 dwSampleRate
!= 64000 &&
220 dwSampleRate
!= 88200 &&
221 dwSampleRate
!= 96000
225 ("CIndigoIO::QueryAudioSampleRate() - rate %ld invalid\n",dwSampleRate
) );
226 return ECHOSTATUS_BAD_FORMAT
;
229 ECHO_DEBUGPRINTF( ( "CIndigoIO::QueryAudioSampleRate()\n" ) );
230 return ECHOSTATUS_OK
;
232 } // ECHOSTATUS CIndigoIO::QueryAudioSampleRate
235 void CIndigoIO::QuerySampleRateRange(DWORD
&dwMinRate
,DWORD
&dwMaxRate
)
242 //===========================================================================
244 // GetAudioLatency - returns the latency for a single pipe
246 //===========================================================================
248 void CIndigoIO::GetAudioLatency(ECHO_AUDIO_LATENCY
*pLatency
)
254 // The latency depends on the current sample rate
256 dwSampleRate
= GetDspCommObject()->GetSampleRate();
257 if (FALSE
== pLatency
->wIsInput
)
259 if (dwSampleRate
< 50000)
260 dwLatency
= INDIGO_IO_OUTPUT_LATENCY_SINGLE_SPEED
;
262 dwLatency
= INDIGO_IO_OUTPUT_LATENCY_DOUBLE_SPEED
;
266 if (dwSampleRate
< 50000)
267 dwLatency
= INDIGO_IO_INPUT_LATENCY_SINGLE_SPEED
;
269 dwLatency
= INDIGO_IO_INPUT_LATENCY_DOUBLE_SPEED
;
272 pLatency
->dwLatency
= dwLatency
;
276 // *** CIndigoIO.cpp ***