[openfirmware] r1596 - dev/hdaudio
svn at openfirmware.info
svn at openfirmware.info
Mon Dec 14 11:01:06 CET 2009
Author: wmb
Date: 2009-12-14 11:01:05 +0100 (Mon, 14 Dec 2009)
New Revision: 1596
Modified:
dev/hdaudio/core.fth
dev/hdaudio/test.fth
Log:
HDAudio driver and selftest - significant changes to reduce memory
leaks, prevent reentrancy in the selftest, and clean up after sound
completion.
Modified: dev/hdaudio/core.fth
===================================================================
--- dev/hdaudio/core.fth 2009-12-14 09:48:18 UTC (rev 1595)
+++ dev/hdaudio/core.fth 2009-12-14 10:01:05 UTC (rev 1596)
@@ -78,11 +78,11 @@
\ \\ Stream Descriptors
\ Default: 48kHz 16bit stereo
-0 instance value sample-base
-0 instance value sample-mul
-0 instance value sample-div
-1 instance value sample-format
-2 instance value #channels
+0 value sample-base
+0 value sample-mul
+0 value sample-div
+1 value sample-format
+2 value #channels
: stream-format ( -- u )
sample-base d# 14 lshift ( acc )
@@ -107,7 +107,7 @@
\ Stream descriptor register interface.
\ There are multiple stream descriptors, each with their own register set.
-0 instance value sd#
+0 value sd#
: sd+ ( offset -- adr ) sd# h# 20 * + au + ;
: sdctl h# 80 sd+ ;
@@ -239,8 +239,8 @@
: init-codec ( -- ) detect-codec open-codec ;
: close-controller ( -- ) reset unmap-regs ;
-d# 48.000 instance value sample-rate
-1 instance value scale-factor
+d# 48.000 value sample-rate
+1 value scale-factor
: low-rate? ( Hz ) dup d# 48.000 < swap d# 44.100 <> and ;
@@ -404,7 +404,8 @@
upsample-channel \ left
src 2+ to src dst 2+ to dst
upsample-channel \ right
- dst 2 - /dst ( dst dst-len )
+ dst 2- to dst ( )
+ dst /dst ( dst dst-len )
;
\ \\ Amplifier control
@@ -453,11 +454,12 @@
stop-stream
free-bdl
release-sound-buffer
+ uninstall-playback-alarm
;
: write-done ( -- ) wait-stream-done (write-done) ;
: write ( adr len -- actual )
- 4 to sd# audio-out install-playback-alarm true to playing?
+ 4 to sd# audio-out true to playing? install-playback-alarm
;
: ?end-sound ( -- )
@@ -475,11 +477,25 @@
\ Alarm handle to stop the stream when the content has been played.
: playback-completed-alarm ( -- )
stop-lock if exit then
- playing? if sd# ?end-sound to sd# then
+ playing? if
+ sd# ?end-sound to sd#
+ else
+ \ If playback has already stopped as a result of
+ \ someone else having waited for completion, we
+ \ just uninstall ourself.
+ uninstall-playback-alarm
+ then
;
' playback-completed-alarm is playback-alarm
+: still-playing? ( -- flag )
+ playing? 0= if false exit then
+ stop-lock if true exit then
+ sd# ?end-sound to sd#
+ playing?
+;
+
: wait-sound ( -- )
true to stop-lock
begin playing? while d# 10 ms ?end-sound repeat
Modified: dev/hdaudio/test.fth
===================================================================
--- dev/hdaudio/test.fth 2009-12-14 09:48:18 UTC (rev 1595)
+++ dev/hdaudio/test.fth 2009-12-14 10:01:05 UTC (rev 1596)
@@ -8,11 +8,9 @@
record-base record-len la1+ " dma-free" $call-parent
;
-: jingle ( -- ) " play-wav rom:splash" evaluate wait-sound ;
-
: ?key-abort ( -- )
key? if
- key h# 1b = abort" Aborting"
+ key h# 1b = if ." Aborting" abort then
then
;
: speaker-test ( -- )
@@ -21,14 +19,8 @@
." Disconnect headphones to continue.. "
begin ?key-abort pin-sense? 0= until cr
then
- ." Playing jingle on the left speaker.. "
- true to right-mute?
- jingle cr
- false to right-mute?
- true to left-mute?
- ." Playing jingle on the right speaker.. "
- jingle cr
- false to left-mute?
+ ." Playing left to right sweep "
+ make-sweep 0 set-volume play cr
;
: headphones-test ( -- )
@@ -37,9 +29,8 @@
." Connect headphones to continue.. "
begin ?key-abort pin-sense? until cr
then
- ." Press a key to play sound.. " key drop cr
h# 1f to node power-off \ turn off speaker
- jingle
+ make-sweep -9 set-volume play
h# 1f to node power-on \ turn speaker back on
;
More information about the openfirmware
mailing list