2 Copyright (C) 2011 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "clock_group.h"
22 ClockGroup::ClockGroup ()
23 : ignore_changes (false)
24 , _clock_mode (AudioClock::Frames
)
28 ClockGroup::~ClockGroup()
33 ClockGroup::add (AudioClock
& clock
)
35 if (clocks
.insert (&clock
).second
) {
36 clock
.mode_changed
.connect (sigc::bind (sigc::mem_fun (*this, &ClockGroup::one_clock_changed
), &clock
));
37 clock
.set_mode (_clock_mode
);
42 ClockGroup::remove (AudioClock
& clock
)
44 clocks
.erase (&clock
);
48 ClockGroup::one_clock_changed (AudioClock
* clock
)
50 if (!ignore_changes
) {
51 set_clock_mode (clock
->mode());
56 ClockGroup::set_clock_mode (AudioClock::Mode mode
)
60 ignore_changes
= true;
61 for (std::set
<AudioClock
*>::iterator c
= clocks
.begin(); c
!= clocks
.end(); ++c
) {
62 (*c
)->set_mode (mode
);
64 ignore_changes
= false;