1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

misc optimisations

This commit is contained in:
jules 2007-06-18 09:56:58 +00:00
parent f87ef700f9
commit 38aa8c42a9
27 changed files with 189 additions and 206 deletions

View file

@ -199,7 +199,7 @@ public:
if (bitDepth == 0) if (bitDepth == 0)
{ {
error = T("device doesn't support a compatible PCM format"); error = "device doesn't support a compatible PCM format";
DBG (T("ALSA error: ") + error + T("\n")); DBG (T("ALSA error: ") + error + T("\n"));
return false; return false;
} }
@ -353,7 +353,7 @@ class ALSAThread : public Thread
{ {
public: public:
ALSAThread (const String& deviceName_) ALSAThread (const String& deviceName_)
: Thread (T("Juce ALSA")), : Thread ("Juce ALSA"),
sampleRate (0), sampleRate (0),
bufferSize (0), bufferSize (0),
deviceName (deviceName_), deviceName (deviceName_),
@ -457,7 +457,7 @@ public:
if (outputDevice == 0 && inputDevice == 0) if (outputDevice == 0 && inputDevice == 0)
{ {
error = T("no channels"); error = "no channels";
return; return;
} }
@ -482,7 +482,7 @@ public:
if (--count < 0 || ! isThreadRunning()) if (--count < 0 || ! isThreadRunning())
{ {
error = T("device didn't start"); error = "device didn't start";
break; break;
} }
} }
@ -528,7 +528,7 @@ public:
if (! inputDevice->read (inputChannelData, bufferSize)) if (! inputDevice->read (inputChannelData, bufferSize))
{ {
DBG (T("ALSA: read failure")); DBG ("ALSA: read failure");
break; break;
} }
} }
@ -567,7 +567,7 @@ public:
jassert (numChannelsRunning >= outputDevice->numChannelsRunning); jassert (numChannelsRunning >= outputDevice->numChannelsRunning);
if (! outputDevice->write (outputChannelData, bufferSize)) if (! outputDevice->write (outputChannelData, bufferSize))
{ {
DBG (T("ALSA: write failure")); DBG ("ALSA: write failure");
break; break;
} }
} }
@ -858,7 +858,7 @@ public:
break; break;
String id, name; String id, name;
id << T("hw:") << cardId << T(",") << device; id << "hw:" << cardId << ',' << device;
if (testDevice (id)) if (testDevice (id))
{ {
@ -868,7 +868,7 @@ public:
name = id; name = id;
if (device > 0) if (device > 0)
name << T(" (") << (device + 1) << T(")"); name << " (" << (device + 1) << ')';
ids.add (id); ids.add (id);
names.add (name); names.add (name);

View file

@ -374,23 +374,23 @@ const File File::getSpecialLocation (const SpecialLocationType type)
} }
case userDocumentsDirectory: case userDocumentsDirectory:
return File (T("~")); return File ("~");
case userDesktopDirectory: case userDesktopDirectory:
return File (T("~/Desktop")); return File ("~/Desktop");
case userApplicationDataDirectory: case userApplicationDataDirectory:
return File (T("~")); return File ("~");
case commonApplicationDataDirectory: case commonApplicationDataDirectory:
return File (T("/var")); return File ("/var");
case globalApplicationsDirectory: case globalApplicationsDirectory:
return File (T("/usr")); return File ("/usr");
case tempDirectory: case tempDirectory:
{ {
File tmp (T("/var/tmp")); File tmp ("/var/tmp");
if (! tmp.isDirectory()) if (! tmp.isDirectory())
{ {

View file

@ -130,7 +130,7 @@ public:
if (fontDirs.size() == 0) if (fontDirs.size() == 0)
{ {
XmlDocument fontsConfig (File (T("/etc/fonts/fonts.conf"))); XmlDocument fontsConfig (File ("/etc/fonts/fonts.conf"));
XmlElement* const fontsInfo = fontsConfig.getDocumentElement(); XmlElement* const fontsInfo = fontsConfig.getDocumentElement();
if (fontsInfo != 0) if (fontsInfo != 0)
@ -145,7 +145,7 @@ public:
} }
if (fontDirs.size() == 0) if (fontDirs.size() == 0)
fontDirs.add (T("/usr/X11R6/lib/X11/fonts")); fontDirs.add ("/usr/X11R6/lib/X11/fonts");
for (int i = 0; i < fontDirs.size(); ++i) for (int i = 0; i < fontDirs.size(); ++i)
enumerateFaces (fontDirs[i]); enumerateFaces (fontDirs[i]);

View file

@ -183,7 +183,7 @@ void MessageManager::doPlatformSpecificInitialisation()
if (! XInitThreads()) if (! XInitThreads())
{ {
// This is fatal! Print error and closedown // This is fatal! Print error and closedown
Logger::outputDebugString (T("Failed to initialise xlib thread support.")); Logger::outputDebugString ("Failed to initialise xlib thread support.");
if (juce_isRunningAsApplication()) if (juce_isRunningAsApplication())
Process::terminate(); Process::terminate();

View file

@ -412,7 +412,7 @@ public:
int bufferSizeSamples) int bufferSizeSamples)
{ {
error = String::empty; error = String::empty;
log (T("CoreAudio reopen")); log ("CoreAudio reopen");
callbacksAllowed = false; callbacksAllowed = false;
stopTimer(); stopTimer();
@ -449,13 +449,13 @@ public:
} }
if (i < 0) if (i < 0)
error = T("Couldn't change sample rate/buffer size"); error = "Couldn't change sample rate/buffer size";
if (sampleRates.size() == 0) if (sampleRates.size() == 0)
error = T("Device has no available sample-rates"); error = "Device has no available sample-rates";
if (bufferSizes.size() == 0) if (bufferSizes.size() == 0)
error = T("Device has no available buffer-sizes"); error = "Device has no available buffer-sizes";
numInputChans = jmin (numInputChans, numInputChannelInfos); numInputChans = jmin (numInputChans, numInputChannelInfos);
numOutputChans = jmin (numOutputChans, numOutputChannelInfos); numOutputChans = jmin (numOutputChans, numOutputChannelInfos);
@ -652,7 +652,7 @@ public:
void timerCallback() void timerCallback()
{ {
stopTimer(); stopTimer();
log (T("CoreAudio device changed callback")); log ("CoreAudio device changed callback");
const double oldSampleRate = sampleRate; const double oldSampleRate = sampleRate;
const int oldBufferSize = bufferSize; const int oldBufferSize = bufferSize;
@ -824,7 +824,7 @@ class CoreAudioIODevice : public AudioIODevice
public: public:
CoreAudioIODevice (const String& deviceName, CoreAudioIODevice (const String& deviceName,
AudioDeviceID deviceId1) AudioDeviceID deviceId1)
: AudioIODevice (deviceName, T("CoreAudio")), : AudioIODevice (deviceName, "CoreAudio"),
isOpen_ (false), isOpen_ (false),
isStarted (false) isStarted (false)
{ {

View file

@ -205,13 +205,13 @@ const StringArray MidiOutput::getDevices()
String name (getConnectedEndpointName (dest)); String name (getConnectedEndpointName (dest));
if (name.isEmpty()) if (name.isEmpty())
name = T("<error>"); name = "<error>";
s.add (name); s.add (name);
} }
else else
{ {
s.add (T("<error>")); s.add ("<error>");
} }
} }
@ -351,13 +351,13 @@ const StringArray MidiInput::getDevices()
String name (getConnectedEndpointName (source)); String name (getConnectedEndpointName (source));
if (name.isEmpty()) if (name.isEmpty())
name = T("<error>"); name = "<error>";
s.add (name); s.add (name);
} }
else else
{ {
s.add (T("<error>")); s.add ("<error>");
} }
} }

View file

@ -629,19 +629,19 @@ const File File::getSpecialLocation (const SpecialLocationType type)
} }
case userDocumentsDirectory: case userDocumentsDirectory:
return File (T("~/Documents")); return File ("~/Documents");
case userDesktopDirectory: case userDesktopDirectory:
return File (T("~/Desktop")); return File ("~/Desktop");
case userApplicationDataDirectory: case userApplicationDataDirectory:
return File (T("~/Library")); return File ("~/Library");
case commonApplicationDataDirectory: case commonApplicationDataDirectory:
return File (T("/Library")); return File ("/Library");
case globalApplicationsDirectory: case globalApplicationsDirectory:
return File (T("/Applications")); return File ("/Applications");
case tempDirectory: case tempDirectory:
{ {

View file

@ -520,9 +520,9 @@ const StringArray Font::findAllTypefaceNames()
void Font::getDefaultFontNames (String& defaultSans, String& defaultSerif, String& defaultFixed) void Font::getDefaultFontNames (String& defaultSans, String& defaultSerif, String& defaultFixed)
{ {
defaultSans = T("Lucida Grande"); defaultSans = "Lucida Grande";
defaultSerif = T("Times New Roman"); defaultSerif = "Times New Roman";
defaultFixed = T("Monaco"); defaultFixed = "Monaco";
} }

View file

@ -198,12 +198,12 @@ private:
const String& optionalPostText, const String& optionalPostText,
const bool isPost) const bool isPost)
{ {
String header (isPost ? T("POST ") : T("GET ")); String header (isPost ? "POST " : "GET ");
if (proxyURL.isEmpty()) if (proxyURL.isEmpty())
{ {
header << hostPath << T(" HTTP/1.1\r\nHost: ") header << hostPath << " HTTP/1.1\r\nHost: "
<< hostName << ":" << hostPort; << hostName << ':' << hostPort;
} }
else else
{ {
@ -213,8 +213,8 @@ private:
if (! decomposeURL (proxyURL, proxyName, proxyPath, proxyPort)) if (! decomposeURL (proxyURL, proxyName, proxyPath, proxyPort))
return String::empty; return String::empty;
header << originalURL << T(" HTTP/1.1\r\nHost: ") header << originalURL << " HTTP/1.1\r\nHost: "
<< proxyName << T(":") << proxyPort; << proxyName << ':' << proxyPort;
/* xxx needs finishing /* xxx needs finishing
const char* proxyAuth = getenv ("http_proxy_auth"); const char* proxyAuth = getenv ("http_proxy_auth");
@ -223,20 +223,20 @@ private:
*/ */
} }
header << T("\r\nUser-Agent: JUCE/") header << "\r\nUser-Agent: JUCE/"
<< JUCE_MAJOR_VERSION << T('.') << JUCE_MINOR_VERSION << JUCE_MAJOR_VERSION << '.' << JUCE_MINOR_VERSION
<< T("\r\nConnection: Close\r\n"); << "\r\nConnection: Close\r\n";
if (isPost && optionalPostText.isNotEmpty()) if (isPost && optionalPostText.isNotEmpty())
{ {
const char* const postTextUTF8 = (const char*) optionalPostText.toUTF8(); const char* const postTextUTF8 = (const char*) optionalPostText.toUTF8();
header << T("Content-type: application/x-www-form-urlencoded\r\nContent-length: ") header << "Content-type: application/x-www-form-urlencoded\r\nContent-length: "
<< (int) strlen (postTextUTF8) << T("\r\n\r\n") << (int) strlen (postTextUTF8) << "\r\n\r\n"
<< optionalPostText; << optionalPostText;
} }
header << T("\r\n"); header << "\r\n";
//DBG (header); //DBG (header);
return header; return header;
} }

View file

@ -87,22 +87,22 @@ BEGIN_JUCE_NAMESPACE
#ifdef ASIO_DEBUGGING #ifdef ASIO_DEBUGGING
static void logError (const String& context, long error) static void logError (const String& context, long error)
{ {
String err (T("unknown error")); String err ("unknown error");
if (error == ASE_NotPresent) if (error == ASE_NotPresent)
err = T("Not Present"); err = "Not Present";
else if (error == ASE_HWMalfunction) else if (error == ASE_HWMalfunction)
err = T("Hardware Malfunction"); err = "Hardware Malfunction";
else if (error == ASE_InvalidParameter) else if (error == ASE_InvalidParameter)
err = T("Invalid Parameter"); err = "Invalid Parameter";
else if (error == ASE_InvalidMode) else if (error == ASE_InvalidMode)
err = T("Invalid Mode"); err = "Invalid Mode";
else if (error == ASE_SPNotAdvancing) else if (error == ASE_SPNotAdvancing)
err = T("Sample position not advancing"); err = "Sample position not advancing";
else if (error == ASE_NoClock) else if (error == ASE_NoClock)
err = T("No Clock"); err = "No Clock";
else if (error == ASE_NoMemory) else if (error == ASE_NoMemory)
err = T("Out of memory"); err = "Out of memory";
log (T("!!error: ") + context + T(" - ") + err); log (T("!!error: ") + context + T(" - ") + err);
} }
@ -163,7 +163,7 @@ public:
currentASIODev = 0; currentASIODev = 0;
close(); close();
log (T("ASIO - exiting")); log ("ASIO - exiting");
removeCurrentDriver(); removeCurrentDriver();
juce_free (tempBuffer); juce_free (tempBuffer);
@ -259,7 +259,7 @@ public:
if (asioObject == 0 || ! isASIOOpen) if (asioObject == 0 || ! isASIOOpen)
{ {
log (T("Warning: device not open")); log ("Warning: device not open");
const String err (openDevice()); const String err (openDevice());
if (asioObject == 0 || ! isASIOOpen) if (asioObject == 0 || ! isASIOOpen)
@ -293,7 +293,7 @@ public:
if (shouldUsePreferredSize) if (shouldUsePreferredSize)
{ {
log (T("Using preferred size for buffer..")); log ("Using preferred size for buffer..");
if ((err = asioObject->getBufferSize (&minSize, &maxSize, &preferredSize, &granularity)) == 0) if ((err = asioObject->getBufferSize (&minSize, &maxSize, &preferredSize, &granularity)) == 0)
{ {
@ -302,7 +302,7 @@ public:
else else
{ {
bufferSizeSamples = 1024; bufferSizeSamples = 1024;
logError (T("GetBufferSize1"), err); logError ("GetBufferSize1", err);
} }
shouldUsePreferredSize = false; shouldUsePreferredSize = false;
@ -333,13 +333,13 @@ public:
int i; int i;
for (i = 0; i < numSources; ++i) for (i = 0; i < numSources; ++i)
{ {
String s (T("clock: ")); String s ("clock: ");
s += clocks[i].name; s += clocks[i].name;
if (clocks[i].isCurrentSource) if (clocks[i].isCurrentSource)
{ {
isSourceSet = true; isSourceSet = true;
s += T(" (cur)"); s << " (cur)";
} }
log (s); log (s);
@ -347,7 +347,7 @@ public:
if (numSources > 1 && ! isSourceSet) if (numSources > 1 && ! isSourceSet)
{ {
log (T("setting clock source")); log ("setting clock source");
asioObject->setClockSource (clocks[0].index); asioObject->setClockSource (clocks[0].index);
Thread::sleep (20); Thread::sleep (20);
} }
@ -355,7 +355,7 @@ public:
{ {
if (numSources == 0) if (numSources == 0)
{ {
log (T("ASIO - no clock sources!")); log ("ASIO - no clock sources!");
} }
} }
@ -367,7 +367,7 @@ public:
} }
else else
{ {
logError (T("GetSampleRate"), err); logError ("GetSampleRate", err);
currentSampleRate = 0; currentSampleRate = 0;
} }
@ -384,12 +384,12 @@ public:
if (err == ASE_NoClock && numSources > 0) if (err == ASE_NoClock && numSources > 0)
{ {
log (T("trying to set a clock source..")); log ("trying to set a clock source..");
Thread::sleep (10); Thread::sleep (10);
err = asioObject->setClockSource (clocks[0].index); err = asioObject->setClockSource (clocks[0].index);
if (err != 0) if (err != 0)
{ {
logError (T("SetClock"), err); logError ("SetClock", err);
} }
Thread::sleep (10); Thread::sleep (10);
@ -405,10 +405,10 @@ public:
{ {
if (isReSync) if (isReSync)
{ {
log (T("Resync request")); log ("Resync request");
} }
log (T("! Resetting ASIO after sample rate change")); log ("! Resetting ASIO after sample rate change");
removeCurrentDriver(); removeCurrentDriver();
loadDriver(); loadDriver();
@ -459,7 +459,7 @@ public:
callbacks.asioMessage = &asioMessagesCallback; callbacks.asioMessage = &asioMessagesCallback;
callbacks.bufferSwitchTimeInfo = &bufferSwitchTimeInfoCallback; callbacks.bufferSwitchTimeInfo = &bufferSwitchTimeInfoCallback;
log (T("disposing buffers")); log ("disposing buffers");
err = asioObject->disposeBuffers(); err = asioObject->disposeBuffers();
log (T("creating buffers: ") + String (totalBuffers) + T(", ") + String (currentBlockSizeSamples)); log (T("creating buffers: ") + String (totalBuffers) + T(", ") + String (currentBlockSizeSamples));
@ -471,7 +471,7 @@ public:
if (err != 0) if (err != 0)
{ {
currentBlockSizeSamples = preferredSize; currentBlockSizeSamples = preferredSize;
logError (T("create buffers 2"), err); logError ("create buffers 2", err);
asioObject->disposeBuffers(); asioObject->disposeBuffers();
err = asioObject->createBuffers (bufferInfos, err = asioObject->createBuffers (bufferInfos,
@ -567,7 +567,7 @@ public:
if (bufferInfos[n].buffers[0] == 0 if (bufferInfos[n].buffers[0] == 0
|| bufferInfos[n].buffers[1] == 0) || bufferInfos[n].buffers[1] == 0)
{ {
log (T("!! Null buffers")); log ("!! Null buffers");
} }
else else
{ {
@ -585,7 +585,7 @@ public:
if (asioObject->getLatencies (&inputLatency, &outputLatency) != 0) if (asioObject->getLatencies (&inputLatency, &outputLatency) != 0)
{ {
log (T("ASIO - no latencies")); log ("ASIO - no latencies");
} }
else else
{ {
@ -610,11 +610,11 @@ public:
if (isUsingThread && ! isThreadRunning()) if (isUsingThread && ! isThreadRunning())
{ {
error = T("Can't start thread!"); error = "Can't start thread!";
} }
else else
{ {
log (T("starting ASIO")); log ("starting ASIO");
calledback = false; calledback = false;
err = asioObject->start(); err = asioObject->start();
@ -628,10 +628,10 @@ public:
} }
isOpen_ = false; isOpen_ = false;
log (T("ASIO - stop on failure")); log ("ASIO - stop on failure");
Thread::sleep (10); Thread::sleep (10);
asioObject->stop(); asioObject->stop();
error = T("Can't start device"); error = "Can't start device";
Thread::sleep (10); Thread::sleep (10);
} }
else else
@ -644,8 +644,8 @@ public:
if (! calledback) if (! calledback)
{ {
error = T("Device didn't start correctly"); error = "Device didn't start correctly";
log (T("ASIO didn't callback - stopping..")); log ("ASIO didn't callback - stopping..");
asioObject->stop(); asioObject->stop();
} }
} }
@ -653,12 +653,12 @@ public:
} }
else else
{ {
error = T("Can't create i/o buffers"); error = "Can't create i/o buffers";
} }
} }
else else
{ {
error = T("Can't set sample rate: "); error = "Can't set sample rate: ";
error << sampleRate; error << sampleRate;
} }
@ -703,7 +703,7 @@ public:
needToReset = false; needToReset = false;
isReSync = false; isReSync = false;
log (T("ASIO - stopping")); log ("ASIO - stopping");
if (asioObject != 0) if (asioObject != 0)
{ {
@ -795,7 +795,7 @@ public:
bool showControlPanel() bool showControlPanel()
{ {
log (T("ASIO - showing control panel")); log ("ASIO - showing control panel");
Component modalWindow (String::empty); Component modalWindow (String::empty);
modalWindow.setOpaque (true); modalWindow.setOpaque (true);
@ -847,7 +847,7 @@ public:
if (bufferIndex < 0) if (bufferIndex < 0)
{ {
log (T("! ASIO callback never called")); log ("! ASIO callback never called");
} }
} }
@ -869,7 +869,7 @@ public:
stopTimer(); stopTimer();
// used to cause a reset // used to cause a reset
log (T("! ASIO restart request!")); log ("! ASIO restart request!");
if (isOpen_) if (isOpen_)
{ {
@ -982,7 +982,7 @@ private:
return String::empty; return String::empty;
} }
return T("No Driver"); return "No Driver";
} }
const String openDevice() const String openDevice()
@ -1062,11 +1062,11 @@ private:
if (currentRate <= 0.0 || currentRate > 192001.0) if (currentRate <= 0.0 || currentRate > 192001.0)
{ {
log (T("setting sample rate")); log ("setting sample rate");
err = asioObject->setSampleRate (44100.0); err = asioObject->setSampleRate (44100.0);
if (err != 0) if (err != 0)
{ {
logError (T("setting sample rate"), err); logError ("setting sample rate", err);
} }
asioObject->getSampleRate (&currentRate); asioObject->getSampleRate (&currentRate);
@ -1077,7 +1077,7 @@ private:
postOutput = (asioObject->outputReady() == 0); postOutput = (asioObject->outputReady() == 0);
if (postOutput) if (postOutput)
{ {
log (T("ASIO outputReady = ok")); log ("ASIO outputReady = ok");
} }
updateSampleRates(); updateSampleRates();
@ -1086,11 +1086,12 @@ private:
inputLatency = outputLatency = 0; inputLatency = outputLatency = 0;
if (asioObject->getLatencies (&inputLatency, &outputLatency) != 0) if (asioObject->getLatencies (&inputLatency, &outputLatency) != 0)
{ {
log (T("ASIO - no latencies")); log ("ASIO - no latencies");
} }
log (String (T("latencies: ")) log (String ("latencies: ")
+ String ((int)inputLatency) + T(", ") + String ((int)outputLatency)); + String ((int) inputLatency)
+ T(", ") + String ((int) outputLatency));
// create some dummy buffers now.. because cubase does.. // create some dummy buffers now.. because cubase does..
numActiveInputChans = 0; numActiveInputChans = 0;
@ -1131,7 +1132,7 @@ private:
err = asioObject->createBuffers (bufferInfos, numChans, preferredSize, &callbacks); err = asioObject->createBuffers (bufferInfos, numChans, preferredSize, &callbacks);
if (err != 0) if (err != 0)
{ {
logError (T("dummy buffers"), err); logError ("dummy buffers", err);
} }
} }
@ -1197,7 +1198,7 @@ private:
if ((err = asioObject->start()) != 0) if ((err = asioObject->start()) != 0)
{ {
// ignore an error here, as it might start later after setting other stuff up // ignore an error here, as it might start later after setting other stuff up
logError (T("ASIO start"), err); logError ("ASIO start", err);
} }
Thread::sleep (100); Thread::sleep (100);
@ -1205,18 +1206,18 @@ private:
} }
else else
{ {
error = T("Can't detect buffer sizes"); error = "Can't detect buffer sizes";
} }
} }
else else
{ {
error = T("Can't detect asio channels"); error = "Can't detect asio channels";
} }
} }
} }
else else
{ {
error = T("No such device"); error = "No such device";
} }
if (error.isNotEmpty()) if (error.isNotEmpty())
@ -1232,7 +1233,7 @@ private:
else else
{ {
isASIOOpen = true; isASIOOpen = true;
log (T("ASIO device open")); log ("ASIO device open");
} }
isOpen_ = false; isOpen_ = false;
@ -1283,7 +1284,7 @@ private:
if (isReSync) if (isReSync)
{ {
log (T("! ASIO resync")); log ("! ASIO resync");
isReSync = false; isReSync = false;
} }
else else

View file

@ -228,7 +228,7 @@ static const String getDSErrorMessage (HRESULT hr)
{ {
if (hr != S_OK) if (hr != S_OK)
{ {
String error (T("DS error at line ")); String error ("DS error at line ");
error << lineNum << T(" - ") << getDSErrorMessage (hr); error << lineNum << T(" - ") << getDSErrorMessage (hr);
log (error); log (error);
} }
@ -392,7 +392,7 @@ public:
primaryDesc.dwBufferBytes = 0; primaryDesc.dwBufferBytes = 0;
primaryDesc.lpwfxFormat = 0; primaryDesc.lpwfxFormat = 0;
log (T("opening dsound out step 2")); log ("opening dsound out step 2");
hr = pDirectSound->CreateSoundBuffer (&primaryDesc, &pPrimaryBuffer, 0); hr = pDirectSound->CreateSoundBuffer (&primaryDesc, &pPrimaryBuffer, 0);
logError (hr); logError (hr);
@ -426,7 +426,7 @@ public:
if (hr == S_OK) if (hr == S_OK)
{ {
log (T("opening dsound out step 3")); log ("opening dsound out step 3");
DWORD dwDataLen; DWORD dwDataLen;
unsigned char* pDSBuffData; unsigned char* pDSBuffData;
@ -981,7 +981,7 @@ public:
DSoundAudioIODevice (const String& deviceName, DSoundAudioIODevice (const String& deviceName,
const int index, const int index,
const int inputIndex_) const int inputIndex_)
: AudioIODevice (deviceName, T("DirectSound")), : AudioIODevice (deviceName, "DirectSound"),
Thread ("Juce DSound"), Thread ("Juce DSound"),
isOpen_ (false), isOpen_ (false),
isStarted (false), isStarted (false),

View file

@ -812,7 +812,7 @@ bool NamedPipe::openInternal (const String& pipeName, const bool createPipe)
NamedPipeInternal* const intern = new NamedPipeInternal(); NamedPipeInternal* const intern = new NamedPipeInternal();
String file (T("\\\\.\\pipe\\")); String file ("\\\\.\\pipe\\");
file += pipeName; file += pipeName;
intern->createdPipe = createPipe; intern->createdPipe = createPipe;

View file

@ -136,11 +136,11 @@ void* juce_openInternetFile (const String& url,
if (request != 0) if (request != 0)
{ {
// (this header is needed to make webservers process a POST request correctly) // (this header is needed to make webservers process a POST request correctly)
const String hdr (T("Content-Type: application/x-www-form-urlencoded")); const String hdr ("Content-Type: application/x-www-form-urlencoded");
if (HttpSendRequest (request, if (HttpSendRequest (request,
hdr, hdr.length(), hdr, hdr.length(),
(void*)(const char*) postText, (void*) (const char*) postText,
postText.length())) postText.length()))
{ {
ConnectionAndRequestStruct* const result = new ConnectionAndRequestStruct(); ConnectionAndRequestStruct* const result = new ConnectionAndRequestStruct();

View file

@ -192,7 +192,7 @@ int JUCEApplication::main (String& commandLine, JUCEApplication* const app)
appInstance = 0; appInstance = 0;
commandLine = String::empty; commandLine = String::empty;
DBG (T("Another instance is running - quitting...")); DBG ("Another instance is running - quitting...");
return 0; return 0;
} }
} }

View file

@ -251,8 +251,8 @@ const File PropertiesFile::getDefaultAppSettingsFile (const String& applicationN
jassert (applicationName == File::createLegalFileName (applicationName)); jassert (applicationName == File::createLegalFileName (applicationName));
#ifdef JUCE_MAC #ifdef JUCE_MAC
File dir (commonToAllUsers ? T("/Library/Preferences") File dir (commonToAllUsers ? "/Library/Preferences"
: T("~/Library/Preferences")); : "~/Library/Preferences");
if (folderName.isNotEmpty()) if (folderName.isNotEmpty())
dir = dir.getChildFile (folderName); dir = dir.getChildFile (folderName);

View file

@ -47,11 +47,11 @@ BEGIN_JUCE_NAMESPACE
static void findCDs (OwnedArray<File>& cds) static void findCDs (OwnedArray<File>& cds)
{ {
File volumes (T("/Volumes")); File volumes ("/Volumes");
volumes.findChildFiles (cds, File::findDirectories, false); volumes.findChildFiles (cds, File::findDirectories, false);
for (int i = cds.size(); --i >= 0;) for (int i = cds.size(); --i >= 0;)
if (! cds[i]->getChildFile (T(".TOC.plist")).exists()) if (! cds[i]->getChildFile (".TOC.plist").exists())
cds.remove (i); cds.remove (i);
} }
@ -80,7 +80,7 @@ AudioCDReader* AudioCDReader::createReaderForCD (const int index)
} }
AudioCDReader::AudioCDReader (const File& volume) AudioCDReader::AudioCDReader (const File& volume)
: AudioFormatReader (0, T("CD Audio")), : AudioFormatReader (0, "CD Audio"),
volumeDir (volume), volumeDir (volume),
currentReaderTrack (-1), currentReaderTrack (-1),
reader (0) reader (0)

View file

@ -48,7 +48,7 @@ class SharedBufferingAudioSourceThread : public DeletedAtShutdown,
{ {
public: public:
SharedBufferingAudioSourceThread() SharedBufferingAudioSourceThread()
: Thread (T("Audio Buffer")), : Thread ("Audio Buffer"),
sources (8) sources (8)
{ {
} }

View file

@ -170,7 +170,7 @@ void AudioDeviceManager::addDeviceNamesToComboBox (ComboBox& combo) const
combo.addSeparator(); combo.addSeparator();
} }
combo.addItem (T("<< no audio device >>"), -1); combo.addItem ("<< no audio device >>", -1);
} }
const String AudioDeviceManager::getCurrentAudioDeviceName() const const String AudioDeviceManager::getCurrentAudioDeviceName() const
@ -256,7 +256,7 @@ const String AudioDeviceManager::setAudioDevice (const String& deviceNameToUse,
else else
{ {
deleteAndZero (currentAudioDevice); deleteAndZero (currentAudioDevice);
error << T("No such device: ") << deviceNameToUse; error << "No such device: " << deviceNameToUse;
} }
} }
else else

View file

@ -171,7 +171,7 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAs (const File& newFile,
TRANS("File already exists"), TRANS("File already exists"),
TRANS("There's already a file called:\n\n") TRANS("There's already a file called:\n\n")
+ newFile.getFullPathName() + newFile.getFullPathName()
+ T("\n\nAre you sure you want to overwrite it?"), + TRANS("\n\nAre you sure you want to overwrite it?"),
TRANS("overwrite"), TRANS("overwrite"),
TRANS("cancel"))) TRANS("cancel")))
{ {
@ -203,7 +203,7 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAs (const File& newFile,
TRANS("Error writing to file..."), TRANS("Error writing to file..."),
TRANS("An error occurred while trying to save \"") TRANS("An error occurred while trying to save \"")
+ getDocumentTitle() + getDocumentTitle()
+ T("\" to the file:\n\n") + TRANS("\" to the file:\n\n")
+ newFile.getFullPathName() + newFile.getFullPathName()
+ T("\n\n") + T("\n\n")
+ error); + error);
@ -251,7 +251,7 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAsInteractive (const bool w
String legalFilename (File::createLegalFileName (getDocumentTitle())); String legalFilename (File::createLegalFileName (getDocumentTitle()));
if (legalFilename.isEmpty()) if (legalFilename.isEmpty())
legalFilename = T("unnamed"); legalFilename = "unnamed";
if (f.existsAsFile() || f.getParentDirectory().isDirectory()) if (f.existsAsFile() || f.getParentDirectory().isDirectory())
f = f.getSiblingFile (legalFilename); f = f.getSiblingFile (legalFilename);

View file

@ -38,6 +38,7 @@ BEGIN_JUCE_NAMESPACE
#include "../../../../juce_core/basics/juce_Random.h" #include "../../../../juce_core/basics/juce_Random.h"
#include "../mouse/juce_DragAndDropContainer.h" #include "../mouse/juce_DragAndDropContainer.h"
#include "../../graphics/imaging/juce_Image.h" #include "../../graphics/imaging/juce_Image.h"
#include "../../../../juce_core/text/juce_LocalisedStrings.h"
//============================================================================== //==============================================================================
@ -290,8 +291,8 @@ public:
{ {
if (owner.isAutoSizeMenuOptionShown()) if (owner.isAutoSizeMenuOptionShown())
{ {
menu.addItem (0xf836743, T("Auto-size this column"), columnIdClicked != 0); menu.addItem (0xf836743, TRANS("Auto-size this column"), columnIdClicked != 0);
menu.addItem (0xf836744, T("Auto-size all columns"), owner.getHeader()->getNumColumns (true) > 0); menu.addItem (0xf836744, TRANS("Auto-size all columns"), owner.getHeader()->getNumColumns (true) > 0);
menu.addSeparator(); menu.addSeparator();
} }

View file

@ -60,7 +60,7 @@ FileBrowserComponent::FileBrowserComponent (FileChooserMode mode_,
mode (mode_), mode (mode_),
listeners (2), listeners (2),
previewComp (previewComp_), previewComp (previewComp_),
thread (T("Juce FileBrowser")) thread ("Juce FileBrowser")
{ {
String filename; String filename;
@ -479,7 +479,7 @@ const BitArray FileBrowserComponent::getRoots (StringArray& rootNames, StringArr
separators.setBit (rootPaths.size()); separators.setBit (rootPaths.size());
OwnedArray <File> volumes; OwnedArray <File> volumes;
File vol (T("/Volumes")); File vol ("/Volumes");
vol.findChildFiles (volumes, File::findDirectories, false); vol.findChildFiles (volumes, File::findDirectories, false);
for (int i = 0; i < volumes.size(); ++i) for (int i = 0; i < volumes.size(); ++i)

View file

@ -497,8 +497,8 @@ void AudioDeviceSelectorComponent::changeListenerCallback (void*)
if (currentDevice->hasControlPanel()) if (currentDevice->hasControlPanel())
{ {
addAndMakeVisible (launchUIButton = new TextButton (T("show this device's control panel"), addAndMakeVisible (launchUIButton = new TextButton (TRANS ("show this device's control panel"),
T("opens the device's own control panel"))); TRANS ("opens the device's own control panel")));
launchUIButton->addButtonListener (this); launchUIButton->addButtonListener (this);
} }

View file

@ -120,7 +120,7 @@ FileLogger* FileLogger::createDefaultAppLogger (const String& logFileSubDirector
const int maxInitialFileSizeBytes) const int maxInitialFileSizeBytes)
{ {
#ifdef JUCE_MAC #ifdef JUCE_MAC
File logFile (T("~/Library/Logs")); File logFile ("~/Library/Logs");
logFile = logFile.getChildFile (logFileName); logFile = logFile.getChildFile (logFileName);
#else #else

View file

@ -256,12 +256,12 @@ const String Time::toString (const bool includeDate,
if (includeDate) if (includeDate)
{ {
result << getDayOfMonth() << T(' ') result << getDayOfMonth() << ' '
<< getMonthName (true) << T(' ') << getMonthName (true) << ' '
<< getYear(); << getYear();
if (includeTime) if (includeTime)
result << T(' '); result << ' ';
} }
if (includeTime) if (includeTime)
@ -283,7 +283,7 @@ const String Time::toString (const bool includeDate,
} }
if (! use24HourClock) if (! use24HourClock)
result << (isAfternoon() ? T("pm") : T("am")); result << (isAfternoon() ? "pm" : "am");
} }
return result.trimEnd(); return result.trimEnd();
@ -428,7 +428,7 @@ const String Time::getTimeZone() const throw()
if (zone[0].length() > 3 if (zone[0].length() > 3
&& zone[0].containsIgnoreCase (T("daylight")) && zone[0].containsIgnoreCase (T("daylight"))
&& zone[0].contains (T("GMT"))) && zone[0].contains (T("GMT")))
zone[0] = T("BST"); zone[0] = "BST";
} }
return zone[0].substring (0, 3); return zone[0].substring (0, 3);

View file

@ -305,7 +305,7 @@ void Socket::close()
{ {
// need to do this to interrupt the accept() function.. // need to do this to interrupt the accept() function..
Socket temp; Socket temp;
temp.connect (T("localhost"), portNumber, 1000); temp.connect ("localhost", portNumber, 1000);
} }
} }

View file

@ -65,26 +65,16 @@ StringArray::StringArray (const juce_wchar** const strings) throw()
{ {
int i = 0; int i = 0;
for (;;) while (strings[i] != 0)
{ add (strings [i++]);
if (strings[i] != 0)
add (strings [i++]);
else
break;
}
} }
StringArray::StringArray (const char** const strings) throw() StringArray::StringArray (const char** const strings) throw()
{ {
int i = 0; int i = 0;
for (;;) while (strings[i] != 0)
{ add (strings [i++]);
if (strings[i] != 0)
add (strings [i++]);
else
break;
}
} }
const StringArray& StringArray::operator= (const StringArray& other) throw() const StringArray& StringArray::operator= (const StringArray& other) throw()
@ -249,7 +239,7 @@ int StringArray::indexOf (const String& stringToLookFor,
//============================================================================== //==============================================================================
void StringArray::remove (const int index) throw() void StringArray::remove (const int index) throw()
{ {
String* const s = (String*) strings[index]; String* const s = (String*) strings [index];
if (s != 0) if (s != 0)
{ {
@ -305,7 +295,7 @@ void StringArray::trim() throw()
class InternalStringArrayComparator class InternalStringArrayComparator
{ {
public: public:
static int compareElements (void* const first, void* const second) throw() static int JUCE_CALLTYPE compareElements (void* const first, void* const second) throw()
{ {
return ((const String*) first)->compare (*(const String*) second); return ((const String*) first)->compare (*(const String*) second);
} }
@ -314,7 +304,7 @@ public:
class InsensitiveInternalStringArrayComparator class InsensitiveInternalStringArrayComparator
{ {
public: public:
static int compareElements (void* const first, void* const second) throw() static int JUCE_CALLTYPE compareElements (void* const first, void* const second) throw()
{ {
return ((const String*) first)->compareIgnoreCase (*(const String*) second); return ((const String*) first)->compareIgnoreCase (*(const String*) second);
} }
@ -324,12 +314,12 @@ void StringArray::sort (const bool ignoreCase) throw()
{ {
if (ignoreCase) if (ignoreCase)
{ {
InsensitiveInternalStringArrayComparator comp; const InsensitiveInternalStringArrayComparator comp;
strings.sort (comp); strings.sort (comp);
} }
else else
{ {
InternalStringArrayComparator comp; const InternalStringArrayComparator comp;
strings.sort (comp); strings.sort (comp);
} }
} }
@ -366,7 +356,7 @@ const String StringArray::joinIntoString (const String& separator,
String result; String result;
result.preallocateStorage (charsNeeded); result.preallocateStorage (charsNeeded);
tchar* dest = (tchar*)(const tchar*) result; tchar* dest = (tchar*) (const tchar*) result;
while (start < last) while (start < last)
{ {

View file

@ -64,7 +64,7 @@ static bool isXmlIdentifierChar_Slow (const tchar c)
class FileInputSource : public XmlInputSource class FileInputSource : public XmlInputSource
{ {
public: public:
FileInputSource (const File& file_) FileInputSource (const File& file_) throw()
: file (file_) : file (file_)
{ {
} }
@ -117,75 +117,66 @@ void XmlDocument::setInputSource (XmlInputSource* const newSource) throw()
XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentElement) XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentElement)
{ {
JUCE_TRY String textToParse (originalText);
if (textToParse.isEmpty() && inputSource != 0)
{ {
String textToParse (originalText); InputStream* const in = inputSource->createInputStreamFor (String::empty);
if (textToParse.isEmpty() && inputSource != 0) if (in != 0)
{ {
InputStream* const in = inputSource->createInputStreamFor (String::empty); MemoryBlock data;
if (in != 0) in->readIntoMemoryBlock (data, onlyReadOuterDocumentElement ? 8192 : -1);
delete in;
if (data.getSize() >= 2
&& ((data[0] == (char)-2 && data[1] == (char)-1)
|| (data[0] == (char)-1 && data[1] == (char)-2)))
{ {
MemoryBlock data; textToParse = String::createStringFromData ((const char*) data.getData(), data.getSize());
in->readIntoMemoryBlock (data, onlyReadOuterDocumentElement ? 8192 : -1);
delete in;
if (data.getSize() >= 2
&& ((data[0] == (char)-2 && data[1] == (char)-1)
|| (data[0] == (char)-1 && data[1] == (char)-2)))
{
textToParse = String::createStringFromData ((const char*) data.getData(), data.getSize());
}
else
{
textToParse = String::fromUTF8 ((const uint8*) data.getData(), data.getSize());
}
if (! onlyReadOuterDocumentElement)
originalText = textToParse;
}
}
input = textToParse;
lastError = String::empty;
errorOccurred = false;
outOfData = false;
needToLoadDTD = true;
for (int i = 0; i < 128; ++i)
identifierLookupTable[i] = isXmlIdentifierChar_Slow ((tchar) i);
if (textToParse.isEmpty())
{
lastError = T("not enough input");
}
else
{
skipHeader();
if (input != 0)
{
XmlElement* const result = readNextElement (! onlyReadOuterDocumentElement);
if (errorOccurred && (result != 0))
delete result;
else
return result;
} }
else else
{ {
lastError = T("incorrect xml header"); textToParse = String::fromUTF8 ((const uint8*) data.getData(), data.getSize());
} }
if (! onlyReadOuterDocumentElement)
originalText = textToParse;
} }
} }
#if JUCE_CATCH_UNHANDLED_EXCEPTIONS
catch (...) input = textToParse;
lastError = String::empty;
errorOccurred = false;
outOfData = false;
needToLoadDTD = true;
for (int i = 0; i < 128; ++i)
identifierLookupTable[i] = isXmlIdentifierChar_Slow ((tchar) i);
if (textToParse.isEmpty())
{ {
lastError = T("internal error"); lastError = "not enough input";
}
else
{
skipHeader();
if (input != 0)
{
XmlElement* const result = readNextElement (! onlyReadOuterDocumentElement);
if (errorOccurred)
delete result;
else
return result;
}
else
{
lastError = "incorrect xml header";
}
} }
#endif
return 0; return 0;
} }