along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
#include <string>
return 0;
}
+void
+Session::set_mmc_receive_device_id (uint32_t device_id)
+{
+ if (mmc) {
+ mmc->set_receive_device_id (device_id);
+ }
+}
+
+void
+Session::set_mmc_send_device_id (uint32_t device_id)
+{
+ if (mmc) {
+ mmc->set_send_device_id (device_id);
+ /* reset MMC buffer */
+ mmc_buffer[2] = mmc->send_device_id();
+ }
+}
+
int
Session::set_mmc_port (string port_tag)
{
+ MIDI::byte old_recv_device_id = 0;
+ MIDI::byte old_send_device_id = 0;
+ bool reset_id = false;
+
if (port_tag.length() == 0) {
if (_mmc_port == 0) {
return 0;
_mmc_port = port;
if (mmc) {
+ old_recv_device_id = mmc->receive_device_id();
+ old_recv_device_id = mmc->send_device_id();
+ reset_id = true;
delete mmc;
}
MMC_CommandSignature,
MMC_ResponseSignature);
+ if (reset_id) {
+ set_mmc_receive_device_id (old_recv_device_id);
+ set_mmc_send_device_id (old_send_device_id);
+ }
mmc->Play.connect
(mem_fun (*this, &Session::mmc_deferred_play));
mmc->TrackRecordStatusChange.connect
(mem_fun (*this, &Session::mmc_record_enable));
+
/* also handle MIDI SPP because its so common */
_mmc_port->input()->start.connect (mem_fun (*this, &Session::spp_start));
mmc_buffer[0] = 0xf0; // SysEx
mmc_buffer[1] = 0x7f; // Real Time SysEx ID for MMC
- mmc_buffer[2] = 0x7f; // "broadcast" device ID
+ mmc_buffer[2] = (mmc ? mmc->send_device_id() : 0x7f);
mmc_buffer[3] = 0x6; // MCC
/* Set up the qtr frame message */
mtc_msg[10] = 0xf1;
mtc_msg[12] = 0xf1;
mtc_msg[14] = 0xf1;
-
- if (_mmc_port != 0) {
-
- Config->set_send_mmc (session_send_mmc);
-
- } else {
-
- mmc = 0;
- session_send_mmc = false;
- }
-
- if (_mtc_port != 0) {
-
- Config->set_send_mtc (session_send_mtc);
-
- } else {
- session_send_mtc = false;
- }
}
int
static bool step_queued = false;
void
-
Session::mmc_step (MIDI::MachineControl &mmc, int steps)
{
if (!Config->get_mmc_control()) {
}
double diff_secs = diff.tv_sec + (diff.tv_usec / 1000000.0);
- double cur_speed = (((steps * 0.5) * Config->get_smpte_frames_per_second()) / diff_secs) / Config->get_smpte_frames_per_second();
+ double cur_speed = (((steps * 0.5) * smpte_frames_per_second()) / diff_secs) / smpte_frames_per_second();
if (_transport_speed == 0 || cur_speed * _transport_speed < 0) {
/* change direction */
return;
}
- jack_nframes_t target_frame;
+ nframes_t target_frame;
SMPTE::Time smpte;
smpte.hours = mmc_tc[0] & 0xf;
smpte.minutes = mmc_tc[1];
smpte.seconds = mmc_tc[2];
smpte.frames = mmc_tc[3];
+ smpte.rate = smpte_frames_per_second();
+ smpte.drop = smpte_drop_frames();
// Also takes smpte offset into account:
smpte_to_sample( smpte, target_frame, true /* use_offset */, false /* use_subframes */ );
void
Session::send_time_code_in_another_thread (bool full)
{
- jack_nframes_t two_smpte_frames_duration;
- jack_nframes_t quarter_frame_duration;
+ nframes_t two_smpte_frames_duration;
+ nframes_t quarter_frame_duration;
/* Duration of two smpte frames */
two_smpte_frames_duration = ((long) _frames_per_smpte_frame) << 1;
if (((mtc_smpte_bits >> 5) != MIDI::MTC_25_FPS) && (transmitting_smpte_time.frames % 2)) {
// start MTC quarter frame transmission on an even frame
SMPTE::increment( transmitting_smpte_time );
- outbound_mtc_smpte_frame += (jack_nframes_t) _frames_per_smpte_frame;
+ outbound_mtc_smpte_frame += (nframes_t) _frames_per_smpte_frame;
}
}
return 0;
}
- jack_nframes_t two_smpte_frames_duration;
- jack_nframes_t quarter_frame_duration;
+ nframes_t two_smpte_frames_duration;
+ nframes_t quarter_frame_duration;
/* Duration of two smpte frames */
two_smpte_frames_duration = ((long) _frames_per_smpte_frame) << 1;
**********************************************************************/
void
-Session::send_mmc_in_another_thread (MIDI::MachineControl::Command cmd, jack_nframes_t target_frame)
+Session::send_mmc_in_another_thread (MIDI::MachineControl::Command cmd, nframes_t target_frame)
{
MIDIRequest* request;
}
void
-Session::deliver_mmc (MIDI::MachineControl::Command cmd, jack_nframes_t where)
+Session::deliver_mmc (MIDI::MachineControl::Command cmd, nframes_t where)
{
using namespace MIDI;
int nbytes = 4;
void
Session::terminate_midi_thread ()
{
- MIDIRequest* request = new MIDIRequest;
- void* status;
-
- request->type = MIDIRequest::Quit;
-
- midi_requests.write (&request, 1);
- poke_midi_thread ();
-
- pthread_join (midi_thread, &status);
+ if (midi_thread) {
+ MIDIRequest* request = new MIDIRequest;
+ void* status;
+
+ request->type = MIDIRequest::Quit;
+
+ midi_requests.write (&request, 1);
+ poke_midi_thread ();
+
+ pthread_join (midi_thread, &status);
+ }
}
void
Session::poke_midi_thread ()
{
- char c;
+ static char c = 0;
if (write (midi_request_pipe[1], &c, 1) != 1) {
error << string_compose(_("cannot send signal to midi thread! (%1)"), strerror (errno)) << endmsg;