/* * Copyright (C) 2002 - David W. Durham * * This file is part of ReZound, an audio editing application. * * ReZound is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * ReZound is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include "CJACKSoundRecorder.h" #ifdef ENABLE_JACK #include #include #include #include #include #include #include "settings.h" #include "AFrontendHooks.h" #include "AStatusComm.h" CJACKSoundRecorder::CJACKSoundRecorder() : ASoundRecorder(), initialized(false), client(NULL), tempBuffer(1) { for(unsigned t=0;tgetChannelCount()); // create two ports channelCount=sound->getChannelCount(); // saved for later in deinitialize too for(unsigned t=0;t outputPortNames; const char **ports=jack_get_ports(client,NULL,NULL,JackPortIsOutput); while(ports && *ports) outputPortNames.push_back(*(ports++)); ports-=outputPortNames.size(); free(ports); // connect the ports for(unsigned t=0;tpromptForJACKPort(_("Choose Port for Input Channel ")+istring(t+1),outputPortNames); } const string portName=gJACKInputPortNames[t]; if(jack_connect(client,portName.c_str(),jack_port_name(input_ports[t]))) { Warning(_("Cannot connect to JACK port, ")+portName+_(", please choose a different one")); gJACKInputPortNames[t]=""; goto askAgain; } } initialized=true; } catch(...) { deinitialize(); throw; } } else throw(runtime_error(string(__func__)+" -- already initialized")); } #warning see about possibly using the same client for players and recorders... and dont close or open it until a reference count goes to zero void CJACKSoundRecorder::deinitialize() { if(client) { jack_deactivate(client); for(unsigned t=0;ttempBuffer; // convert the recorded buffer to the native type and give to ASoundRecorder::onData const unsigned channelCount=that->getSound()->getChannelCount(); for(unsigned i=0;iinput_ports[i],nframes); sample_t *tt=tempBuffer+i; for(unsigned t=0;t(in[t]); } that->onData(that->tempBuffer,nframes); } catch(exception &e) { fprintf(stderr,"exception caught in record callback: %s\n",e.what()); } catch(...) { fprintf(stderr,"unknown exception caught in record callback\n"); } return 0; } int CJACKSoundRecorder::sampleRateChanged(jack_nframes_t nframes,void *arg) { return 0; } void CJACKSoundRecorder::jackShutdown(void *arg) { } #endif // ENABLE_JACK