JackMachServerNotifyChannel.cpp 1.84 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
Copyright (C) 2004-2008 Grame
sletz's avatar
sletz committed
3
4

This program is free software; you can redistribute it and/or modify
sletz's avatar
sletz committed
5
6
7
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.
sletz's avatar
sletz committed
8

sletz's avatar
sletz committed
9
10
11
12
This program 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.
sletz's avatar
sletz committed
13

sletz's avatar
sletz committed
14
15
16
You should have received a copy of the GNU Lesser 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.
sletz's avatar
sletz committed
17
18
19
20
21

*/

#include "JackMachServerNotifyChannel.h"
#include "JackRPCEngineUser.c"
22
#include "JackTools.h"
sletz's avatar
sletz committed
23
#include "JackConstants.h"
sletz's avatar
sletz committed
24
#include "JackError.h"
sletz's avatar
sletz committed
25
#include <stdio.h>
sletz's avatar
sletz committed
26
27
28
29

namespace Jack
{

30
int JackMachServerNotifyChannel::Open(const char* server_name)
sletz's avatar
sletz committed
31
{
sletz's avatar
sletz committed
32
    jack_log("JackMachServerChannel::Open");
sletz's avatar
sletz committed
33
    char jack_server_entry_name[512];
34
    snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s.%d_%s", jack_server_entry, JackTools::GetUID(), server_name);
sletz's avatar
sletz committed
35

36
    if (!fClientPort.ConnectPort(jack_server_entry_name)) {
sletz's avatar
sletz committed
37
38
39
40
41
42
43
44
45
46
47
48
        jack_error("Cannot connect to server port");
        return -1;
    } else {
        return 0;
    }
}

void JackMachServerNotifyChannel::Close()
{
    //fClientPort.DisconnectPort(); pas ncessaire car le JackMachServerChannel a dja disparu?
}

sletz's avatar
sletz committed
49
void JackMachServerNotifyChannel::Notify(int refnum, int notify, int value)
sletz's avatar
sletz committed
50
51
52
{
    kern_return_t res = rpc_jack_client_rt_notify(fClientPort.GetPort(), refnum, notify, value, 0);
    if (res != KERN_SUCCESS) {
sletz's avatar
sletz committed
53
        jack_error("Could not write request ref = %ld notify = %ld err = %s", refnum, notify, mach_error_string(res));
sletz's avatar
sletz committed
54
55
56
57
58
59
    }
}

} // end of namespace