Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couple of fixes for MP3 quark subprocesses #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions MP3.sc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ MP3 {

if(sampleRate.isNil){
sampleRate = Server.default.sampleRate;
if(sampleRate.isNil) {
"Sample rate not available, assuming 44100".warn;
sampleRate = 44100;
};
};
khz = sampleRate * 0.001;

Expand Down Expand Up @@ -121,13 +125,19 @@ MP3 {
// ("MP3.start completed (PID"+(pid?"unknown")++")").postln;
// playing = true;
// });
pid = cmd.unixCmd;
pid = cmd.unixCmd({ |exit|
if(exit != 0) {
"MP3 subprocess (PID %) terminated with error code %".format(pid, exit).warn;
};
playing = false;
pid = nil;
});
("MP3.start completed (PID"+(pid?"unknown")++")").postln;
playing = true;
}

stop {
if(pid.isNil, {
if(this.playing and: { pid.isNil }, {
"MP3.stop - unable to stop automatically, PID not known".warn;
}, {
("kill" + pid).systemCmd;
Expand All @@ -152,7 +162,7 @@ MP3 {
if(pid.isNil, {
^true; // We can only assume it's still playing - we have no better info!
}, {
if(pid.isPIDRunning, {
if(pid.pidRunning, {
^true;
}, {
playing = false;
Expand Down