2 * Copyright (C) 2011-2017 Paul Davis <paul@linuxaudiosystems.com>
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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "clock_group.h"
21 ClockGroup::ClockGroup ()
22 : ignore_changes (false)
23 , _clock_mode (AudioClock::Samples)
27 ClockGroup::~ClockGroup()
32 ClockGroup::add (AudioClock& clock)
34 if (clocks.insert (&clock).second) {
35 clock.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &ClockGroup::one_clock_changed), &clock));
36 clock.set_mode (_clock_mode);
41 ClockGroup::remove (AudioClock& clock)
43 clocks.erase (&clock);
47 ClockGroup::one_clock_changed (AudioClock* clock)
49 if (!ignore_changes) {
50 set_clock_mode (clock->mode());
55 ClockGroup::set_clock_mode (AudioClock::Mode mode)
59 ignore_changes = true;
60 for (std::set<AudioClock*>::iterator c = clocks.begin(); c != clocks.end(); ++c) {
61 (*c)->set_mode (mode);
63 ignore_changes = false;