commit 057c16d4aba0d8c07499cc82ed61e3557f008db5
parent 02d02c4d029443c43c546b3aaf4b2f4557f1b94b
Author: fundamental <[email protected]>
Date: Tue, 4 May 2010 14:47:23 -0400
Nio: Fixed Ugly Logic Error
Diffstat:
4 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/src/Nio/EngineMgr.cpp b/src/Nio/EngineMgr.cpp
@@ -99,20 +99,22 @@ void EngineMgr::start()
//open up the default output(s)
cout << "Starting Audio: " << defaultOut->name << endl;
defaultOut->setAudioEn(true);
- if(!defaultOut->getAudioEn()) {
- cerr << "ERROR: The default audio output failed to open!" << endl;
+ if(defaultOut->getAudioEn()) {
+ cout << "Audio Started" << endl;
}
- else { //recover
+ else {
+ cerr << "ERROR: The default audio output failed to open!" << endl;
sysOut->currentOut = dynamic_cast<AudioOut *>(sysEngine->getEng("NULL"));
sysOut->currentOut->setAudioEn(true);
}
cout << "Starting MIDI: " << defaultIn->name << endl;
defaultIn->setMidiEn(true);
- if(!defaultIn->getMidiEn()) {
- cerr << "ERROR: The default MIDI input failed to open!" << endl;
+ if(defaultIn->getMidiEn()) {
+ cout << "MIDI Started" << endl;
}
else { //recover
+ cerr << "ERROR: The default MIDI input failed to open!" << endl;
sysIn->current = dynamic_cast<MidiIn *>(sysEngine->getEng("NULL"));
sysIn->current->setMidiEn(true);
}
diff --git a/src/Nio/OutMgr.cpp b/src/Nio/OutMgr.cpp
@@ -51,14 +51,15 @@ const Stereo<REALTYPE *> OutMgr::tick(unsigned int frameSize)
//SysEv->execute();
removeStaleSmps();
while(frameSize > storedSmps()) {
- {//get more stuff
- pthread_mutex_lock(&(master->mutex));
- master->AudioOut(outl, outr);
- pthread_mutex_unlock(&(master->mutex));
- addSmps(outl,outr);
- }
+ pthread_mutex_lock(&(master->mutex));
+ master->AudioOut(outl, outr);
+ pthread_mutex_unlock(&(master->mutex));
+ addSmps(outl,outr);
}
- makeStale(frameSize);
+ Stereo<REALTYPE *> ans = priBuffCurrent;
+ ans.l() -= frameSize;
+ ans.r() -= frameSize;
+ //cout << storedSmps() << '=' << frameSize << endl;
return priBuf;
}
@@ -106,6 +107,7 @@ void OutMgr::addSmps(REALTYPE *l, REALTYPE *r)
Stereo<Sample> smps(Sample(SOUND_BUFFER_SIZE, l), Sample(SOUND_BUFFER_SIZE, r));
if(currentOut->getSampleRate() != SAMPLE_RATE) { //we need to resample
+ //cout << "BAD RESAMPLING" << endl;
smps.l().resample(SAMPLE_RATE,currentOut->getSampleRate());
smps.r().resample(SAMPLE_RATE,currentOut->getSampleRate());
}
@@ -117,23 +119,17 @@ void OutMgr::addSmps(REALTYPE *l, REALTYPE *r)
stales += SOUND_BUFFER_SIZE;
}
-void OutMgr::makeStale(unsigned int size)
-{
- //stales = size;
-}
-
void OutMgr::removeStaleSmps()
{
int toShift = storedSmps() - stales;
- cout << "Beta toShift" << toShift << endl << "stales:" << stales << endl;
+ //cout << "toShift: " << toShift << endl << "stales: " << stales << endl << priBuf.l() << ' ' << priBuffCurrent.l() << endl;
if(!stales)
return;
- cout << "toShift" << toShift << endl << "stales:" << stales << endl;
- memmove(priBuf.l(), priBuf.l()+stales, stales*sizeof(float));
- memmove(priBuf.r(), priBuf.r()+stales, stales*sizeof(float));
- priBuffCurrent.l() -= stales;
- priBuffCurrent.r() -= stales;
+ memset(priBuf.l(), '0', 4096*sizeof(REALTYPE));
+ memset(priBuf.r(), '0', 4096*sizeof(REALTYPE));
+ priBuffCurrent = priBuf;
stales = 0;
+
}
diff --git a/src/Nio/OutMgr.h b/src/Nio/OutMgr.h
@@ -47,7 +47,6 @@ class OutMgr
private:
void addSmps(REALTYPE *l, REALTYPE *r);
int storedSmps() const {return priBuffCurrent.l() - priBuf.l();};
- void makeStale(unsigned int size);
void removeStaleSmps();
AudioOut *currentOut;/**<The current output driver*/
diff --git a/src/main.cpp b/src/main.cpp
@@ -456,12 +456,14 @@ int main(int argc, char *argv[])
cerr << "There is no input for " << input << endl;
exit(1);
}
+ cout << input << " selected." << endl;
}
if(!output.empty()) {
- if(!sysEngine->setOutDefault(input)) {
+ if(!sysEngine->setOutDefault(output)) {
cerr << "There is no output for " << output << endl;
exit(1);
}
+ cout << output << " selected." << endl;
}
//Run the Nio system