MCPcopy Create free account
hub / github.com/assaultcube/AC / open

Method open

source/src/oggstream.cpp:107–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107bool 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
139void oggstream::onsourcereassign(source *s)
140{

Callers

nothing calls this directly

Calls 4

openfileFunction · 0.85
pathFunction · 0.85
copystringFunction · 0.85
loopiFunction · 0.70

Tested by

no test coverage detected