// setup conversion from Squeak to device frame format, or vice-versa. // requires: stereo for output, stereo or mono for input. // static int Stream_setFormat(Stream *s, int frameCount, int sampleRate, int stereo) { int nChannels= 1 + stereo; AudioStreamBasicDescription imgFmt, devFmt; UInt32 sz= sizeof(devFmt); if (0 == s->direction) nChannels= 2; // insist if (checkError(AudioDeviceGetProperty(s->id, 0, s->direction, kAudioDevicePropertyStreamFormat, &sz, &devFmt), "GetProperty", "StreamFormat")) return 0; debugf("stream %p[%d] device format:\n", s, s->direction); dumpFormat(&devFmt); imgFmt.mSampleRate = sampleRate; imgFmt.mFormatID = kAudioFormatLinearPCM; #if defined(WORDS_BIGENDIAN) imgFmt.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsBigEndian; #else imgFmt.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger; #endif imgFmt.mBytesPerPacket = SqueakFrameSize / (3 - nChannels); imgFmt.mFramesPerPacket = 1; imgFmt.mBytesPerFrame = SqueakFrameSize / (3 - nChannels); imgFmt.mChannelsPerFrame = nChannels; imgFmt.mBitsPerChannel = 16; debugf("stream %p[%d] image format:\n", s, s->direction); dumpFormat(&imgFmt); if (s->direction) // input { if (checkError(AudioConverterNew(&devFmt, &imgFmt, &s->converter), "AudioConverter", "New")) return 0; sz= sizeof(s->cvtBufSize); s->cvtBufSize= 512 * devFmt.mBytesPerFrame; if (checkError(AudioConverterGetProperty(s->converter, kAudioConverterPropertyCalculateOutputBufferSize, &sz, &s->cvtBufSize), "GetProperty", "OutputBufferSize")) return 0; } else // output { if (checkError(AudioConverterNew(&imgFmt, &devFmt, &s->converter), "AudioConverter", "New")) return 0; } s->channels= nChannels; s->sampleRate= sampleRate; s->imgBufSize= SqueakFrameSize * nChannels * frameCount; frameCount= max(frameCount, 512 * sampleRate / devFmt.mSampleRate); s->buffer= Buffer_new((s->direction ? DeviceFrameSize : SqueakFrameSize) * nChannels * frameCount * 2); debugf("stream %p[%d] sound buffer size %d/%d (%d)\n", s, s->direction, s->imgBufSize, s->buffer->size, frameCount); return 1; }
void ProgramDeclaration::dump(FILE* f, int depth) { fprintf(f, "ProgramDeclaration(\n"); depth++; dumpFormat(f, depth, "program = "); dumpNode<Program>(program, f, depth); fprintf(f, "\n"); depth--; dumpFormat(f, depth, ")"); }
void AliasDeclaration::dump(FILE* f, int depth) { fprintf(f, "AliasDeclaration(\n"); depth++; dumpFormat(f, depth, "identifier = "); dumpNode<Identifier>(identifier, f, depth); fprintf(f, ",\n"); dumpFormat(f, depth, "type = "); dumpNode<TypeDefinition>(type, f, depth); fprintf(f, "\n"); depth--; dumpFormat(f, depth, ")"); }
void VariableDeclaration::dump(FILE* f, int depth) { fprintf(f, "VariableDeclaration(\n"); depth++; dumpFormat(f, depth, "list = "); dumpNode<IdentifierList>(list, f, depth); fprintf(f, ",\n"); dumpFormat(f, depth, "type = "); dumpNode<TypeDefinition>(type, f, depth); fprintf(f, "\n"); depth--; dumpFormat(f, depth, ")"); }
void ConstantDeclaration::dump(FILE* f, int depth) { fprintf(f, "ConstantDeclaration(\n"); depth++; dumpFormat(f, depth, "identifier = "); dumpNode<Identifier>(identifier, f, depth); fprintf(f, ",\n"); dumpFormat(f, depth, "expression = "); dumpNode<Expression>(expression, f, depth); fprintf(f, "\n"); depth--; dumpFormat(f, depth, ")"); }
int QVideoDecoder::getVideoLengthMs() { if(!isOk()) return -1; int secs = pFormatCtx->duration / AV_TIME_BASE; int us = pFormatCtx->duration % AV_TIME_BASE; int l = secs*1000 + us/1000; dumpFormat(pFormatCtx,videoStream,"test video",0); return l; }