JackExternalClient.cpp

00001 /*
00002   Copyright (C) 2001-2003 Paul Davis
00003 Copyright (C) 2004-2008 Grame
00004   
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 */
00020 
00021 #include "JackExternalClient.h"
00022 #include "JackClientControl.h"
00023 #include "JackGlobals.h"
00024 #include "JackChannel.h"
00025 
00026 namespace Jack
00027 {
00028 
00029 JackExternalClient::JackExternalClient(): fClientControl(NULL)
00030 {
00031     fChannel = JackGlobals::MakeNotifyChannel();
00032 }
00033 
00034 JackExternalClient::~JackExternalClient()
00035 {
00036     delete fChannel;
00037 }
00038 
00039 int JackExternalClient::ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2)
00040 {
00041     int result = -1;
00042     JackLog("JackExternalClient::ClientNotify ref = %ld name = %s notify = %ld\n", refnum, name, notify);
00043     fChannel->ClientNotify(refnum, name, notify, sync, value1, value2, &result);
00044     return result;
00045 }
00046 
00047 int JackExternalClient::Open(const char* name, int refnum, int* shared_client)
00048 {
00049     try {
00050 
00051         if (fChannel->Open(name) < 0) {
00052             jack_error("Cannot connect to client name = %s\n", name);
00053             return -1;
00054         }
00055 
00056         fClientControl = new JackClientControl(name, refnum);
00057         if (!fClientControl) {
00058             jack_error("Cannot allocate client shared memory segment");
00059             return -1;
00060         }
00061 
00062         *shared_client = fClientControl->GetShmIndex();
00063         JackLog("JackExternalClient::Open name = %s index = %ld base = %x\n", name, fClientControl->GetShmIndex(), fClientControl->GetShmAddress());
00064         return 0;
00065 
00066     } catch (std::exception e) {
00067         return -1;
00068     }
00069 }
00070 
00071 int JackExternalClient::Close()
00072 {
00073     fChannel->Close();
00074     delete fClientControl;
00075     return 0;
00076 }
00077 
00078 JackClientControl* JackExternalClient::GetClientControl() const
00079 {
00080     return fClientControl;
00081 }
00082 
00083 } // end of namespace

Generated on Thu Feb 14 11:16:01 2008 for Jackdmp by  doxygen 1.5.1