Web Images Videos Maps News Shopping Google Mail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Calling C from sound handler crashes system
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Jonathan Duddingon  
View profile   Translate to Translated (View Original)
 More options 1 Apr 2006, 00:27
Newsgroups: comp.sys.acorn.programmer
From: Jonathan Duddingon <nos...@jsd.clara.co.uk>
Date: Sat, 01 Apr 2006 00:27:46 +0100
Local: Sat 1 Apr 2006 00:27
Subject: Calling C from sound handler crashes system
The Speak text-to-speech module processes text into phonemes and then
into a lower level form of formants (peaks in the frequency spectrum)
which are then queued for output (the "wcmdq")

Speak registers a RISC_OS "Linear Sound Handler" (SWI &40145) which
runs as an interrupt (IRQ mode? I'm not sure of the correct
terminology) whenever the sound DMA needs filling.  Speak's sound
handler takes items from this wcmdq and converts them to the sound
waveform to put into the sound DMA.

When the wcmdq gets low, the sound handler sets a transient callback
(SWI &54) to ask the OS to run the user mode part of the module to
convert some more text->phonemes->wcmdq.

This all works properly in the currently available Speak version 2,
where the sound handler is written entirely in assembler.

I'm now trying to port a re-write which I did on Linux
(espeak.sourceforge.net) to RISC_OS.  I don't want to write the sound
waveform generation code in assembler, so the only assembler code is a
few lines of the sound handler which calls a C function and then sets
the callback if needed.

But calling the C function from the sound handler gives:
   not enough memory - stack overflow
   filecore in use
(which of course means the system then needs a restart).

The callback-setting is commented out, so that's not the problem.

Calling a dummy C function (one which just assigns a couple of
variables) is OK.  No error.

Calling a dummy C function which then calls another dummy C function
gives the error and doesn't return.

I've checked the ARM procedure calling protocols and I think that's OK.
The test code is:

 IMPORT DummyProc1

 DMA_Handler
 ;**********
 ; linear sound handler, fill the sound DMA
 ; preserve r11,r12,r13 (fp,ip,sp)
 ; r1,r2 start and end of DMA buffer

        MOV     r5,ip           ; need to save ip
        MOV     ip,sp           ;set up a stack
        STMFD   sp!, {fp,ip,lr,pc}

        MOV     r6,r1           ;DMA start  16 bit sound
        MOV     r7,r2           ;DMA end

        SUB     r0,r7,r6        ;r0 = size of DMA buffer
 BL  DummyProc1      ; which then calls DuumyProc2

 NOP
 MOV ip,r5
        LDMFD   sp, {fp,sp,pc}   ; procedure exit from Sound Handler

When the error occurs, the NOP isn't reached (i.e. DummyProc1 doesn't
return).

Am I doing something wrong, or is it just not possible to call a chain
of C functions from assembler in general, or from a sound handler in
particular?

--
  change nospam in the reply email address to "jsd"


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google