Cleaned up converter. Added Media Keys support for apple's new multimedia keyboard (has not been tested).
parent
5fd24bd88b
commit
0e2da5efc7
|
@ -76,4 +76,9 @@
|
|||
- (void)registerHotKeys;
|
||||
OSStatus handleHotKey(EventHandlerCallRef nextHandler,EventRef theEvent,void *userData);
|
||||
|
||||
|
||||
- (void)clickPlay;
|
||||
- (void)clickPrev;
|
||||
- (void)clickNext;
|
||||
|
||||
@end
|
||||
|
|
|
@ -191,7 +191,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
|
|||
|
||||
- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key
|
||||
{
|
||||
return [key isEqualToString:@"currentEntry"];
|
||||
return [key isEqualToString:@"currentEntry"] || [key isEqualToString:@"play"];
|
||||
}
|
||||
|
||||
- (void)initShowColumn:(NSMenuItem *)showColumn withIdentifier:(NSString *)identifier
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// MediaKeysApplication.h
|
||||
// Cog
|
||||
//
|
||||
// Created by Vincent Spader on 10/3/07.
|
||||
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <IOKit/hidsystem/ev_keymap.h>
|
||||
|
||||
@interface MediaKeysApplication : NSApplication
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// MediaKeysApplication.m
|
||||
// Cog
|
||||
//
|
||||
// Created by Vincent Spader on 10/3/07.
|
||||
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MediaKeysApplication.h"
|
||||
#import "AppController.h"
|
||||
|
||||
@implementation MediaKeysApplication
|
||||
|
||||
- (void)mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat
|
||||
{
|
||||
switch( key )
|
||||
{
|
||||
case NX_KEYTYPE_PLAY:
|
||||
if( state == 0 )
|
||||
[[self delegate] clickPlay]; //Play pressed and released
|
||||
break;
|
||||
|
||||
case NX_KEYTYPE_FAST:
|
||||
if( state == 0 )
|
||||
[[self delegate] clickNext]; //Next pressed and released
|
||||
break;
|
||||
|
||||
case NX_KEYTYPE_REWIND:
|
||||
if( state == 0 )
|
||||
[[self delegate] clickPrev]; //Previous pressed and released
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sendEvent: (NSEvent*)event
|
||||
{
|
||||
if( [event type] == NSSystemDefined && [event subtype] == 8 )
|
||||
{
|
||||
int keyCode = (([event data1] & 0xFFFF0000) >> 16);
|
||||
int keyFlags = ([event data1] & 0x0000FFFF);
|
||||
int keyState = (((keyFlags & 0xFF00) >> 8)) ==0xA;
|
||||
int keyRepeat = (keyFlags & 0x1);
|
||||
|
||||
[self mediaKeyEvent: keyCode state: keyState repeat: keyRepeat];
|
||||
}
|
||||
|
||||
[super sendEvent: event];
|
||||
}
|
||||
@end
|
|
@ -8,10 +8,6 @@
|
|||
|
||||
#import "ConverterNode.h"
|
||||
|
||||
#define BUFFER_SIZE 512 * 1024
|
||||
#define CHUNK_SIZE 16 * 1024
|
||||
|
||||
|
||||
void PrintStreamDesc (AudioStreamBasicDescription *inDesc)
|
||||
{
|
||||
if (!inDesc) {
|
||||
|
@ -36,16 +32,12 @@ void PrintStreamDesc (AudioStreamBasicDescription *inDesc)
|
|||
static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumberDataPackets, AudioBufferList* ioData, AudioStreamPacketDescription** outDataPacketDescription, void* inUserData)
|
||||
{
|
||||
ConverterNode *converter = (ConverterNode *)inUserData;
|
||||
id previousNode = [converter previousNode];
|
||||
OSStatus err = noErr;
|
||||
void *readPtr;
|
||||
int amountToWrite;
|
||||
int availInput;
|
||||
int amountRead;
|
||||
|
||||
if ([converter shouldContinue] == NO || [converter endOfStream] == YES)
|
||||
{
|
||||
// NSLog(@"END OF STREAM IN CONV");
|
||||
ioData->mBuffers[0].mDataByteSize = 0;
|
||||
*ioNumberDataPackets = 0;
|
||||
|
||||
|
@ -59,14 +51,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
converter->callbackBuffer = malloc(amountToWrite);
|
||||
|
||||
amountRead = [converter readData:converter->callbackBuffer amount:amountToWrite];
|
||||
/* if ([converter endOfStream] == YES)
|
||||
{
|
||||
ioData->mBuffers[0].mDataByteSize = 0;
|
||||
*ioNumberDataPackets = 0;
|
||||
|
||||
return noErr;
|
||||
}
|
||||
*/ if (amountRead == 0)
|
||||
if (amountRead == 0)
|
||||
{
|
||||
ioData->mBuffers[0].mDataByteSize = 0;
|
||||
*ioNumberDataPackets = 0;
|
||||
|
@ -74,43 +59,6 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
return 100; //Keep asking for data
|
||||
}
|
||||
|
||||
/*
|
||||
availInput = [[previousNode buffer] lengthAvailableToReadReturningPointer:&readPtr];
|
||||
if (availInput == 0 )
|
||||
{
|
||||
// NSLog(@"0 INPUT");
|
||||
ioData->mBuffers[0].mDataByteSize = 0;
|
||||
*ioNumberDataPackets = 0;
|
||||
|
||||
if ([previousNode endOfStream] == YES)
|
||||
{
|
||||
NSLog(@"END OF CONVERTER INPUT");
|
||||
[converter setEndOfStream:YES];
|
||||
[converter setShouldContinue:NO];
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
return 100; //Keep asking for data
|
||||
}
|
||||
|
||||
if (amountToWrite > availInput)
|
||||
amountToWrite = availInput;
|
||||
|
||||
*ioNumberDataPackets = amountToWrite/(converter->inputFormat.mBytesPerPacket);
|
||||
|
||||
if (converter->callbackBuffer != NULL)
|
||||
free(converter->callbackBuffer);
|
||||
converter->callbackBuffer = malloc(amountToWrite);
|
||||
memcpy(converter->callbackBuffer, readPtr, amountToWrite);
|
||||
|
||||
if (amountToWrite > 0)
|
||||
{
|
||||
[[previousNode buffer] didReadLength:amountToWrite];
|
||||
[[previousNode semaphore] signal];
|
||||
}
|
||||
*/
|
||||
// NSLog(@"Amount read: %@ %i", converter, amountRead);
|
||||
ioData->mBuffers[0].mData = converter->callbackBuffer;
|
||||
ioData->mBuffers[0].mDataByteSize = amountRead;
|
||||
ioData->mBuffers[0].mNumberChannels = (converter->inputFormat.mChannelsPerFrame);
|
||||
|
@ -138,34 +86,6 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
|
||||
[self writeData:writeBuf amount:amountConverted];
|
||||
}
|
||||
|
||||
/* void *writePtr;
|
||||
int availOutput;
|
||||
int amountConverted;
|
||||
|
||||
while ([self shouldContinue] == YES)
|
||||
{
|
||||
|
||||
availOutput = [buffer lengthAvailableToWriteReturningPointer:&writePtr];
|
||||
|
||||
while (availOutput == 0)
|
||||
{
|
||||
[semaphore wait];
|
||||
|
||||
if (shouldContinue == NO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
availOutput = [buffer lengthAvailableToWriteReturningPointer:&writePtr];
|
||||
}
|
||||
|
||||
amountConverted = [self convert:writePtr amount:availOutput];
|
||||
|
||||
if (amountConverted > 0)
|
||||
[buffer didWriteLength:amountConverted];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
- (int)convert:(void *)dest amount:(int)amount
|
||||
|
@ -185,43 +105,8 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
{
|
||||
return [self convert:dest amount:amount];
|
||||
}
|
||||
// if (err != noErr)
|
||||
// NSLog(@"Converter error: %i", err);
|
||||
|
||||
return ioData.mBuffers[0].mDataByteSize;
|
||||
/*
|
||||
void *readPtr;
|
||||
int availInput;
|
||||
|
||||
availInput = [[previousLink buffer] lengthAvailableToReadReturningPointer:&readPtr];
|
||||
// NSLog(@"AMOUNT: %i %i", amount, availInput);
|
||||
|
||||
if (availInput == 0)
|
||||
{
|
||||
if ([previousLink endOfInput] == YES)
|
||||
{
|
||||
endOfInput = YES;
|
||||
NSLog(@"EOI");
|
||||
shouldContinue = NO;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (availInput < amount)
|
||||
amount = availInput;
|
||||
|
||||
memcpy(dest, readPtr, amount);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
// NSLog(@"READ: %i", amount);
|
||||
[[previousLink buffer] didReadLength:amount];
|
||||
[[previousLink semaphore] signal];
|
||||
}
|
||||
|
||||
return amount;
|
||||
*/
|
||||
}
|
||||
|
||||
- (BOOL)setupWithInputFormat:(AudioStreamBasicDescription)inf outputFormat:(AudioStreamBasicDescription)outf
|
||||
|
@ -249,10 +134,6 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
}
|
||||
}
|
||||
|
||||
// DBLog(@"Created converter");
|
||||
PrintStreamDesc(&inf);
|
||||
PrintStreamDesc(&outf);
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@
|
|||
17818A990C0B27AC001C4916 /* shn.icns in Resources */ = {isa = PBXBuildFile; fileRef = 17818A920C0B27AC001C4916 /* shn.icns */; };
|
||||
17818A9A0C0B27AC001C4916 /* wav.icns in Resources */ = {isa = PBXBuildFile; fileRef = 17818A930C0B27AC001C4916 /* wav.icns */; };
|
||||
17818A9B0C0B27AC001C4916 /* wv.icns in Resources */ = {isa = PBXBuildFile; fileRef = 17818A940C0B27AC001C4916 /* wv.icns */; };
|
||||
1791005E0CB44D6D0070BC5C /* Cog.scriptSuite in Resources */ = {isa = PBXBuildFile; fileRef = 1791005C0CB44D6D0070BC5C /* Cog.scriptSuite */; };
|
||||
1791005F0CB44D6D0070BC5C /* Cog.scriptTerminology in Resources */ = {isa = PBXBuildFile; fileRef = 1791005D0CB44D6D0070BC5C /* Cog.scriptTerminology */; };
|
||||
1791FF8F0CB43A2C0070BC5C /* MediaKeysApplication.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1791FF8D0CB43A2C0070BC5C /* MediaKeysApplication.h */; };
|
||||
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 1791FF8E0CB43A2C0070BC5C /* MediaKeysApplication.m */; };
|
||||
179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 179790DF0C087AB7001D6996 /* OpenURLPanel.m */; };
|
||||
179790F20C087B46001D6996 /* OpenURLPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = 179790F00C087B46001D6996 /* OpenURLPanel.nib */; };
|
||||
17BB5CED0B8A86010009ACB1 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17BB5CEC0B8A86010009ACB1 /* AudioToolbox.framework */; };
|
||||
|
@ -104,8 +108,6 @@
|
|||
8E75757409F31D5A0080F1EE /* PlaylistView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E75753209F31D5A0080F1EE /* PlaylistView.m */; };
|
||||
8E75757509F31D5A0080F1EE /* Shuffle.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E75753409F31D5A0080F1EE /* Shuffle.m */; };
|
||||
8E7575BE09F31D800080F1EE /* wheel.icns in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575A609F31D800080F1EE /* wheel.icns */; };
|
||||
8E7575CC09F31DCA0080F1EE /* Cog.scriptSuite in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575C409F31DCA0080F1EE /* Cog.scriptSuite */; };
|
||||
8E7575CD09F31DCA0080F1EE /* Cog.scriptTerminology in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575C509F31DCA0080F1EE /* Cog.scriptTerminology */; };
|
||||
8E7575DB09F31E930080F1EE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8E7575D909F31E930080F1EE /* Localizable.strings */; };
|
||||
8E9A2E860BA78B500091081B /* SecondsFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A2E840BA78B500091081B /* SecondsFormatter.m */; };
|
||||
8E9A2EDA0BA78D9D0091081B /* IndexFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */; };
|
||||
|
@ -335,6 +337,7 @@
|
|||
17F561400C3BD4F30019975C /* CogAudio.framework in CopyFiles */,
|
||||
170680840B950164006BA573 /* Growl.framework in CopyFiles */,
|
||||
17F94CCD0B8D090800A34E87 /* Sparkle.framework in CopyFiles */,
|
||||
1791FF8F0CB43A2C0070BC5C /* MediaKeysApplication.h in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -441,6 +444,10 @@
|
|||
17818A920C0B27AC001C4916 /* shn.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = shn.icns; sourceTree = "<group>"; };
|
||||
17818A930C0B27AC001C4916 /* wav.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = wav.icns; sourceTree = "<group>"; };
|
||||
17818A940C0B27AC001C4916 /* wv.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = wv.icns; sourceTree = "<group>"; };
|
||||
1791005C0CB44D6D0070BC5C /* Cog.scriptSuite */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Cog.scriptSuite; sourceTree = "<group>"; };
|
||||
1791005D0CB44D6D0070BC5C /* Cog.scriptTerminology */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Cog.scriptTerminology; sourceTree = "<group>"; };
|
||||
1791FF8D0CB43A2C0070BC5C /* MediaKeysApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaKeysApplication.h; sourceTree = "<group>"; };
|
||||
1791FF8E0CB43A2C0070BC5C /* MediaKeysApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MediaKeysApplication.m; sourceTree = "<group>"; };
|
||||
179790DE0C087AB7001D6996 /* OpenURLPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OpenURLPanel.h; sourceTree = "<group>"; };
|
||||
179790DF0C087AB7001D6996 /* OpenURLPanel.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = OpenURLPanel.m; sourceTree = "<group>"; };
|
||||
179790F10C087B46001D6996 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/OpenURLPanel.nib; sourceTree = "<group>"; };
|
||||
|
@ -500,8 +507,6 @@
|
|||
8E75753309F31D5A0080F1EE /* Shuffle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Shuffle.h; sourceTree = "<group>"; };
|
||||
8E75753409F31D5A0080F1EE /* Shuffle.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = Shuffle.m; sourceTree = "<group>"; };
|
||||
8E7575A609F31D800080F1EE /* wheel.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = wheel.icns; sourceTree = "<group>"; };
|
||||
8E7575C409F31DCA0080F1EE /* Cog.scriptSuite */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Cog.scriptSuite; sourceTree = "<group>"; };
|
||||
8E7575C509F31DCA0080F1EE /* Cog.scriptTerminology */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Cog.scriptTerminology; sourceTree = "<group>"; };
|
||||
8E7575C809F31DCA0080F1EE /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html; name = English; path = English.lproj/Credits.html; sourceTree = "<group>"; };
|
||||
8E7575DA09F31E930080F1EE /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
8E9A2E830BA78B500091081B /* SecondsFormatter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SecondsFormatter.h; sourceTree = "<group>"; };
|
||||
|
@ -607,6 +612,8 @@
|
|||
177042980B8BC53600B86321 /* AppController.m */,
|
||||
177042990B8BC53600B86321 /* PlaybackController.h */,
|
||||
1770429A0B8BC53600B86321 /* PlaybackController.m */,
|
||||
1791FF8D0CB43A2C0070BC5C /* MediaKeysApplication.h */,
|
||||
1791FF8E0CB43A2C0070BC5C /* MediaKeysApplication.m */,
|
||||
);
|
||||
path = Application;
|
||||
sourceTree = "<group>";
|
||||
|
@ -909,10 +916,10 @@
|
|||
8D1107310486CEB800E47090 /* Info.plist */,
|
||||
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
|
||||
8E7575D909F31E930080F1EE /* Localizable.strings */,
|
||||
1791005C0CB44D6D0070BC5C /* Cog.scriptSuite */,
|
||||
1791005D0CB44D6D0070BC5C /* Cog.scriptTerminology */,
|
||||
179790F00C087B46001D6996 /* OpenURLPanel.nib */,
|
||||
29B97318FDCFA39411CA2CEA /* MainMenu.nib */,
|
||||
8E7575C409F31DCA0080F1EE /* Cog.scriptSuite */,
|
||||
8E7575C509F31DCA0080F1EE /* Cog.scriptTerminology */,
|
||||
17E41E060C130DFF00AC744D /* Credits.html */,
|
||||
);
|
||||
name = Resources;
|
||||
|
@ -1244,8 +1251,6 @@
|
|||
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */,
|
||||
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
|
||||
8E7575BE09F31D800080F1EE /* wheel.icns in Resources */,
|
||||
8E7575CC09F31DCA0080F1EE /* Cog.scriptSuite in Resources */,
|
||||
8E7575CD09F31DCA0080F1EE /* Cog.scriptTerminology in Resources */,
|
||||
17E41E070C130DFF00AC744D /* Credits.html in Resources */,
|
||||
8E7575DB09F31E930080F1EE /* Localizable.strings in Resources */,
|
||||
177EC0440B8BC2FF0000BC8C /* add_blue.png in Resources */,
|
||||
|
@ -1283,6 +1288,8 @@
|
|||
17818A990C0B27AC001C4916 /* shn.icns in Resources */,
|
||||
17818A9A0C0B27AC001C4916 /* wav.icns in Resources */,
|
||||
17818A9B0C0B27AC001C4916 /* wv.icns in Resources */,
|
||||
1791005E0CB44D6D0070BC5C /* Cog.scriptSuite in Resources */,
|
||||
1791005F0CB44D6D0070BC5C /* Cog.scriptTerminology in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -1338,6 +1345,7 @@
|
|||
8E9A2EDA0BA78D9D0091081B /* IndexFormatter.m in Sources */,
|
||||
8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */,
|
||||
179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */,
|
||||
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -214,7 +214,7 @@
|
|||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<string>MediaKeysApplication</string>
|
||||
<key>SUFeedURL</key>
|
||||
<string>http://cogx.org/appcast/stable.xml</string>
|
||||
</dict>
|
||||
|
|
Loading…
Reference in New Issue