osxaudiosink: Add support for int audio

This commit is contained in:
Josep Torra 2012-06-01 16:37:00 +02:00 committed by Sebastian Dröge
parent 79d20f7ee9
commit 85102c49d5
2 changed files with 45 additions and 4 deletions

View file

@ -98,6 +98,34 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
"signed = (boolean) { TRUE }, "
"width = (int) 32, "
"depth = (int) 32, "
"rate = (int) [1, MAX], "
"channels = (int) [1, MAX];"
"audio/x-raw-int, "
"endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
"signed = (boolean) { TRUE }, "
"width = (int) 32, "
"depth = (int) 32, "
"rate = (int) [1, MAX], "
"channels = (int) [1, MAX];"
"audio/x-raw-int, "
"endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
"signed = (boolean) { TRUE }, "
"width = (int) 24, "
"depth = (int) 24, "
"rate = (int) [1, MAX], "
"channels = (int) [1, MAX];"
"audio/x-raw-int, "
"endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
"signed = (boolean) { TRUE }, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [1, MAX], "
"channels = (int) [1, MAX];"
"audio/x-raw-int, "
"endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
"signed = (boolean) { TRUE }, "
"width = (int) 8, "
"depth = (int) 8, "
"rate = (int) [1, MAX], " "channels = (int) [1, MAX]")
);

View file

@ -329,6 +329,7 @@ gst_osx_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
int layoutSize;
int element;
int i;
int width, depth;
AudioUnitScope scope;
gboolean ret = FALSE;
GstStructure *structure;
@ -341,10 +342,22 @@ gst_osx_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
format.mFormatID = kAudioFormatLinearPCM;
format.mSampleRate = (double) spec->rate;
format.mChannelsPerFrame = spec->channels;
format.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
format.mBytesPerFrame = spec->channels * sizeof (float);
format.mBitsPerChannel = sizeof (float) * 8;
format.mBytesPerPacket = spec->channels * sizeof (float);
if (spec->type == GST_BUFTYPE_FLOAT) {
format.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
width = depth = spec->width;
} else {
format.mFormatFlags = kAudioFormatFlagIsSignedInteger;
width = spec->width;
depth = spec->depth;
if (width == depth) {
format.mFormatFlags |= kAudioFormatFlagIsPacked;
} else {
format.mFormatFlags |= kAudioFormatFlagIsAlignedHigh;
}
}
format.mBytesPerFrame = spec->channels * (width >> 3);
format.mBitsPerChannel = depth;
format.mBytesPerPacket = spec->channels * (width >> 3);
format.mFramesPerPacket = 1;
format.mReserved = 0;