~ubuntu-branches/ubuntu/quantal/jackd2/quantal

« back to all changes in this revision

Viewing changes to .pc/0000_sync_upstream_VCS.patch/common/JackLibAPI.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler, Adrian Knoth, Reinhard Tartler, Jonas Smedegaard
  • Date: 2010-06-19 18:54:29 UTC
  • Revision ID: james.westby@ubuntu.com-20100619185429-zhbhh0mqvukgzx0l
Tags: 1.9.5~dfsg-15
[ Adrian Knoth ]
* Also provide the shlibs file for libjack-jackd2-0
* Fix FTBFS on sparc64 (Closes: #586257)

[ Reinhard Tartler ]
* jackd must not be a virtual package, use 'jack-daemon' for that
* add breaks/replaces on old libjack0
* change shlibsfile to prefer jackd2's libjack
* use conflicts instead of breaks. libjack-jackd2-0 has file conflicts
  with libjack0 and will keep it

[ Jonas Smedegaard ]
* Update control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 2001-2003 Paul Davis
 
3
Copyright (C) 2004-2008 Grame
 
4
 
 
5
This program is free software; you can redistribute it and/or modify
 
6
it under the terms of the GNU Lesser General Public License as published by
 
7
the Free Software Foundation; either version 2.1 of the License, or
 
8
(at your option) any later version.
 
9
 
 
10
This program is distributed in the hope that it will be useful,
 
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
GNU Lesser General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU Lesser General Public License
 
16
along with this program; if not, write to the Free Software 
 
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 
 
19
*/
 
20
 
 
21
#include "JackDebugClient.h"
 
22
#include "JackLibClient.h"
 
23
#include "JackChannel.h"
 
24
#include "JackLibGlobals.h"
 
25
#include "JackGlobals.h"
 
26
#include "JackCompilerDeps.h"
 
27
#include "JackTools.h"
 
28
#include "JackSystemDeps.h"
 
29
#include "JackServerLaunch.h"
 
30
#include <assert.h>
 
31
 
 
32
using namespace Jack;
 
33
 
 
34
#ifdef __cplusplus
 
35
extern "C"
 
36
{
 
37
#endif
 
38
 
 
39
    EXPORT jack_client_t * jack_client_open_aux (const char *client_name,
 
40
            jack_options_t options,
 
41
            jack_status_t *status, va_list ap);
 
42
    EXPORT jack_client_t * jack_client_open (const char *client_name,
 
43
            jack_options_t options,
 
44
            jack_status_t *status, ...);
 
45
    EXPORT int jack_client_close (jack_client_t *client);
 
46
    EXPORT int jack_get_client_pid (const char *name);
 
47
 
 
48
#ifdef __cplusplus
 
49
}
 
50
#endif
 
51
 
 
52
JackLibGlobals* JackLibGlobals::fGlobals = NULL;
 
53
int JackLibGlobals::fClientCount = 0;
 
54
 
 
55
EXPORT jack_client_t* jack_client_open_aux(const char* client_name, jack_options_t options, jack_status_t* status, va_list ap)
 
56
{
 
57
    jack_varargs_t va;          /* variable arguments */
 
58
    jack_status_t my_status;
 
59
    JackClient* client;
 
60
 
 
61
    if (client_name == NULL) {
 
62
        jack_error("jack_client_open called with a NULL client_name");
 
63
        return NULL;
 
64
    }
 
65
 
 
66
    jack_log("jack_client_open %s", client_name);
 
67
   
 
68
    if (status == NULL)                 /* no status from caller? */
 
69
        status = &my_status;    /* use local status word */
 
70
    *status = (jack_status_t)0;
 
71
 
 
72
    /* validate parameters */
 
73
    if ((options & ~JackOpenOptions)) {
 
74
        int my_status1 = *status | (JackFailure | JackInvalidOption);
 
75
        *status = (jack_status_t)my_status1;
 
76
        return NULL;
 
77
    }
 
78
 
 
79
    /* parse variable arguments */
 
80
    if (ap) {
 
81
        jack_varargs_parse(options, ap, &va);
 
82
    } else {
 
83
        jack_varargs_init(&va);
 
84
    }
 
85
        
 
86
    JackLibGlobals::Init(); // jack library initialisation
 
87
 
 
88
    if (try_start_server(&va, options, status)) {
 
89
        jack_error("jack server is not running or cannot be started");
 
90
        JackLibGlobals::Destroy(); // jack library destruction
 
91
        return 0;
 
92
    }
 
93
 
 
94
    if (JACK_DEBUG) {
 
95
        client = new JackDebugClient(new JackLibClient(GetSynchroTable())); // Debug mode
 
96
    } else {
 
97
        client = new JackLibClient(GetSynchroTable());
 
98
    }
 
99
 
 
100
    int res = client->Open(va.server_name, client_name, options, status);
 
101
    if (res < 0) {
 
102
        delete client;
 
103
        JackLibGlobals::Destroy(); // jack library destruction
 
104
        int my_status1 = (JackFailure | JackServerError);
 
105
        *status = (jack_status_t)my_status1;
 
106
        return NULL;
 
107
    } else {
 
108
        return (jack_client_t*)client;
 
109
    }
 
110
}
 
111
 
 
112
EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options_t options, jack_status_t* status, ...)
 
113
{
 
114
    try {
 
115
#ifdef __CLIENTDEBUG__
 
116
        JackGlobals::CheckContext("jack_client_open");
 
117
#endif
 
118
        assert(JackGlobals::fOpenMutex);
 
119
        JackGlobals::fOpenMutex->Lock();
 
120
        va_list ap;
 
121
        va_start(ap, status);
 
122
        jack_client_t* res = jack_client_open_aux(ext_client_name, options, status, ap);
 
123
        va_end(ap);
 
124
        JackGlobals::fOpenMutex->Unlock();
 
125
        return res;
 
126
    } catch(std::bad_alloc& e) {
 
127
        jack_error("Memory allocation error...");
 
128
        return NULL;
 
129
    } catch (...) {
 
130
        jack_error("Unknown error...");
 
131
        return NULL;
 
132
    }
 
133
}
 
134
 
 
135
EXPORT int jack_client_close(jack_client_t* ext_client)
 
136
{
 
137
#ifdef __CLIENTDEBUG__
 
138
    JackGlobals::CheckContext("jack_client_close");
 
139
#endif
 
140
    assert(JackGlobals::fOpenMutex);
 
141
    JackGlobals::fOpenMutex->Lock();
 
142
    int res = -1;
 
143
    jack_log("jack_client_close");
 
144
    JackClient* client = (JackClient*)ext_client;
 
145
    if (client == NULL) {
 
146
        jack_error("jack_client_close called with a NULL client");
 
147
    } else {
 
148
        res = client->Close();
 
149
        delete client;
 
150
        JackLibGlobals::Destroy(); // jack library destruction
 
151
        jack_log("jack_client_close res = %d", res);
 
152
    }
 
153
    JackGlobals::fOpenMutex->Unlock();
 
154
    return res;
 
155
}
 
156
 
 
157
EXPORT int jack_get_client_pid(const char *name)
 
158
{
 
159
    jack_error("jack_get_client_pid : not implemented on library side");
 
160
    return 0;
 
161
}
 
162