Subversion Repositories Kolibri OS

Rev

Rev 6347 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6347 Rev 6386
Line 1... Line 1...
1
#include "SDL_audio.h"
1
#include "SDL_audio.h"
2
#include 
2
#include 
3
#include 
3
#include 
4
#include 
4
#include 
5
#include 
5
#include 
6
#include 
6
#include 
Line 7... Line 7...
7
 
7
 
8
static void GetNotify(uint32_t* event)
8
static void GetNotify(__u32* event)
9
{
9
{
10
        __asm__("int $0x40" :: "a"(68),"b"(14),"c"(event));
10
        __asm__("int $0x40" :: "a"(68),"b"(14),"c"(event));
11
}
11
}
12
static int CreateThread(void* fn, char* p_stack)
12
static int CreateThread(void* fn, char* p_stack)
Line 34... Line 34...
34
static int bInitialized=0;
34
static int bInitialized=0;
35
static SNDBUF hBuff=0;
35
static SNDBUF hBuff=0;
36
static char* data=NULL;
36
static char* data=NULL;
37
static int audio_tid=0;
37
static int audio_tid=0;
38
static int main_slot;
38
static int main_slot;
39
static uint32_t main_tid;
39
static __u32 main_tid;
40
static char audio_thread_stack[40960];
40
static char audio_thread_stack[40960];
41
static uint32_t used_format=0;
41
static __u32 used_format=0;
42
static volatile int mix_size=0;
42
static volatile int mix_size=0;
Line 43... Line 43...
43
 
43
 
44
static void (*callback)(void* userdata, Uint8* stream, int len);
44
static void (*callback)(void* userdata, Uint8* stream, int len);
Line 79... Line 79...
79
static volatile int audio_command=0,audio_response=0,bLocked=0,bInCallback=0;
79
static volatile int audio_command=0,audio_response=0,bLocked=0,bInCallback=0;
80
static void audio_thread(void)
80
static void audio_thread(void)
81
{
81
{
82
	SDL_printf("audio_thread created\n");
82
	SDL_printf("audio_thread created\n");
83
        int bPaused;
83
        int bPaused;
84
        uint32_t event[6];
84
        __u32 event[6];
85
        // initialize
85
        // initialize
86
        if (CreateBuffer(used_format|PCM_RING, 0, &hBuff))
86
        if (CreateBuffer(used_format|PCM_RING, 0, &hBuff))
87
        {
87
        {
88
                audio_response=1;
88
                audio_response=1;
89
		__asm__ __volatile__("int $0x40" ::"a"(-1));
89
                __menuet__sys_exit();
90
        }
90
        }
91
        GetBufferSize(hBuff, &mix_size);
91
        GetBufferSize(hBuff, &mix_size);
92
        SDL_printf("buffer created, size is %d\n",mix_size);
92
        SDL_printf("buffer created, size is %d\n",mix_size);
93
        mix_size >>= 1;
93
        mix_size >>= 1;
94
        data = malloc(mix_size);
94
        data = malloc(mix_size);
95
        audio_response=1;
95
        audio_response=1;
96
        if (!data) __asm__ __volatile__("int $0x40" ::"a"(-1));
96
        if (!data) __menuet__sys_exit();
97
	// wait for resume
97
        // wait for resume
98
        while (audio_command!=AUDIO_RESUME)
98
        while (audio_command!=AUDIO_RESUME)
99
                Yield();
99
                Yield();
100
        // initialize
100
        // initialize
101
/*        bInCallback=1;
101
/*        bInCallback=1;
Line 128... Line 128...
128
                else if (audio_command==AUDIO_DIE)
128
                else if (audio_command==AUDIO_DIE)
129
                {
129
                {
130
                        audio_response = 1;
130
                        audio_response = 1;
131
                        StopBuffer(hBuff);
131
                        StopBuffer(hBuff);
132
                        DestroyBuffer(hBuff);
132
                        DestroyBuffer(hBuff);
133
                        __asm__ __volatile__("int $0x40" ::"a"(-1));
133
                        __menuet__sys_exit();
134
		}
134
                }
135
                else
135
                else
136
                {
136
                {
137
                	GetProcessInfo(main_slot);
137
                	GetProcessInfo(main_slot);
138
                	if (pinfo[0x32]==9 || *(uint32_t*)(pinfo+0x1E)!=main_tid)
138
                	if (pinfo[0x32]==9 || *(__u32*)(pinfo+0x1E)!=main_tid)
139
                	{
139
                	{
140
                		audio_command = AUDIO_DIE;
140
                		audio_command = AUDIO_DIE;
141
                		continue;
141
                		continue;
142
                	}
142
                	}
143
                }
143
                }
144
                if (bPaused)
144
                if (bPaused)
145
                        delay(500);
145
                        __menuet__delay100(5);
146
                else
146
                else
147
                {
147
                {
148
                        GetNotify(event);
148
                        GetNotify(event);
149
                        if (event[0] != 0xFF000001)
149
                        if (event[0] != 0xFF000001)
150
                        	continue;
150
                        	continue;
Line 228... Line 228...
228
                return -1;
228
                return -1;
229
        }
229
        }
230
        callback=desired->callback;
230
        callback=desired->callback;
231
        userdata=desired->userdata;
231
        userdata=desired->userdata;
232
        GetProcessInfo(-1);
232
        GetProcessInfo(-1);
233
        main_tid = *(uint32_t*)(pinfo+0x1E);
233
        main_tid = *(__u32*)(pinfo+0x1E);
234
        for (main_slot=0;;main_slot++)
234
        for (main_slot=0;;main_slot++)
235
        {
235
        {
236
                GetProcessInfo(main_slot);
236
                GetProcessInfo(main_slot);
237
                if (pinfo[0x32]!=9 && *(uint32_t*)(pinfo+0x1E)==main_tid)
237
                if (pinfo[0x32]!=9 && *(__u32*)(pinfo+0x1E)==main_tid)
238
        	        break;
238
        	        break;
239
        }
239
        }
240
        audio_tid=CreateThread(audio_thread,audio_thread_stack+40960);
240
        audio_tid=CreateThread(audio_thread,audio_thread_stack+40960);
241
        if (audio_tid<0)
241
        if (audio_tid<0)
242
        {
242
        {