srctree

Andrew Kelley parent c44961c2 e48a71f1
example of printing metadata

README.md added: 19, removed: 6, total 13
@@ -8,7 +8,7 @@ interface.
## Status
 
The "playlist" example plays a queue of audio files, gaplessly, over the
default output device.
default output device. It also shows printing metadata tags.
 
The "analyze" example spawns a thread for each input file and computes:
- true peak (EBU R.128)
@@ -26,7 +26,6 @@ zig build
 
## Roadmap
 
* example that prints metadata of input file
* example that transcodes a list of input files
* update playlist example to support scripted inputs including pausing,
seeking, volume adjustment
 
example/playlist.zig added: 19, removed: 6, total 13
@@ -31,6 +31,14 @@ pub fn main() !void {
std.log.debug("opening '{s}'", .{arg});
const file = try player.File.open(std.fs.cwd(), arg, try arena.dupeZ(u8, arg));
errdefer file.close();
 
{
var it: ?*const player.File.MetadataEntry = null;
while (file.iterateMetadata(it)) |tag| : (it = tag) {
std.log.info("metadata: {s}={s}", .{ tag.key, tag.value });
}
}
 
try play_queue.files.append(gpa, file);
}
 
 
src/root.zig added: 19, removed: 6, total 13
@@ -92,7 +92,7 @@ pub const File = struct {
pub fn close(f: *File) void {
f.decode.free();
f.fs_file.close();
f.fc.free();
f.fc.close_input();
f.* = undefined;
}
 
@@ -464,6 +464,12 @@ pub const File = struct {
try abuffer_ctx.init_str(null);
return abuffer_ctx;
}
 
pub const MetadataEntry = av.Dictionary.Entry;
 
pub fn iterateMetadata(file: *const File, prev: ?*const MetadataEntry) ?*const MetadataEntry {
return av.Dictionary.iterate(file.fc.metadata, prev);
}
};
 
pub const Analysis = struct {