From 362a8d4bf3609e7c6d7e98384193622b4a15f4f0 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 25 Mar 2014 05:21:58 +0000 Subject: [PATCH] modified play testing for mono devices, compiles OK but can't test as I don't have any mono play devices git-svn-id: https://svn.code.sf.net/p/freetel/code@1480 01035d8c-6547-0410-b346-abe4f91aad63 --- fdmdv2/src/dlg_audiooptions.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/fdmdv2/src/dlg_audiooptions.cpp b/fdmdv2/src/dlg_audiooptions.cpp index 59560e73..994cc51c 100644 --- a/fdmdv2/src/dlg_audiooptions.cpp +++ b/fdmdv2/src/dlg_audiooptions.cpp @@ -947,7 +947,7 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotSca // work out how many input channels this device supports. - deviceInfo = Pa_GetDeviceInfo(g_soundCard1InDeviceNum); + deviceInfo = Pa_GetDeviceInfo(devNum); if (deviceInfo == NULL) { wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card "), wxT("Error"), wxOK); return; @@ -1035,12 +1035,13 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotSca //------------------------------------------------------------------------- void AudioOptsDialog::plotDeviceOutputForAFewSecs(int devNum, PlotScalar *plotScalar) { PaStreamParameters outputParameters; + const PaDeviceInfo *deviceInfo = NULL; PaStream *stream = NULL; PaError err; short out48k_stereo_short[2*TEST_BUF_SIZE]; short out48k_short[TEST_BUF_SIZE]; short out8k_short[TEST_BUF_SIZE]; - int numDevices, nBufs, i, j, src_error, n; + int numDevices, nBufs, i, j, src_error, n, outputChannels; float t; SRC_STATE *src; FIFO *fifo; @@ -1055,8 +1056,22 @@ void AudioOptsDialog::plotDeviceOutputForAFewSecs(int devNum, PlotScalar *plotSc fifo = fifo_create((int)(DT*TEST_WAVEFORM_PLOT_FS*2)); assert(fifo != NULL); src = src_new(SRC_SINC_FASTEST, 1, &src_error); assert(src != NULL); + // work out how many output channels this device supports. + + deviceInfo = Pa_GetDeviceInfo(devNum); + if (deviceInfo == NULL) { + wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card "), wxT("Error"), wxOK); + return; + } + if (deviceInfo->maxOutputChannels == 1) + outputChannels = 1; + else + outputChannels = 2; + + printf("outputChannels: %d\n", outputChannels); + outputParameters.device = devNum; - outputParameters.channelCount = 2; + outputParameters.channelCount = outputChannels; outputParameters.sampleFormat = paInt16; outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultHighOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; @@ -1086,8 +1101,13 @@ void AudioOptsDialog::plotDeviceOutputForAFewSecs(int devNum, PlotScalar *plotSc for(i=0, t=0.0, n=0; i