Fix for non-builtin audio devices

CQTexperiment
vspader 2005-07-23 19:10:06 +00:00
parent c2955e6e3f
commit 91957a3d72
4 changed files with 17 additions and 15 deletions

View File

@ -121,6 +121,8 @@
[playlistController loadPlaylist:[p filename]]; [playlistController loadPlaylist:[p filename]];
} }
[mainWindow makeKeyAndOrderFront:self];
} }
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag

View File

@ -10,6 +10,7 @@ Now has a simple dock menu courtesy of Nathanael Weldon <nathanael (at) mailbloc
The playlist index now starts at 1. The playlist index now starts at 1.
Seekbar now updates the time field as you drag it, Simon Savary <savary (at) oricom.ca> Seekbar now updates the time field as you drag it, Simon Savary <savary (at) oricom.ca>
French translation courtesy of Simon Savary <savary (at) oricom.ca> French translation courtesy of Simon Savary <savary (at) oricom.ca>
Window is now brought to the front when opening a playlist.
0.04 0.04
---- ----

View File

@ -262,7 +262,6 @@
else else
[self setDisplay:[NSString stringWithFormat:@"%@ - %@", artist, title]]; [self setDisplay:[NSString stringWithFormat:@"%@ - %@", artist, title]];
taglib_tag_free_strings(); taglib_tag_free_strings();
} }

28
Sound.m
View File

@ -59,8 +59,8 @@ static OSStatus Sound_ACInputProc(AudioConverterRef inAudioConverter, UInt32* io
Sound *sound = (Sound *)inUserData; Sound *sound = (Sound *)inUserData;
OSStatus err = noErr; OSStatus err = noErr;
// DBLog(@"Convert input proc"); DBLog(@"Convert input proc");
// DBLog(@"Numpackets: %i %i", *ioNumberDataPackets, ioData->mNumberBuffers); DBLog(@"Numpackets: %i %i", *ioNumberDataPackets, ioData->mNumberBuffers);
int amountToWrite; int amountToWrite;
int amountWritten; int amountWritten;
@ -70,16 +70,16 @@ static OSStatus Sound_ACInputProc(AudioConverterRef inAudioConverter, UInt32* io
sourceBuf = malloc(amountToWrite); sourceBuf = malloc(amountToWrite);
sound->conversionBuffer = sourceBuf; sound->conversionBuffer = sourceBuf;
// DBLog(@"Requesting: %i", amountToWrite); DBLog(@"Requesting: %i", amountToWrite);
amountWritten = [sound->soundFile fillBuffer:sourceBuf ofSize:amountToWrite]; amountWritten = [sound->soundFile fillBuffer:sourceBuf ofSize:amountToWrite];
// DBLog(@"PACKET NUMBER RECEIVED: %i", *ioNumberDataPackets); DBLog(@"PACKET NUMBER RECEIVED: %i", *ioNumberDataPackets);
ioData->mBuffers[0].mData = sourceBuf; ioData->mBuffers[0].mData = sourceBuf;
ioData->mBuffers[0].mDataByteSize = amountWritten; ioData->mBuffers[0].mDataByteSize = amountWritten;
ioData->mBuffers[0].mNumberChannels = sound->sourceStreamFormat.mChannelsPerFrame; ioData->mBuffers[0].mNumberChannels = sound->sourceStreamFormat.mChannelsPerFrame;
ioData->mNumberBuffers = 1; ioData->mNumberBuffers = 1;
// DBLog(@"Input complete"); DBLog(@"Input complete");
return err; return err;
} }
@ -485,7 +485,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
ioData.mNumberBuffers = 1; ioData.mNumberBuffers = 1;
// DBLog(@"THIS IS RETARDED: %i", ioData.mBuffers[0].mData); // DBLog(@"THIS IS RETARDED: %i", ioData.mBuffers[0].mData);
// DBLog(@"NUMBER OF PACKETS REQUESTED: %i", ioNumberFrames); DBLog(@"NUMBER OF PACKETS REQUESTED: %i", ioNumberFrames);
err = AudioConverterFillComplexBuffer(converter, Sound_ACInputProc, self, &ioNumberFrames, &ioData, NULL); err = AudioConverterFillComplexBuffer(converter, Sound_ACInputProc, self, &ioNumberFrames, &ioData, NULL);
if (err != noErr) if (err != noErr)
DBLog(@"Converter error: %i", err); DBLog(@"Converter error: %i", err);
@ -493,7 +493,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
free(conversionBuffer); free(conversionBuffer);
// DBLog(@"HERE: %i/%i", destSize, ioData.mBuffers[0].mDataByteSize); DBLog(@"HERE: %i/%i", destSize, ioData.mBuffers[0].mDataByteSize);
// DBLog(@"%i/%i",old, inNumberFrames); // DBLog(@"%i/%i",old, inNumberFrames);
return ioData.mBuffers[0].mDataByteSize; return ioData.mBuffers[0].mDataByteSize;
@ -544,19 +544,19 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
if (err != noErr) if (err != noErr)
return NO; return NO;
/* // change output format... // change output format...
deviceFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger; ///Seems some 3rd party devices return incorrect stuff...or I just don't like noninterleaved data.
deviceFormat.mBytesPerFrame = 4; deviceFormat.mFormatFlags &= ~kLinearPCMFormatFlagIsNonInterleaved;
deviceFormat.mBitsPerChannel = 16; deviceFormat.mBytesPerFrame = deviceFormat.mChannelsPerFrame*(deviceFormat.mBitsPerChannel/8);
deviceFormat.mBytesPerPacket = 4; deviceFormat.mBytesPerPacket = deviceFormat.mBytesPerFrame * deviceFormat.mFramesPerPacket;
DBLog(@"stuff: %i %i %i %i", deviceFormat.mBitsPerChannel, deviceFormat.mBytesPerFrame, deviceFormat.mBytesPerPacket, deviceFormat.mFramesPerPacket); // DBLog(@"stuff: %i %i %i %i", deviceFormat.mBitsPerChannel, deviceFormat.mBytesPerFrame, deviceFormat.mBytesPerPacket, deviceFormat.mFramesPerPacket);
err = AudioUnitSetProperty (outputUnit, err = AudioUnitSetProperty (outputUnit,
kAudioUnitProperty_StreamFormat, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, kAudioUnitScope_Output,
0, 0,
&deviceFormat, &deviceFormat,
size); size);
*/
//Set the stream format of the output to match the input //Set the stream format of the output to match the input
err = AudioUnitSetProperty (outputUnit, err = AudioUnitSetProperty (outputUnit,
kAudioUnitProperty_StreamFormat, kAudioUnitProperty_StreamFormat,