[Scummvm-cvs-logs] CVS: scummvm/sound vorbis.cpp,1.32,1.33
Lars Persson
anotherguest at users.sourceforge.net
Thu Dec 1 11:15:13 CET 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.204,1.205 actor.h,1.100,1.101 puzzle.cpp,1.19,1.20
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm scumm-md5.h,2.134,2.135 scumm.cpp,1.655,1.656
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13690/sound
Modified Files:
vorbis.cpp
Log Message:
Working Vorbis support for Symbian OS
Index: vorbis.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/vorbis.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- vorbis.cpp 6 Nov 2005 13:49:52 -0000 1.32
+++ vorbis.cpp 1 Dec 2005 19:14:38 -0000 1.33
@@ -73,6 +73,16 @@
file_info *f = (file_info *) datasource;
int result;
+#ifdef __SYMBIAN32__
+ // For symbian we must check that an alternative file pointer is created, see if its open
+ // If not re-open file and seek to the last read position
+ if(f->file && !f->file->isOpen()){
+ f->file->open(f->file->name());
+ f->file->seek(f->curr_pos);
+ }
+#endif
+
+
nmemb *= size;
if (f->curr_pos > (int) f->len)
nmemb = 0;
@@ -82,6 +92,12 @@
// the file, so make sure the current position is what we think it is.
f->file->seek(f->start + f->curr_pos);
result = f->file->read(ptr, nmemb);
+#ifdef __SYMBIAN32__
+ // For symbian we now store the last read position and then close the file
+ if(f->file){
+ f->file->close();
+ }
+#endif
if (result == -1) {
f->curr_pos = f->file->pos() - f->start;
return (size_t) -1;
@@ -101,8 +117,25 @@
whence = SEEK_SET;
}
+#ifdef __SYMBIAN32__
+ // For symbian we must check that an alternative file pointer is created, see if its open
+ // If not re-open file and seek to the last read position
+ if(f->file && !f->file->isOpen()){
+ f->file->open(f->file->name());
+ f->file->seek(f->curr_pos);
+ }
+#endif
+
f->file->seek(offset, whence);
f->curr_pos = f->file->pos() - f->start;
+
+#ifdef __SYMBIAN32__
+ // For symbian we now store the last read position and then close the file
+ if(f->file){
+ f->file->close();
+ }
+#endif
+
return f->curr_pos;
}
@@ -126,6 +159,7 @@
VorbisTrackInfo::VorbisTrackInfo(File *file) {
+debug(5, "" __FILE__ ":%i", __LINE__);
_file = file;
if (openTrack()) {
@@ -140,28 +174,43 @@
}
bool VorbisTrackInfo::openTrack() {
+debug(5, "" __FILE__ ":%i", __LINE__);
assert(_file);
file_info *f = new file_info;
- f->file = _file;
+#if defined(__SYMBIAN32__)
+ // Symbian can't share filehandles between different threads.
+ // So create a new file and seek that to the other filehandles position
+ f->file= new (ELeave)File;
+ f->file->open(_file->name());
+ f->file->seek(_file->pos());
+#else
+ f->file = _file;
+#endif
+
f->start = 0;
f->len = _file->size();
f->curr_pos = 0;
_file->seek(0);
bool err = (ov_open_callbacks((void *) f, &_ov_file, NULL, 0, g_File_wrap) < 0);
-
if (err) {
+#ifdef __SYMBIAN32__
+ delete f->file;
+#endif
delete f;
} else {
- _file->incRef();
- }
+#ifndef __SYMBIAN32__
+ _file->incRef();
+#endif
+ }
return err;
}
VorbisTrackInfo::~VorbisTrackInfo() {
+debug(5, "" __FILE__ ":%i", __LINE__);
if (! _error_flag) {
ov_clear(&_ov_file);
_file->decRef();
@@ -169,14 +218,18 @@
}
void VorbisTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration) {
-
+debug(5, "" __FILE__ ":%i", __LINE__);
bool err = openTrack();
assert(!err);
-#ifdef USE_TREMOR
- ov_time_seek(&_ov_file, (ogg_int64_t)(startFrame / 75.0 * 1000));
+#ifdef USE_TREMOR // In Tremor, the ov_time_seek() and ov_time_seek_page() calls take seeking positions in milliseconds as 64 bit integers, rather than in seconds as doubles as in Vorbisfile.
+#if defined(__SYMBIAN32__) && defined(__GCC32__) // SumthinWicked says: fixing "relocation truncated to fit: ARM_26 __fixdfdi" during linking on GCC, see portdefs.h
+ ov_time_seek(&_ov_file, (ogg_int64_t)scumm_fixdfdi(startFrame / 75.0 * 1000));
#else
- ov_time_seek(&_ov_file, startFrame / 75.0);
+ ov_time_seek(&_ov_file, (ogg_int64_t)(startFrame / 75.0 * 1000));
+#endif
+#else
+ ov_time_seek(&_ov_file, startFrame / 75.0);
#endif
AudioStream *input = makeVorbisStream(&_ov_file, duration * ov_info(&_ov_file, -1)->rate / 75);
@@ -184,6 +237,7 @@
}
DigitalTrackInfo *getVorbisTrack(int track) {
+debug(5, "" __FILE__ ":%i", __LINE__);
char track_name[32];
File *file = new File();
@@ -234,6 +288,7 @@
: _ov_file(file),
_bufferEnd(_buffer + ARRAYSIZE(_buffer)),
_deleteFileAfterUse(deleteFileAfterUse) {
+debug(5, "" __FILE__ ":%i", __LINE__);
// Check the header, determine if this is a stereo stream
_numChannels = ov_info(_ov_file, -1)->channels;
@@ -249,16 +304,19 @@
}
VorbisInputStream::~VorbisInputStream() {
+debug(5, "" __FILE__ ":%i", __LINE__);
ov_clear(_ov_file);
if (_deleteFileAfterUse)
delete _ov_file;
}
inline bool VorbisInputStream::eosIntern() const {
+debug(5, "" __FILE__ ":%i", __LINE__);
return _pos >= _bufferEnd;
}
int VorbisInputStream::readBuffer(int16 *buffer, const int numSamples) {
+debug(5, "" __FILE__ ":%i", __LINE__);
int samples = 0;
while (samples < numSamples && !eosIntern()) {
const int len = MIN(numSamples - samples, (int)(_bufferEnd - _pos));
@@ -274,13 +332,14 @@
}
void VorbisInputStream::refill() {
+debug(5, "" __FILE__ ":%i", __LINE__);
// Read the samples
uint len_left = sizeof(_buffer);
char *read_pos = (char *)_buffer;
while (len_left > 0 && _end_pos > ov_pcm_tell(_ov_file)) {
long result = ov_read(_ov_file, read_pos, len_left,
-#ifndef USE_TREMOR
+#ifndef USE_TREMOR // Tremor ov_read() always returns data as signed 16 bit interleaved PCM in host byte order. As such, it does not take arguments to request specific signedness, byte order or bit depth as in Vorbisfile.
#ifdef SCUMM_BIG_ENDIAN
1,
#else
@@ -311,15 +370,25 @@
}
static AudioStream *makeVorbisStream(OggVorbis_File *file, int duration) {
+debug(5, "" __FILE__ ":%i", __LINE__);
return new VorbisInputStream(file, duration, false);
}
AudioStream *makeVorbisStream(File *file, uint32 size) {
+debug(5, "" __FILE__ ":%i", __LINE__);
OggVorbis_File *ov_file = new OggVorbis_File;
file_info *f = new file_info;
- f->file = file;
- f->start = file->pos();
+#if defined(__SYMBIAN32__)
+ // Symbian can't share filehandles between different threads.
+ // So create a new file and seek that to the other filehandles position
+ f->file= new (ELeave)File;
+ f->file->open(file->name());
+ f->file->seek(file->pos());
+#else
+ f->file = file;
+#endif
+ f->start = file->pos();
f->len = size;
f->curr_pos = 0;
@@ -327,11 +396,13 @@
warning("Invalid file format");
delete ov_file;
delete f;
- return 0;
- } else {
- file->incRef();
- return new VorbisInputStream(ov_file, 0, true);
- }
-}
+ return 0;
+ } else {
+#ifndef __SYMBIAN32__
+ file->incRef();
+#endif
+ return new VorbisInputStream(ov_file, 0, true);
+ }
+ }
#endif
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.204,1.205 actor.h,1.100,1.101 puzzle.cpp,1.19,1.20
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm scumm-md5.h,2.134,2.135 scumm.cpp,1.655,1.656
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list