The Trunk: Sound-eem.73.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Sound-eem.73.mcz

commits-2
Eliot Miranda uploaded a new version of Sound to project The Trunk:
http://source.squeak.org/trunk/Sound-eem.73.mcz

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

Name: Sound-eem.73
Author: eem
Time: 19 September 2020, 7:20:30.790279 am
UUID: 4e7631d7-a5fd-4c91-8efa-c9f792aaee06
Ancestors: Sound-eem.72

Add error codes to the relevant SoundPlugin primitives.
Avoid disturbing the sound system when shutting down and the sound system is inactive (requires Kernel-eem.1341!!).

=============== Diff against Sound-eem.72 ===============

Item was changed:
  ----- Method: SoundPlayer class>>primGetDefaultSoundPlayer (in category 'private') -----
  primGetDefaultSoundPlayer
  "Answer the name of the default output device."
+ <primitive: 'primitiveGetDefaultSoundPlayer' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveGetDefaultSoundPlayer' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primGetDefaultSoundRecorder (in category 'private') -----
  primGetDefaultSoundRecorder
  "Answer the name of the default input device."
+ <primitive: 'primitiveGetDefaultSoundRecorder' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveGetDefaultSoundRecorder' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primGetNumberOfSoundPlayerDevices (in category 'private') -----
  primGetNumberOfSoundPlayerDevices
  "Answer the number of output devices."
+ <primitive: 'primitiveGetNumberOfSoundPlayerDevices' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveGetNumberOfSoundPlayerDevices' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primGetNumberOfSoundRecorderDevices (in category 'private') -----
  primGetNumberOfSoundRecorderDevices
  "Answer the number of input devices."
+ <primitive: 'primitiveGetNumberOfSoundRecorderDevices' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveGetNumberOfSoundRecorderDevices' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primGetSoundPlayerDeviceName: (in category 'private') -----
  primGetSoundPlayerDeviceName: n
  "Answer the name of the n'th output device."
+ <primitive: 'primitiveGetSoundPlayerDeviceName' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveGetSoundPlayerDeviceName' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primGetSoundRecorderDeviceName: (in category 'private') -----
  primGetSoundRecorderDeviceName: n
  "Answer the name of the n'th input device."
+ <primitive: 'primitiveGetSoundRecorderDeviceName' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveGetSoundRecorderDeviceName' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primSetDefaultSoundPlayer: (in category 'private') -----
  primSetDefaultSoundPlayer: deviceName
  "Set the default output device by supplying its name."
+ <primitive: 'primitiveSetDefaultSoundPlayer' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveSetDefaultSoundPlayer' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primSetDefaultSoundRecorder: (in category 'private') -----
  primSetDefaultSoundRecorder: deviceName
  "Set the default input device by supplying its name."
+ <primitive: 'primitiveSetDefaultSoundRecorder' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveSetDefaultSoundRecorder' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primSoundAvailableBytes (in category 'private') -----
  primSoundAvailableBytes
+ "Answer the number of bytes of available space in the sound output buffer."
- "Return the number of bytes of available space in the sound output buffer."
  "Note: Squeak always uses buffers containing 4-bytes per sample (2 channels at 2 bytes per channel) regardless of the state of the Stereo flag."
 
+ <primitive: 'primitiveSoundAvailableSpace' module: 'SoundPlugin' error: ec>
+ ^ self primitiveFailed!
- <primitive: 'primitiveSoundAvailableSpace' module: 'SoundPlugin'>
- ^ self primitiveFailed
- !

Item was changed:
  ----- Method: SoundPlayer class>>primSoundEnableAEC: (in category 'private') -----
  primSoundEnableAEC: aBooleanInteger
  "Enable or disable acoustic echo-cancellation (AEC).  aBooleanInteger should be 0 for false, and 1 for true."
+ <primitive: 'primitiveSoundEnableAEC' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveSoundEnableAEC' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primSoundGetRecordLevel (in category 'private') -----
  primSoundGetRecordLevel
+ "Answer sound as array of doubles left then right channel, range is 0.0 to 1.0 but may be overdriven"
+ <primitive: 'primitiveSoundGetRecordLevel' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- "Return sound as array of doubles left then right channel, range is 0.0 to 1.0 but may be overdriven"
- <primitive: 'primitiveSoundGetRecordLevel' module: 'SoundPlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: SoundPlayer class>>primSoundGetVolume (in category 'private') -----
  primSoundGetVolume
+ "Answer sound as an array of doubles left then right channel, range is 0.0 to 1.0 but may be overdriven"
+ <primitive: 'primitiveSoundGetVolume' module: 'SoundPlugin' error: ec>
- "Return sound as array of doubles left then right channel, range is 0.0 to 1.0 but may be overdriven"
- <primitive: 'primitiveSoundGetVolume' module: 'SoundPlugin'>
  ^Array with: 1.0 with: 1.0!

Item was changed:
  ----- Method: SoundPlayer class>>primSoundInsertSamples:from:samplesOfLeadTime: (in category 'private') -----
  primSoundInsertSamples: count from: aSoundBuffer samplesOfLeadTime: anInteger
+ "Mix the given number of sample frames from the given sound buffer into the queue of samples that has already been submitted to the sound driver. This primitive is used to start a sound playing with minimum latency, even if large sound output buffers are being used to ensure smooth sound output. Answers the number of samples consumed, or zero if the primitive is not implemented or fails."
- "Mix the given number of sample frames from the given sound buffer into the queue of samples that has already been submitted to the sound driver. This primitive is used to start a sound playing with minimum latency, even if large sound output buffers are being used to ensure smooth sound output. Returns the number of samples consumed, or zero if the primitive is not implemented or fails."
 
+ <primitive: 'primitiveSoundInsertSamples' module: 'SoundPlugin' error: ec>
+ ^ 0!
- <primitive: 'primitiveSoundInsertSamples' module: 'SoundPlugin'>
- ^ 0
- !

Item was changed:
  ----- Method: SoundPlayer class>>primSoundPlaySamples:from:startingAt: (in category 'private') -----
  primSoundPlaySamples: count from: aSampleBuffer startingAt: index
+ "Copy count frames (pairs) of stereo sound samples into the current sound
+ output buffer from the given sample buffer starting at the given index."
- "Copy count bytes into the current sound output buffer from the given sample buffer starting at the given index."
 
+ <primitive: 'primitiveSoundPlaySamples' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed
- <primitive: 'primitiveSoundPlaySamples' module: 'SoundPlugin'>
- ^ self primitiveFailed
  !

Item was changed:
  ----- Method: SoundPlayer class>>primSoundSetVolumeLeft:volumeRight: (in category 'private') -----
  primSoundSetVolumeLeft: aLeftVolume volumeRight: aRightVolume
  "Set sound pass in float 0.0-1.0 for left and right channel, with possible 2.0 or  higher to overdrive sound channel "
+ <primitive: 'primitiveSoundSetLeftVolume' module: 'SoundPlugin' error: ec>
+ ^self!
- <primitive: 'primitiveSoundSetLeftVolume' module: 'SoundPlugin'>
- !

Item was changed:
  ----- Method: SoundPlayer class>>primSoundStartBufferSize:rate:stereo: (in category 'private') -----
  primSoundStartBufferSize: bufferSize rate: samplesPerSecond stereo: stereoFlag
  "Start double-buffered sound output with the given buffer size and sampling rate. This version has been superceded by primitive 171 (primSoundStartBufferSize:rate:stereo:semaIndex:)."
  "ar 12/5/1998 Turn off the sound if not supported"
+ <primitive: 'primitiveSoundStart' module: 'SoundPlugin' error: ec>
+ SoundSupported := false!
- <primitive: 'primitiveSoundStart' module: 'SoundPlugin'>
- SoundSupported := false.!

Item was changed:
  ----- Method: SoundPlayer class>>primSoundStartBufferSize:rate:stereo:semaIndex: (in category 'private') -----
  primSoundStartBufferSize: bufferSize rate: samplesPerSecond stereo: stereoFlag semaIndex: anInteger
  "Start double-buffered sound output with the given buffer size and sampling rate. 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 when the sound driver is ready to accept another buffer of samples."
  "Details: If this primitive fails, this method tries to use the older version instead."
 
+ <primitive: 'primitiveSoundStartWithSemaphore' module: 'SoundPlugin' error: ec>
- <primitive: 'primitiveSoundStartWithSemaphore' module: 'SoundPlugin'>
  UseReadySemaphore := false.
+ self primSoundStartBufferSize: bufferSize rate: samplesPerSecond stereo: stereoFlag!
- self primSoundStartBufferSize: bufferSize rate: samplesPerSecond stereo: stereoFlag.
- !

Item was changed:
  ----- Method: SoundPlayer class>>primSoundStop (in category 'private') -----
  primSoundStop
  "Stop double-buffered sound output. Must not raise an error because it is used inside error handling and at system shutdown"
 
+ <primitive: 'primitiveSoundStop' module: 'SoundPlugin' error: ec>
+ ^self!
- <primitive: 'primitiveSoundStop' module: 'SoundPlugin'>!

Item was changed:
  ----- Method: SoundPlayer class>>primSoundSupportsAEC (in category 'private') -----
  primSoundSupportsAEC
  "Answer if the plugin supports echo-cancellation on this OS/hardware."
+ <primitive: 'primitiveSoundSupportsAEC' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveSoundSupportsAEC' module: 'SoundPlugin'>
- self primitiveFailed!

Item was added:
+ ----- Method: SoundPlayer class>>soundPluginActive (in category 'private') -----
+ soundPluginActive
+ "Answer quickly if the SoundPlugin is actually active."
+ "self soundPluginActive"
+ ^SoundSupported
+ and: [(self class compiledMethodAt: (UseReadySemaphore
+ ifTrue: [#primSoundStartBufferSize:rate:stereo:semaIndex:]
+ ifFalse: [#primSoundStartBufferSize:rate:stereo:])) isLinkedNamedPrimitive]!

Item was changed:
  ----- Method: SoundPlayer class>>stopPlayerProcess (in category 'player process') -----
  stopPlayerProcess
  "Stop the sound player process."
  "SoundPlayer stopPlayerProcess"
 
+ PlayerProcess ifNotNil:
+ [PlayerProcess ~~ Processor activeProcess ifTrue:
+ [PlayerProcess terminate].
+ PlayerProcess := nil].
+ "Don't load the SoundPlugin if it is not in use..."
+ self soundPluginActive ifTrue: [self primSoundStop].
+ ActiveSounds isEmpty ifFalse:
+ [ActiveSounds := OrderedCollection new].
- (PlayerProcess == nil or:[PlayerProcess == Processor activeProcess])
- ifFalse:[PlayerProcess terminate].
- PlayerProcess := nil.
- self primSoundStop.
- ActiveSounds := OrderedCollection new.
  Buffer := nil.
+ PlayerSemaphore isEmpty ifFalse:
+ [PlayerSemaphore := Semaphore forMutualExclusion].
- PlayerSemaphore := Semaphore forMutualExclusion.
  ReadyForBuffer ifNotNil:
+ [Smalltalk unregisterExternalObject: ReadyForBuffer.
+ ReadyForBuffer := nil]!
- [Smalltalk unregisterExternalObject: ReadyForBuffer].
- ReadyForBuffer := nil.
- !

Item was changed:
  ----- Method: SoundRecorder>>primGetActualRecordingSampleRate (in category 'primitives') -----
  primGetActualRecordingSampleRate
+ "Answer the actual sample rate being used for recording. This primitive fails unless sound recording is currently in progress."
- "Return the actual sample rate being used for recording. This primitive fails unless sound recording is currently in progress."
 
+ <primitive: 'primitiveSoundGetRecordingSampleRate' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveSoundGetRecordingSampleRate' module: 'SoundPlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: SoundRecorder>>primRecordSamplesInto:startingAt: (in category 'primitives') -----
  primRecordSamplesInto: aWordArray startingAt: index
+ "Record a sequence of 16-bit sound samples into the given array starting at the given sample index. Answer the number of samples recorded, which may be zero if no samples are currently available."
- "Record a sequence of 16-bit sound samples into the given array starting at the given sample index. Return the number of samples recorded, which may be zero if no samples are currently available."
 
+ <primitive: 'primitiveSoundRecordSamples' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveSoundRecordSamples' module: 'SoundPlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: SoundRecorder>>primSetRecordLevel: (in category 'primitives') -----
  primSetRecordLevel: anInteger
  "Set the desired recording level to the given value in the range 0-1000, where 0 is the lowest recording level and 1000 is the maximum. Do nothing if the sound input hardware does not support changing the recording level."
 
+ <primitive: 'primitiveSoundSetRecordLevel' module: 'SoundPlugin' error: ec>
+ ^self primitiveFailed!
- <primitive: 'primitiveSoundSetRecordLevel' module: 'SoundPlugin'>
- self primitiveFailed
- !