tim Rowledge uploaded a new version of Sound to project The Trunk:
http://source.squeak.org/trunk/Sound-tpr.47.mcz ==================== Summary ==================== Name: Sound-tpr.47 Author: tpr Time: 15 December 2015, 4:33:09.091 pm UUID: 998878c2-2ae5-41e1-b60a-dbc169c238cd Ancestors: Sound-nice.46 Protect SoundRecorder from primitiveFailed inside a critical block; raise a Warning signal afterwards instead of a raw error =============== Diff against Sound-nice.46 =============== Item was changed: ----- Method: SoundRecorder>>primStartRecordingDesiredSampleRate:stereo:semaIndex: (in category 'primitives') ----- primStartRecordingDesiredSampleRate: samplesPerSec stereo: stereoFlag semaIndex: anInteger + "Start sound recording with the given stereo setting. Use a sampling rate as close to the desired rate as the underlying platform will support. If the given semaphore index is > 0, it is taken to be the index of a Semaphore in the external objects array to be signalled every time a recording buffer is filled. + We do *not* raise a primitiveFailed error here since this prim is called insdied a critical blcok and that often makes things painful. The only really likely case where this prim fails is a linux machine with no sound input hardware (a Raspberry Pi for example). See the startRecording method for how the failure is handled" - "Start sound recording with the given stereo setting. Use a sampling rate as close to the desired rate as the underlying platform will support. If the given semaphore index is > 0, it is taken to be the index of a Semaphore in the external objects array to be signalled every time a recording buffer is filled." <primitive: 'primitiveSoundStartRecording' module: 'SoundPlugin'> + "self primitiveFailed" - self primitiveFailed ! Item was changed: ----- Method: SoundRecorder>>startRecording (in category 'recording controls') ----- startRecording + "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." - "Turn of the sound input driver and start the recording process. Initially, recording is paused." recordLevel ifNil: [recordLevel := 0.5]. "lazy initialization" CanRecordWhilePlaying ifFalse: [SoundPlayer shutDown]. 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! |
Free forum by Nabble | Edit this page |