const Event& operator=(const Event& copy);
- void set(uint8_t* buf, uint32_t size, Time t);
+ void set(const uint8_t* buf, uint32_t size, Time t);
inline bool operator==(const Event& other) const {
if (_type != other._type)
template<typename Timestamp>
void
-Event<Timestamp>::set(uint8_t* buf, uint32_t size, Timestamp t)
+Event<Timestamp>::set (const uint8_t* buf, uint32_t size, Timestamp t)
{
if (_owns_buf) {
if (_size < size) {
}
memcpy (_buf, buf, size);
} else {
- _buf = buf;
+ /* XXX this is really dangerous given the
+ const-ness of buf. The API should really
+ intervene here.
+ */
+ _buf = const_cast<uint8_t*> (buf);
}
_original_time = t;
}
int
-IPMIDIPort::write (byte* msg, size_t msglen, timestamp_t /* ignored */) {
+IPMIDIPort::write (const byte* msg, size_t msglen, timestamp_t /* ignored */) {
if (sockout) {
Glib::Mutex::Lock lm (write_lock);
- if (::sendto (sockout, (char *) msg, msglen, 0, (struct sockaddr *) &addrout, sizeof(struct sockaddr_in)) < 0) {
+ if (::sendto (sockout, (const char *) msg, msglen, 0, (struct sockaddr *) &addrout, sizeof(struct sockaddr_in)) < 0) {
::perror("sendto");
return -1;
}
}
int
-JackMIDIPort::write(byte * msg, size_t msglen, timestamp_t timestamp)
+JackMIDIPort::write (const byte * msg, size_t msglen, timestamp_t timestamp)
{
int ret = 0;
XMLNode& get_state () const;
void set_state (const XMLNode&);
- int write (byte *msg, size_t msglen, timestamp_t timestamp);
+ int write (const byte *msg, size_t msglen, timestamp_t timestamp);
int read (byte *buf, size_t bufsize);
void parse (framecnt_t timestamp);
int selectable () const;
void cycle_end ();
void parse (framecnt_t timestamp);
- int write (byte *msg, size_t msglen, timestamp_t timestamp);
+ int write (const byte *msg, size_t msglen, timestamp_t timestamp);
int read (byte *buf, size_t bufsize);
void drain (int check_interval_usecs);
int selectable () const { return xthread.selectable(); }
* @param timestamp Time stamp in frames of this message (relative to cycle start)
* @return number of bytes successfully written
*/
- virtual int write (byte *msg, size_t msglen, timestamp_t timestamp) = 0;
+ virtual int write (const byte *msg, size_t msglen, timestamp_t timestamp) = 0;
/** Read raw bytes from a port.
* @param buf memory to store read data in
using namespace std;
-MidiByteArray::MidiByteArray( size_t size, MIDI::byte array[] )
-: std::vector<MIDI::byte>()
+MidiByteArray::MidiByteArray (size_t size, MIDI::byte array[])
+ : std::vector<MIDI::byte>()
{
- for ( size_t i = 0; i < size; ++i )
+ for (size_t i = 0; i < size; ++i)
{
- push_back( array[i] );
+ push_back (array[i]);
}
}
-MidiByteArray::MidiByteArray( size_t count, MIDI::byte first, ... )
-: vector<MIDI::byte>()
+MidiByteArray::MidiByteArray (size_t count, MIDI::byte first, ...)
+ : vector<MIDI::byte>()
{
- push_back( first );
+ push_back (first);
va_list var_args;
- va_start( var_args, first );
- for ( size_t i = 1; i < count; ++i )
+ va_start (var_args, first);
+ for (size_t i = 1; i < count; ++i)
{
- MIDI::byte b = va_arg( var_args, int );
- push_back( b );
+ MIDI::byte b = va_arg (var_args, int);
+ push_back (b);
}
- va_end( var_args );
+ va_end (var_args);
}
-boost::shared_array<MIDI::byte> MidiByteArray::bytes() const
-{
- MIDI::byte * buf = new MIDI::byte[size()];
- const_iterator it = begin();
- for( MIDI::byte * ptr = buf; it != end(); ++it )
- {
- *ptr++ = *it;
- }
- return boost::shared_array<MIDI::byte>( buf );
-}
-void MidiByteArray::copy( size_t count, MIDI::byte * arr )
+void MidiByteArray::copy (size_t count, MIDI::byte * arr)
{
- for( size_t i = 0; i < count; ++i )
- {
- push_back( arr[i] );
+ for (size_t i = 0; i < count; ++i) {
+ push_back (arr[i]);
}
}
-MidiByteArray & operator << ( MidiByteArray & mba, const MIDI::byte & b )
+MidiByteArray & operator << (MidiByteArray & mba, const MIDI::byte & b)
{
- mba.push_back( b );
+ mba.push_back (b);
return mba;
}
-MidiByteArray & operator << ( MidiByteArray & mba, const MidiByteArray & barr )
+MidiByteArray & operator << (MidiByteArray & mba, const MidiByteArray & barr)
{
- back_insert_iterator<MidiByteArray> bit( mba );
- copy( barr.begin(), barr.end(), bit );
+ back_insert_iterator<MidiByteArray> bit (mba);
+ copy (barr.begin(), barr.end(), bit);
return mba;
}
-ostream & operator << ( ostream & os, const MidiByteArray & mba )
+ostream & operator << (ostream & os, const MidiByteArray & mba)
{
os << "[";
char fill = os.fill('0');
- for( MidiByteArray::const_iterator it = mba.begin(); it != mba.end(); ++it )
- {
- if ( it != mba.begin() ) os << " ";
+ for (MidiByteArray::const_iterator it = mba.begin(); it != mba.end(); ++it) {
+ if (it != mba.begin()) os << " ";
os << hex << setw(2) << (int)*it;
}
- os.fill( fill );
+ os.fill (fill);
os << dec;
os << "]";
return os;
}
-MidiByteArray & operator << ( MidiByteArray & mba, const std::string & st )
+MidiByteArray & operator << (MidiByteArray & mba, const std::string & st)
{
- for ( string::const_iterator it = st.begin(); it != st.end(); ++it )
- {
+ for (string::const_iterator it = st.begin(); it != st.end(); ++it) {
mba << *it;
}
return mba;
*/
MidiByteArray( size_t count, MIDI::byte first, ... );
- /// return smart pointer to a copy of the bytes
- boost::shared_array<MIDI::byte> bytes() const;
-
/// copy the given number of bytes from the given array
void copy( size_t count, MIDI::byte arr[] );
};
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("port %1 write %2\n", output_port().name(), mba));
- int count = output_port().write (mba.bytes().get(), mba.size(), 0);
+ if (mba[0] != 0xf0 && mba.size() > 3) {
+ std::cerr << "TOO LONG WRITE: " << mba << std::endl;
+ }
+
+ /* this call relies on std::vector<T> using contiguous storage. not
+ * actually guaranteed by the standard, but way, way beyond likely.
+ */
+
+ int count = output_port().write (&mba[0], mba.size(), 0);
- if (count != (int)mba.size()) {
+ if (count != (int) mba.size()) {
- if (errno == 0) {
+ if (errno == 0) {
cout << "port overflow on " << output_port().name() << ". Did not write all of " << mba << endl;
<JogWheel value="yes"/>
<TouchSenseFaders value="yes"/>
<LogicControlButtons value="yes"/>
- <UsesIPMIDI value="yes"/>
+ <UsesIPMIDI value="no"/>
</MackieProtocolDevice>