iOS コア オーディオには、 「オーディオ データのパケット記述の配列へのポインター」として定義されたパラメーターを持つAPI AudioFileWritePacketsがあります。inPacketDescriptions
メソッドシグネチャでは次のようになります。
const AudioStreamPacketDescription *inPacketDescriptions,
現在、構造体 AudioStreamPacketDescription は次のように定義されています。
struct AudioStreamPacketDescription
{
SInt64 mStartOffset;
UInt32 mVariableFramesInPacket;
UInt32 mDataByteSize;
};
typedef struct AudioStreamPacketDescription AudioStreamPacketDescription;
そのような「構造体の配列へのポインター」を作成して設定する方法、または変数が与えられたら、それを読み取る方法を知りたいです。Apple のspeakHereの例を使用して、変数を受け取るブレークポイントを設定し、そのすべての内容をログにダンプしようとしました。これは試行の例です。
void AQRecorder::printPacketDescriptionContents(const AudioStreamPacketDescription * inPacketDescriptions, UInt32 inNumberPackets)
{
for (int i = 0; i < inNumberPackets; ++i)
{
NSLog(@"\n----------------\n");
NSLog(@"this is packetDescriptionArray[%d].mStartOffset: %lld", i, (*inPacketDescriptions).mStartOffset);
NSLog(@"this is packetDescriptionArray[%d].mVariableFramesInPacket: %lu", i, (*inPacketDescriptions).mVariableFramesInPacket);
NSLog(@"this is packetDescriptionArray[%d].mDataByteSize: %lu", i, (*inPacketDescriptions).mDataByteSize);
NSLog(@"\n----------------\n");
}
}
何か案は?
更新:これは私がそれをいじろうとしているサンプルログです..多分それは答えに役立つかもしれません(一番下にnullが表示され続けることに注意してください..全体が単なるパックであることは意味がありませんこれはコールバックによって返される変数であるため、適切に入力する必要があります。また、返されたパケットの数についても通知されることに注意してください......また、コードを実行すると((const AudioStreamPacketDescription *)(inPacketDescriptions +i))->mDataByteSize)
EXC_BAD_ACCESS エラーが発生します
(lldb) po **(inPacketDescriptions)
error: indirection requires pointer operand ('const AudioStreamPacketDescription' invalid)
error: 1 errors parsing expression
(lldb) po *(inPacketDescriptions)
(AudioStreamPacketDescription) $1 = [no Objective-C description available]
(lldb) po *(inPacketDescriptions).mStartOffset
error: member reference type 'const AudioStreamPacketDescription *' is a pointer; maybe you meant to use '->'?
error: indirection requires pointer operand ('SInt64' (aka 'long long') invalid)
error: 2 errors parsing expression
(lldb) po (*inPacketDescriptions).mStartOffset
(SInt64) $2 = 0 <nil>
(lldb) po (const AudioStreamPacketDescription *)(inPacketDescriptions +1)
(const class AudioStreamPacketDescription *) $3 = 0x00000010 [no Objective-C description available]
(lldb) po (const AudioStreamPacketDescription *)(inPacketDescriptions +1)->mStartOffset
error: Execution was interrupted, reason: Attempted to dereference an invalid pointer..
The process has been returned to the state before execution.
(lldb) po ((const AudioStreamPacketDescription *)(inPacketDescriptions +1))->mStartOffset
(SInt64) $5 = 0 <nil>
(lldb) po ((const AudioStreamPacketDescription *)(inPacketDescriptions +1))->mDataByteSize
(UInt32) $6 = 0 <nil>
(lldb) po ((const AudioStreamPacketDescription *)(inPacketDescriptions +100))->mDataByteSize
(UInt32) $7 = 0 <nil>
(lldb) po ((const AudioStreamPacketDescription *)(inPacketDescriptions +500))->mDataByteSize
(UInt32) $8 = 0 <nil>
(lldb) po inPacketDescriptions[0].mStartOffset
error: parent failed to evaluate: parent is NULL
(lldb)
また、XCodeインスペクターでの表示は次のとおりです。