- int section=0;
- int res=ov_read(&ovfile, buf, len, 0, 2, 1, §ion);
- if(res<0)
- throw Exception("Error reading ogg vorbis file");
- return res;
+ if(data)
+ {
+ len=min(len, size-read_pos);
+ memcpy(buf, data+read_pos, len);
+ read_pos+=len;
+ return len;
+ }
+ else if(ovfile.datasource)
+ {
+ int section=0;
+ int res=ov_read(&ovfile, buf, len, 0, 2, 1, §ion);
+ if(res<0)
+ throw Exception("Error reading ogg vorbis file");
+ else if(res==0)
+ eof_flag=true;
+ return res;
+ }
+ else
+ throw InvalidState("No data available");
+}
+
+const char *Sound::get_data() const
+{
+ if(!data)
+ throw InvalidState("Data has not been loaded");
+ return data;