Command line application help


#1

I’m trying to use the Audio Device handling classes of Juce in my command line application and at the moment I can’t get it to work.

My question is this, do I need to use the full juceapplication wrapper for my application, or can I just use the Juce classes as is? I read an old post that says that if I don’t want to use Juce’s event handling then I can just use the classes straight off. This isn’t working for me at the moment however, my application breaks in juce_messagelistener.cpp.

any help greatly appreciated.

mark


#2

Which intialise/shutdown methods are you using? I think you have to use initialiseJuce_GUI and shutdownJuce_GUI if you’re using the audio classes, even with a console app. I don’t make console programs myself, but it sounds like something I’ve read around here.


#3

Ah that sounds like it could be the problem, i was using the nonGUI intialising function. Now I’ve changed my project to use initialiseJuce_GUI(), but on running it vc++ claims it’s detected memory leaks, the dump is below. The project is just a vanilla win32 console application with the intialiseJuce_Gui function added to main.

thanks for your help.

mark

[code]

JUCE v1.45
’jucetest2.exe’: Loaded ‘C:\Windows\System32\uxtheme.dll’, No symbols loaded.
Detected memory leaks!
Dumping objects ->
c:\users\wood\downloads\juce\src\juce_core\containers\juce_arrayallocationbase.h(94) : {192} normal block at 0x00B366B0, 32 bytes long.
Data: < > 00 00 00 00 00 00 00 00 90 06 00 00 1A 04 00 00
c:\users\wood\downloads\juce\src\juce_core\containers\juce_arrayallocationbase.h(94) : {191} normal block at 0x00B36650, 32 bytes long.
Data: < > 00 00 00 00 00 00 00 00 90 06 00 00 FC 03 00 00
c:\users\wood\downloads\juce\src\juce_appframework\gui\components\juce_desktop.h(207) : {190} normal block at 0x00B36580, 148 bytes long.
Data: <8nq (nq > 38 6E 71 00 28 6E 71 00 00 00 00 00 00 00 00 00
c:\users\wood\downloads\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {189} normal block at 0x00B36960, 288 bytes long.
Data: < DD > FF BB BB FF FF 44 44 FF 00 00 00 FF FF BB BB FF
c:\users\wood\downloads\juce\src\juce_core\containers\juce_arrayallocationbase.h(96) : {188} normal block at 0x00B36800, 288 bytes long.
Data: < > 00 01 00 01 01 01 00 01 02 01 00 01 00 0D 00 01
c:\users\wood\downloads\juce\src\juce_appframework\gui\components\lookandfeel\juce_lookandfeel.h(532) : {171} normal block at 0x00B36518, 44 bytes long.
Data: 64 44 71 00 00 68 B3 00 48 00 00 00 08 00 00 00
c:\users\wood\downloads\juce\src\juce_appframework\events\juce_message.h(81) : {167} normal block at 0x00B32410, 24 bytes long.
Data: <,Pq > 2C 50 71 00 CD CD CD CD CD CD CD CD CD CD CD CD
c:\users\wood\downloads\juce\src\juce_core\containers\juce_arrayallocationbase.h(94) : {166} normal block at 0x00B363A0, 32 bytes long.
Data: < ( ( e e > A4 28 B3 00 B0 28 B3 00 9C 65 B3 00 9C 65 B3 00
c:\users\wood\downloads\juce\src\juce_core\text\juce_string.cpp(69) : {165} normal block at 0x00B36340, 32 bytes long.
Data: < J u c e > 01 00 00 00 0A 00 00 00 4A 00 75 00 63 00 65 00
c:\users\wood\downloads\juce\src\juce_core\threads\juce_thread.h(268) : {164} normal block at 0x00B32868, 92 bytes long.
Data: < Qq @c $ > 80 51 71 00 40 63 B3 00 00 00 00 00 E0 A0 24 00
c:\users\wood\downloads\juce\src\juce_appframework\events\juce_messagemanager.h(191) : {157} normal block at 0x00B32238, 108 bytes long.
Data: < $q $q > A8 24 71 00 98 24 71 00 FA 00 00 00 FA 00 00 00
Object dump complete.[/code]


#4

It’s pretty tough to track down a memory leak just from the listing.

You’re calling shutdownJuce_GUI, right?


#5

Yeah, looks like you’re missing the shutdownJuce_GUI call from that dump. Having said that, I just made a quick app, and I get a leak in juce_message.h, even with a shutdown call.

[code]#include “…/…/…/juce.h”

void func();

int main(int argc, char** argv)
{
initialiseJuce_GUI();
func();
shutdownJuce_GUI();
return 0;
}

void func()
{
AudioDeviceManager adm;
adm.initialise(0,2,0,false);
ToneGeneratorAudioSource source;
AudioSourcePlayer player;
player.setSource(&source);
adm.setAudioCallback(&player);
Thread::sleep(1000);
adm.setAudioCallback(0);
player.setSource(0);
}[/code]

edit: never mind, that’s what I get for posting before doing any debugging. I’m clearly not dispatching any messages above, so it makes sense that it was being leaked. I really ought to take a look at what’s going on behind the scenes with the JUCEApplication class.


#6

Yeah I was missing the shutdown call. There’s still one memory leak but I’m not worried about that as I can create the audio device ok now. Thanks for your help.

mark


#7