[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] death while asleep? Or: trying to fix "scope works only with internal server"



Trying to finally fix the annoying bug that makes it impossible to use server.scope after the computer was asleep. There are e few connected issues. I'd like to fix (c) first, because without it, nothing will work properly. But the rest is quite a mess, too.

(a) Incorrect error message (points in the wrong direction)
(b) Very intransparent conditions for selection of the correct Stethosope class
(c) The most difficult, but most serious: loss of the shm interface when computer wakes up from sleep.

			***

(a) is easy to solve:
This is wrong: "scope works only with internal server"

In QStethoscope something like:

*new { arg server, numChannels = 2, index, bufsize = 4096, zoom, rate, view, bufnum;
    if(server.isLocal.not, { "scope works only with local servers".error; ^nil });
    ^super.newCopyArgs(server, numChannels, rate ? \audio).makeWindow(view)
    .index_(index ? 0).zoom_(zoom).allocBuffer(bufsize, bufnum).run;
}

But this may fail when the server has been killed by someone else.
So better: "couldn't connect to memory interface", maybe?

Btw., these methods in Server are analogous:

	getControlBusValue {|busIndex|
		if (serverInterface.isNil) {
			Error("Server-getControlBusValue only supports local servers").throw;
		} {
			^serverInterface.getControlBusValue(busIndex)
		}
	}


				
			***



(b) I find this really hard to understand, but don't know the reasons for the way it is written. Any clue what we should do with this?

*new {  arg server, numChannels = 2, index = 0, bufsize = 4096, zoom = 1, rate = \audio, view, bufnum;
	index = index.asControlInput;
	
	if (GUI.id == \qt and:
		{ server.serverRunning and: server.hasShmInterface.not })
	{
		^GUI.current.stethoscope1.new
		(server, numChannels, index, bufsize, zoom, rate, view, bufnum)
	}{
		^super.new(server, numChannels, index, bufsize, zoom, rate, view, bufnum)
	};
}

I suppose that things would become much easier if we dropped the GUI redirects. But obviously, I hesitate a little bit!

			***


(c) I have opened an issue here: https://github.com/supercollider/supercollider/issues/889?source=cc
In a sense this is a regression, because long ago, we had similar problems for different reasons.

It may be, however, that it is only Server. serverRunning_  which behaves incorrectly. Here is a reproducer:


Server.default.boot;
ServerQuit.add({ "I died while asleep.".postln }, Server.default);

// put your computer to sleep, and wake it up again.  
// it prints: I died while asleep.
// but:

Server.default.serverRunning; // true

serverRunning_ should be a little refactored, but it seems, that digging further (sorry!), it is thisProcess.platform.isSleeping.
Here is a reproducer:

(
fork {
	var startTime = Main.elapsedTime;
	loop {
		1.wait;
		[(Main.elapsedTime - startTime).round(0.1), thisProcess.platform.isSleeping].postln;
	}
} 
)

a Routine
[ 1, false ]
[ 2, false ]
[ 3, false ]
[ 4, false ]
[ 5, false ]
[ 6, false ]
[ 7, false ]
[ 8, false ]
[ 10, false ]
[ 10, false ]
[ 11, false ]
I died while asleep.
[ 12, false ]
[ 13, false ]
[ 14, false ]
[ 15, false ]
[ 16, false ]
[ 17, false ]

So it has twice the same time and never is asleep. Is this OS specific?

Any kind of suggestions or hints are welcome!



_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/