| 105 | } |
| 106 | |
| 107 | bool oggstream::open(const char *f) |
| 108 | { |
| 109 | ASSERT(valid); |
| 110 | if(!f) return false; |
| 111 | if(playing() || isopen) reset(); |
| 112 | |
| 113 | const char *exts[] = { "", ".wav", ".ogg" }; |
| 114 | string filepath; |
| 115 | |
| 116 | loopi(sizeof(exts)/sizeof(exts[0])) |
| 117 | { |
| 118 | formatstring(filepath)("packages/audio/soundtracks/%s%s", f, exts[i]); |
| 119 | ::stream *file = openfile(path(filepath), "rb"); |
| 120 | if(!file) continue; |
| 121 | |
| 122 | isopen = !ov_open_callbacks(file, &oggfile, NULL, 0, oggcallbacks); |
| 123 | if(!isopen) |
| 124 | { |
| 125 | delete file; |
| 126 | continue; |
| 127 | } |
| 128 | |
| 129 | info = ov_info(&oggfile, -1); |
| 130 | format = info->channels == 2 ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; |
| 131 | totalseconds = ov_time_total(&oggfile, -1); |
| 132 | copystring(name, f); |
| 133 | |
| 134 | return true; |
| 135 | } |
| 136 | return false; |
| 137 | } |
| 138 | |
| 139 | void oggstream::onsourcereassign(source *s) |
| 140 | { |
nothing calls this directly
no test coverage detected