c++ - iOS - 在 C++ 中获取可写路径

标签 c++ ios native audioqueue

我正在使用 native C++ 为 iOS 编写录音机,但我无法使用 Foundation API。

我需要这样的东西:

recordFilePath = 
(CFStringRef)[NSTemporaryDirectory() stringByAppendingPathComponent: @"recordedFile.caf"];

在 iPhone 上获取可写路径。

非常感谢。

最佳答案

当然可以,但自信地说,这是我客户的任务,他不要求核心类中涉及 Foundation 的任何外部功能或桥梁或任何东西。所以我不得不构建一个不引用 Foundation 的音频队列组件。

郑重声明,我这样做就成功了:

        const char *home = getenv("HOME");
        const char *subdir = "/Documents/";
        const char *file = "recordedFile.caf";

        char *recPath = (char*)(calloc(strlen(home) + strlen(subdir) 
                              + strlen(file) + 1, sizeof(char)));

        strcpy(recPath, home); // copy string one into the result.
        strcat(recPath, subdir); // append string two to the result.
        strcat(recPath, file); // append string three to the result.

        //recordFilePath is our CFStringRef
        recordFilePath = CFStringCreateWithCString(0, recPath, kCFStringEncodingUTF8);

        //recorder is an AQRecorder class like the one from SpeakHere code sample
          recorder->StartRecord(recordFilePath);

关于c++ - iOS - 在 C++ 中获取可写路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39288270/

相关文章:

ios - 字符串上的 XCTAssertEqual 总是失败

ios - 如何播放和读取 .caf PCM 音频文件

swift - 更改多个 CAShapeLayer 的绘制顺序

c++ - for循环不执行

c++ - 如何从 std::integer_sequence 初始化静态数组?

c++ - 使用复杂的显示功能会阻止 glutKeyboardFunc 工作

c++ - 如何导航文件夹来读取图像?

ios - Swift UNUsernotification applicationIconBadgeNumber 始终显示一个

javascript - 使用 JavaScript 构建 native 应用程序的最佳方式?

java - 加载 java native 文件库