小编Jim*_*ong的帖子

有没有办法在 node-gyp 命令行上指定编译器标志(例如,预处理器宏定义)?

我正在尝试将 Node.js 插件集成到基于 CMake 的现有构建系统中。插件构建需要 CMake 上下文中可用的大量预处理器宏定义和库依赖项。我希望能够在node-gypCMake 调用时将它们传递给它。不幸的是,我一直无法找到一种简单的方法来做到这一点。

我试过使用用于普通旧的方法,gyp如下所示:

node-gyp configure -d -DPOSIX=1
Run Code Online (Sandbox Code Playgroud)

但该-D选项似乎没有通过node-gyp. 查看 的来源node-gyp,这并不完全令人惊讶。有没有一种直接、直接的方法来做到这一点,或者我是否坚持以binding.gyp编程方式生成条目,从环境或其他方面提取这些信息?

node.js node-gyp

5
推荐指数
1
解决办法
3478
查看次数

同时使用AVCaptureSession和Audio Units会导致AVAssetWriterInput出现问题

我正在开发一个同时执行两项操作的iOS应用程序:

  1. 它捕获音频和视频并将它们中继到服务器以提供视频聊天功能.
  2. 它捕获本地音频和视频,并将它们编码为mp4文件,以便为后代保存.

不幸的是,当我们使用音频单元配置应用程序以启用回声消除时,录制功能会中断:AVAssetWriterInput我们用于编码音频的实例会拒绝传入的样本.当我们没有设置音频单元时,录音工作,但我们有可怕的回声.

为了启用回声消除,我们配置了这样的音频单元(为了简洁起见):

AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_VoiceProcessingIO;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
AudioComponent comp = AudioComponentFindNext(NULL, &desc);
OSStatus status = AudioComponentInstanceNew(comp, &_audioUnit);
status = AudioUnitInitialize(_audioUnit);
Run Code Online (Sandbox Code Playgroud)

这适用于视频聊天,但它打破了录制功能,这样设置(再次,释义 - 实际实现分散在几种方法).

_captureSession = [[AVCaptureSession alloc] init];

// Need to use the existing audio session & configuration to ensure we get echo cancellation
_captureSession.usesApplicationAudioSession = YES;
_captureSession.automaticallyConfiguresApplicationAudioSession = NO;

[_captureSession beginConfiguration];
AVCaptureDeviceInput *audioInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self audioCaptureDevice] error:NULL];
[_captureSession addInput:audioInput];
_audioDataOutput …
Run Code Online (Sandbox Code Playgroud)

audio core-audio audio-recording ios

5
推荐指数
1
解决办法
1039
查看次数

将 AudioBufferList 转换为 CMSampleBuffer 会产生意想不到的结果

我正在尝试AudioBufferList将从音频单元获得的一个转换为一个CMSampleBuffer我可以传递给一个AVAssetWriter以保存来自麦克风的音频。这种转换有效,因为我为执行转换而进行的调用不会失败,但记录最终确实会失败,而且我在日志中看到一些似乎引起关注的输出。

我正在使用的代码如下所示:

- (void)handleAudioSamples:(AudioBufferList*)samples numSamples:(UInt32)numSamples hostTime:(UInt64)hostTime {
    // Create a CMSampleBufferRef from the list of samples, which we'll own
    AudioStreamBasicDescription monoStreamFormat;
    memset(&monoStreamFormat, 0, sizeof(monoStreamFormat));
    monoStreamFormat.mSampleRate = 48000;
    monoStreamFormat.mFormatID = kAudioFormatLinearPCM;
    monoStreamFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked | kAudioFormatFlagIsNonInterleaved;
    monoStreamFormat.mBytesPerPacket = 2;
    monoStreamFormat.mFramesPerPacket = 1;
    monoStreamFormat.mBytesPerFrame = 2;
    monoStreamFormat.mChannelsPerFrame = 1;
    monoStreamFormat.mBitsPerChannel = 16;

    CMFormatDescriptionRef format = NULL;
    OSStatus status = CMAudioFormatDescriptionCreate(kCFAllocatorDefault, &monoStreamFormat, 0, NULL, 0, NULL, NULL, &format);
    if (status != noErr) { …
Run Code Online (Sandbox Code Playgroud)

audio core-audio ios

5
推荐指数
1
解决办法
1977
查看次数

使用仿函数调用find_if的编译错误

我们在使用find_if搜索对的向量时遇到一些麻烦,对于该对象的第一个元素匹配特定值.为了完成这项工作,我们定义了一个简单的函子,其operator()将一对作为输入,并将第一个条目与字符串进行比较.

不幸的是,当我们实际使用使用临时字符串值构造的函数实例添加对find_if的调用时,编译器会生成大量错误消息.奇怪(对我来说,无论如何),如果我们用我们在堆栈上创建的字符串替换临时字符,事情似乎有效.

这是代码(包括两个版本)的样子:

typedef std::pair<std::string, std::string> MyPair;
typedef std::vector<MyPair> MyVector;

struct MyFunctor: std::unary_function <const MyPair&, bool>
{
  explicit MyFunctor(const std::string& val)
    : m_val(val) {}

  bool operator() (const MyPair& p)
  {
    return p.first == m_val;
  }

  const std::string m_val;
};

bool f(const char* s)
{
  MyFunctor f(std::string(s));  // ERROR
  // std::string str(s);                                                                                                  
  // MyFunctor f(str);              // OK                                                                                                    
  MyVector vec;
  MyVector::const_iterator i = std::find_if(vec.begin(), vec.end(), f);
  return i != vec.end();
}
Run Code Online (Sandbox Code Playgroud)

这是最有趣的错误消息:

/usr/include/c++/4.2.1/bits/stl_algo.h:260:错误:从'std :: pair,std :: allocator>,std :: basic_string,std :: allocator >>'转换为非请求标量类型'std …

c++ stl

3
推荐指数
1
解决办法
1755
查看次数

标签 统计

audio ×2

core-audio ×2

ios ×2

audio-recording ×1

c++ ×1

node-gyp ×1

node.js ×1

stl ×1