|
From: Johnny P. <ele...@us...> - 2004-04-23 14:35:25
|
Update of /cvsroot/xpanda/Panda/Drivers/MACOSX/Jack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20700/Jack Modified Files: JackRender.cpp main.cpp JackRender.h Log Message: fix Index: main.cpp =================================================================== RCS file: /cvsroot/xpanda/Panda/Drivers/MACOSX/Jack/main.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.cpp 15 Feb 2004 23:37:16 -0000 1.2 --- main.cpp 23 Apr 2004 14:35:14 -0000 1.3 *************** *** 8,96 **** main.cpp - main file. ! under the terms of the Artistic License : ! ! The Artistic License ! ! Preamble ! ! The intent of this document is to state the conditions under which a Package may be copied, ! such that the Copyright Holder maintains some semblance of artistic control over the development of the package, ! while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, ! plus the right to make reasonable modifications. ! ! Definitions: ! ! "Package" refers to the collection of files distributed by the Copyright Holder, ! and derivatives of that collection of files created through textual modification. ! ! "Standard Version" refers to such a Package if it has not been modified, ! or has been modified in accordance with the wishes of the Copyright Holder. ! ! "Copyright Holder" is whoever is named in the copyright or copyrights for the package. ! ! "You" is you, if you're thinking about copying or distributing this Package. ! ! "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, ! time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, ! but only to the computing community at large as a market that must bear the fee.) ! ! "Freely Available" means that no fee is charged for the item itself, ! though there may be fees involved in handling the item. ! It also means that recipients of the item may redistribute it under the same conditions they received it. ! ! 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, ! provided that you duplicate all of the original copyright notices and associated disclaimers. ! ! 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. ! A Package modified in such a way shall still be considered the Standard Version. ! ! 3. You may otherwise modify your copy of this Package in any way, ! provided that you insert a prominent notice in each changed file stating how and when you changed that file, ! and provided that you do at least ONE of the following: ! ! a) place your modifications in the Public Domain or otherwise make them Freely Available, ! such as by posting said modifications to Usenet or an equivalent medium, ! or placing the modifications on a major archive site such as ftp.uu.net, ! or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. ! ! b) use the modified Package only within your corporation or organization. ! ! c) rename any non-standard executables so the names do not conflict with standard executables, ! which must also be provided, and provide a separate manual page for each non-standard executable ! that clearly documents how it differs from the Standard Version. ! ! d) make other distribution arrangements with the Copyright Holder. ! ! 4. You may distribute the programs of this Package in object code or executable form, ! provided that you do at least ONE of the following: ! ! a) distribute a Standard Version of the executables and library files, ! together with instructions (in the manual page or equivalent) on where to get the Standard Version. ! ! b) accompany the distribution with the machine-readable source of the Package with your modifications. ! ! c) accompany any non-standard executables with their corresponding Standard Version executables, ! giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), ! together with instructions on where to get the Standard Version. ! ! d) make other distribution arrangements with the Copyright Holder. ! ! 5. You may charge a reasonable copying fee for any distribution of this Package. ! You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. ! However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of ! a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. ! ! 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically ! fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. - 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. ! 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. - 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - - The End. */ --- 8,30 ---- main.cpp - main file. ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! This library 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 ! Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + elementicaotici - by Johnny (Giovanni) Petrantoni, ITALY - Rome. + e-mail: jo...@la... + */ *************** *** 107,111 **** }; - MyData * HelloPandaDriver(void) { MyData *x; --- 41,44 ---- *************** *** 137,141 **** x->inCh = 0; x->outCh = 2; ! strcpy(&x->clientName[0],"Panda"); x->isConfigured = false; --- 70,75 ---- x->inCh = 0; x->outCh = 2; ! bzero(&x->clientName[0],sizeof(char)*256); ! strcpy(&x->clientName[0],"PandaJack"); x->isConfigured = false; Index: JackRender.cpp =================================================================== RCS file: /cvsroot/xpanda/Panda/Drivers/MACOSX/Jack/JackRender.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JackRender.cpp 15 Feb 2004 23:37:16 -0000 1.2 --- JackRender.cpp 23 Apr 2004 14:35:14 -0000 1.3 *************** *** 8,103 **** JackRender.cpp ! under the terms of the Artistic License : ! ! The Artistic License ! ! Preamble ! ! The intent of this document is to state the conditions under which a Package may be copied, ! such that the Copyright Holder maintains some semblance of artistic control over the development of the package, ! while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, ! plus the right to make reasonable modifications. ! ! Definitions: ! ! "Package" refers to the collection of files distributed by the Copyright Holder, ! and derivatives of that collection of files created through textual modification. ! ! "Standard Version" refers to such a Package if it has not been modified, ! or has been modified in accordance with the wishes of the Copyright Holder. ! ! "Copyright Holder" is whoever is named in the copyright or copyrights for the package. ! ! "You" is you, if you're thinking about copying or distributing this Package. ! ! "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, ! time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, ! but only to the computing community at large as a market that must bear the fee.) ! ! "Freely Available" means that no fee is charged for the item itself, ! though there may be fees involved in handling the item. ! It also means that recipients of the item may redistribute it under the same conditions they received it. ! ! 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, ! provided that you duplicate all of the original copyright notices and associated disclaimers. ! ! 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. ! A Package modified in such a way shall still be considered the Standard Version. ! ! 3. You may otherwise modify your copy of this Package in any way, ! provided that you insert a prominent notice in each changed file stating how and when you changed that file, ! and provided that you do at least ONE of the following: ! ! a) place your modifications in the Public Domain or otherwise make them Freely Available, ! such as by posting said modifications to Usenet or an equivalent medium, ! or placing the modifications on a major archive site such as ftp.uu.net, ! or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. ! ! b) use the modified Package only within your corporation or organization. ! ! c) rename any non-standard executables so the names do not conflict with standard executables, ! which must also be provided, and provide a separate manual page for each non-standard executable ! that clearly documents how it differs from the Standard Version. ! ! d) make other distribution arrangements with the Copyright Holder. ! ! 4. You may distribute the programs of this Package in object code or executable form, ! provided that you do at least ONE of the following: ! ! a) distribute a Standard Version of the executables and library files, ! together with instructions (in the manual page or equivalent) on where to get the Standard Version. ! ! b) accompany the distribution with the machine-readable source of the Package with your modifications. ! ! c) accompany any non-standard executables with their corresponding Standard Version executables, ! giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), ! together with instructions on where to get the Standard Version. ! ! d) make other distribution arrangements with the Copyright Holder. ! ! 5. You may charge a reasonable copying fee for any distribution of this Package. ! You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. ! However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of ! a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. ! ! 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically ! fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. ! ! 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. - 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. ! 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, ! INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - The End. */ - #include "JackRender.h" int JackRender::renderProcess(jack_nframes_t nframes,void *arg) { - JackRender *x = (JackRender*)arg; --- 8,35 ---- JackRender.cpp ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! This library 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 ! Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + elementicaotici - by Johnny (Giovanni) Petrantoni, ITALY - Rome. + e-mail: jo...@la... + */ #include "JackRender.h" int JackRender::renderProcess(jack_nframes_t nframes,void *arg) { JackRender *x = (JackRender*)arg; *************** *** 105,119 **** x->in_buffers[i] = (float*)jack_port_get_buffer(x->inPorts[i],nframes); } - for(int i=0;i<x->output_ports;i++) { x->out_buffers[i] = (float*)jack_port_get_buffer(x->outPorts[i],nframes); } - for(int i=0;i<x->output_ports;i++) { ! memset(x->out_buffers[i],0x0,sizeof(float)*nframes); ! } doPandaRender(nframes); ! return 0; } --- 37,49 ---- x->in_buffers[i] = (float*)jack_port_get_buffer(x->inPorts[i],nframes); } for(int i=0;i<x->output_ports;i++) { x->out_buffers[i] = (float*)jack_port_get_buffer(x->outPorts[i],nframes); } for(int i=0;i<x->output_ports;i++) { ! bzero(x->out_buffers[i],sizeof(float)*nframes); ! } doPandaRender(nframes); ! return 0; } *************** *** 121,208 **** void JackRender::JackShutDown(void *arg) { JackRender *x = (JackRender*)arg; - - x->isOn = false; - free(x->inPorts); - free(x->outPorts); - free(x->in_buffers); - free(x->out_buffers); delete x; } ! ! JackRender::JackRender(int inChannels,int outChannels) : input_ports(inChannels), output_ports(outChannels) { isOn = false; - client = jack_client_new("Panda"); - if(!client) return; - - if(inChannels>0) inPorts = (jack_port_t**)malloc(sizeof(jack_port_t*)*inChannels); - if(outChannels>0) outPorts = (jack_port_t**)malloc(sizeof(jack_port_t*)*outChannels); - - for(int i=0;i<inChannels;i++) { - char name[256]; - sprintf(&name[0],"in%d",i+1); - inPorts[i] = jack_port_register(client, &name[0], JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); - } - - for(int i=0;i<outChannels;i++) { - char name[256]; - sprintf(&name[0],"out%d",i+1); - outPorts[i] = jack_port_register(client, &name[0], JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); - } - - bufferSize = jack_get_buffer_size(client); - sampleRate = jack_get_sample_rate(client); - - if(jack_set_process_callback(client,renderProcess,this)!=0) return; - jack_on_shutdown (client,JackShutDown,this); - - if(inChannels>0) in_buffers = (float**)malloc(sizeof(float*)*inChannels); - if(outChannels>0) out_buffers = (float**)malloc(sizeof(float*)*outChannels); ! input_ports = inChannels; ! output_ports = outChannels; ! ! SetPandaBufferSize(bufferSize); ! SetPandaSampleRate(sampleRate); ! SetPandaInChannels(input_ports); ! SetPandaOutChannels(output_ports); ! ! setDAC(out_buffers); ! setADC(in_buffers); - isOn = true; - } - - JackRender::JackRender(int inChannels,int outChannels,char *clientName) { - isOn = false; client = jack_client_new(clientName); if(!client) return; - if(inChannels>0) inPorts = (jack_port_t**)malloc(sizeof(jack_port_t*)*inChannels); - if(outChannels>0) outPorts = (jack_port_t**)malloc(sizeof(jack_port_t*)*outChannels); - for(int i=0;i<inChannels;i++) { char name[256]; sprintf(&name[0],"in%d",i+1); ! inPorts[i] = jack_port_register(client, &name[0], JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); } for(int i=0;i<outChannels;i++) { char name[256]; sprintf(&name[0],"out%d",i+1); ! outPorts[i] = jack_port_register(client, &name[0], JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); } bufferSize = jack_get_buffer_size(client); sampleRate = jack_get_sample_rate(client); - if(jack_set_process_callback(client,renderProcess,this)!=0) return; - jack_on_shutdown (client,JackShutDown,this); - if(inChannels>0) in_buffers = (float**)malloc(sizeof(float*)*inChannels); if(outChannels>0) out_buffers = (float**)malloc(sizeof(float*)*outChannels); - input_ports = inChannels; - output_ports = outChannels; - SetPandaBufferSize(bufferSize); SetPandaSampleRate(sampleRate); --- 51,88 ---- void JackRender::JackShutDown(void *arg) { JackRender *x = (JackRender*)arg; delete x; } ! ! JackRender::JackRender(int inChannels,int outChannels,char *clientName) : input_ports(inChannels),output_ports(outChannels) { isOn = false; ! if(inChannels > 128 || outChannels > 128) return; client = jack_client_new(clientName); if(!client) return; for(int i=0;i<inChannels;i++) { char name[256]; + bzero(&name[0],sizeof(char)*256); sprintf(&name[0],"in%d",i+1); ! inPorts[i] = jack_port_register(client,&name[0],JACK_DEFAULT_AUDIO_TYPE,JackPortIsInput,0); } for(int i=0;i<outChannels;i++) { char name[256]; + bzero(&name[0],sizeof(char)*256); sprintf(&name[0],"out%d",i+1); ! outPorts[i] = jack_port_register(client,&name[0],JACK_DEFAULT_AUDIO_TYPE,JackPortIsOutput,0); } + jack_set_process_callback(client,renderProcess,this); + jack_on_shutdown (client,JackShutDown,this); + bufferSize = jack_get_buffer_size(client); sampleRate = jack_get_sample_rate(client); if(inChannels>0) in_buffers = (float**)malloc(sizeof(float*)*inChannels); if(outChannels>0) out_buffers = (float**)malloc(sizeof(float*)*outChannels); SetPandaBufferSize(bufferSize); SetPandaSampleRate(sampleRate); *************** *** 210,215 **** SetPandaOutChannels(output_ports); ! setDAC(out_buffers); ! setADC(in_buffers); isOn = true; --- 90,95 ---- SetPandaOutChannels(output_ports); ! if(outChannels>0) setDAC(out_buffers); ! if(inChannels>0) setADC(in_buffers); isOn = true; *************** *** 219,234 **** if(client && isOn) { jack_deactivate(client); ! /*for(int i=0;i<input_ports;i++) { jack_port_unregister(client,inPorts[i]); } for(int i=0;i<output_ports;i++) { jack_port_unregister(client,outPorts[i]); ! }*/ ! free(inPorts); ! free(outPorts); ! free(in_buffers); ! free(out_buffers); jack_client_close(client); isOn = false; } } --- 99,113 ---- if(client && isOn) { jack_deactivate(client); ! for(int i=0;i<input_ports;i++) { jack_port_unregister(client,inPorts[i]); } for(int i=0;i<output_ports;i++) { jack_port_unregister(client,outPorts[i]); ! } ! if(input_ports > 0) free(in_buffers); ! if(output_ports > 0) free(out_buffers); jack_client_close(client); isOn = false; + client = NULL; } } Index: JackRender.h =================================================================== RCS file: /cvsroot/xpanda/Panda/Drivers/MACOSX/Jack/JackRender.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JackRender.h 15 Feb 2004 23:37:16 -0000 1.2 --- JackRender.h 23 Apr 2004 14:35:14 -0000 1.3 *************** *** 8,105 **** JackRender.h ! under the terms of the Artistic License : ! ! The Artistic License ! ! Preamble ! ! The intent of this document is to state the conditions under which a Package may be copied, ! such that the Copyright Holder maintains some semblance of artistic control over the development of the package, ! while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, ! plus the right to make reasonable modifications. ! ! Definitions: ! ! "Package" refers to the collection of files distributed by the Copyright Holder, ! and derivatives of that collection of files created through textual modification. ! ! "Standard Version" refers to such a Package if it has not been modified, ! or has been modified in accordance with the wishes of the Copyright Holder. ! ! "Copyright Holder" is whoever is named in the copyright or copyrights for the package. ! ! "You" is you, if you're thinking about copying or distributing this Package. ! ! "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, ! time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, ! but only to the computing community at large as a market that must bear the fee.) ! ! "Freely Available" means that no fee is charged for the item itself, ! though there may be fees involved in handling the item. ! It also means that recipients of the item may redistribute it under the same conditions they received it. ! ! 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, ! provided that you duplicate all of the original copyright notices and associated disclaimers. ! ! 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. ! A Package modified in such a way shall still be considered the Standard Version. ! ! 3. You may otherwise modify your copy of this Package in any way, ! provided that you insert a prominent notice in each changed file stating how and when you changed that file, ! and provided that you do at least ONE of the following: ! ! a) place your modifications in the Public Domain or otherwise make them Freely Available, ! such as by posting said modifications to Usenet or an equivalent medium, ! or placing the modifications on a major archive site such as ftp.uu.net, ! or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. ! ! b) use the modified Package only within your corporation or organization. ! ! c) rename any non-standard executables so the names do not conflict with standard executables, ! which must also be provided, and provide a separate manual page for each non-standard executable ! that clearly documents how it differs from the Standard Version. ! ! d) make other distribution arrangements with the Copyright Holder. ! ! 4. You may distribute the programs of this Package in object code or executable form, ! provided that you do at least ONE of the following: ! ! a) distribute a Standard Version of the executables and library files, ! together with instructions (in the manual page or equivalent) on where to get the Standard Version. ! ! b) accompany the distribution with the machine-readable source of the Package with your modifications. ! ! c) accompany any non-standard executables with their corresponding Standard Version executables, ! giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), ! together with instructions on where to get the Standard Version. ! ! d) make other distribution arrangements with the Copyright Holder. ! ! 5. You may charge a reasonable copying fee for any distribution of this Package. ! You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. ! However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of ! a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. ! ! 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically ! fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. - 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. ! 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. - 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - - The End. */ ! ! #include <Panda/panda_drivers.h> #include <Jack/jack.h> class JackRender { public: ! JackRender(int inChannels,int outChannels); JackRender(int inChannels,int outChannels,char *clientName); ~JackRender(); --- 8,38 ---- JackRender.h ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! This library 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 ! Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + elementicaotici - by Johnny (Giovanni) Petrantoni, ITALY - Rome. + e-mail: jo...@la... + */ ! #include <Panda/panda.h> #include <Jack/jack.h> class JackRender { public: ! JackRender(int inChannels,int outChannels) { JackRender(inChannels,outChannels,"PandaJack"); } JackRender(int inChannels,int outChannels,char *clientName); ~JackRender(); *************** *** 107,116 **** bool startAudio(); bool stopAudio(); - private: static int renderProcess(jack_nframes_t nframes,void *arg); static void JackShutDown(void *arg); jack_client_t *client; ! jack_port_t **inPorts; ! jack_port_t **outPorts; int input_ports; int output_ports; --- 40,49 ---- bool startAudio(); bool stopAudio(); static int renderProcess(jack_nframes_t nframes,void *arg); static void JackShutDown(void *arg); + private: jack_client_t *client; ! jack_port_t *inPorts[128]; ! jack_port_t *outPorts[128]; int input_ports; int output_ports; |