Subversion Repositories Kolibri OS

Rev

Rev 5603 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5603 Rev 6106
Line 8... Line 8...
8
#include "fplay.h"
8
#include "fplay.h"
9
 
9
 
Line 10... Line 10...
10
extern uint32_t  hw2d ;
10
extern uint32_t  hw2d ;
Line 11... Line -...
11
 
-
 
12
#if 0
-
 
13
#define FUTEX_INIT      0
-
 
14
#define FUTEX_DESTROY   1
-
 
15
#define FUTEX_WAIT      2
-
 
16
#define FUTEX_WAKE      3
-
 
17
 
-
 
18
int __fastcall mutex_init(mutex_t *mutex)
-
 
19
{
-
 
20
    unsigned int handle;
-
 
21
 
-
 
22
    mutex->lock = 0;
-
 
23
 
-
 
24
    asm volatile(
-
 
25
    "int $0x40\t"
-
 
26
    :"=a"(handle)
-
 
27
    :"a"(77),"b"(FUTEX_INIT),"c"(mutex));
-
 
28
    mutex->handle = handle;
-
 
29
 
-
 
30
    return handle;
-
 
31
};
-
 
32
 
-
 
33
int __fastcall mutex_destroy(mutex_t *mutex)
-
 
34
{
-
 
35
    int retval;
-
 
36
 
-
 
37
    asm volatile(
-
 
38
    "int $0x40\t"
-
 
39
    :"=a"(retval)
-
 
40
    :"a"(77),"b"(FUTEX_DESTROY),"c"(mutex->handle));
-
 
41
 
-
 
42
    return retval;
-
 
43
};
-
 
44
 
-
 
45
#define exchange_acquire(ptr, new) \
-
 
46
  __atomic_exchange_4((ptr), (new), __ATOMIC_ACQUIRE)
-
 
47
 
-
 
48
#define exchange_release(ptr, new) \
-
 
49
  __atomic_exchange_4((ptr), (new), __ATOMIC_RELEASE)
-
 
50
 
-
 
51
void __fastcall mutex_lock(mutex_t *mutex)
-
 
52
{
-
 
53
    int tmp;
-
 
54
 
-
 
55
    if( __sync_fetch_and_add(&mutex->lock, 1) == 0)
-
 
56
        return;
-
 
57
 
-
 
58
    while (exchange_acquire (&mutex->lock, 2) != 0)
-
 
59
    {
-
 
60
        asm volatile(
-
 
61
        "int $0x40\t"
-
 
62
        :"=a"(tmp)
-
 
63
        :"a"(77),"b"(FUTEX_WAIT),
-
 
64
        "c"(mutex->handle),"d"(2),"S"(0));
-
 
65
   }
-
 
66
}
-
 
67
 
-
 
68
int __fastcall mutex_trylock (mutex_t *mutex)
-
 
69
{
-
 
70
  int zero = 0;
-
 
71
 
-
 
72
  return __atomic_compare_exchange_4(&mutex->lock, &zero, 1,0,__ATOMIC_ACQUIRE,__ATOMIC_RELAXED);
-
 
73
}
-
 
74
 
-
 
75
void  __fastcall mutex_unlock(mutex_t *mutex)
-
 
76
{
-
 
77
    int prev;
-
 
78
 
-
 
79
    prev = exchange_release (&mutex->lock, 0);
-
 
80
 
-
 
81
    if (prev != 1)
-
 
82
    {
-
 
83
        asm volatile(
-
 
84
        "int $0x40\t"
-
 
85
        :"=a"(prev)
-
 
86
        :"a"(77),"b"(FUTEX_WAKE),
-
 
87
        "c"(mutex->handle),"d"(1));
-
 
88
    };
-
 
89
};
-
 
90
#endif
-
 
91
 
11
 
92
int64_t _lseeki64(int fd, int64_t offset,  int origin )
12
int64_t _lseeki64(int fd, int64_t offset,  int origin )
93
{
13
{
94
    int off = offset;
14
    int off = offset;
95
    return lseek(fd, off, origin);
15
    return lseek(fd, off, origin);
Line 96... Line 16...
96
}
16
}
97
 
17
 
98
int put_packet(queue_t *q, AVPacket *pkt)
18
int put_packet(queue_t *q, AVPacket *pkt)
Line 99... Line -...
99
{
-
 
100
    AVPacketList *q_pkt;
-
 
101
 
-
 
102
    /* duplicate the packet */
-
 
103
//    if (av_dup_packet(pkt) < 0)
19
{
104
//        return -1;
20
    AVPacketList *q_pkt;
105
 
21
 
Line 106... Line 22...
106
    q_pkt = av_malloc(sizeof(AVPacketList));
22
    q_pkt = av_malloc(sizeof(AVPacketList));