[squeak-dev] The Inbox: Sound-ct.82.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Oct 3 13:21:01 UTC 2021

A new version of Sound was added to project The Inbox:

==================== Summary ====================

Name: Sound-ct.82
Author: ct
Time: 3 October 2021, 3:21:00.283874 pm
UUID: 61a3c1d0-1c49-d542-8624-096b1b67e309
Ancestors: Sound-eem.81

Fixes SoundRecorder accesses to CanRecordWhilePlaying by always using the preference getter. As the class variable is nil in current Trunk images, you could not even open the Multimedia category in the parts bin before.

Removes the initialization of CanRecordWhilePlaying to support lazy default values from the preference getter. Also, this initialize method apparently has never been called in the current Trunk image.

=============== Diff against Sound-eem.81 ===============

Item was removed:
- ----- Method: SoundRecorder class>>initialize (in category 'class initialization') -----
- initialize
- 	"SoundRecorder initialize"
- 	"Details: Some computers cannot record and playback sound at the same time. If CanRecordWhilePlaying is false, then the SoundRecorder alternates between recording and playing. If it is true, sounds can be playing during recording."
- 	CanRecordWhilePlaying := false.
- !

Item was changed:
  ----- Method: SoundRecorder>>pause (in category 'recording controls') -----
  	"Go into pause mode. The record level continues to be updated, but no sound is recorded."
  	paused := true.
  	((currentBuffer ~~ nil) and: [nextIndex > 1])
  		ifTrue: [self emitPartialBuffer.
  				self allocateBuffer].
  	soundPlaying ifNotNil: [
  		soundPlaying pause.
  		soundPlaying := nil].
  	"Note: there can be problems if canRecordWhilePlaying is true. Recorders which only pause will inhibit other recorders from recording. I chose to make #stopPlaying unconditional in a subclass. The same might be appropriate here at the expense of making recorders resumable"
+ 	self class canRecordWhilePlaying ifFalse: [self stopRecording].!
- 	CanRecordWhilePlaying ifFalse: [self stopRecording].
- !

Item was changed:
  ----- Method: SoundRecorder>>resumeRecording (in category 'recording controls') -----
  	"Continue recording from the point at which it was last paused."
  	self flag: #bob.
  	"Note: If canRecordWhilePlaying is true, then recordings may never get started (at least by this method). One possibility, used in a subclass, is to make the #startPlaying unconditional. Another would be to use #startPlaying instead of #resumePlaying in appropriate cases"
+ 	self class canRecordWhilePlaying ifFalse: [self startRecording].
- 	CanRecordWhilePlaying ifFalse: [self startRecording].
  	paused := false.

Item was changed:
  ----- Method: SoundRecorder>>startRecording (in category 'recording controls') -----
  	"Turn on the sound input driver and start the recording process. Initially, recording is paused.
  	If the primStartRecordingDesiredSampleRate:... fails it almost certainly means we have no usable 
  	sound input device. Rather than having the prim raise a failure error we let it quietly do nothing
  	(since I hate trying to debug errors inside a critical block) and check the actual sampling rate later.
  	If the sampling rate is 0 we know the startup failed and raise an application level Signal to let any
  	user code know about the problem. 
  	You might think we should also use the stopRecording message to close things down cleanly but
  	that simply results in astorm of attempts to start recording so it is simpler to let it be deluded. An
  	attempts to start recording will repeat the test and thereby handle any plug-in hardware etc."
  	recordLevel ifNil: [recordLevel := 0.5].  "lazy initialization"
+ 	self class canRecordWhilePlaying ifFalse: [SoundPlayer shutDown: true].
- 	CanRecordWhilePlaying ifFalse: [SoundPlayer shutDown: true].
  	recordProcess ifNotNil: [self stopRecording].
  	paused := true.
  	meteringBuffer := SoundBuffer newMonoSampleCount: 1024.
  	meterLevel := 0.
  	self allocateBuffer.
  	Smalltalk newExternalSemaphoreDo: [ :semaphore :index |
  		bufferAvailableSema := semaphore.
  		self primStartRecordingDesiredSampleRate: samplingRate asInteger
  			stereo: stereo
  			semaIndex: index ].
  	RecorderActive := true.
  	samplingRate := self primGetActualRecordingSampleRate.
  	samplingRate = 0 ifTrue: [ Warning signal: 'SoundRecorder: unable to connect to sound input device'].
  	self primSetRecordLevel: (1000.0 * recordLevel) asInteger.
  	recordProcess := [self recordLoop] newProcess.
  	recordProcess priority: Processor userInterruptPriority.
  	recordProcess resume!

More information about the Squeak-dev mailing list