1// **************************************************************************** 2// 3// CIndigoDJ.cpp 4// 5// Implementation file for the CIndigoDJ driver class. 6// Set editor tabs to 3 for your viewing pleasure. 7// 8// ---------------------------------------------------------------------------- 9// 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 13// www.echoaudio.com 14// 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. 19// 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. 24// 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 28// 29// **************************************************************************** 30 31#include "CIndigoDJ.h" 32 33#define INDIGO_DJ_OUTPUT_LATENCY_SINGLE_SPEED 44 34#define INDIGO_DJ_OUTPUT_LATENCY_DOUBLE_SPEED 37 35 36 37/**************************************************************************** 38 39 Construction and destruction 40 41 ****************************************************************************/ 42 43//=========================================================================== 44// 45// Overload new & delete so memory for this object is allocated 46// from non-paged memory. 47// 48//=========================================================================== 49 50PVOID CIndigoDJ::operator new( size_t Size ) 51{ 52 PVOID pMemory; 53 ECHOSTATUS Status; 54 55 Status = OsAllocateNonPaged(Size,&pMemory); 56 57 if ( (ECHOSTATUS_OK != Status) || (NULL == pMemory )) 58 { 59 ECHO_DEBUGPRINTF(("CIndigoDJ::operator new - memory allocation failed\n")); 60 61 pMemory = NULL; 62 } 63 else 64 { 65 memset( pMemory, 0, Size ); 66 } 67 68 return pMemory; 69 70} // PVOID CIndigoDJ::operator new( size_t Size ) 71 72 73VOID CIndigoDJ::operator delete( PVOID pVoid ) 74{ 75 if ( ECHOSTATUS_OK != OsFreeNonPaged( pVoid ) ) 76 { 77 ECHO_DEBUGPRINTF(("CIndigoDJ::operator delete memory free failed\n")); 78 } 79} // VOID CIndigoDJ::operator delete( PVOID pVoid ) 80 81 82 83//=========================================================================== 84// 85// Constructor and destructor 86// 87//=========================================================================== 88 89CIndigoDJ::CIndigoDJ( PCOsSupport pOsSupport ) 90 : CIndigo( pOsSupport ) 91{ 92 ECHO_DEBUGPRINTF( ( "CIndigoDJ::CIndigoDJ() is born!\n" ) ); 93} 94 95CIndigoDJ::~CIndigoDJ() 96{ 97 ECHO_DEBUGPRINTF( ( "CIndigoDJ::~CIndigoDJ() is toast!\n" ) ); 98} 99 100 101 102//=========================================================================== 103// 104// Every card has an InitHw method 105// 106//=========================================================================== 107 108ECHOSTATUS CIndigoDJ::InitHw() 109{ 110 ECHOSTATUS Status; 111 112 // 113 // Call the base method 114 // 115 if ( ECHOSTATUS_OK != ( Status = CEchoGals::InitHw() ) ) 116 return Status; 117 118 // 119 // Create the DSP comm object 120 // 121 m_pDspCommObject = new CIndigoDJDspCommObject( (PDWORD) m_pvSharedMemory, 122 m_pOsSupport ); 123 if (NULL == m_pDspCommObject) 124 { 125 ECHO_DEBUGPRINTF(("CIndigoDJ::InitHw - could not create DSP comm object\n")); 126 return ECHOSTATUS_NO_MEM; 127 } 128 129 // 130 // Load the DSP 131 // 132 GetDspCommObject()->LoadFirmware(); 133 if ( GetDspCommObject()->IsBoardBad() ) 134 return ECHOSTATUS_DSP_DEAD; 135 136 // 137 // Do flags 138 // 139 m_wFlags &= ~ECHOGALS_FLAG_BADBOARD; 140 m_wFlags |= ECHOGALS_ROFLAG_SUPER_INTERLEAVE_OK; 141 142 // 143 // Must call this here after DSP is init to 144 // init gains and mutes 145 // 146 Status = InitLineLevels(); 147 if ( ECHOSTATUS_OK != Status ) 148 return Status; 149 150 // 151 // Get default sample rate from DSP 152 // 153 m_dwSampleRate = GetDspCommObject()->GetSampleRate(); 154 155 ECHO_DEBUGPRINTF( ( "CIndigo::InitHw()\n" ) ); 156 return Status; 157 158} // ECHOSTATUS CIndigo::InitHw() 159 160 161//=========================================================================== 162// 163// GetAudioLatency - returns the latency for a single pipe 164// 165//=========================================================================== 166 167void CIndigoDJ::GetAudioLatency(ECHO_AUDIO_LATENCY *pLatency) 168{ 169 DWORD dwLatency; 170 DWORD dwSampleRate; 171 172 dwSampleRate = GetDspCommObject()->GetSampleRate(); 173 if (FALSE == pLatency->wIsInput) 174 { 175 // 176 // The latency depends on the current sample rate 177 // 178 if (dwSampleRate < 50000) 179 dwLatency = INDIGO_DJ_OUTPUT_LATENCY_SINGLE_SPEED; 180 else 181 dwLatency = INDIGO_DJ_OUTPUT_LATENCY_DOUBLE_SPEED; 182 } 183 else 184 { 185 // 186 // Inputs? What inputs? 187 // 188 dwLatency = 0; 189 } 190 191 pLatency->dwLatency = dwLatency; 192 193} // GetAudioLatency 194 195 196// *** CIndigoDJ.cpp *** 197