Browse Source

added a CD-eject method for the mac; fixed a small CoreAudio bug; sorted out some minor message loop problems on the mac and windows; added a PlatformUtilities method to add an item to the OSX dock.

tags/2021-05-28
jules 16 years ago
parent
commit
da340b4d2f
12 changed files with 129 additions and 14 deletions
  1. +9
    -0
      build/macosx/platform_specific_code/juce_mac_AudioCDBurner.mm
  2. +1
    -4
      build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp
  3. +1
    -1
      build/macosx/platform_specific_code/juce_mac_MessageManager.mm
  4. +16
    -0
      build/macosx/platform_specific_code/juce_mac_MiscUtilities.mm
  5. +1
    -0
      build/macosx/platform_specific_code/juce_mac_NativeCode.mm
  6. +20
    -0
      build/macosx/platform_specific_code/juce_posix_SharedCode.h
  7. +67
    -7
      juce_amalgamated.cpp
  8. +2
    -0
      juce_amalgamated.h
  9. +7
    -1
      src/juce_appframework/events/juce_MessageManager.cpp
  10. +1
    -1
      src/juce_appframework/gui/components/controls/juce_Label.cpp
  11. +2
    -0
      src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp
  12. +2
    -0
      src/juce_core/misc/juce_PlatformUtilities.h

+ 9
- 0
build/macosx/platform_specific_code/juce_mac_AudioCDBurner.mm View File

@@ -431,4 +431,13 @@ const String AudioCDBurner::burn (JUCE_NAMESPACE::AudioCDBurner::BurnProgressLis
return error;
}
//==============================================================================
void AudioCDReader::ejectDisk()
{
const ScopedAutoReleasePool p;
[[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath: juceStringToNS (volumeDir.getFullPathName())];
}
#endif

+ 1
- 4
build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp View File

@@ -166,7 +166,6 @@ public:
{
if (activeInputChans[chanNum])
{
inputChannelInfo [activeChans].sourceChannelNum = chanNum;
inputChannelInfo [activeChans].streamNum = i;
inputChannelInfo [activeChans].dataOffsetSamples = j;
inputChannelInfo [activeChans].dataStrideSamples = b.mNumberChannels;
@@ -180,7 +179,6 @@ public:
{
if (activeOutputChans[chanNum])
{
outputChannelInfo [activeChans].sourceChannelNum = chanNum;
outputChannelInfo [activeChans].streamNum = i;
outputChannelInfo [activeChans].dataOffsetSamples = j;
outputChannelInfo [activeChans].dataStrideSamples = b.mNumberChannels;
@@ -583,7 +581,7 @@ public:
for (i = numInputChans; --i >= 0;)
{
const CallbackDetailsForChannel& info = inputChannelInfo[i];
float* dest = tempInputBuffers [info.sourceChannelNum];
float* dest = tempInputBuffers [i];
const float* src = ((const float*) inInputData->mBuffers[info.streamNum].mData)
+ info.dataOffsetSamples;
const int stride = info.dataStrideSamples;
@@ -755,7 +753,6 @@ private:
struct CallbackDetailsForChannel
{
int sourceChannelNum;
int streamNum;
int dataOffsetSamples;
int dataStrideSamples;


+ 1
- 1
build/macosx/platform_specific_code/juce_mac_MessageManager.mm View File

@@ -279,7 +279,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor;
NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001];
while (Time::getMillisecondCounter() < endTime)
while (Time::getMillisecondCounter() < endTime && ! quitMessagePosted)
{
const ScopedAutoReleasePool pool;


+ 16
- 0
build/macosx/platform_specific_code/juce_mac_MiscUtilities.mm View File

@@ -51,6 +51,21 @@ void PlatformUtilities::beep()
NSBeep();
}
//==============================================================================
void PlatformUtilities::addItemToDock (const File& file)
{
// check that it's not already there...
if (! juce_getOutputFromCommand ("defaults read com.apple.dock persistent-apps")
.containsIgnoreCase (file.getFullPathName()))
{
juce_runSystemCommand ("defaults write com.apple.dock persistent-apps -array-add \"<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>"
+ file.getFullPathName() + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>\"");
juce_runSystemCommand ("osascript -e \"tell application \\\"Dock\\\" to quit\"");
}
}
//==============================================================================
#if ! JUCE_ONLY_BUILD_CORE_LIBRARY
@@ -243,6 +258,7 @@ void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords, const bool c
jassert (monitorCoords.size() > 0);
}
#endif
#endif

+ 1
- 0
build/macosx/platform_specific_code/juce_mac_NativeCode.mm View File

@@ -70,6 +70,7 @@ BEGIN_JUCE_NAMESPACE
#include "../../../src/juce_appframework/gui/components/special/juce_WebBrowserComponent.h"
#include "../../../src/juce_appframework/gui/components/filebrowser/juce_FileChooser.h"
#include "../../../src/juce_appframework/audio/audio_file_formats/juce_AudioCDBurner.h"
#include "../../../src/juce_appframework/audio/audio_file_formats/juce_AudioCDReader.h"
#include "../../../src/juce_appframework/audio/audio_sources/juce_AudioSource.h"
#include "../../../src/juce_appframework/audio/dsp/juce_AudioDataConverters.h"
#include "../../../src/juce_appframework/audio/devices/juce_AudioIODeviceType.h"


+ 20
- 0
build/macosx/platform_specific_code/juce_posix_SharedCode.h View File

@@ -390,6 +390,26 @@ const String juce_getVolumeLabel (const String& filenameOnVolume,
return String::empty;
}
//==============================================================================
void juce_runSystemCommand (const String& command)
{
system ((const char*) command.toUTF8());
}
const String juce_getOutputFromCommand (const String& command)
{
// slight bodge here, as we just pipe the output into a temp file and read it...
const File tempFile (File::getSpecialLocation (File::tempDirectory)
.getNonexistentChildFile (String::toHexString (Random::getSystemRandom().nextInt()), ".tmp", false));
juce_runSystemCommand (command + " > " + tempFile.getFullPathName());
String result (tempFile.loadFileAsString());
tempFile.deleteFile();
return result;
}
//==============================================================================
#if JUCE_64BIT
#define filedesc ((long long) internal)


+ 67
- 7
juce_amalgamated.cpp View File

@@ -36933,7 +36933,13 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
{
JUCE_TRY
{
juce_dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0);
if (! juce_dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0))
{
const int msToWait = (int) (endTime - Time::currentTimeMillis());

if (msToWait > 0)
Thread::sleep (jmin (5, msToWait));
}
}
JUCE_CATCH_EXCEPTION
}
@@ -43768,7 +43774,7 @@ void Label::showEditor()
if (editor == 0)
{
addAndMakeVisible (editor = createEditorComponent());
editor->setText (getText());
editor->setText (getText(), false);
editor->addListener (this);
editor->grabKeyboardFocus();
editor->setHighlightedRegion (0, text.length());
@@ -60972,8 +60978,10 @@ void LookAndFeel::drawPopupMenuBackground (Graphics& g, int width, int height)
for (int i = 0; i < height; i += 3)
g.fillRect (0, i, width, 1);

#if ! JUCE_MAC
g.setColour (findColour (PopupMenu::textColourId).withAlpha (0.6f));
g.drawRect (0, 0, width, height);
#endif
}

void LookAndFeel::drawPopupMenuUpDownArrow (Graphics& g,
@@ -255314,6 +255322,24 @@ const String juce_getVolumeLabel (const String& filenameOnVolume,
return String::empty;
}

void juce_runSystemCommand (const String& command)
{
system ((const char*) command.toUTF8());
}

const String juce_getOutputFromCommand (const String& command)
{
// slight bodge here, as we just pipe the output into a temp file and read it...
const File tempFile (File::getSpecialLocation (File::tempDirectory)
.getNonexistentChildFile (String::toHexString (Random::getSystemRandom().nextInt()), ".tmp", false));

juce_runSystemCommand (command + " > " + tempFile.getFullPathName());

String result (tempFile.loadFileAsString());
tempFile.deleteFile();
return result;
}

#if JUCE_64BIT
#define filedesc ((long long) internal)
#else
@@ -265350,6 +265376,24 @@ const String juce_getVolumeLabel (const String& filenameOnVolume,
return String::empty;
}

void juce_runSystemCommand (const String& command)
{
system ((const char*) command.toUTF8());
}

const String juce_getOutputFromCommand (const String& command)
{
// slight bodge here, as we just pipe the output into a temp file and read it...
const File tempFile (File::getSpecialLocation (File::tempDirectory)
.getNonexistentChildFile (String::toHexString (Random::getSystemRandom().nextInt()), ".tmp", false));

juce_runSystemCommand (command + " > " + tempFile.getFullPathName());

String result (tempFile.loadFileAsString());
tempFile.deleteFile();
return result;
}

#if JUCE_64BIT
#define filedesc ((long long) internal)
#else
@@ -266036,6 +266080,19 @@ void PlatformUtilities::beep()
NSBeep();
}

void PlatformUtilities::addItemToDock (const File& file)
{
// check that it's not already there...
if (! juce_getOutputFromCommand ("defaults read com.apple.dock persistent-apps")
.containsIgnoreCase (file.getFullPathName()))
{
juce_runSystemCommand ("defaults write com.apple.dock persistent-apps -array-add \"<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>"
+ file.getFullPathName() + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>\"");

juce_runSystemCommand ("osascript -e \"tell application \\\"Dock\\\" to quit\"");
}
}

#if ! JUCE_ONLY_BUILD_CORE_LIBRARY

bool AlertWindow::showNativeDialogBox (const String& title,
@@ -269801,6 +269858,12 @@ const String AudioCDBurner::burn (JUCE_NAMESPACE::AudioCDBurner::BurnProgressLis
return error;
}

void AudioCDReader::ejectDisk()
{
const ScopedAutoReleasePool p;
[[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath: juceStringToNS (volumeDir.getFullPathName())];
}

#endif
/********* End of inlined file: juce_mac_AudioCDBurner.mm *********/

@@ -270378,7 +270441,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor;
NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001];

while (Time::getMillisecondCounter() < endTime)
while (Time::getMillisecondCounter() < endTime && ! quitMessagePosted)
{
const ScopedAutoReleasePool pool;

@@ -270850,7 +270913,6 @@ public:
{
if (activeInputChans[chanNum])
{
inputChannelInfo [activeChans].sourceChannelNum = chanNum;
inputChannelInfo [activeChans].streamNum = i;
inputChannelInfo [activeChans].dataOffsetSamples = j;
inputChannelInfo [activeChans].dataStrideSamples = b.mNumberChannels;
@@ -270864,7 +270926,6 @@ public:
{
if (activeOutputChans[chanNum])
{
outputChannelInfo [activeChans].sourceChannelNum = chanNum;
outputChannelInfo [activeChans].streamNum = i;
outputChannelInfo [activeChans].dataOffsetSamples = j;
outputChannelInfo [activeChans].dataStrideSamples = b.mNumberChannels;
@@ -271265,7 +271326,7 @@ public:
for (i = numInputChans; --i >= 0;)
{
const CallbackDetailsForChannel& info = inputChannelInfo[i];
float* dest = tempInputBuffers [info.sourceChannelNum];
float* dest = tempInputBuffers [i];
const float* src = ((const float*) inInputData->mBuffers[info.streamNum].mData)
+ info.dataOffsetSamples;
const int stride = info.dataStrideSamples;
@@ -271436,7 +271497,6 @@ private:

struct CallbackDetailsForChannel
{
int sourceChannelNum;
int streamNum;
int dataOffsetSamples;
int dataStrideSamples;


+ 2
- 0
juce_amalgamated.h View File

@@ -13121,6 +13121,8 @@ public:
/** MAC ONLY - Returns true if this file is actually a bundle. */
static bool isBundle (const String& filename);

/** MAC ONLY - Adds an item to the dock */
static void addItemToDock (const File& file);
#endif

#if JUCE_WIN32 || DOXYGEN


+ 7
- 1
src/juce_appframework/events/juce_MessageManager.cpp View File

@@ -163,7 +163,13 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
{
JUCE_TRY
{
juce_dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0);
if (! juce_dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0))
{
const int msToWait = (int) (endTime - Time::currentTimeMillis());
if (msToWait > 0)
Thread::sleep (jmin (5, msToWait));
}
}
JUCE_CATCH_EXCEPTION
}


+ 1
- 1
src/juce_appframework/gui/components/controls/juce_Label.cpp View File

@@ -203,7 +203,7 @@ void Label::showEditor()
if (editor == 0)
{
addAndMakeVisible (editor = createEditorComponent());
editor->setText (getText());
editor->setText (getText(), false);
editor->addListener (this);
editor->grabKeyboardFocus();
editor->setHighlightedRegion (0, text.length());


+ 2
- 0
src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp View File

@@ -961,8 +961,10 @@ void LookAndFeel::drawPopupMenuBackground (Graphics& g, int width, int height)
for (int i = 0; i < height; i += 3)
g.fillRect (0, i, width, 1);
#if ! JUCE_MAC
g.setColour (findColour (PopupMenu::textColourId).withAlpha (0.6f));
g.drawRect (0, 0, width, height);
#endif
}
void LookAndFeel::drawPopupMenuUpDownArrow (Graphics& g,


+ 2
- 0
src/juce_core/misc/juce_PlatformUtilities.h View File

@@ -77,6 +77,8 @@ public:
/** MAC ONLY - Returns true if this file is actually a bundle. */
static bool isBundle (const String& filename);
/** MAC ONLY - Adds an item to the dock */
static void addItemToDock (const File& file);
#endif


Loading…
Cancel
Save