From: drowe67 Date: Mon, 5 Nov 2012 05:25:34 +0000 (+0000) Subject: building up soundcard auto detect code X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=b44295feb109456fa179260cdfb3560749ed6fbc;p=freetel-svn-tracking.git building up soundcard auto detect code git-svn-id: https://svn.code.sf.net/p/freetel/code@931 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/fdmdv2/src/fdmdv2_main.cpp b/fdmdv2/src/fdmdv2_main.cpp index 5608aac5..79c2ec41 100644 --- a/fdmdv2/src/fdmdv2_main.cpp +++ b/fdmdv2/src/fdmdv2_main.cpp @@ -74,7 +74,8 @@ IMPLEMENT_APP(MainApp); bool MainApp::OnInit() { g_file = fopen("/home/david/codec2-dev/raw/hts1a.raw","rb"); - assert(g_file != NULL); + if (g_file === NULL) + printf("reading hts1a disabled...\n"); if(!wxApp::OnInit()) { @@ -1000,6 +1001,34 @@ void MainFrame::destroy_src(void) src_delete(m_rxUserdata->outsrc2); } +void MainFrame::autoDetectSoundCards(PortAudioWrap *pa) +{ + const PaDeviceInfo *deviceInfo; + int i; + + // trap zero sound devices + + if (pa->getDeviceCount() == 0) { + wxMessageBox(wxT("No sound devices found"), wxT("Error"), wxOK); + return; + } + + for(i=0; igetDeviceCount(); i++) { + deviceInfo = Pa_GetDeviceInfo( i ); + + // supports full duplex and 44800 and 44100 + // is there something unique so we know it's a hw device? + // does this work on Linux & Windows? + + printf( "--------------------------------------- device #%d\n", i ); + printf( "Name = %s\n", deviceInfo->name ); + printf( "Host API = %s\n", Pa_GetHostApiInfo( deviceInfo->hostApi )->name ); + printf( "Max inputs = %d", deviceInfo->maxInputChannels ); + printf( ", Max outputs = %d\n", deviceInfo->maxOutputChannels ); + printf( "Default sample rate = %8.2f\n", deviceInfo->defaultSampleRate ); + } +} + int MainFrame::initPortAudioDevice(PortAudioWrap *pa, int inDevice, int outDevice, int soundCard, int sampleRate) { char s[256]; @@ -1065,6 +1094,7 @@ void MainFrame::startRxStream() m_RxRunning = true; m_rxPa = new PortAudioWrap(); + autoDetectSoundCards(m_rxPa); // Init Sound card 1 ---------------------------------------------- @@ -1507,7 +1537,7 @@ int MainFrame::rxCallback( fwrite( in8k_short, sizeof(short), nout, g_write_file); } - if (read_file) { + if (read_file && (g_file != NULL)) { int n = fread( in8k_short , sizeof(short), 2*N8, g_file); if (n != 2*N8) { rewind(g_file); diff --git a/fdmdv2/src/fdmdv2_main.h b/fdmdv2/src/fdmdv2_main.h index ca591f87..c60d8bf0 100644 --- a/fdmdv2/src/fdmdv2_main.h +++ b/fdmdv2/src/fdmdv2_main.h @@ -198,6 +198,7 @@ class MainFrame : public TopFrame void destroy_fifos(void); void destroy_src(void); + void autoDetectSoundCards(PortAudioWrap *pa); static int rxCallback( const void *inBuffer,