Browse Source

Remove MIDI-programs from AudioFile, so it becomes really RT-Safe

tags/1.9.4
falkTX 11 years ago
parent
commit
fe67975f3a
3 changed files with 5 additions and 82 deletions
  1. +2
    -0
      source/backend/native/audio-base.hpp
  2. +3
    -76
      source/backend/native/audio-file.cpp
  3. +0
    -6
      source/backend/plugin/NativePlugin.cpp

+ 2
- 0
source/backend/native/audio-base.hpp View File

@@ -85,6 +85,8 @@ struct AudioFilePool {

void reset()
{
CARLA_ASSERT(size != 0);

startFrame = 0;
carla_zeroFloat(buffer[0], size);
carla_zeroFloat(buffer[1], size);


+ 3
- 76
source/backend/native/audio-file.cpp View File

@@ -88,28 +88,6 @@ protected:
return fLoopMode ? 1.0f : 0.0f;
}

// -------------------------------------------------------------------
// Plugin midi-program calls

uint32_t getMidiProgramCount() override
{
return PROGRAM_COUNT;
}

const MidiProgram* getMidiProgramInfo(const uint32_t index) override
{
if (index >= PROGRAM_COUNT)
return NULL;

static MidiProgram midiProgram;

midiProgram.bank = 0;
midiProgram.program = index;
midiProgram.name = (const char*)fPrograms.shortNames[index];

return &midiProgram;
}

// -------------------------------------------------------------------
// Plugin state calls

@@ -127,48 +105,12 @@ protected:
fThread.setNeedsRead();
}

void setMidiProgram(const uint8_t, const uint32_t bank, const uint32_t program) override
{
if (bank != 0 || program >= PROGRAM_COUNT)
return;

if (fPrograms.current != program)
{
loadFilename(fPrograms.fullNames[program]);
fPrograms.current = program;
}
}

void setCustomData(const char* const key, const char* const value) override
{
if (std::strlen(key) != 6)
return;
if (std::strncmp(key, "file", 4) != 0)
return;
if (key[4] < '0' || key[4] > '9')
if (std::strcmp(key, "file") != 0)
return;
if (key[5] < '0' || key[5] > '9')
return;

uint8_t tens = key[4]-'0';
uint8_t nums = key[5]-'0';

uint32_t program = tens*10 + nums;

if (program >= PROGRAM_COUNT)
return;

fPrograms.fullNames[program] = value;

if (const char* const shortName = std::strrchr(value, OS_SEP))
fPrograms.shortNames[program] = shortName+1;
else
fPrograms.shortNames[program] = value;

fPrograms.shortNames[program].truncate(fPrograms.shortNames[program].rfind('.'));

if (fPrograms.current == program)
loadFilename(value);
loadFilename(value);
}

// -------------------------------------------------------------------
@@ -253,13 +195,7 @@ protected:
return;

if (const char* const filename = uiOpenFile(false, "Open Audio File", ""))
{
char fileStr[] = { 'f', 'i', 'l', 'e', '\0', '\0', '\0' };
fileStr[4] = '0' + (fPrograms.current / 10);
fileStr[5] = '0' + (fPrograms.current % 10);

uiCustomDataChanged(fileStr, filename);
}
uiCustomDataChanged("file", filename);

uiClosed();
}
@@ -274,15 +210,6 @@ private:
AudioFilePool fPool;
AudioFileThread fThread;

struct Programs {
uint32_t current;
CarlaString fullNames[PROGRAM_COUNT];
CarlaString shortNames[PROGRAM_COUNT];

Programs()
: current(0) {}
} fPrograms;

void loadFilename(const char* const filename)
{
CARLA_ASSERT(filename != nullptr);


+ 0
- 6
source/backend/plugin/NativePlugin.cpp View File

@@ -638,12 +638,6 @@ public:

if (sendGui && fIsUiVisible && fDescriptor->ui_set_custom_data != nullptr)
fDescriptor->ui_set_custom_data(fHandle, key, value);

if (std::strlen(key) == 6 && std::strncmp(key, "file", 4) == 0)
{
const ScopedDisabler sd(this);
reloadPrograms(false);
}
}

CarlaPlugin::setCustomData(type, key, value, sendGui);


Loading…
Cancel
Save