You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(35) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(37) |
Feb
(10) |
Mar
|
Apr
(2) |
May
(17) |
Jun
(1) |
Jul
(14) |
Aug
(14) |
Sep
(4) |
Oct
|
Nov
(14) |
Dec
(4) |
| 2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(92) |
Dec
(12) |
| 2006 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(5) |
May
(3) |
Jun
(15) |
Jul
(3) |
Aug
(1) |
Sep
(29) |
Oct
(1) |
Nov
(6) |
Dec
(5) |
| 2007 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
(3) |
May
(14) |
Jun
(2) |
Jul
(16) |
Aug
(73) |
Sep
(12) |
Oct
(9) |
Nov
(27) |
Dec
(3) |
| 2008 |
Jan
(4) |
Feb
(4) |
Mar
(3) |
Apr
(8) |
May
(23) |
Jun
(4) |
Jul
(1) |
Aug
(3) |
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
(1) |
| 2009 |
Jan
|
Feb
(10) |
Mar
|
Apr
(4) |
May
(4) |
Jun
(10) |
Jul
|
Aug
(1) |
Sep
|
Oct
(7) |
Nov
|
Dec
(1) |
| 2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(1) |
Sep
|
Oct
(15) |
Nov
(1) |
Dec
(5) |
| 2011 |
Jan
(4) |
Feb
(1) |
Mar
(6) |
Apr
|
May
(22) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2012 |
Jan
|
Feb
(10) |
Mar
(1) |
Apr
(6) |
May
(27) |
Jun
(48) |
Jul
(30) |
Aug
(4) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(11) |
| 2013 |
Jan
(4) |
Feb
(7) |
Mar
(6) |
Apr
(18) |
May
(28) |
Jun
(20) |
Jul
|
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(7) |
| 2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(9) |
May
(11) |
Jun
(10) |
Jul
|
Aug
(18) |
Sep
(12) |
Oct
(17) |
Nov
(10) |
Dec
(16) |
| 2015 |
Jan
(5) |
Feb
(1) |
Mar
(5) |
Apr
(4) |
May
(28) |
Jun
(2) |
Jul
|
Aug
|
Sep
(6) |
Oct
|
Nov
(2) |
Dec
(1) |
| 2016 |
Jan
(14) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(1) |
| 2017 |
Jan
(11) |
Feb
|
Mar
(21) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(13) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(10) |
Feb
(9) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(18) |
Jul
(4) |
Aug
(2) |
Sep
(20) |
Oct
(2) |
Nov
|
Dec
|
| 2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2022 |
Jan
(1) |
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
| 2023 |
Jan
(10) |
Feb
(7) |
Mar
(29) |
Apr
(31) |
May
(29) |
Jun
(34) |
Jul
(3) |
Aug
(24) |
Sep
(22) |
Oct
(10) |
Nov
(38) |
Dec
(27) |
| 2024 |
Jan
(15) |
Feb
(8) |
Mar
(4) |
Apr
(20) |
May
(33) |
Jun
(18) |
Jul
(15) |
Aug
(23) |
Sep
(26) |
Oct
(32) |
Nov
(6) |
Dec
(4) |
| 2025 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
(4) |
May
(46) |
Jun
(19) |
Jul
(26) |
Aug
(48) |
Sep
(30) |
Oct
(8) |
Nov
(9) |
Dec
|
|
From: <ljs...@us...> - 2007-05-25 14:37:20
|
Revision: 411
http://svn.sourceforge.net/cadcdev/?rev=411&view=rev
Author: ljsebald
Date: 2007-05-25 07:37:18 -0700 (Fri, 25 May 2007)
Log Message:
-----------
Made the UDP code so that it works in an irq properly.
Modified Paths:
--------------
kos/kernel/net/net_udp.c
Modified: kos/kernel/net/net_udp.c
===================================================================
--- kos/kernel/net/net_udp.c 2007-05-25 14:28:34 UTC (rev 410)
+++ kos/kernel/net/net_udp.c 2007-05-25 14:37:18 UTC (rev 411)
@@ -15,6 +15,7 @@
#include <sys/queue.h>
#include <kos/dbgio.h>
#include <kos/fs_socket.h>
+#include <arch/irq.h>
#include <sys/socket.h>
#include <errno.h>
#include "net_ipv4.h"
@@ -70,7 +71,15 @@
/* Get the sockaddr_in structure, rather than the sockaddr one */
realaddr = (struct sockaddr_in *) addr;
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *)hnd->data;
if(udpsock == NULL) {
@@ -133,7 +142,15 @@
return -1;
}
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *)hnd->data;
if(udpsock == NULL) {
@@ -172,7 +189,15 @@
struct udp_sock *udpsock;
struct udp_pkt *pkt;
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *)hnd->data;
if(udpsock == NULL) {
@@ -199,7 +224,8 @@
return -1;
}
- if(TAILQ_EMPTY(&udpsock->packets) && (udpsock->flags & O_NONBLOCK)) {
+ if(TAILQ_EMPTY(&udpsock->packets) && ((udpsock->flags & O_NONBLOCK) ||
+ irq_inside_int())) {
mutex_unlock(udp_mutex);
errno = EWOULDBLOCK;
return -1;
@@ -234,7 +260,15 @@
struct udp_sock *udpsock;
struct udp_pkt *pkt;
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *)hnd->data;
if(udpsock == NULL) {
@@ -254,7 +288,8 @@
return -1;
}
- if(TAILQ_EMPTY(&udpsock->packets) && (udpsock->flags & O_NONBLOCK)) {
+ if(TAILQ_EMPTY(&udpsock->packets) && ((udpsock->flags & O_NONBLOCK) ||
+ irq_inside_int())) {
mutex_unlock(udp_mutex);
errno = EWOULDBLOCK;
return -1;
@@ -304,7 +339,15 @@
int flags) {
struct udp_sock *udpsock;
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *)hnd->data;
if(udpsock == NULL) {
@@ -366,7 +409,15 @@
struct udp_sock *udpsock;
struct sockaddr_in *realaddr;
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *)hnd->data;
if(udpsock == NULL) {
@@ -419,7 +470,15 @@
int net_udp_shutdownsock(net_socket_t *hnd, int how) {
struct udp_sock *udpsock;
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *)hnd->data;
if(udpsock == NULL) {
@@ -461,7 +520,16 @@
TAILQ_INIT(&udpsock->packets);
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
+
LIST_INSERT_HEAD(&net_udp_sockets, udpsock, sock_list);
mutex_unlock(udp_mutex);
@@ -474,12 +542,21 @@
struct udp_sock *udpsock;
struct udp_pkt *pkt;
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *)hnd->data;
if(udpsock == NULL) {
mutex_unlock(udp_mutex);
errno = EBADF;
+ return;
}
TAILQ_FOREACH(pkt, &udpsock->packets, pkt_queue) {
@@ -497,7 +574,15 @@
int net_udp_setflags(net_socket_t *hnd, int flags) {
struct udp_sock *udpsock;
- mutex_lock(udp_mutex);
+ if(irq_inside_int()) {
+ if(mutex_trylock(udp_mutex) == -1) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ }
+ else {
+ mutex_lock(udp_mutex);
+ }
udpsock = (struct udp_sock *) hnd->data;
if(udpsock == NULL) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ljs...@us...> - 2007-05-25 14:28:36
|
Revision: 410
http://svn.sourceforge.net/cadcdev/?rev=410&view=rev
Author: ljsebald
Date: 2007-05-25 07:28:34 -0700 (Fri, 25 May 2007)
Log Message:
-----------
Made net_ipv4_checksum accept the number of bytes in the data to be checksummed rather than the number of words.
Modified Paths:
--------------
kos/kernel/net/net_icmp.c
kos/kernel/net/net_ipv4.c
kos/kernel/net/net_ipv4.h
kos/kernel/net/net_udp.c
Modified: kos/kernel/net/net_icmp.c
===================================================================
--- kos/kernel/net/net_icmp.c 2007-05-25 03:14:34 UTC (rev 409)
+++ kos/kernel/net/net_icmp.c 2007-05-25 14:28:34 UTC (rev 410)
@@ -102,13 +102,13 @@
/* Recompute the IP header checksum */
ip->checksum = 0;
- ip->checksum = net_ipv4_checksum((uint16*)ip,
- 2 * (ip->version_ihl & 0x0f));
+ ip->checksum = net_ipv4_checksum((uint8 *)ip,
+ 4 * (ip->version_ihl & 0x0f));
/* Recompute the ICMP header checksum */
icmp->checksum = 0;
- icmp->checksum = net_ipv4_checksum((uint16*)icmp, ntohs(ip->length) /
- 2 - 2 * (ip->version_ihl & 0x0f));
+ icmp->checksum = net_ipv4_checksum((uint8 *)icmp, ntohs(ip->length) -
+ 4 * (ip->version_ihl & 0x0f));
/* Send it */
memcpy(pktbuf, ip, 20);
@@ -129,9 +129,8 @@
i = icmp->checksum;
icmp->checksum = 0;
memcpy(pktbuf, icmp, ntohs(ip->length) - 4 * (ip->version_ihl & 0x0f));
- icmp->checksum = net_ipv4_checksum((uint16*)pktbuf,
- (ntohs(ip->length) + 1) / 2 -
- 2 * (ip->version_ihl & 0x0f));
+ icmp->checksum = net_ipv4_checksum(pktbuf, (ntohs(ip->length) + 1) -
+ 4 * (ip->version_ihl & 0x0f));
if (i != icmp->checksum) {
dbglog(DBG_KDEBUG, "net_icmp: icmp with invalid checksum\n");
@@ -198,11 +197,10 @@
ip.dest = htonl(net_ipv4_address(ipaddr));
/* Compute the ICMP Checksum */
- icmp->checksum = net_ipv4_checksum((uint16*)databuf,
- (sizeof(icmp_hdr_t) + size) / 2);
+ icmp->checksum = net_ipv4_checksum(databuf, sizeof(icmp_hdr_t) + size);
/* Compute the IP Checksum */
- ip.checksum = net_ipv4_checksum((uint16*)&ip, sizeof(ip_hdr_t) / 2);
+ ip.checksum = net_ipv4_checksum((uint8 *)&ip, sizeof(ip_hdr_t));
newping = (struct __ping_pkt*) malloc(sizeof(struct __ping_pkt));
newping->data = (uint8 *)malloc(size);
Modified: kos/kernel/net/net_ipv4.c
===================================================================
--- kos/kernel/net/net_ipv4.c 2007-05-25 03:14:34 UTC (rev 409)
+++ kos/kernel/net/net_ipv4.c 2007-05-25 14:28:34 UTC (rev 410)
@@ -19,20 +19,45 @@
#include "net_udp.h"
/* Perform an IP-style checksum on a block of data */
-uint16 net_ipv4_checksum(const uint16 *data, int words) {
- uint32 sum;
+uint16 net_ipv4_checksum(const uint8 *data, int bytes) {
+ uint32 sum = 0;
int i;
- sum = 0;
- for (i=0; i<words; i++) {
- sum += data[i];
- if (sum & 0xffff0000) {
- sum &= 0xffff;
- sum++;
- }
- }
+ /* Make sure we don't do any unaligned memory accesses */
+ if(((uint32)data) & 0x01) {
+ for(i = 0; i < bytes; i += 2) {
+ sum += (data[i]) | (data[i + 1] << 8);
- return ~(sum & 0xffff);
+ if(sum & 0xFFFF0000) {
+ sum &= 0xFFFF;
+ ++sum;
+ }
+ }
+ }
+ else {
+ uint16 *ptr = (uint16 *)data;
+
+ for(i = 0; i < (bytes >> 1); ++i) {
+ sum += ptr[i];
+
+ if(sum & 0xFFFF0000) {
+ sum &= 0xFFFF;
+ ++sum;
+ }
+ }
+ }
+
+ /* Handle the last byte, if we have an odd byte count */
+ if(bytes & 0x01) {
+ sum += data[bytes - 1];
+
+ if(sum & 0xFFFF0000) {
+ sum &= 0xFFFF;
+ ++sum;
+ }
+ }
+
+ return sum ^ 0xFFFF;
}
/* Determine if a given IP is in the current network */
@@ -130,7 +155,7 @@
/* Check ip header checksum */
i = ip->checksum;
ip->checksum = 0;
- ip->checksum = net_ipv4_checksum((uint16*)ip, 2 *
+ ip->checksum = net_ipv4_checksum((uint8 *)ip, 4 *
(ip->version_ihl & 0x0f));
if(i != ip->checksum) {
Modified: kos/kernel/net/net_ipv4.h
===================================================================
--- kos/kernel/net/net_ipv4.h 2007-05-25 03:14:34 UTC (rev 409)
+++ kos/kernel/net/net_ipv4.h 2007-05-25 14:28:34 UTC (rev 410)
@@ -43,7 +43,7 @@
} ip_pseudo_hdr_t;
#undef packed
-uint16 net_ipv4_checksum(const uint16 *data, int words);
+uint16 net_ipv4_checksum(const uint8 *data, int bytes);
int net_ipv4_send_packet(netif_t *net, ip_hdr_t *hdr, const uint8 *data, int size);
int net_ipv4_input(netif_t *src, const uint8 *pkt, int pktsize);
Modified: kos/kernel/net/net_udp.c
===================================================================
--- kos/kernel/net/net_udp.c 2007-05-25 03:14:34 UTC (rev 409)
+++ kos/kernel/net/net_udp.c 2007-05-25 14:28:34 UTC (rev 410)
@@ -537,12 +537,12 @@
ps->data[size - sizeof(udp_hdr_t)] = 0;
checksum = ps->checksum;
ps->checksum = 0;
- ps->checksum = net_ipv4_checksum((uint16 *) buf, (size + 13) >> 1);
+ ps->checksum = net_ipv4_checksum(buf, size + 13);
}
else {
checksum = ps->checksum;
ps->checksum = 0;
- ps->checksum = net_ipv4_checksum((uint16 *) buf, (size + 12) >> 1);
+ ps->checksum = net_ipv4_checksum(buf, size + 12);
}
if(checksum != ps->checksum) {
@@ -631,12 +631,10 @@
/* Compute the UDP checksum */
if(size & 0x01) {
- ps->checksum = net_ipv4_checksum((uint16 *) buf,
- (size + 13) >> 1);
+ ps->checksum = net_ipv4_checksum(buf, size + 13);
}
else {
- ps->checksum = net_ipv4_checksum((uint16 *) buf,
- (size + 12) >> 1);
+ ps->checksum = net_ipv4_checksum(buf, size + 12);
}
/* Fill in the IPv4 Header */
@@ -652,7 +650,7 @@
ip.dest = ps->dst_addr;
/* Compute the IPv4 checksum */
- ip.checksum = net_ipv4_checksum((uint16 *) &ip, sizeof(ip_hdr_t) >> 1);
+ ip.checksum = net_ipv4_checksum((uint8 *) &ip, sizeof(ip_hdr_t));
/* send it away.... */
if(net_ipv4_send_packet(net, &ip, buf + 12, size)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ljs...@us...> - 2007-05-25 03:14:35
|
Revision: 409
http://svn.sourceforge.net/cadcdev/?rev=409&view=rev
Author: ljsebald
Date: 2007-05-24 20:14:34 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Made it so that the IPv4 input code does not pass around ethernet headers. Also, fixed a few little issues with ping packet sending.
Modified Paths:
--------------
kos/kernel/net/net_icmp.c
kos/kernel/net/net_icmp.h
kos/kernel/net/net_input.c
kos/kernel/net/net_ipv4.c
kos/kernel/net/net_ipv4.h
kos/kernel/net/net_udp.c
kos/kernel/net/net_udp.h
Modified: kos/kernel/net/net_icmp.c
===================================================================
--- kos/kernel/net/net_icmp.c 2007-05-25 01:37:40 UTC (rev 408)
+++ kos/kernel/net/net_icmp.c 2007-05-25 03:14:34 UTC (rev 409)
@@ -3,7 +3,7 @@
kernel/net/net_icmp.c
Copyright (C) 2002 Dan Potter
- Copyright (C) 2005, 2006 Lawrence Sebald
+ Copyright (C) 2005, 2006, 2007 Lawrence Sebald
*/
@@ -64,8 +64,8 @@
net_echo_cb net_icmp_echo_cb = icmp_default_echo_cb;
/* Handle Echo Reply (ICMP type 0) packets */
-static void net_icmp_input_0(netif_t *src, eth_hdr_t *eth, ip_hdr_t *ip,
- icmp_hdr_t *icmp, const uint8 *d, int s) {
+static void net_icmp_input_0(netif_t *src, ip_hdr_t *ip, icmp_hdr_t *icmp,
+ const uint8 *d, int s) {
uint64 tmr;
struct __ping_pkt *ping;
uint16 seq;
@@ -88,19 +88,13 @@
}
/* Handle Echo (ICMP type 8) packets */
-static void net_icmp_input_8(netif_t *src, eth_hdr_t *eth, ip_hdr_t *ip,
- icmp_hdr_t *icmp, const uint8 *d, int s) {
- uint8 tmp[6];
+static void net_icmp_input_8(netif_t *src, ip_hdr_t *ip, icmp_hdr_t *icmp,
+ const uint8 *d, int s) {
int i;
/* Set type to echo reply */
icmp->type = 0;
- /* Swap source and dest addresses */
- memcpy(tmp, eth->dest, 6);
- memcpy(eth->dest, eth->src, 6);
- memcpy(eth->src, tmp, 6);
-
/* Swap source and dest ip addresses */
i = ip->src;
ip->src = ip->dest;
@@ -117,15 +111,13 @@
2 - 2 * (ip->version_ihl & 0x0f));
/* Send it */
- memcpy(pktbuf, eth, 14);
- memcpy(pktbuf + 14, ip, 20);
- memcpy(pktbuf + 14 + 20, d, ntohs(ip->length) - 4 *
- (ip->version_ihl & 0x0F));
- src->if_tx(src, pktbuf, 14 + ntohs(ip->length), NETIF_BLOCK);
+ memcpy(pktbuf, ip, 20);
+ memcpy(pktbuf + 20, d, ntohs(ip->length) - 4 * (ip->version_ihl & 0x0F));
+ net_ipv4_send_packet(src, ip, pktbuf + 20, ntohs(ip->length) -
+ 4 * (ip->version_ihl & 0x0F));
}
-int net_icmp_input(netif_t *src, eth_hdr_t *eth, ip_hdr_t *ip, const uint8 *d,
- int s) {
+int net_icmp_input(netif_t *src, ip_hdr_t *ip, const uint8 *d, int s) {
icmp_hdr_t *icmp;
int i;
@@ -148,7 +140,7 @@
switch(icmp->type) {
case 0: /* Echo reply */
- net_icmp_input_0(src, eth, ip, icmp, d, s);
+ net_icmp_input_0(src, ip, icmp, d, s);
break;
case 3: /* Destination unreachable */
dbglog(DBG_KDEBUG, "net_icmp: Destination unreachable,"
@@ -156,7 +148,7 @@
break;
case 8: /* Echo */
- net_icmp_input_8(src, eth, ip, icmp, d, s);
+ net_icmp_input_8(src, ip, icmp, d, s);
break;
default:
@@ -184,7 +176,7 @@
icmp->checksum = 0;
icmp->misc[0] = (uint8) 'D';
icmp->misc[1] = (uint8) 'C';
- icmp->misc[2] = (uint8) (icmp_echo_seq >> 16);
+ icmp->misc[2] = (uint8) (icmp_echo_seq >> 8);
icmp->misc[3] = (uint8) (icmp_echo_seq & 0xFF);
memcpy(databuf + sizeof(icmp_hdr_t), data, size);
@@ -197,7 +189,12 @@
ip.ttl = 64;
ip.protocol = 1; /* ICMP */
ip.checksum = 0;
- ip.src = htonl(net_ipv4_address(net->ip_addr));
+
+ if(net_ipv4_address(ipaddr) == 0x7F000001)
+ ip.src = htonl(net_ipv4_address(ipaddr));
+ else
+ ip.src = htonl(net_ipv4_address(net->ip_addr));
+
ip.dest = htonl(net_ipv4_address(ipaddr));
/* Compute the ICMP Checksum */
Modified: kos/kernel/net/net_icmp.h
===================================================================
--- kos/kernel/net/net_icmp.h 2007-05-25 01:37:40 UTC (rev 408)
+++ kos/kernel/net/net_icmp.h 2007-05-25 03:14:34 UTC (rev 409)
@@ -2,10 +2,8 @@
kernel/net/net_icmp.h
Copyright (C) 2002 Dan Potter
- Copyright (C) 2005 Lawrence Sebald
+ Copyright (C) 2005, 2007 Lawrence Sebald
- $Id: net_icmp.h,v 1.2 2002/03/24 00:27:05 bardtx Exp $
-
*/
#ifndef __LOCAL_NET_ICMP_H
@@ -26,8 +24,7 @@
} icmp_hdr_t;
#undef packed
-int net_icmp_input(netif_t *src, eth_hdr_t *eh, ip_hdr_t *ih, const uint8 *data,
- int size);
+int net_icmp_input(netif_t *src, ip_hdr_t *ih, const uint8 *data, int size);
__END_DECLS
Modified: kos/kernel/net/net_input.c
===================================================================
--- kos/kernel/net/net_input.c 2007-05-25 01:37:40 UTC (rev 408)
+++ kos/kernel/net/net_input.c 2007-05-25 03:14:34 UTC (rev 409)
@@ -23,7 +23,8 @@
switch(ntohs(*proto)) {
case 0x0800:
- return net_ipv4_input(nif, data, len);
+ return net_ipv4_input(nif, data + sizeof(eth_hdr_t),
+ len - sizeof(eth_hdr_t));
case 0x0806:
return net_arp_input(nif, data, len);
default:
Modified: kos/kernel/net/net_ipv4.c
===================================================================
--- kos/kernel/net/net_ipv4.c 2007-05-25 01:37:40 UTC (rev 408)
+++ kos/kernel/net/net_ipv4.c 2007-05-25 03:14:34 UTC (rev 409)
@@ -2,7 +2,7 @@
kernel/net/net_ipv4.c
- Copyright (C) 2005, 2006 Lawrence Sebald
+ Copyright (C) 2005, 2006, 2007 Lawrence Sebald
Portions adapted from KOS' old net_icmp.c file:
Copyright (c) 2002 Dan Potter
@@ -119,25 +119,14 @@
}
int net_ipv4_input(netif_t *src, const uint8 *pkt, int pktsize) {
- eth_hdr_t *eth;
ip_hdr_t *ip;
int i;
uint8 *data;
- uint16 *ethproto;
/* Get pointers */
- eth = (eth_hdr_t*) (pkt);
- ip = (ip_hdr_t*) (pkt + sizeof(eth_hdr_t));
- data = (uint8 *) (pkt + sizeof(eth_hdr_t) + 4 *
- (ip->version_ihl & 0x0f));
- ethproto = (uint16 *) (pkt + 12);
+ ip = (ip_hdr_t*) pkt;
+ data = (uint8 *) (pkt + 4 * (ip->version_ihl & 0x0f));
- /* Make sure this packet is actually marked as an IP packet */
- if(ntohs(*ethproto) != 0x0800) {
- dbglog(DBG_KDEBUG, "net_ipv4: Discarding non IP packet\n");
- return 0;
- }
-
/* Check ip header checksum */
i = ip->checksum;
ip->checksum = 0;
@@ -152,11 +141,11 @@
switch(ip->protocol) {
case 1:
- net_icmp_input(src, eth, ip, data, ntohs(ip->length) -
+ net_icmp_input(src, ip, data, ntohs(ip->length) -
(ip->version_ihl & 0x0f) * 4);
break;
case 17:
- net_udp_input(src, eth, ip, data, ntohs(ip->length) -
+ net_udp_input(src, ip, data, ntohs(ip->length) -
(ip->version_ihl & 0x0f) * 4);
break;
default:
Modified: kos/kernel/net/net_ipv4.h
===================================================================
--- kos/kernel/net/net_ipv4.h 2007-05-25 01:37:40 UTC (rev 408)
+++ kos/kernel/net/net_ipv4.h 2007-05-25 03:14:34 UTC (rev 409)
@@ -1,7 +1,7 @@
/* KallistiOS ##version##
kernel/net/net_ipv4.h
- Copyright (C) 2005 Lawrence Sebald
+ Copyright (C) 2005, 2007 Lawrence Sebald
*/
Modified: kos/kernel/net/net_udp.c
===================================================================
--- kos/kernel/net/net_udp.c 2007-05-25 01:37:40 UTC (rev 408)
+++ kos/kernel/net/net_udp.c 2007-05-25 03:14:34 UTC (rev 409)
@@ -1,7 +1,7 @@
/* KallistiOS ##version##
kernel/net/net_udp.c
- Copyright (C) 2005, 2006 Lawrence Sebald
+ Copyright (C) 2005, 2006, 2007 Lawrence Sebald
*/
@@ -518,8 +518,7 @@
return 0;
}
-int net_udp_input(netif_t *src, eth_hdr_t *eh, ip_hdr_t *ip, const uint8 *data,
- int size) {
+int net_udp_input(netif_t *src, ip_hdr_t *ip, const uint8 *data, int size) {
uint8 buf[size + 13];
ip_pseudo_hdr_t *ps = (ip_pseudo_hdr_t *)buf;
uint16 checksum;
Modified: kos/kernel/net/net_udp.h
===================================================================
--- kos/kernel/net/net_udp.h 2007-05-25 01:37:40 UTC (rev 408)
+++ kos/kernel/net/net_udp.h 2007-05-25 03:14:34 UTC (rev 409)
@@ -1,7 +1,7 @@
/* KallistiOS ##version##
kernel/net/net_udp.h
- Copyright (C) 2005, 2006 Lawrence Sebald
+ Copyright (C) 2005, 2006, 2007 Lawrence Sebald
*/
@@ -20,8 +20,7 @@
} udp_hdr_t;
#undef packed
-int net_udp_input(netif_t *src, eth_hdr_t *eh, ip_hdr_t *ih, const uint8 *data,
- int size);
+int net_udp_input(netif_t *src, ip_hdr_t *ih, const uint8 *data, int size);
int net_udp_send_raw(netif_t *net, uint32 src_ip, uint16 src_port,
uint32 dst_ip, uint16 dst_port, const uint8 *data,
int size);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ljs...@us...> - 2007-05-25 01:37:45
|
Revision: 408
http://svn.sourceforge.net/cadcdev/?rev=408&view=rev
Author: ljsebald
Date: 2007-05-24 18:37:40 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Rearranged the network shutdown stuff so that it happens in a more correct order.
Modified Paths:
--------------
kos/kernel/net/net_core.c
Modified: kos/kernel/net/net_core.c
===================================================================
--- kos/kernel/net/net_core.c 2007-05-25 01:29:11 UTC (rev 407)
+++ kos/kernel/net/net_core.c 2007-05-25 01:37:40 UTC (rev 408)
@@ -148,6 +148,7 @@
/* Initialize the UDP system */
net_udp_init();
+ /* Initialize the sockets-like interface */
fs_socket_init();
return 0;
@@ -155,9 +156,18 @@
/* Shutdown */
void net_shutdown() {
- /* Shut down all activated network devices */
netif_t *cur;
+ /* Shut down the sockets-like interface */
+ fs_socket_shutdown();
+
+ /* Shut down the UDP system */
+ net_udp_shutdown();
+
+ /* Shut down the ARP cache */
+ net_arp_shutdown();
+
+ /* Shut down all activated network devices */
LIST_FOREACH(cur, &net_if_list, if_list) {
if (cur->flags & NETIF_RUNNING && cur->if_stop)
cur->if_stop(cur);
@@ -168,12 +178,4 @@
/* Blank out the list */
LIST_INIT(&net_if_list);
-
- /* Shut down the ARP cache */
- net_arp_shutdown();
-
- /* Shut down the UDP system */
- net_udp_shutdown();
-
- fs_socket_shutdown();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ljs...@us...> - 2007-05-25 01:29:12
|
Revision: 407
http://svn.sourceforge.net/cadcdev/?rev=407&view=rev
Author: ljsebald
Date: 2007-05-24 18:29:11 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Added in a short delay during initialization of the lan adapter. Mine seems to need a delay after initialization before sending anything out on it.
Modified Paths:
--------------
kos/kernel/arch/dreamcast/hardware/network/lan_adapter.c
Modified: kos/kernel/arch/dreamcast/hardware/network/lan_adapter.c
===================================================================
--- kos/kernel/arch/dreamcast/hardware/network/lan_adapter.c 2007-05-25 01:16:24 UTC (rev 406)
+++ kos/kernel/arch/dreamcast/hardware/network/lan_adapter.c 2007-05-25 01:29:11 UTC (rev 407)
@@ -582,6 +582,12 @@
if (!(self->flags & NETIF_INITIALIZED))
return -1;
+ /* The Lan adapter seems a bit picky if you try to send packets too soonly
+ after initialization (or at least mine is). 3 seconds seems to be enough
+ of a delay, but 2 seconds certainly is not. Give it 4 seconds, just in
+ case its in a bad mood this run. */
+ timer_spin_sleep(4000);
+
self->flags |= NETIF_RUNNING;
if (la_started == LA_PAUSED)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ljs...@us...> - 2007-05-25 01:16:25
|
Revision: 406
http://svn.sourceforge.net/cadcdev/?rev=406&view=rev
Author: ljsebald
Date: 2007-05-24 18:16:24 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Added in code to support polling receives on the BBA. Also, made it so that this new functionality works in an irq.
Modified Paths:
--------------
kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c
Modified: kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c
===================================================================
--- kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c 2007-05-25 01:10:09 UTC (rev 405)
+++ kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c 2007-05-25 01:16:24 UTC (rev 406)
@@ -4,6 +4,7 @@
Copyright (C)2001,2003,2005 Dan Potter
Copyright (C)2004 Vincent Penne
+ Copyright (C)2007 Lawrence Sebald
*/
@@ -517,7 +518,7 @@
if (len <= 0)
return 1;
- if (len > DMA_THRESHOLD) {
+ if (len > DMA_THRESHOLD && !irq_inside_int()) {
uint32 add;
/*
@@ -952,9 +953,26 @@
return 0;
}
-/* All RX is done via the interrupt */
static int bba_if_rx_poll(netif_t *self) {
- return -1;
+ int intr;
+
+ intr = g2_read_16(NIC(RT_INTRSTATUS));
+
+ if (intr & RT_INT_RX_ACK) {
+ bba_rx();
+
+ /* so that the irq is not called */
+ g2_write_16(NIC(RT_INTRSTATUS), RT_INT_RX_ACK);
+ }
+
+ if (rxout != rxin) {
+ /* Call the callback to process it */
+ eth_rx_callback(rx_pkt[rxout].rxbuff, rx_pkt[rxout].pkt_size);
+
+ rxout = (rxout + 1) % MAX_PKTS;
+ }
+
+ return 0;
}
/* Don't need to hook anything here yet */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ljs...@us...> - 2007-05-25 01:10:16
|
Revision: 405
http://svn.sourceforge.net/cadcdev/?rev=405&view=rev
Author: ljsebald
Date: 2007-05-24 18:10:09 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Got rid of net_ntohl and net_ntohs, considering ntohl and ntohs have been in here for a while.
Modified Paths:
--------------
kos/kernel/net/net_ipv4.c
kos/kernel/net/net_ipv4.h
Modified: kos/kernel/net/net_ipv4.c
===================================================================
--- kos/kernel/net/net_ipv4.c 2007-05-25 01:06:52 UTC (rev 404)
+++ kos/kernel/net/net_ipv4.c 2007-05-25 01:10:09 UTC (rev 405)
@@ -18,15 +18,6 @@
#include "net_icmp.h"
#include "net_udp.h"
-uint16 net_ntohs(uint16 n) {
- return ((n & 0xff) << 8) | ((n >> 8) & 0xff);
-}
-
-uint32 net_ntohl(uint32 n) {
- return ((n & 0xFF) << 24) | ((n & 0xFF00) << 8) |
- ((n >> 8) & 0xFF00) | ((n >> 24) & 0xFF);
-}
-
/* Perform an IP-style checksum on a block of data */
uint16 net_ipv4_checksum(const uint16 *data, int words) {
uint32 sum;
Modified: kos/kernel/net/net_ipv4.h
===================================================================
--- kos/kernel/net/net_ipv4.h 2007-05-25 01:06:52 UTC (rev 404)
+++ kos/kernel/net/net_ipv4.h 2007-05-25 01:10:09 UTC (rev 405)
@@ -47,7 +47,4 @@
int net_ipv4_send_packet(netif_t *net, ip_hdr_t *hdr, const uint8 *data, int size);
int net_ipv4_input(netif_t *src, const uint8 *pkt, int pktsize);
-uint16 net_ntohs(uint16 n);
-uint32 net_ntohl(uint32 n);
-
#endif /* __LOCAL_NET_IPV4_H */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ljs...@us...> - 2007-05-25 01:06:54
|
Revision: 404
http://svn.sourceforge.net/cadcdev/?rev=404&view=rev
Author: ljsebald
Date: 2007-05-24 18:06:52 -0700 (Thu, 24 May 2007)
Log Message:
-----------
Fixed a crashing issue in the ARP shutdown code and made the ARP code garbage collect expired entries on each lookup.
Modified Paths:
--------------
kos/kernel/net/net_arp.c
Modified: kos/kernel/net/net_arp.c
===================================================================
--- kos/kernel/net/net_arp.c 2007-05-08 00:10:41 UTC (rev 403)
+++ kos/kernel/net/net_arp.c 2007-05-25 01:06:52 UTC (rev 404)
@@ -95,6 +95,9 @@
int net_arp_lookup(netif_t *nif, uint8 ip_in[4], uint8 mac_out[6]) {
netarp_t *cur;
+ /* Garbage collect expired entries */
+ net_arp_gc();
+
/* Look for the entry */
LIST_FOREACH(cur, &net_arp_cache, ac_list) {
if (!memcmp(ip_in, cur->ip, 4)) {
@@ -140,7 +143,7 @@
return -1;
}
-/* Send an ARP reply packet on the specified network adaptor */
+/* Send an ARP reply packet on the specified network adapter */
static int net_arp_send(netif_t *nif, arp_pkt_t *pkt) {
arp_pkt_t pkt_out;
eth_hdr_t eth_hdr;
@@ -261,7 +264,7 @@
a1 = LIST_FIRST(&net_arp_cache);
while (a1 != NULL) {
a2 = LIST_NEXT(a1, ac_list);
- free(a2);
+ free(a1);
a1 = a2;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-05-08 00:10:44
|
Revision: 403
http://svn.sourceforge.net/cadcdev/?rev=403&view=rev
Author: c99koder
Date: 2007-05-07 17:10:41 -0700 (Mon, 07 May 2007)
Log Message:
-----------
Tiki: win32: initialize OpenAL without ALUT
Modified Paths:
--------------
tiki/win32/src/init_shutdown.cpp
Modified: tiki/win32/src/init_shutdown.cpp
===================================================================
--- tiki/win32/src/init_shutdown.cpp 2007-05-06 15:15:21 UTC (rev 402)
+++ tiki/win32/src/init_shutdown.cpp 2007-05-08 00:10:41 UTC (rev 403)
@@ -6,18 +6,28 @@
#include "Tiki/stream.h"
#include <al.h>
-#include <alut.h>
+#include <alc.h>
#include <MMSystem.h>
#pragma comment(lib, "winmm.lib")
-#pragma comment(lib, "ALut.lib")
#pragma comment(lib, "OpenAL32.lib")
bool Tiki::init(int argc, char **argv) {
// Let us run with millisecond precision if possible.
timeBeginPeriod(1);
- alutInit(&argc, argv);
+ ALCdevice *dev = NULL;
+ ALCcontext *ctx = NULL;
+
+ dev = alcOpenDevice(getenv("OPENAL_DEVICE")); // getenv()==NULL is okay.
+ if (dev != NULL) {
+ ctx = alcCreateContext(dev, 0);
+ if (ctx != NULL) {
+ alcMakeContextCurrent(ctx);
+ alcProcessContext(ctx);
+ } // if
+ } // if
+
Audio::Stream::initGlobal();
Audio::Sound::initGlobal();
@@ -31,7 +41,6 @@
Hid::shutdown();
Audio::Sound::shutdownGlobal();
Audio::Stream::shutdownGlobal();
- alutExit();
timeEndPeriod(1);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-05-06 15:15:25
|
Revision: 402
http://svn.sourceforge.net/cadcdev/?rev=402&view=rev
Author: c99koder
Date: 2007-05-06 08:15:21 -0700 (Sun, 06 May 2007)
Log Message:
-----------
Tiki: dc: fix KOS sfx wrapper class
Modified Paths:
--------------
tiki/dc/src/audio/sound.cpp
Modified: tiki/dc/src/audio/sound.cpp
===================================================================
--- tiki/dc/src/audio/sound.cpp 2007-05-01 20:43:50 UTC (rev 401)
+++ tiki/dc/src/audio/sound.cpp 2007-05-06 15:15:21 UTC (rev 402)
@@ -42,6 +42,8 @@
//////////////////////////////////////////////////////////////////////////////////////////
Sound::Sound(const string & fn) {
+ handle = SFXHND_INVALID;
+
if (!loadFromFile(fn))
assert( false );
}
@@ -73,11 +75,11 @@
}
int Sound::play() {
- return play((int)(m_default_vol * 255), 0x80);
+ return play(m_default_vol, 0x80);
}
int Sound::play(float vol) {
- return play((int)(vol * 255), 0x80);
+ return play(vol, 0x80);
}
int Sound::play(float vol, float pan) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-05-01 20:43:52
|
Revision: 401
http://svn.sourceforge.net/cadcdev/?rev=401&view=rev
Author: c99koder
Date: 2007-05-01 13:43:50 -0700 (Tue, 01 May 2007)
Log Message:
-----------
Tiki: win32: define _WIN32_WINNT=0x0500 (required for WM_SCROLLWHEEL)
Modified Paths:
--------------
tiki/win32/tiki_vs80.vcproj
Modified: tiki/win32/tiki_vs80.vcproj
===================================================================
--- tiki/win32/tiki_vs80.vcproj 2007-05-01 20:42:51 UTC (rev 400)
+++ tiki/win32/tiki_vs80.vcproj 2007-05-01 20:43:50 UTC (rev 401)
@@ -42,6 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="include;../include;../3rdparty/libpng;../3rdparty/zlib;../3rdparty/libjpeg;../3rdparty/libogg/include;../3rdparty/libvorbis/include;"C:\Program Files\OpenAL 1.1 SDK\include""
+ PreprocessorDefinitions="_WIN32_WINNT=0x0500"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -107,6 +108,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="include;../include;../3rdparty/libpng;../3rdparty/zlib;../3rdparty/libjpeg;../3rdparty/libogg/include;../3rdparty/libvorbis/include;"C:\Program Files\OpenAL 1.1 SDK\include""
+ PreprocessorDefinitions="_WIN32_WINNT=0x0500"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="pch.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-05-01 20:42:55
|
Revision: 400
http://svn.sourceforge.net/cadcdev/?rev=400&view=rev
Author: c99koder
Date: 2007-05-01 13:42:51 -0700 (Tue, 01 May 2007)
Log Message:
-----------
Tiki: win32: Make Tiki multitask better and support mouse wheel events
Modified Paths:
--------------
tiki/win32/src/platgl.cpp
tiki/win32/src/plathid.cpp
Modified: tiki/win32/src/platgl.cpp
===================================================================
--- tiki/win32/src/platgl.cpp 2007-05-01 19:20:11 UTC (rev 399)
+++ tiki/win32/src/platgl.cpp 2007-05-01 20:42:51 UTC (rev 400)
@@ -109,10 +109,16 @@
m_hThread = CreateThread(NULL, 0, GameThread, lpCmdLine, 0, &m_dwThreadID);
- while(m_hThread != NULL && GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ while(m_hThread != NULL) {
+ do {
+ if (GetMessage(&msg, NULL, NULL, NULL)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ } while (::PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE));
+
+ Sleep(2);
}
return (int)msg.wParam;
@@ -135,6 +141,9 @@
case WM_MBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
+#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) //WM_MOUSEWHEEL requires Windows 98 or above
+ case WM_MOUSEWHEEL:
+#endif
Tiki::RecvEvent(iMsg, wParam, lParam);
break;
case WM_CLOSE:
Modified: tiki/win32/src/plathid.cpp
===================================================================
--- tiki/win32/src/plathid.cpp 2007-05-01 19:20:11 UTC (rev 399)
+++ tiki/win32/src/plathid.cpp 2007-05-01 20:42:51 UTC (rev 400)
@@ -1,6 +1,5 @@
#include "pch.h"
#include "Tiki/hid.h"
-
using namespace Tiki::Hid;
class KbDevice : public Device {
@@ -185,6 +184,7 @@
evt.y = HIWORD(lParam);
sendEvent(evt);
}
+ break;
case WM_LBUTTONUP:
case WM_LBUTTONDOWN:
@@ -196,6 +196,7 @@
evt.y = HIWORD(lParam);
sendEvent(evt);
}
+ break;
case WM_MBUTTONUP:
case WM_MBUTTONDOWN:
@@ -207,6 +208,7 @@
evt.y = HIWORD(lParam);
sendEvent(evt);
}
+ break;
case WM_RBUTTONUP:
case WM_RBUTTONDOWN:
@@ -218,7 +220,19 @@
evt.y = HIWORD(lParam);
sendEvent(evt);
}
-
+ break;
+#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) //WM_MOUSEWHEEL requires Windows 98 or above
+ case WM_MOUSEWHEEL:
+ {
+ Event evt(Event::EvtBtnPress);
+ evt.dev = win32mouse;
+ evt.btn = (GET_WHEEL_DELTA_WPARAM(wParam) < 0) ? Event::MouseWheelDown : Event::MouseWheelUp;
+ evt.x = LOWORD(lParam);
+ evt.y = HIWORD(lParam);
+ sendEvent(evt);
+ }
+ break;
+#endif
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-05-01 19:20:13
|
Revision: 399
http://svn.sourceforge.net/cadcdev/?rev=399&view=rev
Author: c99koder
Date: 2007-05-01 12:20:11 -0700 (Tue, 01 May 2007)
Log Message:
-----------
Tiki: replace deprecated ALUT code with pure OpenAL
Modified Paths:
--------------
tiki/src/audio/sound.cpp
tiki/src/audio/stream.cpp
Modified: tiki/src/audio/sound.cpp
===================================================================
--- tiki/src/audio/sound.cpp 2007-05-01 18:21:33 UTC (rev 398)
+++ tiki/src/audio/sound.cpp 2007-05-01 19:20:11 UTC (rev 399)
@@ -13,16 +13,6 @@
#include <string.h>
-#if TIKI_PLAT == TIKI_OSX
-# include <OpenAL/alut.h>
-#else
-#if TIKI_PLAT == TIKI_SDL
-# include <AL/alut.h>
-#else
-# include <alut.h>
-#endif
-#endif
-
/*
This port of the snd_sfx manager uses OpenAL to do its work. For simplicity's
@@ -131,23 +121,69 @@
ALsizei size;
ALvoid* data;
ALsizei freq;
+
+ char magic[4];
+ uint32 len, hz;
+ uint16 *tmp, chn, bitsize, fmt;
+
+ File wavFile(fn,"r");
+ wavFile.seek(8, SEEK_SET);
+ wavFile.read(magic, 4);
+
+ if(strncmp(magic, "WAVE", 4)) {
+ Debug::printf("Sound::loadFromFile: file is not RIFF WAVE\n");
+ wavFile.close();
+ alDeleteBuffers(1, &m_buffer); m_buffer = 0;
+ return false;
+ }
+
+ /* Read WAV header info */
+ wavFile.seek(0x14, SEEK_SET);
+ wavFile.readle16(&fmt, 1);
+ wavFile.readle16(&chn, 1);
+ wavFile.readle32(&hz, 1);
+ wavFile.seek(0x22, SEEK_SET);
+ wavFile.readle16(&bitsize, 1);
+
+ /* Read WAV data */
+ wavFile.seek(0x28, SEEK_SET);
+ wavFile.readle32(&len, 1);
-// Good one, Apple...
-#if TIKI_PLAT == TIKI_OSX
- alutLoadWAVFile((ALbyte *)fn.c_str(), &format, &data, &size, &freq);
-#else
- ALboolean looping;
- alutLoadWAVFile((ALbyte *)fn.c_str(), &format, &data, &size, &freq, &looping);
-#endif
- ALuint err = alGetError();
- if (err != AL_NO_ERROR) {
- Debug::printf("Sound::loadFromFile: couldn't load WAV: %d\n", err);
+ Debug::printf("WAVE file is %s, %dHZ, %d bits/sample, %d bytes total, format %d\n",
+ chn==1 ? "mono" : "stereo", hz, bitsize, len, fmt);
+
+ if(chn == 1 && bitsize == 8) {
+ format = AL_FORMAT_MONO8;
+ } else if(chn == 1 && bitsize == 16) {
+ format = AL_FORMAT_MONO16;
+ } else if(chn == 2 && bitsize == 8) {
+ format = AL_FORMAT_STEREO8;
+ } else if(chn == 2 && bitsize == 16) {
+ format = AL_FORMAT_STEREO16;
+ } else {
+ Debug::printf("Sound::loadFromFile: unsupported bitsize / channel combination\n");
+ wavFile.close();
alDeleteBuffers(1, &m_buffer); m_buffer = 0;
return false;
}
+
+ size = (ALsizei)len;
+ freq = (ALsizei)hz;
+
+ data = malloc(len);
+ if(bitsize == 8) {
+ wavFile.read(data, len);
+ } else { //byte swapping may be needed, depending on host endianness
+ for(int i = 0; i < size; i+=2) {
+ wavFile.readle16((uint8 *)data + i, 1);
+ }
+ }
+
alBufferData(m_buffer, format, data, size, freq);
check();
- alutUnloadWAV(format, data, size, freq);
+
+ free(data);
+ wavFile.close();
check();
if (format == AL_FORMAT_MONO16 || format == AL_FORMAT_MONO8)
Modified: tiki/src/audio/stream.cpp
===================================================================
--- tiki/src/audio/stream.cpp 2007-05-01 18:21:33 UTC (rev 398)
+++ tiki/src/audio/stream.cpp 2007-05-01 19:20:11 UTC (rev 399)
@@ -12,16 +12,6 @@
#include <string.h>
-#if TIKI_PLAT == TIKI_OSX
-# include <OpenAL/alut.h>
-#else
-#if TIKI_PLAT == TIKI_SDL
-# include <AL/alut.h>
-#else
-# include <alut.h>
-#endif
-#endif
-
using namespace Tiki::Audio;
using namespace Tiki::Thread;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-05-01 18:21:35
|
Revision: 398
http://svn.sourceforge.net/cadcdev/?rev=398&view=rev
Author: c99koder
Date: 2007-05-01 11:21:33 -0700 (Tue, 01 May 2007)
Log Message:
-----------
Tiki: handle mouse wheel events on OS X
Modified Paths:
--------------
tiki/osx/src/TikiMain.m
tiki/osx/src/plathid.mm
Modified: tiki/osx/src/TikiMain.m
===================================================================
--- tiki/osx/src/TikiMain.m 2007-04-20 01:23:50 UTC (rev 397)
+++ tiki/osx/src/TikiMain.m 2007-05-01 18:21:33 UTC (rev 398)
@@ -177,6 +177,7 @@
case NSLeftMouseUp:
case NSRightMouseDown:
case NSRightMouseUp:
+ case NSScrollWheel:
{
NSPoint point = [event locationInWindow];
// make Y start in top left vs bottom left
Modified: tiki/osx/src/plathid.mm
===================================================================
--- tiki/osx/src/plathid.mm 2007-04-20 01:23:50 UTC (rev 397)
+++ tiki/osx/src/plathid.mm 2007-05-01 18:21:33 UTC (rev 398)
@@ -176,6 +176,19 @@
sendEvent(evt);
}
break;
+ case NSScrollWheel:
+ {
+ if([event deltaY] != 0) { //only handle up and down for now
+ Event evt(Event::EvtBtnPress);
+ evt.port = 0;
+ evt.dev = cocoaMouse;
+ evt.x = (int)point->x;
+ evt.y = (int)point->y;
+ evt.btn = ([event deltaY] < 0) ? Event::MouseWheelDown : Event::MouseWheelUp;
+ sendEvent(evt);
+ }
+ }
+ break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-04-20 01:23:53
|
Revision: 397
http://svn.sourceforge.net/cadcdev/?rev=397&view=rev
Author: c99koder
Date: 2007-04-19 18:23:50 -0700 (Thu, 19 Apr 2007)
Log Message:
-----------
Tiki: TikiSnake: Add Visual Studio project file and fix Win32 compile errors
Modified Paths:
--------------
tiki/examples/console/TikiSnake/src/TikiSnake.cpp
tiki/examples/console/TikiSnake/src/snake.cpp
Added Paths:
-----------
tiki/examples/console/TikiSnake/TikiSnake.sln
tiki/examples/console/TikiSnake/TikiSnake.vcproj
tiki/examples/console/TikiSnake/resources/OpenAL32.dll
tiki/examples/console/TikiSnake/resources/alut.dll
Added: tiki/examples/console/TikiSnake/TikiSnake.sln
===================================================================
--- tiki/examples/console/TikiSnake/TikiSnake.sln (rev 0)
+++ tiki/examples/console/TikiSnake/TikiSnake.sln 2007-04-20 01:23:50 UTC (rev 397)
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TikiSnake", "TikiSnake.vcproj", "{FCAE4EF3-7B5D-4C0D-8793-4157F7D8709F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FCAE4EF3-7B5D-4C0D-8793-4157F7D8709F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {FCAE4EF3-7B5D-4C0D-8793-4157F7D8709F}.Debug|Win32.Build.0 = Debug|Win32
+ {FCAE4EF3-7B5D-4C0D-8793-4157F7D8709F}.Release|Win32.ActiveCfg = Release|Win32
+ {FCAE4EF3-7B5D-4C0D-8793-4157F7D8709F}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: tiki/examples/console/TikiSnake/TikiSnake.vcproj
===================================================================
--- tiki/examples/console/TikiSnake/TikiSnake.vcproj (rev 0)
+++ tiki/examples/console/TikiSnake/TikiSnake.vcproj 2007-04-20 01:23:50 UTC (rev 397)
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="TikiSnake"
+ ProjectGUID="{FCAE4EF3-7B5D-4C0D-8793-4157F7D8709F}"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..\win32\include;..\..\..\include;"C:\Program Files\OpenAL 1.1 SDK\include""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="gdi32.lib kernel32.lib user32.lib opengl32.lib glu32.lib comdlg32.lib"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="..\..\..\win32\Debug;"C:\Program Files\OpenAL 1.1 SDK\libs\Win32""
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\..\win32\include;..\..\..\include;"C:\Program Files\OpenAL 1.1 SDK\include""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="gdi32.lib kernel32.lib user32.lib opengl32.lib glu32.lib comdlg32.lib"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="..\..\..\win32\Release;C:\Program Files\OpenAL 1.1 SDK\libs\Win32"
+ IgnoreDefaultLibraryNames=""
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\src\snake.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\TikiSnake.cpp"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: tiki/examples/console/TikiSnake/resources/OpenAL32.dll
===================================================================
(Binary files differ)
Property changes on: tiki/examples/console/TikiSnake/resources/OpenAL32.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: tiki/examples/console/TikiSnake/resources/alut.dll
===================================================================
(Binary files differ)
Property changes on: tiki/examples/console/TikiSnake/resources/alut.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: tiki/examples/console/TikiSnake/src/TikiSnake.cpp
===================================================================
--- tiki/examples/console/TikiSnake/src/TikiSnake.cpp 2007-04-20 01:22:28 UTC (rev 396)
+++ tiki/examples/console/TikiSnake/src/TikiSnake.cpp 2007-04-20 01:23:50 UTC (rev 397)
@@ -10,6 +10,7 @@
#if TIKI_PLAT == TIKI_WIN32
#include <windows.h>
+#include "pch.h"
static char szAppName[] = "TikiSnake";
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Modified: tiki/examples/console/TikiSnake/src/snake.cpp
===================================================================
--- tiki/examples/console/TikiSnake/src/snake.cpp 2007-04-20 01:22:28 UTC (rev 396)
+++ tiki/examples/console/TikiSnake/src/snake.cpp 2007-04-20 01:23:50 UTC (rev 397)
@@ -59,7 +59,7 @@
bool go=1;
bool dead=0;
- srand(time(NULL));
+ //srand(time(NULL));
// Init Tiki
if(!Tiki::init(argc, argv))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-04-20 01:22:30
|
Revision: 396
http://svn.sourceforge.net/cadcdev/?rev=396&view=rev
Author: c99koder
Date: 2007-04-19 18:22:28 -0700 (Thu, 19 Apr 2007)
Log Message:
-----------
Tiki: add Console drawable to Visual Studio 2005 project
Modified Paths:
--------------
tiki/win32/tiki_vs80.vcproj
Modified: tiki/win32/tiki_vs80.vcproj
===================================================================
--- tiki/win32/tiki_vs80.vcproj 2007-04-15 20:59:34 UTC (rev 395)
+++ tiki/win32/tiki_vs80.vcproj 2007-04-20 01:22:28 UTC (rev 396)
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="include;../include;../3rdparty/libpng;../3rdparty/zlib;../3rdparty/libjpeg;../3rdparty/libogg/include;../3rdparty/libvorbis/include;../../../OpenAL/include"
+ AdditionalIncludeDirectories="include;../include;../3rdparty/libpng;../3rdparty/zlib;../3rdparty/libjpeg;../3rdparty/libogg/include;../3rdparty/libvorbis/include;"C:\Program Files\OpenAL 1.1 SDK\include""
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -106,7 +106,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="include;../include;../3rdparty/libpng;../3rdparty/zlib;../3rdparty/libjpeg;../3rdparty/libogg/include;../3rdparty/libvorbis/include;../../../OpenAL/include"
+ AdditionalIncludeDirectories="include;../include;../3rdparty/libpng;../3rdparty/zlib;../3rdparty/libjpeg;../3rdparty/libogg/include;../3rdparty/libvorbis/include;"C:\Program Files\OpenAL 1.1 SDK\include""
RuntimeLibrary="0"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="pch.h"
@@ -300,6 +300,10 @@
>
</File>
<File
+ RelativePath="..\src\gl\drawables\console.cpp"
+ >
+ </File>
+ <File
RelativePath="..\src\gl\drawables\cursor.cpp"
>
</File>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-04-15 20:59:49
|
Revision: 395
http://svn.sourceforge.net/cadcdev/?rev=395&view=rev
Author: bardtx
Date: 2007-04-15 13:59:34 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
tiki: make refcnt/refptr /actually/ thread-safe on win32 (we need some
solution for other plats that can have multiple cores still probably...)
Modified Paths:
--------------
tiki/include/Tiki/refcnt.h
tiki/src/base/object.cpp
Modified: tiki/include/Tiki/refcnt.h
===================================================================
--- tiki/include/Tiki/refcnt.h 2007-02-28 20:04:09 UTC (rev 394)
+++ tiki/include/Tiki/refcnt.h 2007-04-15 20:59:34 UTC (rev 395)
@@ -37,7 +37,11 @@
void unref();
protected:
+#if TIKI_PLAT == TIKI_WIN32
+ long m_refcnt;
+#else
int m_refcnt;
+#endif
};
/// A "smart pointer" to handle the RefCnt objects.
Modified: tiki/src/base/object.cpp
===================================================================
--- tiki/src/base/object.cpp 2007-02-28 20:04:09 UTC (rev 394)
+++ tiki/src/base/object.cpp 2007-04-15 20:59:34 UTC (rev 395)
@@ -25,19 +25,29 @@
void RefCnt::ref() {
assert( this != NULL );
+
+ // This actually ought to be in plat, probably...
+#if TIKI_PLAT == TIKI_WIN32
+ InterlockedIncrement(&m_refcnt);
+#else
m_refcnt++;
+#endif
}
void RefCnt::unref() {
assert( this != NULL );
+#if TIKI_PLAT == TIKI_WIN32
+ InterlockedDecrement(&m_refcnt);
+#else
m_refcnt--;
+#endif
+
if (m_refcnt < 0) {
Debug::printf("RefCnt::unref() refcount underflow! this=%p\n", this);
assert( false );
- } else {
- if (m_refcnt == 0)
- delete this;
+ } else if (m_refcnt == 0) {
+ delete this;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-02-28 20:04:11
|
Revision: 394
http://svn.sourceforge.net/cadcdev/?rev=394&view=rev
Author: c99koder
Date: 2007-02-28 12:04:09 -0800 (Wed, 28 Feb 2007)
Log Message:
-----------
Tiki: lower priority of dreamcast audio thread
Modified Paths:
--------------
tiki/dc/src/audio/stream.cpp
Modified: tiki/dc/src/audio/stream.cpp
===================================================================
--- tiki/dc/src/audio/stream.cpp 2007-02-28 19:43:35 UTC (rev 393)
+++ tiki/dc/src/audio/stream.cpp 2007-02-28 20:04:09 UTC (rev 394)
@@ -190,7 +190,7 @@
m_threadActive = false;
}
lock.unlock();
- thd_sleep(2);
+ thd_sleep(50);
}
printf("Stopping stream...\n");
snd_stream_stop(hnd);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-02-28 19:54:52
|
Revision: 393
http://svn.sourceforge.net/cadcdev/?rev=393&view=rev
Author: c99koder
Date: 2007-02-28 11:43:35 -0800 (Wed, 28 Feb 2007)
Log Message:
-----------
Tiki: Dreamcast sound streaming wrapper
Modified Paths:
--------------
tiki/dc/src/audio/stream.cpp
tiki/include/Tiki/stream.h
Modified: tiki/dc/src/audio/stream.cpp
===================================================================
--- tiki/dc/src/audio/stream.cpp 2007-01-28 22:41:27 UTC (rev 392)
+++ tiki/dc/src/audio/stream.cpp 2007-02-28 19:43:35 UTC (rev 393)
@@ -3,6 +3,7 @@
stream.cpp
+ Copyright (C)2007 Sam Steele
Copyright (C)2005 Cryptic Allusion, LLC
*/
@@ -10,10 +11,33 @@
#include "Tiki/stream.h"
#include <string.h>
+#include <vector>
using namespace Tiki::Audio;
using namespace Tiki::Thread;
+Stream *streams[SND_STREAM_MAX];
+static uint8 pcm_buffer[SND_STREAM_BUFFER_MAX+16384];
+
+void *cbk(snd_stream_hnd_t hnd, int size, int * size_out) {
+ int pcm_decoded = 0;
+
+ /* Check if the callback requests more data than our buffer can hold */
+ if (size > SND_STREAM_BUFFER_MAX)
+ size = SND_STREAM_BUFFER_MAX;
+
+ pcm_decoded = size / (2 * streams[(int)hnd]->getChannelCount());
+ Stream::GetDataResult rv = streams[(int)hnd]->getData((uint16 *)pcm_buffer,&pcm_decoded);
+ pcm_decoded *= (2 * streams[(int)hnd]->getChannelCount());
+ if(rv == Stream::GDError || rv == Stream::GDEOS) {
+ *size_out = 0;
+ return NULL;
+ } else {
+ *size_out = pcm_decoded;
+ return pcm_buffer;
+ }
+}
+
TIKI_OBJECT_NAME(Stream)
TIKI_OBJECT_BEGIN(Object, Stream)
TIKI_OBJECT_RECEIVER("start", Stream::objectStart)
@@ -30,13 +54,15 @@
Stream::Stream() {
// Default our members.
- m_bufSize = 0x4000;
- m_chnCount = 2;
+ m_bufSize = SND_STREAM_BUFFER_MAX;
+ m_chnCount = 1;
m_freq = 44100;
m_queueing = false;
- m_isPlaying = false;
m_volume = 0.8f;
m_mutex = new Mutex();
+ m_thread = NULL;
+ m_threadActive = false;
+ m_state = StateStopped;
}
Stream::~Stream() {
@@ -44,16 +70,21 @@
}
bool Stream::create() {
- AutoLock lock(m_mutex);
+ destroy();
+
+ assert( m_state == StateStopped );
+ hnd = snd_stream_alloc(cbk,SND_STREAM_BUFFER_MAX);
+ streams[hnd] = this;
+
return true;
}
void Stream::destroy() {
- AutoLock lock(m_mutex);
+ stop();
+
+ assert( m_state == StateStopped );
}
-// virtual void filter(int freq, int chncount, void * buffer, int smpcnt) { }
-
void Stream::filterAdd(Filter * f) {
AutoLock lock(m_mutex);
@@ -85,24 +116,37 @@
}
void Stream::start() {
- AutoLock lock(m_mutex);
- m_isPlaying = true;
+ if (m_state != StateStopped)
+ return;
+
+ m_state = StatePlaying;
+ snd_stream_volume(hnd,int(255.0f * m_volume));
+ printf("Starting audio thread...\n");
+ m_threadActive = true;
+ m_thread = new Thread::Thread(alThreadProc, this);
}
void Stream::stop() {
- AutoLock lock(m_mutex);
+ if (m_state == StateStopped)
+ return;
- pause();
+ assert( m_thread );
+ m_threadActive = false;
+ printf("Joining audio thread...\n");
+ m_thread->join();
+ delete m_thread;
+ m_thread = NULL;
}
void Stream::pause() {
- AutoLock lock(m_mutex);
- m_isPlaying = false;
+ if (m_state != StatePlaying)
+ return;
+
+ m_state = StatePaused;
}
void Stream::resume() {
AutoLock lock(m_mutex);
- m_isPlaying = true;
}
void Stream::setVolume(float vol) {
@@ -112,9 +156,7 @@
}
bool Stream::isPlaying() {
- AutoLock lock(m_mutex);
-
- return m_isPlaying;
+ return m_state == StatePlaying;
}
int Stream::objectStart(Object * /*from*/, Object * /*arg*/) {
@@ -129,32 +171,31 @@
void Stream::processFilters(void * buffer, int smpcnt) {
}
-// "len" is a *sample* count.
-void Stream::sepData(void * buffer, int len, bool stereo, int16 * outl, int16 * outr) {
- int16 * sep_buffer[2] = { outl, outr };
- int16 * bufsrc, * bufdst;
- int cnt;
+void * Stream::alThreadProc(void * u) {
+ Stream * us = (Stream *)u;
+ us->threadProc();
+ return NULL;
+}
- if (stereo) {
- bufsrc = (int16*)buffer;
- bufdst = sep_buffer[0];
- cnt = len;
- do {
- *bufdst = *bufsrc;
- bufdst++; bufsrc+=2; cnt--;
- } while (cnt > 0);
+void Stream::threadProc() {
+ int stat;
+
+ printf("Starting stream...\n");
+ snd_stream_start(hnd,m_freq,m_chnCount-1);
- bufsrc = (int16*)buffer; bufsrc++;
- bufdst = sep_buffer[1];
- cnt = len;
- do {
- *bufdst = *bufsrc;
- bufdst++; bufsrc+=2; cnt--;
- } while (cnt > 0);
- } else {
- memcpy(sep_buffer[0], buffer, len * 2);
- memcpy(sep_buffer[1], buffer, len * 2);
+ while (m_threadActive) {
+ AutoLock lock(m_mutex);
+ if((stat = snd_stream_poll(hnd)) < 0) {
+ printf("Stopping, status: %d\n",stat);
+ m_threadActive = false;
+ }
+ lock.unlock();
+ thd_sleep(2);
}
+ printf("Stopping stream...\n");
+ snd_stream_stop(hnd);
+ m_state = StateStopped;
+ printf("Stream stopped\n");
}
Stream::GetDataResult Stream::getData(uint16 * buffer, int * numSamples) {
Modified: tiki/include/Tiki/stream.h
===================================================================
--- tiki/include/Tiki/stream.h 2007-01-28 22:41:27 UTC (rev 392)
+++ tiki/include/Tiki/stream.h 2007-02-28 19:43:35 UTC (rev 393)
@@ -75,6 +75,7 @@
void setQueueing(bool isQueued);
void setFrequency(int freq);
void setChannelCount(int chncount);
+ int getChannelCount() { return m_chnCount; }
virtual void start();
virtual void stop();
virtual void pause();
@@ -87,7 +88,7 @@
int objectStart(Object * from, Object * arg);
int objectStop(Object * from, Object * arg);
-protected:
+public:
// Your subclass must override this to provide data for the stream. When
// this is called, you should try to place numSamples samples into buffer.
// Return the disposition of the stream, and place the actual number of
@@ -103,8 +104,9 @@
};
virtual GetDataResult getData(uint16 * buffer, int * numSamples);
+protected:
void processFilters(void * buffer, int smpcnt);
-static void sepData(void * buffer, int len, bool stereo, int16 * outl, int16 * outr);
+ void sepData(void * buffer, int len, bool stereo, int16 * outl, int16 * outr);
protected:
@@ -128,11 +130,13 @@
ALuint m_buffers[2];
ALuint m_source;
ALenum m_format;
+#else
+
#endif
Thread::Thread * m_thread;
volatile bool m_threadActive;
-static void * alThreadProc(void * us);
+static void * alThreadProc(void * us);
void threadProc();
void check();
#if TIKI_PLAT != TIKI_DC && TIKI_PLAT != TIKI_NDS
@@ -141,7 +145,7 @@
#if TIKI_PLAT == TIKI_DC
private:
- bool m_isPlaying;
+ int hnd;
#endif
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2007-01-28 22:41:29
|
Revision: 392
http://svn.sourceforge.net/cadcdev/?rev=392&view=rev
Author: c99koder
Date: 2007-01-28 14:41:27 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
Tiki: Win32: Center window on screen, and don't make window resizable
Modified Paths:
--------------
tiki/win32/src/platgl.cpp
Modified: tiki/win32/src/platgl.cpp
===================================================================
--- tiki/win32/src/platgl.cpp 2007-01-01 03:31:29 UTC (rev 391)
+++ tiki/win32/src/platgl.cpp 2007-01-28 22:41:27 UTC (rev 392)
@@ -89,10 +89,16 @@
if(!RegisterClassEx(&wc))
return FALSE;
- AdjustWindowRect(&WindowRect, WS_OVERLAPPEDWINDOW, FALSE);
+ AdjustWindowRect(&WindowRect, WS_POPUP|WS_CAPTION|WS_SYSMENU, FALSE);
- m_hWndMain = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, m_hInstance, NULL);
+ //Center the window
+ WindowRect.left += (GetSystemMetrics(SM_CXSCREEN)/2 - m_targetW/2);
+ WindowRect.right += (GetSystemMetrics(SM_CXSCREEN)/2 - m_targetW/2);
+ WindowRect.top += (GetSystemMetrics(SM_CYSCREEN)/2 - m_targetH/2);
+ WindowRect.bottom += (GetSystemMetrics(SM_CYSCREEN)/2 - m_targetH/2);
+ m_hWndMain = CreateWindow(szAppName, szAppName, WS_POPUP|WS_CAPTION|WS_SYSMENU, WindowRect.left, WindowRect.top, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, m_hInstance, NULL);
+
if(!m_hWndMain)
return FALSE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <at...@us...> - 2007-01-01 03:31:32
|
Revision: 391
http://svn.sourceforge.net/cadcdev/?rev=391&view=rev
Author: atani
Date: 2006-12-31 19:31:29 -0800 (Sun, 31 Dec 2006)
Log Message:
-----------
Various fixes for Code::Blocks 1.0rc2 and gcc on win32.
Modified Paths:
--------------
tiki/3rdparty/libjpeg/jconfig.h
tiki/3rdparty/libogg/include/ogg/os_types.h
tiki/examples/TikiTest/tikitest.cbp
tiki/examples/TikiTest/tikitest.layout
tiki/src/gl/texture.cpp
tiki/win32/tiki.cbp
tiki/win32/tiki.layout
Modified: tiki/3rdparty/libjpeg/jconfig.h
===================================================================
--- tiki/3rdparty/libjpeg/jconfig.h 2006-12-31 03:17:23 UTC (rev 390)
+++ tiki/3rdparty/libjpeg/jconfig.h 2007-01-01 03:31:29 UTC (rev 391)
@@ -23,7 +23,7 @@
#undef INCOMPLETE_TYPES_BROKEN
/* Define "boolean" as unsigned char, not int, per Windows custom */
-#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
+#if !defined(boolean)
typedef unsigned char boolean;
#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
Modified: tiki/3rdparty/libogg/include/ogg/os_types.h
===================================================================
--- tiki/3rdparty/libogg/include/ogg/os_types.h 2006-12-31 03:17:23 UTC (rev 390)
+++ tiki/3rdparty/libogg/include/ogg/os_types.h 2007-01-01 03:31:29 UTC (rev 391)
@@ -24,7 +24,7 @@
#define _ogg_realloc realloc
#define _ogg_free free
-#ifdef _WIN32
+#ifdef _WIN32
# ifndef __GNUC__
/* MSVC/Borland */
@@ -33,14 +33,21 @@
typedef unsigned __int32 ogg_uint32_t;
typedef __int16 ogg_int16_t;
typedef unsigned __int16 ogg_uint16_t;
-# else
+# elif defined(__GNUC__)
+ /* MingW32/GCC */
+ typedef short ogg_int16_t;
+ typedef unsigned short ogg_uint16_t;
+ typedef int ogg_int32_t;
+ typedef unsigned int ogg_uint32_t;
+ typedef long long ogg_int64_t;
+# else
/* Cygwin */
#include <_G_config.h>
typedef _G_int64_t ogg_int64_t;
typedef _G_int32_t ogg_int32_t;
typedef _G_uint32_t ogg_uint32_t;
typedef _G_int16_t ogg_int16_t;
- typedef _G_uint16_t ogg_uint16_t;
+ typedef _G_uint16_t ogg_uint16_t;
# endif
#elif defined(__MACOS__)
Modified: tiki/examples/TikiTest/tikitest.cbp
===================================================================
--- tiki/examples/TikiTest/tikitest.cbp 2006-12-31 03:17:23 UTC (rev 390)
+++ tiki/examples/TikiTest/tikitest.cbp 2007-01-01 03:31:29 UTC (rev 391)
@@ -6,7 +6,7 @@
<Option title="TikiTest"/>
<Option makefile="Makefile"/>
<Option makefile_is_custom="0"/>
- <Option compiler="1"/>
+ <Option compiler="0"/>
<Build>
<Target title="default">
<Option output="C:\projects\tiki\examples\TikiTest\tikitest.exe"/>
@@ -14,7 +14,7 @@
<Option object_output=".objs"/>
<Option deps_output=".deps"/>
<Option type="0"/>
- <Option compiler="1"/>
+ <Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="0"/>
</Target>
</Build>
@@ -26,19 +26,25 @@
<Add library="gdi32"/>
<Add library="user32"/>
<Add library="kernel32"/>
+ <Add library="tiki"/>
+ <Add library="opengl32"/>
+ <Add library="alut"/>
<Add directory="..\..\win32"/>
<Add directory="C:\Program Files\OpenAL 1.1 SDK\libs\Win32"/>
</Linker>
<Unit filename="src\TikiTest.cpp">
<Option compilerVar="CPP"/>
+ <Option objectName="TikiTest.obj"/>
<Option target="default"/>
</Unit>
<Unit filename="src\test.cpp">
<Option compilerVar="CPP"/>
+ <Option objectName="test.obj"/>
<Option target="default"/>
</Unit>
<Unit filename="src\testobj.cpp">
<Option compilerVar="CPP"/>
+ <Option objectName="testobj.obj"/>
<Option target="default"/>
</Unit>
<Unit filename="src\testobj.h">
Modified: tiki/examples/TikiTest/tikitest.layout
===================================================================
--- tiki/examples/TikiTest/tikitest.layout 2006-12-31 03:17:23 UTC (rev 390)
+++ tiki/examples/TikiTest/tikitest.layout 2007-01-01 03:31:29 UTC (rev 391)
@@ -7,6 +7,4 @@
<File name="src\test.cpp" open="0" top="0">
<Cursor position="5471" topLine="217"/>
</File>
- <Expand folder="/Sources/src"/>
- <Expand folder="/Sources"/>
</CodeBlocks_layout_file>
Modified: tiki/src/gl/texture.cpp
===================================================================
--- tiki/src/gl/texture.cpp 2006-12-31 03:17:23 UTC (rev 390)
+++ tiki/src/gl/texture.cpp 2007-01-01 03:31:29 UTC (rev 391)
@@ -65,10 +65,10 @@
void Texture::convertToGl() {
uint16 * src16 = (uint16 *)m_ptr;
uint8 * dst = m_txrdata;
-
+
if (m_fmt == RGBA8888)
return;
-
+
// The data needs to be converted from its source format to ARGB8888, and
// it needs to be Y-inverted as well.
// NOTE: The Y-inversion is only true so "proper" GL coordinates can be obtained.
@@ -117,7 +117,8 @@
}
}
-#if TIKI_PLAT == TIKI_WIN32
+#if TIKI_PLAT == TIKI_WIN32
+#if !defined(__GNUC__)
// Win32 doesn't seem to have this... perhaps it's not really ANSI?
static int strcasecmp(const char * cs,const char * ct) {
int c1, c2, res;
@@ -132,6 +133,7 @@
return res;
}
+#endif
#endif
@@ -211,17 +213,17 @@
/* We'll write the converted data into this buffer */
if (!m_txrdata)
m_txrdata = new uint8[img->w * img->h * 4];
-
+
convertToGl();
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_w, m_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_txrdata);
-
+
GLenum err = glGetError();
#elif TIKI_PLAT == TIKI_DC
- m_txrdata = (uint8 *)pvr_mem_malloc(img->w * img->h * 2);
+ m_txrdata = (uint8 *)pvr_mem_malloc(img->w * img->h * 2);
pvr_txr_load_ex(m_ptr, m_txrdata, img->w, img->h, PVR_TXRLOAD_16BPP);
-
+
if(use_alpha) {
glKosTex2D(GL_ARGB4444_TWID, m_w, m_h, m_txrdata);
} else {
@@ -315,15 +317,19 @@
select();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gumode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gvmode);
-
+
// This provides the expected behavior on newer OpenGL impls...
-#if TIKI_PLAT != TIKI_DC
+#if TIKI_PLAT != TIKI_DC
+// for whatever reason the Windows 2003 R2 PSDK is only
+// OpenGL 1.1 which doesnt have GL_CLAMP_TO_EDGE
+#if !defined(GL_VERSION_1_1)
if (gumode == GL_CLAMP)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
if (gvmode == GL_CLAMP)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-#endif
-#endif
+ glTexParameteri(GL_EXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+#endif // GL_VERSION_1_1
+#endif // TIKI_DC
+#endif // TIKI_NDS
}
void * Texture::canvasLock() {
Modified: tiki/win32/tiki.cbp
===================================================================
--- tiki/win32/tiki.cbp 2006-12-31 03:17:23 UTC (rev 390)
+++ tiki/win32/tiki.cbp 2007-01-01 03:31:29 UTC (rev 391)
@@ -6,15 +6,15 @@
<Option title="Tiki"/>
<Option makefile="Makefile"/>
<Option makefile_is_custom="0"/>
- <Option compiler="1"/>
+ <Option compiler="0"/>
<Build>
<Target title="default">
- <Option output="C:\projects\tiki\win32\tiki.lib"/>
+ <Option output="libtiki.a"/>
<Option working_dir=""/>
<Option object_output=".objs"/>
<Option deps_output=".deps"/>
<Option type="2"/>
- <Option compiler="1"/>
+ <Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="2"/>
</Target>
</Build>
@@ -28,8 +28,10 @@
<Add directory="..\3rdparty\zlib"/>
<Add directory="C:\Program Files\OpenAL 1.1 SDK\include"/>
<Add directory="C:\Program Files\Microsoft DirectX 9.0 SDK (February 2005)\Include"/>
+ <Add directory="..\3rdparty\libvorbis\lib"/>
</Compiler>
<Linker>
+ <Add library="opengl32"/>
<Add directory="C:\Program Files\OpenAL 1.1 SDK\libs\Win32"/>
<Add directory="C:\Program Files\Microsoft DirectX 9.0 SDK (February 2005)\Lib\x86"/>
</Linker>
Modified: tiki/win32/tiki.layout
===================================================================
--- tiki/win32/tiki.layout 2006-12-31 03:17:23 UTC (rev 390)
+++ tiki/win32/tiki.layout 2007-01-01 03:31:29 UTC (rev 391)
@@ -2,11 +2,17 @@
<!DOCTYPE CodeBlocks_layout_file>
<CodeBlocks_layout_file>
<File name="..\3rdparty\libjpeg\jconfig.h" open="0" top="0">
- <Cursor position="116" topLine="0"/>
+ <Cursor position="653" topLine="2"/>
</File>
+ <File name="..\3rdparty\libjpeg\jpeglib.h" open="0" top="0">
+ <Cursor position="1105" topLine="11"/>
+ </File>
<File name="..\3rdparty\libogg\src\bitwise.c" open="0" top="0">
<Cursor position="1119" topLine="0"/>
</File>
+ <File name="..\3rdparty\libvorbis\lib\modes\setup_44.h" open="0" top="0">
+ <Cursor position="956" topLine="1"/>
+ </File>
<File name="..\include\Tiki\stream.h" open="0" top="0">
<Cursor position="471" topLine="26"/>
</File>
@@ -16,9 +22,15 @@
<File name="..\src\audio\oggvorbis\sndoggvorbis.cpp" open="0" top="0">
<Cursor position="205" topLine="0"/>
</File>
+ <File name="..\src\audio\sound.cpp" open="0" top="0">
+ <Cursor position="42" topLine="5"/>
+ </File>
<File name="..\src\gl\animation.cpp" open="0" top="0">
<Cursor position="10" topLine="0"/>
</File>
+ <File name="..\src\gl\texture.cpp" open="0" top="0">
+ <Cursor position="7819" topLine="301"/>
+ </File>
<File name="include\Tiki\glhdrs.h" open="0" top="0">
<Cursor position="123" topLine="0"/>
</File>
@@ -46,12 +58,4 @@
<File name="src\tikitime.cpp" open="0" top="0">
<Cursor position="161" topLine="2"/>
</File>
- <Expand folder="/Sources/win32/src"/>
- <Expand folder="/Sources/win32"/>
- <Expand folder="/Sources"/>
- <Expand folder="/Headers/include"/>
- <Expand folder="/Headers/win32/include/Tiki"/>
- <Expand folder="/Headers/win32/include"/>
- <Expand folder="/Headers/win32"/>
- <Expand folder="/Headers"/>
</CodeBlocks_layout_file>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2006-12-31 03:17:26
|
Revision: 390
http://svn.sourceforge.net/cadcdev/?rev=390&view=rev
Author: c99koder
Date: 2006-12-30 19:17:23 -0800 (Sat, 30 Dec 2006)
Log Message:
-----------
Tiki: EventCollector: Add a method to check whether EventHandler is already listening
Modified Paths:
--------------
tiki/include/Tiki/eventcollector.h
Modified: tiki/include/Tiki/eventcollector.h
===================================================================
--- tiki/include/Tiki/eventcollector.h 2006-12-24 13:30:58 UTC (rev 389)
+++ tiki/include/Tiki/eventcollector.h 2006-12-31 03:17:23 UTC (rev 390)
@@ -41,6 +41,11 @@
// Are there any events available?
bool eventsAvailable() const;
+ // Are we listening for events?
+ bool listening() const {
+ return (m_cookie >= 0);
+ }
+
// Retrieve an event if one is available. Returns true if
// you got one.
bool getEvent(Event & evtOut);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2006-12-24 13:31:01
|
Revision: 389
http://svn.sourceforge.net/cadcdev/?rev=389&view=rev
Author: c99koder
Date: 2006-12-24 05:30:58 -0800 (Sun, 24 Dec 2006)
Log Message:
-----------
Tiki: dc: increase PVR vertex buffer size to 512K
Modified Paths:
--------------
tiki/dc/src/init_shutdown.cpp
Modified: tiki/dc/src/init_shutdown.cpp
===================================================================
--- tiki/dc/src/init_shutdown.cpp 2006-12-03 18:23:38 UTC (rev 388)
+++ tiki/dc/src/init_shutdown.cpp 2006-12-24 13:30:58 UTC (rev 389)
@@ -18,8 +18,8 @@
/* Enable opaque and translucent polygons with size 32 */
{ PVR_BINSIZE_32, PVR_BINSIZE_0, PVR_BINSIZE_32, PVR_BINSIZE_0, PVR_BINSIZE_0 },
- /* Vertex buffer size 256K */
- 256*1024
+ /* Vertex buffer size 512K */
+ 512*1024
};
namespace Tiki {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2006-12-03 18:23:41
|
Revision: 388
http://svn.sourceforge.net/cadcdev/?rev=388&view=rev
Author: c99koder
Date: 2006-12-03 10:23:38 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
Tiki: add File::writele16() and File::writele32()
Modified Paths:
--------------
tiki/include/Tiki/file.h
tiki/src/base/file.cpp
Modified: tiki/include/Tiki/file.h
===================================================================
--- tiki/include/Tiki/file.h 2006-12-03 03:47:53 UTC (rev 387)
+++ tiki/include/Tiki/file.h 2006-12-03 18:23:38 UTC (rev 388)
@@ -42,6 +42,13 @@
// Read cnt 32-bit little-endian words from the file.
bool readle32(void * out, int cnt);
+ // Write cnt 16-bit little-endian words to the file.
+ bool writele16(uint16 * in, int cnt);
+
+ // Write cnt 32-bit little-endian words to the file.
+ bool writele32(uint32 * in, int cnt);
+
+
// Seek in the file.
int seek(int where, int whence);
Modified: tiki/src/base/file.cpp
===================================================================
--- tiki/src/base/file.cpp 2006-12-03 03:47:53 UTC (rev 387)
+++ tiki/src/base/file.cpp 2006-12-03 18:23:38 UTC (rev 388)
@@ -90,6 +90,42 @@
#endif
}
+bool File::writele16(uint16 * in, int cnt) {
+#if BYTE_ORDER == BIG_ENDIAN
+ for (int i=0; i<cnt; i++) {
+ uint16 v = *in;
+ v = ((v & 0xff00) >> 8)
+ | ((v & 0x00ff) << 8);
+
+ if (write(&v, 2) < 2)
+ return false;
+ in = ((uint16 *)in) + 1;
+ }
+ return true;
+#else
+ return write(in, 2 * cnt) == 2 * cnt;
+#endif
+}
+
+bool File::writele32(uint32 * in, int cnt) {
+#if BYTE_ORDER == BIG_ENDIAN
+ for (int i=0; i<cnt; i++) {
+ uint16 v = *in;
+ v = ((v & 0x000000ff) << 24) |
+ ((v & 0x0000ff00) << 8) |
+ ((v & 0x00ff0000) >> 8) |
+ ((v & 0xff000000) >> 24);
+
+ if (write(&v, 4) < 4)
+ return false;
+ in = ((uint32 *)in) + 1;
+ }
+ return true;
+#else
+ return write(in, 4 * cnt) == 4 * cnt;
+#endif
+}
+
int File::seek(int where, int whence) {
if (!isValid())
return -1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <c99...@us...> - 2006-12-03 03:47:54
|
Revision: 387
http://svn.sourceforge.net/cadcdev/?rev=387&view=rev
Author: c99koder
Date: 2006-12-02 19:47:53 -0800 (Sat, 02 Dec 2006)
Log Message:
-----------
Tiki: Generate the OpenAL source before the buffers
Modified Paths:
--------------
tiki/src/audio/stream.cpp
Modified: tiki/src/audio/stream.cpp
===================================================================
--- tiki/src/audio/stream.cpp 2006-12-03 03:43:41 UTC (rev 386)
+++ tiki/src/audio/stream.cpp 2006-12-03 03:47:53 UTC (rev 387)
@@ -71,10 +71,10 @@
assert( m_state == StateStopped );
+ alGenSources(1, &m_source);
+ check();
alGenBuffers(2, m_buffers);
check();
- alGenSources(1, &m_source);
- check();
alSource3f(m_source, AL_POSITION, 0.0, 0.0, 0.0);
check();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|