Test for jack_set_port_rename_callback presence at both compile time and run time.

git-svn-id: file:///home/vcs/svn/jsweeper/trunk@41 6611ac79-6612-48ef-a1e9-b906f853523e
master
petern 2010-03-26 15:07:18 +00:00
parent c444ab7334
commit 66a92a0725
8 changed files with 15 additions and 17 deletions

View File

@ -4,6 +4,7 @@ PROJECT(jsweeper)
INCLUDE( ${CMAKE_ROOT}/Modules/FindPkgConfig.cmake )
INCLUDE( ${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake )
INCLUDE( CheckLibraryExists)
pkg_check_modules(JACK jack>=0.118)
pkg_check_modules(GTKMM gtkmm-2.4>=2.4)
@ -60,6 +61,11 @@ INCLUDE_DIRECTORIES(
${PCRE_INCLUDE_DIRS}
)
CHECK_LIBRARY_EXISTS(jack jack_set_port_rename_callback ${JACK_INCLUDE_DIRS}/jack.h RENAME_FOUND)
IF (RENAME_FOUND)
ADD_DEFINITIONS(-DHAVE_RENAME)
ENDIF()
ADD_DEFINITIONS(-Wall -Wextra -ansi -pedantic)
ADD_EXECUTABLE(jsweeper ${SOURCES})

View File

@ -24,9 +24,10 @@ Gui::Gui(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder)
Refresh();
Glib::signal_timeout().connect(sigc::mem_fun(*this, &Gui::on_timeout), 50);
#ifndef HAVE_RENAME
Glib::signal_timeout().connect(sigc::mem_fun(*this, &Gui::on_timeout_2), 1000);
#endif
if (!jack_set_port_rename_callback) {
Glib::signal_timeout().connect(sigc::mem_fun(*this, &Gui::on_timeout_2), 1000);
}
Glib::RefPtr<Gtk::UIManager> uim = Glib::RefPtr<Gtk::UIManager>::cast_static(builder->get_object("uimanager1"));
uim->get_action("/menubar1/menuitem1/menu_quit")->signal_activate().connect(sigc::mem_fun(*this, &Gui::on_quit));
@ -176,7 +177,6 @@ bool Gui::on_timeout()
return true;
}
#ifndef HAVE_RENAME
bool Gui::on_timeout_2()
{
if (m_closing) return false;
@ -188,7 +188,6 @@ bool Gui::on_timeout_2()
return true;
}
#endif
void Gui::on_notebook_switch_page(GtkNotebookPage * /* page */, guint /* page_num */)
{

View File

@ -30,9 +30,7 @@ public:
protected:
bool on_timeout();
#ifndef HAVE_RENAME
bool on_timeout_2();
#endif
void on_notebook_switch_page(GtkNotebookPage * /* page */, guint /* page_num */);
void on_quit();

View File

@ -37,11 +37,9 @@ void JackDriver::Connect()
jack_on_shutdown(m_client, &ShutdownCallbackHandler, this);
jack_set_port_registration_callback(m_client, &PortRegistrationCallbackHandler, this);
jack_set_port_connect_callback(m_client, &PortConnectCallbackHandler, this);
#ifdef HAVE_RENAME
if (jack_set_port_rename_callback) {
jack_set_port_rename_callback(m_client, &PortRenameCallbackHandler, this);
}
#endif
jack_activate(m_client);

View File

@ -5,6 +5,11 @@
#include <jack/jack.h>
#include <jack/ringbuffer.h>
#ifndef HAVE_RENAME
typedef int (*JackPortRenameCallback)(jack_port_id_t port, const char* old_name, const char* new_name, void *arg);
int jack_set_port_rename_callback (jack_client_t *, JackPortRenameCallback rename_callback, void *arg) __attribute__((__weak__));
#endif
enum PortEventType
{
PET_REGISTER,

View File

@ -89,9 +89,7 @@ struct Port : Base
Client *m_client;
PortGroup *m_group;
PortList m_connections;
#ifndef HAVE_RENAME
std::string m_real_name;
#endif
virtual ConnectionMode ConnectedTo(Port *port);
virtual ConnectionMode ConnectedTo(PortGroup *group);

View File

@ -118,9 +118,7 @@ void PortManager::Add(jack_port_t *port)
p->m_port = port;
p->m_is_input = (JackPortFlags)jack_port_flags(port) & JackPortIsInput;
#ifndef HAVE_RENAME
p->m_real_name = jack_port_name(port);
#endif
std::string type = jack_port_type(port);
p->m_is_midi = type == JACK_DEFAULT_MIDI_TYPE;
@ -227,7 +225,6 @@ void PortManager::Rename(jack_port_t *port)
RefreshConnections();
}
#ifndef HAVE_RENAME
bool PortManager::PollPortRenames()
{
// Queue for storing ports to be renamed, to avoid messing up the
@ -251,7 +248,6 @@ bool PortManager::PollPortRenames()
return queue.size() > 0;
}
#endif
Client *PortManager::FindOrMakeClient(std::string name, bool is_input, bool is_midi)
{

View File

@ -46,9 +46,7 @@ public:
void Disconnect(jack_port_t *port_a, jack_port_t *port_b);
void Rename(jack_port_t *port);
#ifndef HAVE_RENAME
bool PollPortRenames();
#endif
Client *FindOrMakeClient(std::string name, bool is_input, bool is_midi);
PortGroup *FindOrMakeGroup(Client *client, std::string name);