- Set a default PCM volume so that something can be heard when driver is
[AROS.git] / workbench / devs / AHI / Drivers / Void / void-playslave.c
blob6785a3688ff4d41e61e5e1f013bb7e2228edff63
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(LONG, 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 struct VoidBase* VoidBase;
51 BOOL running;
52 ULONG signals;
54 /* Note that in OS4, we cannot call FindTask(NULL) here, since IExec
55 * is inside AHIsubBase! */
56 AudioCtrl = (struct AHIAudioCtrlDrv*) SysBase->ThisTask->tc_UserData;
57 AHIsubBase = (struct DriverBase*) dd->ahisubbase;
58 VoidBase = (struct VoidBase*) AHIsubBase;
60 dd->slavesignal = AllocSignal( -1 );
62 if( dd->slavesignal != -1 )
64 // Everything set up. Tell Master we're alive and healthy.
66 Signal( (struct Task*) dd->mastertask,
67 1L << dd->mastersignal );
69 running = TRUE;
71 while( running )
73 signals = SetSignal(0L,0L);
75 if( signals & ( SIGBREAKF_CTRL_C | (1L << dd->slavesignal) ) )
77 running = FALSE;
79 else
81 CallHookPkt( AudioCtrl->ahiac_PlayerFunc, AudioCtrl, NULL );
82 CallHookPkt( AudioCtrl->ahiac_MixerFunc, AudioCtrl, dd->mixbuffer );
84 // The mixing buffer is now filled with AudioCtrl->ahiac_BuffSamples
85 // of sample frames (type AudioCtrl->ahiac_BuffType). Send them
86 // to the sound card here.
91 FreeSignal( dd->slavesignal );
92 dd->slavesignal = -1;
94 Forbid();
96 // Tell the Master we're dying
98 Signal( (struct Task*) dd->mastertask,
99 1L << dd->mastersignal );
101 dd->slavetask = NULL;
103 // Multitaking will resume when we are dead.