[squeak-dev] The Inbox: Sound-ul.41.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Oct 27 15:59:09 UTC 2014


A new version of Sound was added to project The Inbox:
http://source.squeak.org/inbox/Sound-ul.41.mcz

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

Name: Sound-ul.41
Author: ul
Time: 27 October 2014, 4:48:59.268 pm
UUID: b700fc19-c219-47e3-bc55-4874db9dea22
Ancestors: Sound-nice.38

- use the new ExternalObjectTable API

=============== Diff against Sound-nice.38 ===============

Item was changed:
  ----- Method: SoundPlayer class>>startPlayerProcessBufferSize:rate:stereo:sound: (in category 'player process') -----
  startPlayerProcessBufferSize: bufferSize rate: samplesPerSecond stereo: stereoFlag sound: aSound
  	"Start the sound player process. Terminate the old process, if any."
  	"SoundPlayer startPlayerProcessBufferSize: 1000 rate: 11025 stereo: false"
  
  	self stopPlayerProcess.
  	aSound
  		ifNil:[ActiveSounds := OrderedCollection new]
  		ifNotNil:[ActiveSounds := OrderedCollection with: aSound].
  	Buffer := SoundBuffer newStereoSampleCount: (bufferSize // 4) * 4.
  	LastBuffer ifNotNil:[LastBuffer := SoundBuffer basicNew: Buffer basicSize].
  	PlayerSemaphore := Semaphore forMutualExclusion.
  	SamplingRate := samplesPerSecond.
  	Stereo := stereoFlag.
- 	ReadyForBuffer := Semaphore new.
  	SoundSupported := true. "Assume so"
  	UseReadySemaphore := true.  "set to false if ready semaphore not supported by VM"
+ 	Smalltalk newExternalSemaphoreDo: [ :semaphore :index |
+ 		ReadyForBuffer := semaphore.
+ 		self primSoundStartBufferSize: Buffer stereoSampleCount
+ 			rate: samplesPerSecond
+ 			stereo: Stereo
+ 			semaIndex: index ].
- 	self primSoundStartBufferSize: Buffer stereoSampleCount
- 		rate: samplesPerSecond
- 		stereo: Stereo
- 		semaIndex: (Smalltalk registerExternalObject: ReadyForBuffer).
  	"Check if sound start prim was successful"
+ 	SoundSupported ifFalse:[
+ 		Smalltalk unregisterExternalObject: ReadyForBuffer.
+ 		ReadyForBuffer := nil.
+ 		^self ].
- 	SoundSupported ifFalse:[^self].
  	UseReadySemaphore
  		ifTrue: [PlayerProcess := [SoundPlayer playLoop] newProcess]
  		ifFalse: [PlayerProcess := [SoundPlayer oldStylePlayLoop] newProcess].
  	UseReverb ifTrue: [self startReverb].
  
  	PlayerProcess priority: Processor userInterruptPriority.
+ 	PlayerProcess resume!
- 	PlayerProcess resume.!

Item was changed:
  ----- Method: SoundRecorder>>startRecording (in category 'recording controls') -----
  startRecording
  	"Turn of the sound input driver and start the recording process. Initially, recording is paused."
  
- 	| semaIndex |
  	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 ].
- 	bufferAvailableSema := Semaphore new.
- 	semaIndex := Smalltalk registerExternalObject: bufferAvailableSema.
- 	self primStartRecordingDesiredSampleRate: samplingRate asInteger
- 		stereo: stereo
- 		semaIndex: semaIndex.
  	RecorderActive := true.
  	samplingRate := self primGetActualRecordingSampleRate.
  	self primSetRecordLevel: (1000.0 * recordLevel) asInteger.
  	recordProcess := [self recordLoop] newProcess.
  	recordProcess priority: Processor userInterruptPriority.
+ 	recordProcess resume!
- 	recordProcess resume.
- !



More information about the Squeak-dev mailing list