AlsaBridge.cpp
author František Kučera <franta-hg@frantovo.cz>
Fri, 18 Dec 2020 23:19:32 +0100
branchv_0
changeset 2 f34476ab597f
child 3 e238528eb19c
permissions -rw-r--r--
background thread + AlsaBridge skeleton
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * DJM-Fix
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#include <iostream>
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include "AlsaBridge.h"
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
namespace djmfix {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
namespace alsa {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
class AlsaBridgeImpl : public AlsaBridge, private djmfix::MidiSender {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
private:
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
	djmfix::DJMFix* djmFix;
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
public:
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
	AlsaBridgeImpl(djmfix::DJMFix* djmFix) : djmFix(djmFix) {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
		djmFix->setMidiSender(this);
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
	}
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
	virtual ~AlsaBridgeImpl() {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
		std::cerr << "~AlsaBridgeImpl()" << std::endl; // TODO: do not mess STDIO
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
	}
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
	virtual void start() override {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
		djmFix->start();
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
	}
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	virtual void stop() override {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
		djmFix->stop();
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
	}
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
	virtual void send(MidiMessage midiMessage) override {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
		std::cerr << "AlsaBridgeImpl::send()" << std::endl; // TODO: do not mess STDIO
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	}
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
};
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
AlsaBridge* create(djmfix::DJMFix* djmFix) {
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
	return new AlsaBridgeImpl(djmFix);
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
}
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
}
f34476ab597f background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
}