tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / devs / AHI / Drivers / Void / void-playslave.c
blob332a4f3d6332cd1699b936249f50e5e5dad28862
2 #include <config.h>
4 #include <devices/ahi.h>
5 #include <exec/execbase.h>
6 #include <libraries/ahi_sub.h>
8 #include "DriverData.h"
9 #include "library.h"
11 #define dd ((struct VoidData*) AudioCtrl->ahiac_DriverData)
13 /******************************************************************************
14 ** The slave process **********************************************************
15 ******************************************************************************/
17 #undef SysBase
19 void Slave( struct ExecBase* SysBase );
21 #if defined( __AROS__ )
23 #include <aros/asmcall.h>
25 AROS_UFH3(void, SlaveEntry,
26 AROS_UFHA(STRPTR, argPtr, A0),
27 AROS_UFHA(ULONG, argSize, D0),
28 AROS_UFHA(struct ExecBase *, SysBase, A6))
30 AROS_USERFUNC_INIT
31 Slave( SysBase );
32 AROS_USERFUNC_EXIT
35 #else
37 void SlaveEntry(void)
39 struct ExecBase* SysBase = *((struct ExecBase**) 4);
41 Slave( SysBase );
43 #endif
45 void
46 Slave( struct ExecBase* SysBase )
48 struct AHIAudioCtrlDrv* AudioCtrl;
49 struct DriverBase* AHIsubBase;
50 BOOL running;
51 ULONG signals;
53 /* Note that in OS4, we cannot call FindTask(NULL) here, since IExec
54 * is inside AHIsubBase! */
55 AudioCtrl = (struct AHIAudioCtrlDrv*) FindTask(NULL)->tc_UserData;
56 AHIsubBase = (struct DriverBase*) dd->ahisubbase;
58 dd->slavesignal = AllocSignal( -1 );
60 if( dd->slavesignal != -1 )
62 // Everything set up. Tell Master we're alive and healthy.
64 Signal( (struct Task*) dd->mastertask,
65 1L << dd->mastersignal );
67 running = TRUE;
69 while( running )
71 signals = SetSignal(0L,0L);
73 if( signals & ( SIGBREAKF_CTRL_C | (1L << dd->slavesignal) ) )
75 running = FALSE;
77 else
79 CallHookPkt( AudioCtrl->ahiac_PlayerFunc, AudioCtrl, NULL );
80 CallHookPkt( AudioCtrl->ahiac_MixerFunc, AudioCtrl, dd->mixbuffer );
82 // The mixing buffer is now filled with AudioCtrl->ahiac_BuffSamples
83 // of sample frames (type AudioCtrl->ahiac_BuffType). Send them
84 // to the sound card here.
89 FreeSignal( dd->slavesignal );
90 dd->slavesignal = -1;
92 Forbid();
94 // Tell the Master we're dying
96 Signal( (struct Task*) dd->mastertask,
97 1L << dd->mastersignal );
99 dd->slavetask = NULL;
101 // Multitaking will resume when we are dead.