ardour/libs/ardour/midi_source.cc
David Robillard 30c08ba655 - Changed IO's vector<Port*>'s to PortList
- Added new Port classes, code to drive them
- Added PortList, which is a filthy mess ATM (nevermind that, it's the interface that's important at this stage)
- Added ChanCount, though it isn't very thoroughly used yet.  That's the next step....
- Fixed a few bugs relating to loading sessions saved with trunk
- Fixed a few random other bugs

Slowly working towards type agnosticism while keeping all the former code/logic intact is the name of the game here

Warning:  Removing ports is currently (intentionally) broken due solely to laziness.


git-svn-id: svn://localhost/ardour2/branches/midi@786 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-08-11 03:24:57 +00:00

115 lines
2.3 KiB
C++

/*
Copyright (C) 2006 Paul Davis
Written by Dave Robillard, 2006
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 <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#include <float.h>
#include <cerrno>
#include <ctime>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <pbd/xml++.h>
#include <pbd/pthread_utils.h>
#include <ardour/midi_source.h>
#include "i18n.h"
using namespace std;
using namespace ARDOUR;
using namespace PBD;
sigc::signal<void,MidiSource *> MidiSource::MidiSourceCreated;
MidiSource::MidiSource (string name)
: Source (name)
{
_read_data_count = 0;
_write_data_count = 0;
}
MidiSource::MidiSource (const XMLNode& node)
: Source (node)
{
_read_data_count = 0;
_write_data_count = 0;
if (set_state (node)) {
throw failed_constructor();
}
}
MidiSource::~MidiSource ()
{
}
XMLNode&
MidiSource::get_state ()
{
XMLNode& node (Source::get_state());
if (_captured_for.length()) {
node.add_property ("captured-for", _captured_for);
}
return node;
}
int
MidiSource::set_state (const XMLNode& node)
{
const XMLProperty* prop;
Source::set_state (node);
if ((prop = node.property ("captured-for")) != 0) {
_captured_for = prop->value();
}
return 0;
}
jack_nframes_t
MidiSource::read (RawMidi* dst, jack_nframes_t start, jack_nframes_t cnt) const
{
Glib::Mutex::Lock lm (_lock);
return read_unlocked (dst, start, cnt);
}
jack_nframes_t
MidiSource::write (RawMidi* dst, jack_nframes_t cnt)
{
Glib::Mutex::Lock lm (_lock);
return write_unlocked (dst, cnt);
}
bool
MidiSource::file_changed (string path)
{
struct stat stat_file;
int e1 = stat (path.c_str(), &stat_file);
return ( !e1 );
}