使用POCO启动后台进程(launch background process with POCO)
我正在使用ROS并尝试将Poco Process集成到ROS QT接口中的流程管理中。
这是我的节点到目前为止的样子:
void My_Interface::gazebo_launch_world() { std::string command = "roslaunch"; std::vector<std::string> args; args.push_back("robot_gazebo"); args.push_back("robot_gazebo.launch"); PocoProcess pp(command, args); pp.run(); } int PocoProcess::run() { int rc; try { Poco::Pipe outPipe; Poco::ProcessHandle ph = Poco::Process::launch(command_, args_, 0, &outPipe, 0); rc = ph.id(); Poco::PipeInputStream istr(outPipe); Poco::StreamCopier::copyStream(istr, std::cout); } catch (Poco::SystemException& exc) { std::cout << exc.displayText() << std::endl; return (-1); } return rc; }
这工作正常(启动过程),但问题是我的界面在等待进程完成时冻结,这是非常不受欢迎的。
那么,无论如何我可以在后台启动POCO流程吗?
PS :(绝望地)我甚至尝试了args矢量上的“&”,但它没有用!
谢谢,
I am working with ROS and trying to integrate Poco Process for processes management in a ROS QT Interface.
Here's an example of what my node looks like so far :
void My_Interface::gazebo_launch_world() { std::string command = "roslaunch"; std::vector<std::string> args; args.push_back("robot_gazebo"); args.push_back("robot_gazebo.launch"); PocoProcess pp(command, args); pp.run(); } int PocoProcess::run() { int rc; try { Poco::Pipe outPipe; Poco::ProcessHandle ph = Poco::Process::launch(command_, args_, 0, &outPipe, 0); rc = ph.id(); Poco::PipeInputStream istr(outPipe); Poco::StreamCopier::copyStream(istr, std::cout); } catch (Poco::SystemException& exc) { std::cout << exc.displayText() << std::endl; return (-1); } return rc; }
This works fine (launching the process) but, the problem is that my interface freezes while waiting for the process to finish, which is really undesirable.
So, is there anyway that I can launch a POCO Process in the background ?
PS: (Hopelessly) I tried even the "&" on the args vector but it didn't work !
Thanks,
原文:https://stackoverflow.com/questions/37460127
最满意答案
在iOS 8中,他们为AVAudioSession添加了一个新属性:
[AVAudioSession sharedInstance].recordPermission
返回
AVAudioSessionRecordPermission
:enum { AVAudioSessionRecordPermissionUndetermined = 'undt', AVAudioSessionRecordPermissionDenied = 'deny', AVAudioSessionRecordPermissionGranted = 'grnt' }; typedef NSUInteger AVAudioSessionRecordPermission;
但是在iOS 7中似乎没有办法。
In iOS 8, they added a new property to AVAudioSession:
[AVAudioSession sharedInstance].recordPermission
That returns a
AVAudioSessionRecordPermission
:enum { AVAudioSessionRecordPermissionUndetermined = 'undt', AVAudioSessionRecordPermissionDenied = 'deny', AVAudioSessionRecordPermissionGranted = 'grnt' }; typedef NSUInteger AVAudioSessionRecordPermission;
But there doesn't seem to be a way in iOS 7.
相关问答
更多-
显然,设置属性的顺序很重要,尽管在文档中没有提到这一点。 对于那些最终发现这一点的人来说,以下是有效的: //Init and set the interrupt listener. last parameter is passed to interruptlistener AudioSessionInitialize(NULL, NULL, interruptlistener, NULL); //Allow the app sound to continue to play when the scre ...
-
使用方法: - (BOOL)setActive:(BOOL)beActive error:(NSError **)outError 激活或停用AVAudioSession。 这将关闭会话。 如果您需要代表警告其他课程,您可以使用通知。 希望能帮助到你! Use the method: - (BOOL)setActive:(BOOL)beActive error:(NSError **)outError to activate or deactivate your AVAudioSession. This ...
-
我解决了这个问题,在AVAudioPlayerDelegate的方法中插入这个代码。 -(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{ [audioPlayer stop]; [audioPlayer prepareToPlay]; } 其中audioPlayer是在类的标题中声明的变量。 指令prepareToPlay应该解决你的问题! I solved this problem ...
-
iOS中可用的输入/输出AVAudioSession数据源(Available Input/output AVAudioSession data sources in iOS)[2024-02-01]
找到了。 从文档 : 目前这仅适用于某些USB设备。 这个API将在iOS 7中发生变化,但6仅限于“某些USB设备”的模糊定义。 顺便说一句,从我的测试来看 - 它适用于iOS 6.02的iPhone麦克风,但不适用于6.1.4(iPhone 5上的两项测试)。 Found it. From the documentation: This currently only applies to certain USB devices. This API is going to change in iOS 7, ... -
恢复AVAudioSession(Resume AVAudioSession)[2022-03-02]
您可能正在遇到一种称为音频中断的事情 - 基本上,您的应用程序的后台处理会暂时停止正在运行的音频会话。 您可以根据需要处理这些中断并恢复音频会话。 有关详细信息,请参阅“ 音频会话编程指南” I figured out the solution, I was using simple audio engine of cocos2d with it which created problems. simple audio engine called cdaudiomanager and it was also ... -
对于那些可能遇到这个问题的人,我想出来了。 你必须让你的玩家的控制器成为第一个响应者 - 特别是对于远程控制事件。 这不仅可以让您接收远程控制事件(如通用播放/暂停/前进/后退控制),还可以将播放图标放在状态菜单中。 [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self becomeFirstResponder]; For those who may come across this question, I ...
-
在iOS 8中,他们为AVAudioSession添加了一个新属性: [AVAudioSession sharedInstance].recordPermission 返回AVAudioSessionRecordPermission : enum { AVAudioSessionRecordPermissionUndetermined = 'undt', AVAudioSessionRecordPermissionDenied = 'deny', AVAudi ...
-
AVAudioSession.requestRecordPermission不显示对话框(AVAudioSession.requestRecordPermission not showing dialog)[2023-07-11]
在“Info.plist”中设置“Bundle显示名称”(基本上是您的应用的名称)将解决问题。 Setting the "Bundle display name" (basically the name of your app) in the "Info.plist" will fix the problem. -
在iOS 8中,他们为AVAudioSession添加了一个新属性: [AVAudioSession sharedInstance].recordPermission 返回AVAudioSessionRecordPermission : enum { AVAudioSessionRecordPermissionUndetermined = 'undt', AVAudioSessionRecordPermissionDenied = 'deny', AVAudi ...
-
AVAudioSession错误(AVAudioSession error)[2024-02-07]
我跟踪了我在谷歌上找到的每一个相关主题,几乎所有这些主题都引出了AVAudioSessionCategoryOptionMixWithOthers选项。 我将它与我在PlayAndRecord类别上使用的其他选项进行了OR操作并且它有效...去图。 如果有人对这个谜团有任何见解,请回答或评论,但现在,尝试该选项,看看会发生什么。 当我了解更多信息时,我会更新。 I followed every relevant thread I could find on Google and almost all of ...