Author: ArcRiley
Date: 2007-07-04 16:31:29 -0400 (Wed, 04 Jul 2007)
New Revision: 346
Added:
trunk/pysoy/src/storage/Transport.pxi
trunk/pysoy/src/storage/soy.transports.pxd
Removed:
trunk/pysoy/src/storage/Store.pxi
trunk/pysoy/src/storage/soy.storage.pxd
Modified:
trunk/pysoy/src/storage/File.pxi
trunk/pysoy/src/storage/soy.storage.pyx
Log:
moving soy.storage back to soy.transports
Modified: trunk/pysoy/src/storage/File.pxi
===================================================================
--- trunk/pysoy/src/storage/File.pxi 2007-07-04 03:07:24 UTC (rev 345)
+++ trunk/pysoy/src/storage/File.pxi 2007-07-04 20:31:29 UTC (rev 346)
@@ -22,7 +22,10 @@
This class handles loading and saving .soy and .ogg files to disk.
'''
- def __new__(self, path, *args, **keywords) :
+ def __new__(self, *args, **keywords) :
+ self._chan = []
+
+ def __init__(self, path, *args, **keywords) :
cdef char _magic[4]
self._path = path
self._file = stdio.fopen(self._path, 'r')
@@ -57,3 +60,108 @@
return ogg.OGG2_SUCCESS
_byts = stdio.fwrite(_buff, 1, _byts, self._file)
return ogg.ogg2_sync_read(_sync, _byts)
+
+ cdef void _scan(self) :
+ # Run scan for objects
+ _bytes = 1
+ _offset = 0
+ _page.header = NULL
+ _page.body = NULL
+ _packet.packet = NULL
+ _packbuffer = <ogg.ogg2pack_buffer *> py.PyMem_Malloc(
+ ogg.ogg2pack_buffersize())
+ if _packbuffer == NULL :
+ raise('Out of Memory')
+ _sync = ogg.ogg2_sync_create()
+ while _bytes>0 :
+ # This loops for each chained object in the file
+ streams = {}
+ _start = _offset
+ _inhead = 1
+
+ while True :
+ while not (_status==1 or _bytes==0) :
+ _status = ogg.ogg2_sync_pageout(_sync, &_page)
+ if _status==1 :
+ break
+ _filebuffer = ogg.ogg2_sync_bufferin(_sync, 4096)
+ _bytes = stdio.fread(_filebuffer, 1, 4096, self._file)
+ _status = ogg.ogg2_sync_wrote(_sync, _bytes)
+ if _status != ogg.OGG2_SUCCESS :
+ py.PyMem_Free(_packbuffer)
+ ogg.ogg2_page_release(&_page)
+ raise('Error writing to ogg2_sync buffer')
+ _status = ogg.ogg2_sync_pageout(_sync, &_page)
+ if _bytes==0 :
+ break
+ _serialno = ogg.ogg2_page_serialno(&_page)
+ _offset = _offset + _page.header_len + _page.body_len
+ if streams.has_key(_serialno) :
+ ogg.ogg2_page_release(&_page)
+ _inhead = 0
+ _status = 0
+ else :
+ if _inhead :
+ _end = _offset
+ # Read packet0 to a header string
+ _stream = ogg.ogg2_stream_create(_serialno)
+ _status = ogg.ogg2_stream_pagein(_stream, &_page)
+ _status = ogg.ogg2_stream_packetout(_stream, &_packet)
+ ogg.ogg2packB_readinit(_packbuffer, _packet.packet)
+ if ogg.ogg2packB_read(_packbuffer, 32, &_v) == 0 :
+ # detect then call the codec packet0 scanner
+ if _v == 1936685312 :
+ streams[_serialno] = ['.soy0','','']
+ # Read Class Name
+ ogg.ogg2packB_read(_packbuffer, 8, &_v)
+ for _i from 0 <= _i < _v :
+ ogg.ogg2packB_read(_packbuffer, 8, &_c)
+ _string[_i] = _c
+ streams[_serialno][1] = _string[:_v]
+ # Read Object Name
+ ogg.ogg2packB_read(_packbuffer, 8, &_v)
+ for _i from 0 <= _i < _v :
+ ogg.ogg2packB_read(_packbuffer, 8, &_c)
+ _string[_i] = _c
+ streams[_serialno][2] = _string[:_v]
+ elif _v == 24538994 :
+ streams[_serialno] = 'Vorbis'
+ elif _v == 2155112549L :
+ streams[_serialno] = 'Theora'
+ elif _v == 7828073 :
+ streams[_serialno] = 'Writ'
+ elif _v == 1399874917L :
+ streams[_serialno] = 'Speex'
+ elif _v == 2135313473L :
+ streams[_serialno] = 'FLAC'
+ else :
+ streams[_serialno] = 'Unknown'
+ ogg.ogg2_stream_destroy(_stream)
+ _status = 0
+ else :
+ break
+ codecs = streams.values()
+ codecs.sort()
+ if codecs[0][0] == '.soy0' :
+ for stream in streams :
+ if streams[stream][0] == '.soy0' :
+ modstr = '.'.join(streams[stream][1].split('.')[:-1])
+ clsstr = streams[stream][1].split('.')[-1]
+ module = __import__(modstr, [], [], [clsstr])
+ self._objs[streams[stream][2]] = module.__dict__[clsstr]()
+ # Ok, start main loop over, using this page first thing
+ _status = 1
+ py.PyMem_Free(_packbuffer)
+ ogg.ogg2_sync_destroy(_sync)
+
+ def __getitem__(self, key) :
+ return self._chan[key]
+
+ def __repr__(self) :
+ return self._chan.__repr__()
+
+ def __str__(self) :
+ return self._chan.__str__()
+
+ def __len__(self) :
+ return self._chan.__len__()
Deleted: trunk/pysoy/src/storage/Store.pxi
===================================================================
--- trunk/pysoy/src/storage/Store.pxi 2007-07-04 03:07:24 UTC (rev 345)
+++ trunk/pysoy/src/storage/Store.pxi 2007-07-04 20:31:29 UTC (rev 346)
@@ -1,131 +0,0 @@
-# PySoy storage.Store Class
-#
-# Copyright (C) 2006,2007 Team PySoy
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-
-cdef class Transport :
- '''PySoy Transport
-
- This class provides the basic data stream parsing for all transports.
- '''
- def __new__(self, *args, **keywords) :
- self._chan = []
-
- cdef void _scan(self) :
- # Run scan for objects
- _bytes = 1
- _offset = 0
- _page.header = NULL
- _page.body = NULL
- _packet.packet = NULL
- _packbuffer = <ogg.ogg2pack_buffer *> py.PyMem_Malloc(
- ogg.ogg2pack_buffersize())
- if _packbuffer == NULL :
- raise('Out of Memory')
- _sync = ogg.ogg2_sync_create()
- while _bytes>0 :
- # This loops for each chained object in the file
- streams = {}
- _start = _offset
- _inhead = 1
-
- while True :
- while not (_status==1 or _bytes==0) :
- _status = ogg.ogg2_sync_pageout(_sync, &_page)
- if _status==1 :
- break
- _filebuffer = ogg.ogg2_sync_bufferin(_sync, 4096)
- _bytes = stdio.fread(_filebuffer, 1, 4096, self._file)
- _status = ogg.ogg2_sync_wrote(_sync, _bytes)
- if _status != ogg.OGG2_SUCCESS :
- py.PyMem_Free(_packbuffer)
- ogg.ogg2_page_release(&_page)
- raise('Error writing to ogg2_sync buffer')
- _status = ogg.ogg2_sync_pageout(_sync, &_page)
- if _bytes==0 :
- break
- _serialno = ogg.ogg2_page_serialno(&_page)
- _offset = _offset + _page.header_len + _page.body_len
- if streams.has_key(_serialno) :
- ogg.ogg2_page_release(&_page)
- _inhead = 0
- _status = 0
- else :
- if _inhead :
- _end = _offset
- # Read packet0 to a header string
- _stream = ogg.ogg2_stream_create(_serialno)
- _status = ogg.ogg2_stream_pagein(_stream, &_page)
- _status = ogg.ogg2_stream_packetout(_stream, &_packet)
- ogg.ogg2packB_readinit(_packbuffer, _packet.packet)
- if ogg.ogg2packB_read(_packbuffer, 32, &_v) == 0 :
- # detect then call the codec packet0 scanner
- if _v == 1936685312 :
- streams[_serialno] = ['.soy0','','']
- # Read Class Name
- ogg.ogg2packB_read(_packbuffer, 8, &_v)
- for _i from 0 <= _i < _v :
- ogg.ogg2packB_read(_packbuffer, 8, &_c)
- _string[_i] = _c
- streams[_serialno][1] = _string[:_v]
- # Read Object Name
- ogg.ogg2packB_read(_packbuffer, 8, &_v)
- for _i from 0 <= _i < _v :
- ogg.ogg2packB_read(_packbuffer, 8, &_c)
- _string[_i] = _c
- streams[_serialno][2] = _string[:_v]
- elif _v == 24538994 :
- streams[_serialno] = 'Vorbis'
- elif _v == 2155112549L :
- streams[_serialno] = 'Theora'
- elif _v == 7828073 :
- streams[_serialno] = 'Writ'
- elif _v == 1399874917L :
- streams[_serialno] = 'Speex'
- elif _v == 2135313473L :
- streams[_serialno] = 'FLAC'
- else :
- streams[_serialno] = 'Unknown'
- ogg.ogg2_stream_destroy(_stream)
- _status = 0
- else :
- break
- codecs = streams.values()
- codecs.sort()
- if codecs[0][0] == '.soy0' :
- for stream in streams :
- if streams[stream][0] == '.soy0' :
- modstr = '.'.join(streams[stream][1].split('.')[:-1])
- clsstr = streams[stream][1].split('.')[-1]
- module = __import__(modstr, [], [], [clsstr])
- self._objs[streams[stream][2]] = module.__dict__[clsstr]()
- # Ok, start main loop over, using this page first thing
- _status = 1
- py.PyMem_Free(_packbuffer)
- ogg.ogg2_sync_destroy(_sync)
-
- def __getitem__(self, key) :
- return self._chan[key]
-
- def __repr__(self) :
- return self._chan.__repr__()
-
- def __str__(self) :
- return self._chan.__str__()
-
- def __len__(self) :
- return self._chan.__len__()
Copied: trunk/pysoy/src/storage/Transport.pxi (from rev 341,
trunk/pysoy/src/storage/Store.pxi)
===================================================================
--- trunk/pysoy/src/storage/Transport.pxi (rev 0)
+++ trunk/pysoy/src/storage/Transport.pxi 2007-07-04 20:31:29 UTC (rev
346)
@@ -0,0 +1,131 @@
+# PySoy storage.Store Class
+#
+# Copyright (C) 2006,2007 Team PySoy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+cdef class Transport :
+ '''PySoy Transport
+
+ This class provides the basic data stream parsing for all transports.
+ '''
+ def __new__(self, *args, **keywords) :
+ self._chan = []
+
+ cdef void _scan(self) :
+ # Run scan for objects
+ _bytes = 1
+ _offset = 0
+ _page.header = NULL
+ _page.body = NULL
+ _packet.packet = NULL
+ _packbuffer = <ogg.ogg2pack_buffer *> py.PyMem_Malloc(
+ ogg.ogg2pack_buffersize())
+ if _packbuffer == NULL :
+ raise('Out of Memory')
+ _sync = ogg.ogg2_sync_create()
+ while _bytes>0 :
+ # This loops for each chained object in the file
+ streams = {}
+ _start = _offset
+ _inhead = 1
+
+ while True :
+ while not (_status==1 or _bytes==0) :
+ _status = ogg.ogg2_sync_pageout(_sync, &_page)
+ if _status==1 :
+ break
+ _filebuffer = ogg.ogg2_sync_bufferin(_sync, 4096)
+ _bytes = stdio.fread(_filebuffer, 1, 4096, self._file)
+ _status = ogg.ogg2_sync_wrote(_sync, _bytes)
+ if _status != ogg.OGG2_SUCCESS :
+ py.PyMem_Free(_packbuffer)
+ ogg.ogg2_page_release(&_page)
+ raise('Error writing to ogg2_sync buffer')
+ _status = ogg.ogg2_sync_pageout(_sync, &_page)
+ if _bytes==0 :
+ break
+ _serialno = ogg.ogg2_page_serialno(&_page)
+ _offset = _offset + _page.header_len + _page.body_len
+ if streams.has_key(_serialno) :
+ ogg.ogg2_page_release(&_page)
+ _inhead = 0
+ _status = 0
+ else :
+ if _inhead :
+ _end = _offset
+ # Read packet0 to a header string
+ _stream = ogg.ogg2_stream_create(_serialno)
+ _status = ogg.ogg2_stream_pagein(_stream, &_page)
+ _status = ogg.ogg2_stream_packetout(_stream, &_packet)
+ ogg.ogg2packB_readinit(_packbuffer, _packet.packet)
+ if ogg.ogg2packB_read(_packbuffer, 32, &_v) == 0 :
+ # detect then call the codec packet0 scanner
+ if _v == 1936685312 :
+ streams[_serialno] = ['.soy0','','']
+ # Read Class Name
+ ogg.ogg2packB_read(_packbuffer, 8, &_v)
+ for _i from 0 <= _i < _v :
+ ogg.ogg2packB_read(_packbuffer, 8, &_c)
+ _string[_i] = _c
+ streams[_serialno][1] = _string[:_v]
+ # Read Object Name
+ ogg.ogg2packB_read(_packbuffer, 8, &_v)
+ for _i from 0 <= _i < _v :
+ ogg.ogg2packB_read(_packbuffer, 8, &_c)
+ _string[_i] = _c
+ streams[_serialno][2] = _string[:_v]
+ elif _v == 24538994 :
+ streams[_serialno] = 'Vorbis'
+ elif _v == 2155112549L :
+ streams[_serialno] = 'Theora'
+ elif _v == 7828073 :
+ streams[_serialno] = 'Writ'
+ elif _v == 1399874917L :
+ streams[_serialno] = 'Speex'
+ elif _v == 2135313473L :
+ streams[_serialno] = 'FLAC'
+ else :
+ streams[_serialno] = 'Unknown'
+ ogg.ogg2_stream_destroy(_stream)
+ _status = 0
+ else :
+ break
+ codecs = streams.values()
+ codecs.sort()
+ if codecs[0][0] == '.soy0' :
+ for stream in streams :
+ if streams[stream][0] == '.soy0' :
+ modstr = '.'.join(streams[stream][1].split('.')[:-1])
+ clsstr = streams[stream][1].split('.')[-1]
+ module = __import__(modstr, [], [], [clsstr])
+ self._objs[streams[stream][2]] = module.__dict__[clsstr]()
+ # Ok, start main loop over, using this page first thing
+ _status = 1
+ py.PyMem_Free(_packbuffer)
+ ogg.ogg2_sync_destroy(_sync)
+
+ def __getitem__(self, key) :
+ return self._chan[key]
+
+ def __repr__(self) :
+ return self._chan.__repr__()
+
+ def __str__(self) :
+ return self._chan.__str__()
+
+ def __len__(self) :
+ return self._chan.__len__()
Deleted: trunk/pysoy/src/storage/soy.storage.pxd
===================================================================
--- trunk/pysoy/src/storage/soy.storage.pxd 2007-07-04 03:07:24 UTC (rev
345)
+++ trunk/pysoy/src/storage/soy.storage.pxd 2007-07-04 20:31:29 UTC (rev
346)
@@ -1,35 +0,0 @@
-# PySoy storage declarations
-#
-# Copyright (C) 2007 Team PySoy
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-
-cimport ogg
-cimport py
-cimport stdio
-cimport soy._internals
-
-cdef struct OggStream :
- char _name[257]
- ogg.ogg2_stream_state *state
-
-cdef class File :
- cdef object _path
- cdef object _objs
- cdef void* _file
- cdef int _mode # 0 = idle, 1 = load, 2 = save
- cdef ogg.ogg2_sync_state *_sync
- cdef OggStream _stat[256]
Modified: trunk/pysoy/src/storage/soy.storage.pyx
===================================================================
--- trunk/pysoy/src/storage/soy.storage.pyx 2007-07-04 03:07:24 UTC (rev
345)
+++ trunk/pysoy/src/storage/soy.storage.pyx 2007-07-04 20:31:29 UTC (rev
346)
@@ -25,4 +25,3 @@
include "File.pxi"
include "Soy.pxi"
-include "Store.pxi"
Copied: trunk/pysoy/src/storage/soy.transports.pxd (from rev 341,
trunk/pysoy/src/storage/soy.storage.pxd)
===================================================================
--- trunk/pysoy/src/storage/soy.transports.pxd (rev 0)
+++ trunk/pysoy/src/storage/soy.transports.pxd 2007-07-04 20:31:29 UTC (rev
346)
@@ -0,0 +1,35 @@
+# PySoy storage declarations
+#
+# Copyright (C) 2007 Team PySoy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+cimport ogg
+cimport py
+cimport stdio
+cimport soy._internals
+
+cdef struct OggStream :
+ char _name[257]
+ ogg.ogg2_stream_state *state
+
+cdef class File :
+ cdef object _path
+ cdef object _objs
+ cdef void* _file
+ cdef int _mode # 0 = idle, 1 = load, 2 = save
+ cdef ogg.ogg2_sync_state *_sync
+ cdef OggStream _stat[256]
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn