The daemon can apply a configuration change to the following parameters without a restart: sap_interval, syslog_proto, syslog_server, log_severity, sample_rate The daemon can apply a configuration change to the following parameters without a light restart: http_port, rtsp_port, http_base_dir, rtp_mcast_base, sap_mcast_addr, rtp_port, rtp_port, status_file, interface_name, mdns_enabled A light restart means that the configuration can be applied without interrupting the playback/capture applications A change to one of following paramters causes a full daemon restart: interface_name, tic_frame_size_at_1fs, max_tic_frame_size On PTP status change the daemon can run in background an external shell script whose path name is specified by the new ptp_status_script Config parameter. If this parameter is empty, no script is invoked. The PTP clock status is passed as first parameter to the script and it can be unlocked, locking or locked. A sample script is provided in daemon/scripts/ptp_status.sh
84 lines
2.9 KiB
C++
84 lines
2.9 KiB
C++
//
|
|
// driver_handler.hpp
|
|
//
|
|
// Copyright (c) 2019 2020 Andrea Bondavalli. All rights reserved.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
//
|
|
|
|
#ifndef _DRIVER_HANDLER_HPP_
|
|
#define _DRIVER_HANDLER_HPP_
|
|
|
|
#include <future>
|
|
|
|
#include "MT_ALSA_message_defs.h"
|
|
#include "config.hpp"
|
|
#include "error_code.hpp"
|
|
#include "log.hpp"
|
|
#include "netlink_client.hpp"
|
|
|
|
class DriverHandler {
|
|
public:
|
|
static constexpr size_t max_payload = MAX_PAYLOAD;
|
|
static constexpr off_t data_offset =
|
|
sizeof(struct MT_ALSA_msg) /*+ sizeof(int)*/;
|
|
static constexpr int reply_timeout_secs = 1; // 1sec in driver
|
|
static constexpr size_t buffer_size =
|
|
NLMSG_SPACE(max_payload) + sizeof(struct MT_ALSA_msg);
|
|
|
|
DriverHandler(){};
|
|
DriverHandler(const DriverHandler&) = delete;
|
|
DriverHandler& operator=(const DriverHandler&) = delete;
|
|
virtual ~DriverHandler(){};
|
|
|
|
virtual bool init(const Config& config);
|
|
virtual bool terminate(const Config& config);
|
|
|
|
protected:
|
|
virtual void send_command(enum MT_ALSA_msg_id id,
|
|
size_t size = 0,
|
|
const uint8_t* data = nullptr);
|
|
virtual void on_command_done(enum MT_ALSA_msg_id id,
|
|
size_t size = 0,
|
|
const uint8_t* data = nullptr) = 0;
|
|
virtual void on_command_error(enum MT_ALSA_msg_id id,
|
|
std::error_code error) = 0;
|
|
virtual void on_event(enum MT_ALSA_msg_id id,
|
|
size_t& res_size,
|
|
uint8_t* res,
|
|
size_t req_size = 0,
|
|
const uint8_t* req = nullptr) = 0;
|
|
virtual void on_event_error(enum MT_ALSA_msg_id id,
|
|
std::error_code error) = 0;
|
|
|
|
private:
|
|
void send(enum MT_ALSA_msg_id id,
|
|
NetlinkClient& client,
|
|
uint8_t* buffer,
|
|
size_t data_size,
|
|
const uint8_t* data);
|
|
bool event_receiver();
|
|
|
|
std::future<bool> res_;
|
|
std::atomic_bool running_{false};
|
|
uint8_t command_buffer_[buffer_size];
|
|
uint8_t event_buffer_[buffer_size];
|
|
uint8_t response_buffer_[buffer_size];
|
|
NetlinkClient client_u2k_{"commands"}; /* u2k for commands */
|
|
NetlinkClient client_k2u_{"events"}; /* k2u for events */
|
|
std::mutex mutex_; /* one command at a time */
|
|
};
|
|
|
|
#endif
|