#ifndef PROTOTYPE1_SRC_L2_LIZA_PLAYING_SOUND_LOOP_H
#define PROTOTYPE1_SRC_L2_LIZA_PLAYING_SOUND_LOOP_H

// todo: move loop here and rewrite with l1_5 help

#include "../../l1/core/int_primitives.h"

typedef struct {
    /* self (takes ownership) */
    void (*drop)(void*);
    /* self, returns: pcm value */
    double (*next)(void*);
    /* self, returns: duration in frames */
    size_t (*get_duration)(const void*);
} LizaSound_Table;

typedef struct {
    const void* r;
    const LizaSound_Table* t;
} RefLizaSound;

typedef struct {
    void* r;
    const LizaSound_Table* t;
} RefMutLizaSound;

/* Existence of Box<Trait> type implies that _drop method is virtual according to this trait  */
typedef struct {
    void* m; /* Owns memory block r and object in it */
    const LizaSound_Table* t;
} BoxLizaSound;

void BoxLizaSound_drop(BoxLizaSound self) {
    self.t->drop(self.m);
    free(self.m);
}

#include "../../../gen/l1/eve/liza/VecBoxLizaSound.h"


#endif