driver.cpp
来自「语音接口~语音识别 & 从声音识别到对各种情报的查找/提供 资料请求~」· C++ 代码 · 共 132 行
CPP
132 行
// Copyright (C) 2005 Open Source Telecom Corp.// // 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 2 of the License, or// (at your option) 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, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#include "driver.h"namespace scdriver {using namespace ost;using namespace std;static Keydata::Define driver[] = { {"type", "peer"}, {"device", "0"}, {"stack", "0"}, {"events", "8"}, {"priority", "0"}, {"level", "200"}, {NULL, NULL}};#ifdef WIN32#define KEYS "/bayonne/soundcard"#else#define KEYS "/bayonne/driver/soundcard"#endifDriver Driver::soundcard;Driver::Driver() :BayonneDriver(driver, KEYS, "soundcard", false){ const char *cp;#ifdef WIN32 const char *env = Process::getEnv("DRIVERCONFIG"); if(env) loadFile(env, "soundcard");#else if(Bayonne::provision_user) load("~bayonne/soundcard");#endif device = atoi(getLast("device")); active = Audio::hasDevice(device); keyboard = NULL;#ifdef HAVE_FOX desktop = NULL;#endif cp = getLast("level"); if(cp) audio_level = atoi(cp); if(!active) slog.warn("soundcard/*: device %d unavailable", device); if(peer_encoding == Audio::unknownEncoding) peer_encoding = Audio::mulawAudio; if(!peer_framing) peer_framing = Audio::getFraming(peer_encoding, 10); seize_timer = 0; // no seizure}void Driver::startDriver(void){ bool kb = true; msgport = new BayonneMsgport(this);#ifdef HAVE_FOX const char *d = Process::getEnv("DISPLAY"); if(d && *d) { desktop = new Desktop(getFirst());// kb = false; }#endif#ifdef WIN32 if(kb) keyboard = new Keyboard(ts_used);#else if(getppid() > 1 && kb) keyboard = new Keyboard(ts_used);#endif timeslot = ts_used; new Session(ts_used, device); count = ts_used - timeslot; msgport->start(); if(keyboard) keyboard->start();#ifdef HAVE_FOX if(desktop) desktop->start();#endif BayonneDriver::startDriver();}void Driver::stopDriver(void){ if(keyboard) { delete keyboard; keyboard = NULL; }#ifdef HAVE_FOX if(desktop) { delete desktop; desktop = NULL; }#endif BayonneDriver::stopDriver();}}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?