mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-05 05:05:43 +01:00
get soundgrid initialization running in its own thread, with a hand-holding GUI pulsing progress bar, and make first call into mixer core to get LAN id's
git-svn-id: svn://localhost/ardour2/branches/3.0-SG@12615 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
f228d2c68e
commit
e392b271d5
9 changed files with 234 additions and 75 deletions
|
|
@ -713,11 +713,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
|||
bool _feedback_exists;
|
||||
|
||||
void resize_text_widgets ();
|
||||
|
||||
#ifdef USE_SOUNDGRID
|
||||
void soundgrid_init ();
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif /* __ardour_gui_h__ */
|
||||
|
|
|
|||
|
|
@ -601,11 +601,6 @@ ARDOUR_UI::editor_realized ()
|
|||
{
|
||||
boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
|
||||
Config->map_parameters (pc);
|
||||
|
||||
#ifdef USE_SOUNDGRID
|
||||
soundgrid_init ();
|
||||
#endif
|
||||
|
||||
reset_dpi ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2012 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "ardour/soundgrid.h"
|
||||
|
||||
#include "ardour_ui.h"
|
||||
#include "public_editor.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define Marker MarkerStupidApple
|
||||
#include <gdk/gdkquartz.h>
|
||||
#undef Marker
|
||||
|
||||
#ifdef check
|
||||
#undef check
|
||||
#endif
|
||||
#ifdef NO
|
||||
#undef NO
|
||||
#endif
|
||||
#ifdef YES
|
||||
#undef YES
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_SOUNDGRID
|
||||
|
||||
void
|
||||
ARDOUR_UI::soundgrid_init ()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
NSView* nsview = gdk_quartz_window_get_nsview (editor->get_window()->gobj());
|
||||
ARDOUR::SoundGrid::instance().initialize (nsview);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -59,6 +59,8 @@
|
|||
#endif
|
||||
|
||||
#include "engine_dialog.h"
|
||||
#include "soundgrid.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -694,6 +696,11 @@ EngineControl::enumerate_devices (const string& driver)
|
|||
} else if (driver == "CoreAudio") {
|
||||
devices[driver] = enumerate_coreaudio_devices ();
|
||||
} else if (driver == "SoundGrid") {
|
||||
|
||||
cerr << "calling soundgrid_init()\n";
|
||||
soundgrid_init ();
|
||||
cerr << "done with soundgrid_init()\n";
|
||||
|
||||
devices[driver] = SoundGrid::lan_port_names ();
|
||||
|
||||
#else
|
||||
|
|
@ -913,6 +920,8 @@ EngineControl::driver_changed ()
|
|||
string::size_type maxlen = 0;
|
||||
int n = 0;
|
||||
|
||||
cerr << "Driver has changed, now set to " << driver << endl;
|
||||
|
||||
enumerate_devices (driver);
|
||||
|
||||
vector<string>& strings = devices[driver];
|
||||
|
|
@ -928,6 +937,7 @@ EngineControl::driver_changed ()
|
|||
}
|
||||
|
||||
if (driver == _("SoundGrid")) {
|
||||
|
||||
device_label.set_text (_("LAN Port"));
|
||||
|
||||
if (soundgrid_vbox.children().empty()) {
|
||||
|
|
|
|||
157
gtk2_ardour/soundgrid.mm
Normal file
157
gtk2_ardour/soundgrid.mm
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
Copyright (C) 2012 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "ardour/soundgrid.h"
|
||||
|
||||
#include "ardour_ui.h"
|
||||
#include "public_editor.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define Marker MarkerStupidApple
|
||||
#include <gdk/gdkquartz.h>
|
||||
#undef Marker
|
||||
|
||||
#ifdef check
|
||||
#undef check
|
||||
#endif
|
||||
#ifdef NO
|
||||
#undef NO
|
||||
#endif
|
||||
#ifdef YES
|
||||
#undef YES
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_SOUNDGRID
|
||||
|
||||
#include <glibmm/thread.h>
|
||||
#include <gtkmm/label.h>
|
||||
|
||||
#include "pbd/compose.h"
|
||||
|
||||
#include "ardour/debug.h"
|
||||
|
||||
#include "ardour_window.h"
|
||||
#include "soundgrid.h"
|
||||
|
||||
using namespace PBD;
|
||||
using std::cerr;
|
||||
|
||||
static int sg_status = -1;
|
||||
|
||||
static void sg_init ()
|
||||
{
|
||||
DEBUG_TRACE (PBD::DEBUG::SoundGrid, "thread starting SG init\n");
|
||||
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSWindow* window = [[NSWindow alloc] initWithContentRect:NSZeroRect
|
||||
styleMask:NSTitledWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:1];
|
||||
|
||||
ARDOUR::SoundGrid::instance().set_pool (pool);
|
||||
|
||||
if (ARDOUR::SoundGrid::instance().initialize ([window contentView]) == 0) {
|
||||
sg_status = 1;
|
||||
} else {
|
||||
sg_status = -1;
|
||||
}
|
||||
|
||||
cerr << "initialization done, status === " << sg_status << std::endl;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
@interface DummyThread : NSThread
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation DummyThread
|
||||
- (void) main
|
||||
{
|
||||
printf ("dummy thread running\n");
|
||||
}
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
static bool hack (sigc::slot<void> theSlot)
|
||||
{
|
||||
theSlot();
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
soundgrid_init ()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
/* need to ensure that Cocoa is multithreaded */
|
||||
if (![NSThread isMultiThreaded]) {
|
||||
cerr << "Starting dummy thread\n";
|
||||
NSThread* dummy = [[DummyThread alloc] init];
|
||||
[dummy start];
|
||||
} else {
|
||||
cerr << "Already multithreaded\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
ArdourWindow win (_("Initializing SoundGrid"));
|
||||
Gtk::Label label (_("Please wait while SoundGrid initializes"));
|
||||
Gtk::VBox packer;
|
||||
Gtk::ProgressBar progress;
|
||||
|
||||
label.show ();
|
||||
progress.show();
|
||||
packer.show ();
|
||||
packer.pack_start (label);
|
||||
packer.pack_start (progress);
|
||||
|
||||
win.set_position (Gtk::WIN_POS_MOUSE);
|
||||
win.add (packer);
|
||||
win.present ();
|
||||
|
||||
DEBUG_TRACE (DEBUG::SoundGrid, "Initializing SoundGrid instance\n");
|
||||
|
||||
sg_status = 0;
|
||||
|
||||
Glib::Thread* thr = Glib::Thread::create (sigc::ptr_fun (sg_init));
|
||||
|
||||
Glib::signal_timeout().connect (sigc::bind (sigc::ptr_fun (hack), sigc::mem_fun (progress, &Gtk::ProgressBar::pulse)), 500);
|
||||
|
||||
while (sg_status == 0) {
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
|
||||
win.hide ();
|
||||
|
||||
while (gtk_events_pending ()) {
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
|
||||
thr->join ();
|
||||
|
||||
DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("SG initialization returned %1\n", sg_status));
|
||||
return sg_status;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -39,7 +39,6 @@ gtk2_ardour_sources = [
|
|||
'ardour_ui_dialogs.cc',
|
||||
'ardour_ui_ed.cc',
|
||||
'ardour_ui_mixer.cc',
|
||||
'ardour_ui_sg.mm',
|
||||
'ardour_ui_options.cc',
|
||||
'ardour_window.cc',
|
||||
'audio_clock.cc',
|
||||
|
|
@ -213,6 +212,7 @@ gtk2_ardour_sources = [
|
|||
'shuttle_control.cc',
|
||||
'simpleline.cc',
|
||||
'simplerect.cc',
|
||||
'soundgrid.mm',
|
||||
'splash.cc',
|
||||
'speaker_dialog.cc',
|
||||
'startup.cc',
|
||||
|
|
|
|||
|
|
@ -69,21 +69,26 @@ class SoundGrid : public boost::noncopyable
|
|||
|
||||
static void driver_register (const WSDCoreHandle, const WSCoreCallbackTable*, const WSMixerConfig*);
|
||||
|
||||
static void set_pool (void* pool);
|
||||
|
||||
private:
|
||||
SoundGrid ();
|
||||
static SoundGrid* _instance;
|
||||
|
||||
void* dl_handle;
|
||||
void* _sg; // handle managed by SoundGrid library
|
||||
WSDCoreHandle _host_handle;
|
||||
const WSCoreCallbackTable* _callback_table;
|
||||
const WSMixerConfig* _mixer_config;
|
||||
WSDCoreHandle _host_handle;
|
||||
WSCoreCallbackTable _callback_table;
|
||||
WSMixerConfig _mixer_config;
|
||||
void* _pool;
|
||||
|
||||
void display_update ();
|
||||
static void _display_update ();
|
||||
|
||||
static WTErr _sg_callback (const WSControlID* pControlID);
|
||||
static WTErr sg_callback (const WSControlID* pControlID);
|
||||
|
||||
WTErr get (WSControlID*, WSControlInfo*);
|
||||
};
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
|
|
|||
|
|
@ -25,11 +25,15 @@
|
|||
#include <WavesPublicAPI/WCMixerCore_API.h>
|
||||
|
||||
#include "pbd/compose.h"
|
||||
#include "pbd/stacktrace.h"
|
||||
|
||||
#include "ardour/debug.h"
|
||||
#include "ardour/soundgrid.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
const char* sndgrid_dll_name = "mixerapplicationcoresg.dylib";
|
||||
#else
|
||||
const char* sndgrid_dll_name = "mixerapplicationcoresg.so";
|
||||
|
|
@ -48,8 +52,7 @@ SoundGrid::SoundGrid ()
|
|||
: dl_handle (0)
|
||||
, _sg (0)
|
||||
, _host_handle (0)
|
||||
, _callback_table (0)
|
||||
, _mixer_config (0)
|
||||
, _pool (0)
|
||||
{
|
||||
const char *s;
|
||||
string path;
|
||||
|
|
@ -86,15 +89,37 @@ SoundGrid::~SoundGrid()
|
|||
if (dl_handle) {
|
||||
dlclose (dl_handle);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (_pool) {
|
||||
NSAutoreleasePool* p = (NSAutoreleasePool*) _pool;
|
||||
[p release];
|
||||
_pool = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
SoundGrid::set_pool (void* pool)
|
||||
{
|
||||
instance()._pool = pool;
|
||||
}
|
||||
|
||||
int
|
||||
SoundGrid::initialize (void* window_handle)
|
||||
{
|
||||
WTErr ret;
|
||||
DEBUG_TRACE (DEBUG::SoundGrid, "Initializing SG core...\n");
|
||||
ret = InitializeMixerCoreDLL (window_handle, sg_callback, &_sg);
|
||||
DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Initialized SG core, ret = %1 core handle %2\n", ret, _sg));
|
||||
if (!_sg) {
|
||||
WTErr ret;
|
||||
DEBUG_TRACE (DEBUG::SoundGrid, "Initializing SG core...\n");
|
||||
if ((ret = InitializeMixerCoreDLL (window_handle, sg_callback, &_sg)) != eNoErr) {
|
||||
DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Initialized SG core, ret = %1 core handle %2\n", ret, _sg));
|
||||
return -1;
|
||||
}
|
||||
DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Initialized SG core, core handle %2\n", _sg));
|
||||
} else {
|
||||
DEBUG_TRACE (DEBUG::SoundGrid, "SG core already initialized...\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -127,10 +152,34 @@ SoundGrid::available ()
|
|||
return instance().dl_handle != 0;
|
||||
}
|
||||
|
||||
int
|
||||
SoundGrid::get (WSControlID* id, WSControlInfo* info)
|
||||
{
|
||||
if (!_host_handle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_callback_table.getControlInfoProc (_host_handle, this, id, info) != eNoErr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
vector<string>
|
||||
SoundGrid::lan_port_names ()
|
||||
{
|
||||
WTErr eRetVal;
|
||||
std::vector<string> names;
|
||||
|
||||
WSAudioDevicesControlInfo audioDevices;
|
||||
Init_WSAudioDevicesControlInfo(&audioDevices);
|
||||
eRetVal = instance().get (&audioDevices.m_controlInfo.m_controlID, (WSControlInfo*)&audioDevices);
|
||||
|
||||
for (uint32_t n = 0; n < audioDevices.m_audioDevices.numberOfDevices; ++n) {
|
||||
cerr << "Discovered audio device [" << audioDevices.m_audioDevices.deviceNames[n] << "]\n";
|
||||
}
|
||||
|
||||
names.push_back ("00:00:00:1e:af - builtin ethernet controller");
|
||||
return names;
|
||||
}
|
||||
|
|
@ -228,7 +277,7 @@ SoundGrid::driver_register (const WSDCoreHandle ch, const WSCoreCallbackTable* c
|
|||
{
|
||||
if (_instance) {
|
||||
_instance->_host_handle = ch;
|
||||
_instance->_callback_table = ct;
|
||||
_instance->_mixer_config = mc;
|
||||
_instance->_callback_table = *ct;
|
||||
_instance->_mixer_config = *mc;
|
||||
}
|
||||
}
|
||||
|
|
@ -201,7 +201,7 @@ libardour_sources = [
|
|||
'sndfile_helpers.cc',
|
||||
'sndfileimportable.cc',
|
||||
'sndfilesource.cc',
|
||||
'soundgrid.cc',
|
||||
'soundgrid.mm',
|
||||
'source.cc',
|
||||
'source_factory.cc',
|
||||
'speakers.cc',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue