[squeak-dev] The Inbox: Sound-ul.40.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Oct 25 23:53:44 UTC 2014
A new version of Sound was added to project The Inbox:
http://source.squeak.org/inbox/Sound-ul.40.mcz
==================== Summary ====================
Name: Sound-ul.40
Author: ul
Time: 26 October 2014, 1:43:33.816 am
UUID: c4759ae3-93c9-4344-bc16-600a8e018ca6
Ancestors: Sound-nice.38
- use the new ExternalSemaphoreTable 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"
+ ExternalSemaphoreTable 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:[
+ ExternalSemaphoreTable 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: SoundPlayer class>>stopPlayerProcess (in category 'player process') -----
stopPlayerProcess
"Stop the sound player process."
"SoundPlayer stopPlayerProcess"
(PlayerProcess == nil or:[PlayerProcess == Processor activeProcess])
ifFalse:[PlayerProcess terminate].
PlayerProcess := nil.
self primSoundStop.
ActiveSounds := OrderedCollection new.
Buffer := nil.
PlayerSemaphore := Semaphore forMutualExclusion.
ReadyForBuffer ifNotNil:
+ [ExternalSemaphoreTable unregisterExternalObject: ReadyForBuffer].
- [Smalltalk unregisterExternalObject: ReadyForBuffer].
ReadyForBuffer := nil.
!
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.
+ ExternalSemaphoreTable 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.
- !
Item was changed:
----- Method: SoundRecorder>>stopRecording (in category 'recording controls') -----
stopRecording
"Stop the recording process and turn of the sound input driver."
recordProcess ifNotNil: [recordProcess terminate].
recordProcess := nil.
self primStopRecording.
RecorderActive := false.
+ ExternalSemaphoreTable unregisterExternalObject: bufferAvailableSema.
- Smalltalk unregisterExternalObject: bufferAvailableSema.
((currentBuffer ~~ nil) and: [nextIndex > 1])
ifTrue: [self emitPartialBuffer].
self initializeRecordingState.
!
More information about the Squeak-dev
mailing list
|