From 9a8212950731a6ea375f819d8869864420155893 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 12 Oct 2009 13:40:26 +0100 Subject: [PATCH] whitespace clean-up --- extras/juce demo/src/ApplicationStartup.cpp | 2 +- src/core/juce_DataConversions.h | 2 +- src/core/juce_SystemStats.h | 2 +- src/core/juce_TargetPlatform.h | 2 +- .../windows/juce_DocumentWindow.cpp | 16 +- src/juce_app_includes.h | 40 +- src/juce_core_includes.h | 37 +- src/native/juce_mac_NativeCode.mm | 3 +- src/native/mac/juce_iphone_Audio.cpp | 417 ------------------ src/native/mac/juce_iphone_MiscUtilities.mm | 2 +- .../mac/juce_iphone_UIViewComponentPeer.mm | 44 +- src/native/mac/juce_mac_FileChooser.mm | 2 +- src/native/mac/juce_mac_Files.mm | 8 +- src/native/mac/juce_mac_ObjCSuffix.h | 1 - 14 files changed, 81 insertions(+), 497 deletions(-) diff --git a/extras/juce demo/src/ApplicationStartup.cpp b/extras/juce demo/src/ApplicationStartup.cpp index fab310f558..a3be1b1b8c 100644 --- a/extras/juce demo/src/ApplicationStartup.cpp +++ b/extras/juce demo/src/ApplicationStartup.cpp @@ -62,7 +62,7 @@ public: { // just create the main window... theMainWindow = new MainDemoWindow(); - + #if JUCE_IPHONE theMainWindow->setVisible (true); theMainWindow->setBounds (0, 20, 320, 460); diff --git a/src/core/juce_DataConversions.h b/src/core/juce_DataConversions.h index 5f53fb8417..ec1835506f 100644 --- a/src/core/juce_DataConversions.h +++ b/src/core/juce_DataConversions.h @@ -34,7 +34,7 @@ // Endianness conversions.. #if JUCE_IPHONE -// a gcc compiler error seems to mean that these functions only work properly +// a gcc compiler error seems to mean that these functions only work properly // on the iPhone if they are declared static.. static forcedinline uint32 swapByteOrder (uint32 n) throw(); static inline uint16 swapByteOrder (const uint16 n) throw(); diff --git a/src/core/juce_SystemStats.h b/src/core/juce_SystemStats.h index 29a6baa230..aeba75a52a 100644 --- a/src/core/juce_SystemStats.h +++ b/src/core/juce_SystemStats.h @@ -147,7 +147,7 @@ public: @param addresses an array into which the MAC addresses should be copied @param maxNum the number of elements in this array - @param littleEndian the endianness of the numbers to return. If this is true, + @param littleEndian the endianness of the numbers to return. If this is true, the least-significant byte of each number is the first byte of the mac address. If false, the least significant byte is the last number. Note that the default values of this parameter diff --git a/src/core/juce_TargetPlatform.h b/src/core/juce_TargetPlatform.h index ed57c58f7e..a77b8341fd 100644 --- a/src/core/juce_TargetPlatform.h +++ b/src/core/juce_TargetPlatform.h @@ -166,4 +166,4 @@ #endif -#endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ +#endif // __JUCE_TARGETPLATFORM_JUCEHEADER__ diff --git a/src/gui/components/windows/juce_DocumentWindow.cpp b/src/gui/components/windows/juce_DocumentWindow.cpp index 7c69ff6e0b..9796d582b7 100644 --- a/src/gui/components/windows/juce_DocumentWindow.cpp +++ b/src/gui/components/windows/juce_DocumentWindow.cpp @@ -72,7 +72,7 @@ DocumentWindow::~DocumentWindow() void DocumentWindow::repaintTitleBar() { const Rectangle titleBarArea (getTitleBarArea()); - repaint (titleBarArea.getX(), titleBarArea.getY(), + repaint (titleBarArea.getX(), titleBarArea.getY(), titleBarArea.getWidth(), titleBarArea.getHeight()); } @@ -178,9 +178,9 @@ void DocumentWindow::paint (Graphics& g) if (resizableBorder == 0) { g.setColour (getBackgroundColour().overlaidWith (Colour (0x80000000))); - + const BorderSize border (getBorderThickness()); - + g.fillRect (0, 0, getWidth(), border.getTop()); g.fillRect (0, border.getTop(), border.getLeft(), getHeight() - border.getTopAndBottom()); g.fillRect (getWidth() - border.getRight(), border.getTop(), border.getRight(), getHeight() - border.getTopAndBottom()); @@ -208,9 +208,9 @@ void DocumentWindow::paint (Graphics& g) getLookAndFeel().drawDocumentWindowTitleBar (*this, g, titleBarArea.getWidth(), titleBarArea.getHeight(), - titleSpaceX1, + titleSpaceX1, jmax (1, titleSpaceX2 - titleSpaceX1), - titleBarIcon, + titleBarIcon, ! drawTitleTextCentred); } @@ -222,7 +222,7 @@ void DocumentWindow::resized() titleBarButtons[1]->setToggleState (isFullScreen(), false); const Rectangle titleBarArea (getTitleBarArea()); - + getLookAndFeel() .positionDocumentWindowButtons (*this, titleBarArea.getX(), titleBarArea.getY(), @@ -250,7 +250,7 @@ const BorderSize DocumentWindow::getContentComponentBorder() border.setTop (border.getTop() + (isUsingNativeTitleBar() ? 0 : titleBarHeight) + (menuBar != 0 ? menuBarHeight : 0)); - + return border; } @@ -264,7 +264,7 @@ const Rectangle DocumentWindow::getTitleBarArea() const BorderSize border (getBorderThickness()); return Rectangle (border.getLeft(), border.getTop(), - getWidth() - border.getLeftAndRight(), + getWidth() - border.getLeftAndRight(), getTitleBarHeight()); } diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index c342c6027d..2c893459b1 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -188,9 +188,6 @@ #ifndef __JUCE_AUDIOCDBURNER_JUCEHEADER__ #include "audio/audio_file_formats/juce_AudioCDBurner.h" #endif -#ifndef __JUCE_AUDIOCDREADER_JUCEHEADER__ - #include "audio/audio_file_formats/juce_AudioCDReader.h" -#endif #ifndef __JUCE_AUDIOFORMAT_JUCEHEADER__ #include "audio/audio_file_formats/juce_AudioFormat.h" #endif @@ -209,15 +206,18 @@ #ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ #include "audio/audio_file_formats/juce_FlacAudioFormat.h" #endif -#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ - #include "audio/audio_file_formats/juce_AudioSubsectionReader.h" -#endif #ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ #include "audio/audio_file_formats/juce_WavAudioFormat.h" #endif +#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ + #include "audio/audio_file_formats/juce_AudioSubsectionReader.h" +#endif #ifndef __JUCE_AUDIOTHUMBNAIL_JUCEHEADER__ #include "audio/audio_file_formats/juce_AudioThumbnail.h" #endif +#ifndef __JUCE_AUDIOCDREADER_JUCEHEADER__ + #include "audio/audio_file_formats/juce_AudioCDReader.h" +#endif #ifndef __JUCE_OGGVORBISAUDIOFORMAT_JUCEHEADER__ #include "audio/audio_file_formats/juce_OggVorbisAudioFormat.h" #endif @@ -629,12 +629,12 @@ #ifndef __JUCE_FILEPREVIEWCOMPONENT_JUCEHEADER__ #include "gui/components/filebrowser/juce_FilePreviewComponent.h" #endif -#ifndef __JUCE_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__ - #include "gui/components/filebrowser/juce_FileSearchPathListComponent.h" -#endif #ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__ #include "gui/components/filebrowser/juce_FileTreeComponent.h" #endif +#ifndef __JUCE_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__ + #include "gui/components/filebrowser/juce_FileSearchPathListComponent.h" +#endif #ifndef __JUCE_FILENAMECOMPONENT_JUCEHEADER__ #include "gui/components/filebrowser/juce_FilenameComponent.h" #endif @@ -662,17 +662,14 @@ #ifndef __JUCE_SPLASHSCREEN_JUCEHEADER__ #include "gui/components/windows/juce_SplashScreen.h" #endif -#ifndef __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ - #include "gui/components/windows/juce_ThreadWithProgressWindow.h" -#endif #ifndef __JUCE_TOOLTIPWINDOW_JUCEHEADER__ #include "gui/components/windows/juce_TooltipWindow.h" #endif #ifndef __JUCE_TOPLEVELWINDOW_JUCEHEADER__ #include "gui/components/windows/juce_TopLevelWindow.h" #endif -#ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ - #include "gui/components/special/juce_ActiveXControlComponent.h" +#ifndef __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ + #include "gui/components/windows/juce_ThreadWithProgressWindow.h" #endif #ifndef __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ #include "gui/components/special/juce_AudioDeviceSelectorComponent.h" @@ -683,12 +680,12 @@ #ifndef __JUCE_COLOURSELECTOR_JUCEHEADER__ #include "gui/components/special/juce_ColourSelector.h" #endif -#ifndef __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ - #include "gui/components/special/juce_BubbleMessageComponent.h" -#endif #ifndef __JUCE_DROPSHADOWER_JUCEHEADER__ #include "gui/components/special/juce_DropShadower.h" #endif +#ifndef __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ + #include "gui/components/special/juce_BubbleMessageComponent.h" +#endif #ifndef __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ #include "gui/components/special/juce_WebBrowserComponent.h" #endif @@ -698,12 +695,12 @@ #ifndef __JUCE_NSVIEWCOMPONENT_JUCEHEADER__ #include "gui/components/special/juce_NSViewComponent.h" #endif -#ifndef __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ - #include "gui/components/special/juce_MidiKeyboardComponent.h" -#endif #ifndef __JUCE_OPENGLCOMPONENT_JUCEHEADER__ #include "gui/components/special/juce_OpenGLComponent.h" #endif +#ifndef __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ + #include "gui/components/special/juce_MidiKeyboardComponent.h" +#endif #ifndef __JUCE_PREFERENCESPANEL_JUCEHEADER__ #include "gui/components/special/juce_PreferencesPanel.h" #endif @@ -713,6 +710,9 @@ #ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ #include "gui/components/special/juce_SystemTrayIconComponent.h" #endif +#ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ + #include "gui/components/special/juce_ActiveXControlComponent.h" +#endif #ifndef __JUCE_LOOKANDFEEL_JUCEHEADER__ #include "gui/components/lookandfeel/juce_LookAndFeel.h" #endif diff --git a/src/juce_core_includes.h b/src/juce_core_includes.h index d65d472204..ba34fe7714 100644 --- a/src/juce_core_includes.h +++ b/src/juce_core_includes.h @@ -29,9 +29,6 @@ #ifndef __JUCE_ATOMIC_JUCEHEADER__ #include "core/juce_Atomic.h" #endif -#ifndef __JUCE_DATACONVERSIONS_JUCEHEADER__ - #include "core/juce_DataConversions.h" -#endif #ifndef __JUCE_FILELOGGER_JUCEHEADER__ #include "core/juce_FileLogger.h" #endif @@ -41,42 +38,48 @@ #ifndef __JUCE_LOGGER_JUCEHEADER__ #include "core/juce_Logger.h" #endif -#ifndef __JUCE_MATHSFUNCTIONS_JUCEHEADER__ - #include "core/juce_MathsFunctions.h" -#endif #ifndef __JUCE_MEMORY_JUCEHEADER__ #include "core/juce_Memory.h" #endif #ifndef __JUCE_PERFORMANCECOUNTER_JUCEHEADER__ #include "core/juce_PerformanceCounter.h" #endif -#ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ - #include "core/juce_PlatformDefs.h" -#endif -#ifndef __JUCE_PLATFORMUTILITIES_JUCEHEADER__ - #include "core/juce_PlatformUtilities.h" -#endif #ifndef __JUCE_RANDOM_JUCEHEADER__ #include "core/juce_Random.h" #endif +#ifndef __JUCE_DATACONVERSIONS_JUCEHEADER__ + #include "core/juce_DataConversions.h" +#endif #ifndef __JUCE_RELATIVETIME_JUCEHEADER__ #include "core/juce_RelativeTime.h" #endif #ifndef __JUCE_SINGLETON_JUCEHEADER__ #include "core/juce_Singleton.h" #endif -#ifndef __JUCE_STANDARDHEADER_JUCEHEADER__ - #include "core/juce_StandardHeader.h" +#ifndef __JUCE_TIME_JUCEHEADER__ + #include "core/juce_Time.h" #endif #ifndef __JUCE_SYSTEMSTATS_JUCEHEADER__ #include "core/juce_SystemStats.h" #endif -#ifndef __JUCE_TIME_JUCEHEADER__ - #include "core/juce_Time.h" -#endif #ifndef __JUCE_UUID_JUCEHEADER__ #include "core/juce_Uuid.h" #endif +#ifndef __JUCE_TARGETPLATFORM_JUCEHEADER__ + #include "core/juce_TargetPlatform.h" +#endif +#ifndef __JUCE_STANDARDHEADER_JUCEHEADER__ + #include "core/juce_StandardHeader.h" +#endif +#ifndef __JUCE_PLATFORMUTILITIES_JUCEHEADER__ + #include "core/juce_PlatformUtilities.h" +#endif +#ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ + #include "core/juce_PlatformDefs.h" +#endif +#ifndef __JUCE_MATHSFUNCTIONS_JUCEHEADER__ + #include "core/juce_MathsFunctions.h" +#endif #ifndef __JUCE_ARRAY_JUCEHEADER__ #include "containers/juce_Array.h" #endif diff --git a/src/native/juce_mac_NativeCode.mm b/src/native/juce_mac_NativeCode.mm index 7f3e7e3583..648c97a8b6 100644 --- a/src/native/juce_mac_NativeCode.mm +++ b/src/native/juce_mac_NativeCode.mm @@ -104,8 +104,7 @@ BEGIN_JUCE_NAMESPACE #include "mac/juce_mac_OpenGLComponent.mm" #include "mac/juce_mac_MouseCursor.mm" #include "mac/juce_mac_WebBrowserComponent.mm" - //#include "mac/juce_mac_CoreAudio.cpp" - //#include "mac/juce_mac_CameraDevice.mm" + #include "mac/juce_iphone_Audio.cpp" #include "mac/juce_mac_CoreMidi.cpp" #else #include "mac/juce_mac_NSViewComponentPeer.mm" diff --git a/src/native/mac/juce_iphone_Audio.cpp b/src/native/mac/juce_iphone_Audio.cpp index 382a622929..923808f664 100644 --- a/src/native/mac/juce_iphone_Audio.cpp +++ b/src/native/mac/juce_iphone_Audio.cpp @@ -28,422 +28,5 @@ #ifdef JUCE_INCLUDED_FILE -@interface UIKitAUIOHost : UIViewController -{ -@public - /** READONLY The audio format of the data stream. */ - AudioStreamBasicDescription format; - AURenderCallbackStruct inputProc; - Float64 hwSampleRate; - AudioUnit rioUnit; - UGen rawInput; - UGen postFadeOutput; - UGen preFadeOutput; - int bufferSize; - float *floatBuffer; - UInt32 audioInputIsAvailable; - UInt32 numInputChannels; - UInt32 numOutputChannels; - bool isRunning; - float fadeInTime; - UGenArray others; - NSLock* nsLock; -} - -/** Initialises the AudioUnit framework and structures. - Do not call this method, it is called automatically when the application launches. */ -- (void)initAudio; - -/** Construct a UGen graph. - You must implement this in your subclass. You should return a UGen which will be the UGen graph which is - performed and rendered to the host. The input parameter may be ignored if only signal generation is required - or may be used if a processing algorithm is being implemented (e.g., filtering incoming audio data). - - @param input The input UGen which will contain audio data from the host. - @return the UGen graph which will be performed */ -- (UGen)constructGraph:(UGen)input; - -- (void)addOther:(UGen)ugen; - -- (void)lock; -- (void)unlock; -- (BOOL)tryLock; - -@end - -#define NUM_CHANNELS 2 - -void SetFormat(AudioStreamBasicDescription& format) -{ - memset(&format, 0, sizeof(AudioStreamBasicDescription)); - format.mFormatID = kAudioFormatLinearPCM; - int sampleSize = sizeof(AudioSampleType); - format.mFormatFlags = kAudioFormatFlagsCanonical; - format.mBitsPerChannel = 8 * sampleSize; - format.mChannelsPerFrame = NUM_CHANNELS; - format.mFramesPerPacket = 1; - format.mBytesPerPacket = format.mBytesPerFrame = sampleSize; - format.mFormatFlags |= kAudioFormatFlagIsNonInterleaved; -} - -int SetupRemoteIO (AudioUnit& inRemoteIOUnit, AURenderCallbackStruct inRenderProc, AudioStreamBasicDescription& outFormat) -{ - // Open the output unit - AudioComponentDescription desc; - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_RemoteIO; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - - AudioComponent comp = AudioComponentFindNext (NULL, &desc); - AudioComponentInstanceNew (comp, &inRemoteIOUnit); - - const UInt32 one = 1; - AudioUnitSetProperty(inRemoteIOUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &one, sizeof(one)); - AudioUnitSetProperty(inRemoteIOUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &inRenderProc, sizeof(inRenderProc)); - - AudioUnitSetProperty(inRemoteIOUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &outFormat, sizeof(outFormat)); - AudioUnitSetProperty(inRemoteIOUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &outFormat, sizeof(outFormat)); - - AudioUnitInitialize(inRemoteIOUnit); - - return 0; -} - -static const float FloatToFixed824_Factor = 16777216.f; -static const float Fixed824ToFloat_Factor = 5.960464477539e-08f; - -static const float FloatToPCM16Bit_Factor = 32767.f; -static const float PCM16BitToFloat_Factor = 3.051850947600e-05f; - -static OSStatus PerformThru(void *inRefCon, - AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList *ioData) -{ - OSStatus err = 0; - UIKitAUIOHost *x = (UIKitAUIOHost *)inRefCon; - - [x lock]; - - if(x->audioInputIsAvailable) - { - err = AudioUnitRender(x->rioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData); - if (err) { printf("PerformThru: error %d\n", (int)err); return err; } - } - - if(inNumberFrames > x->bufferSize) - { - delete [] x->floatBuffer; - x->bufferSize = inNumberFrames; - - x->floatBuffer = new float[inNumberFrames * NUM_CHANNELS]; - } - - long blockID = UGen::getNextBlockID(inNumberFrames); - - float *floatBufferData[2]; - floatBufferData[0] = x->floatBuffer; - floatBufferData[1] = floatBufferData[0] + inNumberFrames; - - if(x->audioInputIsAvailable) - { - for (UInt32 channel = 0; channel < x->numInputChannels; channel++) - { - AudioSampleType *audioUnitBuffer = (AudioSampleType*)ioData->mBuffers[0].mData; - float *floatBuffer = floatBufferData[channel]; - - for(int sample = 0; sample < inNumberFrames; sample++) - { - floatBuffer[sample] = (float)audioUnitBuffer[sample] * PCM16BitToFloat_Factor; - } - } - - x->rawInput.getSource().setInputs((const float**)floatBufferData, inNumberFrames, x->numInputChannels); - } - else - { - memset(x->floatBuffer, 0, x->numInputChannels * inNumberFrames * sizeof(float)); - } - - x->postFadeOutput.setOutputs(floatBufferData, inNumberFrames, 2); - x->postFadeOutput.prepareAndProcessBlock(inNumberFrames, blockID); - - for (UInt32 channel = 0; channel < ioData->mNumberBuffers; channel++) - { - AudioSampleType *audioUnitBuffer = (AudioSampleType*)ioData->mBuffers[channel].mData; - float *floatBuffer = floatBufferData[channel]; - - for(int sample = 0; sample < inNumberFrames; sample++) - { - audioUnitBuffer[sample] = (AudioSampleType)(floatBuffer[sample] * FloatToPCM16Bit_Factor); - } - } - - for(int i = 0; i < x->others.size(); i++) - { - x->others[i].prepareAndProcessBlock(inNumberFrames, blockID); - } - - [x unlock]; - - return err; -} - -void propListener(void * inClientData, - AudioSessionPropertyID inID, - UInt32 inDataSize, - const void * inPropertyValue) -{ - printf("Property changed!\n"); - - UIKitAUIOHost *x = (UIKitAUIOHost *)inClientData; - - if(!x->isRunning) return; - - if(inPropertyValue) - { - CFDictionaryRef routeChangeDictionary = (CFDictionaryRef)inPropertyValue; - CFNumberRef routeChangeReasonRef = - (CFNumberRef)CFDictionaryGetValue (routeChangeDictionary, - CFSTR (kAudioSession_AudioRouteChangeKey_Reason)); - - SInt32 routeChangeReason; - CFNumberGetValue(routeChangeReasonRef, kCFNumberSInt32Type, &routeChangeReason); - - CFStringRef newAudioRoute; - UInt32 propertySize = sizeof (CFStringRef); - AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &newAudioRoute); - - printf("route=%s\n", CFStringGetCStringPtr(newAudioRoute, CFStringGetSystemEncoding())); - - } - - UInt32 size = sizeof(UInt32); - AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &x->numInputChannels); - AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputNumberChannels, &size, &x->numOutputChannels); - AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &x->audioInputIsAvailable); - - printf("inputs=%d outputs=%d audioInputIsAvailable=%d\n", x->numInputChannels, x->numOutputChannels, x->audioInputIsAvailable); - - if(x->rioUnit) - { - AudioComponentInstanceDispose(x->rioUnit); - } - - SetFormat(x->format); - SetupRemoteIO(x->rioUnit, x->inputProc, x->format); - - x->rawInput.setSource(AudioIn::AR(x->numInputChannels), true); - x->postFadeOutput = Plug::AR(UGen::emptyChannels(x->preFadeOutput.getNumChannels())); - x->postFadeOutput.fadeSourceAndRelease(x->preFadeOutput, x->fadeInTime); - - AudioSessionSetActive(true); - AudioOutputUnitStart(x->rioUnit); -} - -void rioInterruptionListener(void *inClientData, UInt32 inInterruption) -{ - printf("Session interrupted! --- %s ---\n", inInterruption == kAudioSessionBeginInterruption ? "Begin Interruption" : "End Interruption"); - - UIKitAUIOHost *x = (UIKitAUIOHost *)inClientData; - - if (inInterruption == kAudioSessionEndInterruption) { - // make sure we are again the active session - //AudioSessionSetActive(false); - AudioSessionSetActive(true); - x->isRunning = true; - AudioOutputUnitStart(x->rioUnit); - } - - if (inInterruption == kAudioSessionBeginInterruption) { - x->isRunning = false; - AudioOutputUnitStop(x->rioUnit); - - printf("rioInterruptionListener audioInputIsAvailable=%d\n", x->audioInputIsAvailable); - - UIAlertView *baseAlert = [[UIAlertView alloc] initWithTitle:@"Audio interrupted" - message:@"This could have been interrupted by another application or due to unplugging a headset:" - delegate:x - cancelButtonTitle:nil - otherButtonTitles:@"Resume", @"Cancel", nil]; - [baseAlert show]; - } - -} - -@implementation UIKitAUIOHost - -- (id)init -{ - if (self = [super init]) - { - nsLock = [[NSLock alloc] init]; - fadeInTime = 1.0; - [self performSelector:@selector(initAudio) withObject:nil afterDelay:1.0]; - } - return self; -} - -- (void)initAudio -{ - // render proc - inputProc.inputProc = PerformThru; - inputProc.inputProcRefCon = self; - - // session - AudioSessionInitialize (NULL, NULL, rioInterruptionListener, self); - AudioSessionSetActive (true); - - UInt32 audioCategory = kAudioSessionCategory_PlayAndRecord; - AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory); - AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, propListener, self); - - UInt32 size = sizeof(hwSampleRate); - AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate, &size, &hwSampleRate); - - Float32 bufferDuration = 512 / hwSampleRate; - AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, sizeof(bufferDuration), &bufferDuration); - - UGen::initialise(); - UGen::prepareToPlay(hwSampleRate, 512); - - rawInput = Plug::AR(UGen::emptyChannels(2)); - preFadeOutput = [self constructGraph: rawInput]; - - rioUnit = NULL; - isRunning = true; - propListener((void*)self, 0,0,0); - - size = sizeof(format); - AudioUnitGetProperty(rioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &format, &size); - - //Float32 bufferDuration; - size = sizeof(bufferDuration); - AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareIOBufferDuration, &size, &bufferDuration); - - bufferSize = (int)(hwSampleRate*bufferDuration+0.5); - floatBuffer = new float[bufferSize * NUM_CHANNELS]; -} - -- (UGen)constructGraph:(UGen)input -{ - return UGen::emptyChannels(NUM_CHANNELS); -} - -- (void)addOther:(UGen)ugen -{ - [self lock]; - others <<= ugen; - [self unlock]; -} - -- (void)lock -{ - [nsLock lock]; -} - -- (void)unlock -{ - [nsLock unlock]; -} - -- (BOOL)tryLock -{ - return [nsLock tryLock]; -} - -- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex -{ - printf("buttonIndex=%d\n", buttonIndex); - - if(buttonIndex == 0) - { - // resume - isRunning = true; - propListener((void*)self, 0,0,0); - } - - [alertView release]; -} - - --(void) dealloc -{ - UGen::shutdown(); - delete [] floatBuffer; - [nsLock release]; - [super dealloc]; -} -@end - - -//============================================================================== -class IPhoneAudioIODeviceType : public AudioIODeviceType -{ -public: - //============================================================================== - IPhoneAudioIODeviceType() - : AudioIODeviceType (T("iPhone Audio")), - hasScanned (false) - { - } - - ~IPhoneAudioIODeviceType() - { - } - - //============================================================================== - void scanForDevices() - { - } - - const StringArray getDeviceNames (const bool wantInputNames) const - { - StringArray s; - return s; - } - - int getDefaultDeviceIndex (const bool forInput) const - { - return 0; - } - - int getIndexOfDevice (AudioIODevice* device, const bool asInput) const - { - return 0; - } - - bool hasSeparateInputsAndOutputs() const { return true; } - - AudioIODevice* createDevice (const String& outputDeviceName, - const String& inputDeviceName) - { - if (outputDeviceName.isNotEmpty() && inputDeviceName.isNotEmpty()) - return new CoreAudioIODevice (deviceName, - inputIds [inputIndex], - inputIndex, - outputIds [outputIndex], - outputIndex); - - return 0; - } - - //============================================================================== - juce_UseDebuggingNewOperator - -private: - IPhoneAudioIODeviceType (const IPhoneAudioIODeviceType&); - const IPhoneAudioIODeviceType& operator= (const IPhoneAudioIODeviceType&); -}; - -//============================================================================== -AudioIODeviceType* juce_createAudioIODeviceType_iPhoneAudio() -{ - return new IPhoneAudioIODeviceType(); -} #endif diff --git a/src/native/mac/juce_iphone_MiscUtilities.mm b/src/native/mac/juce_iphone_MiscUtilities.mm index 1b7cb0204b..b3cf7e8332 100644 --- a/src/native/mac/juce_iphone_MiscUtilities.mm +++ b/src/native/mac/juce_iphone_MiscUtilities.mm @@ -108,7 +108,7 @@ bool AlertWindow::showNativeDialogBox (const String& title, otherButtonTitles: (isOkCancel ? @"Cancel" : nil), nil] autorelease]; alert.cancelButtonIndex = alert.firstOtherButtonIndex; [alert show]; - + // xxx need to use a delegate to find which button was clicked return false; } diff --git a/src/native/mac/juce_iphone_UIViewComponentPeer.mm b/src/native/mac/juce_iphone_UIViewComponentPeer.mm index 593ba27957..37ce36f1c2 100644 --- a/src/native/mac/juce_iphone_UIViewComponentPeer.mm +++ b/src/native/mac/juce_iphone_UIViewComponentPeer.mm @@ -189,12 +189,12 @@ static int64 getMouseTime (UIEvent* e) { return (int64) [e timestamp] * 1000.0; //============================================================================== - (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event { - NSArray* const t = [[event touchesForView: self] allObjects]; + NSArray* const t = [[event touchesForView: self] allObjects]; - switch ([t count]) - { - case 1: // One finger.. - { + switch ([t count]) + { + case 1: // One finger.. + { CGPoint p = [[t objectAtIndex: 0] locationInView: self]; currentModifiers |= getModifierForButtonNumber (0); @@ -209,12 +209,12 @@ static int64 getMouseTime (UIEvent* e) { return (int64) [e timestamp] * 1000.0; - (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event { - NSArray* const t = [[event touchesForView: self] allObjects]; + NSArray* const t = [[event touchesForView: self] allObjects]; - switch ([t count]) - { - case 1: // One finger.. - { + switch ([t count]) + { + case 1: // One finger.. + { CGPoint p = [[t objectAtIndex: 0] locationInView: self]; owner->handleMouseDrag (p.x, p.y, getMouseTime (event)); } @@ -227,12 +227,12 @@ static int64 getMouseTime (UIEvent* e) { return (int64) [e timestamp] * 1000.0; - (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event { - NSArray* const t = [[event touchesForView: self] allObjects]; + NSArray* const t = [[event touchesForView: self] allObjects]; - switch ([t count]) - { - case 1: // One finger.. - { + switch ([t count]) + { + case 1: // One finger.. + { CGPoint p = [[t objectAtIndex: 0] locationInView: self]; const int oldMods = currentModifiers; currentModifiers &= ~getModifierForButtonNumber (0); @@ -312,9 +312,9 @@ public: lineStride, pixelStride); CGDataProviderRef provider = CGDataProviderCreateWithData (0, imageData, lineStride * pixelStride, 0); - - imageRef = CGImageCreate (width, height, - 8, pixelStride * 8, lineStride, + + imageRef = CGImageCreate (width, height, + 8, pixelStride * 8, lineStride, CGColorSpaceCreateDeviceRGB(), hasAlpha ? (kCGImageAlphaFirst | kCGBitmapByteOrder32Little) : kCGBitmapByteOrderDefault, provider, @@ -322,7 +322,7 @@ public: true, kCGRenderingIntentDefault); juceImage.releasePixelDataReadWrite (imageData); - + uiImage = [[UIImage imageWithCGImage: imageRef] retain]; } @@ -360,7 +360,7 @@ public: if (juceImage.hasAlphaChannel()) swapRGBOrder (0, 0, juceImage.getWidth(), juceImage.getHeight());*/ - + } private: @@ -793,7 +793,7 @@ void UIViewComponentPeer::drawRect (CGRect r) return; DBG (Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height).toString()); - + const float y = r.origin.y;//[view frame].size.height - (r.origin.y + r.size.height); JuceUIImage temp ((int) (r.size.width + 0.5f), @@ -806,7 +806,7 @@ void UIViewComponentPeer::drawRect (CGRect r) context.setOrigin (originX, originY); handlePaint (context); - + //CGContextClipToRect (UIGraphicsGetCurrentContext(), r); temp.draw (r.origin.x, r.origin.y); } diff --git a/src/native/mac/juce_mac_FileChooser.mm b/src/native/mac/juce_mac_FileChooser.mm index d4de6b4db6..781bcb4ba5 100644 --- a/src/native/mac/juce_mac_FileChooser.mm +++ b/src/native/mac/juce_mac_FileChooser.mm @@ -163,7 +163,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, FilePreviewComponent* extraInfoComponent) { const ScopedAutoReleasePool pool; - + jassertfalse //xxx to do } diff --git a/src/native/mac/juce_mac_Files.mm b/src/native/mac/juce_mac_Files.mm index 606ac878e7..79e2dac613 100644 --- a/src/native/mac/juce_mac_Files.mm +++ b/src/native/mac/juce_mac_Files.mm @@ -301,7 +301,7 @@ const File File::getLinkedTarget() const throw() #else NSString* dest = [[NSFileManager defaultManager] pathContentOfSymbolicLinkAtPath: juceStringToNS (getFullPathName())]; #endif - + if (dest != nil) return File (nsStringToJuce (dest)); @@ -348,7 +348,7 @@ bool juce_findFileNext (void* handle, String& resultFile, [ff->enumerator skipDescendents]; resultFile = nsStringToJuce (file); - + const String path (ff->parentDir + resultFile); if (isDir != 0 || fileSize != 0) @@ -380,7 +380,7 @@ bool juce_findFileNext (void* handle, String& resultFile, if (isReadOnly != 0) *isReadOnly = ! juce_canWriteToFile (path); - + return true; } @@ -507,7 +507,7 @@ const String PlatformUtilities::makePathFromFSRef (FSRef* file) OSType PlatformUtilities::getTypeOfFile (const String& filename) { const ScopedAutoReleasePool pool; - + #if JUCE_IPHONE || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (filename) error: nil]; #else diff --git a/src/native/mac/juce_mac_ObjCSuffix.h b/src/native/mac/juce_mac_ObjCSuffix.h index 64e8b3a55f..6cc3d6bdb8 100644 --- a/src/native/mac/juce_mac_ObjCSuffix.h +++ b/src/native/mac/juce_mac_ObjCSuffix.h @@ -23,7 +23,6 @@ ============================================================================== */ - /** This suffix is used for naming all Obj-C classes that are used inside juce. Because of the flat naming structure used by Obj-C, you can get horrible situations where