/* coding: utf-8; */
#include "soundio-util.h"

#ifndef __SOUNDIO_DEMO_H__
#define __SOUNDIO_DEMO_H__

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
	char *working_directory;
	char **envp;
	char *argv[20];

	/* any malloced data associated with this struct that
	 * will be freed in work_handle_uninit */
	void *free_list[5];

	pid_t pid;

	/* stdin, stdout, stderr */
	int _in;
	int _out;
	int _err;

	/* status: >=0: ret_code,  <0: signr which killed by */
	int status;

	/* wait @stop_wait us for exit, 0 for disable this feature */
	int stop_wait;
} WorkerHandle;

void worker_handle_init(WorkerHandle *h);
void worker_handle_uninit(WorkerHandle *h);

bool worker_handle_push_tofree(WorkerHandle *h, void *addr);

int worker_stop(WorkerHandle *worker);
int worker_check_stopped(WorkerHandle *worker);

int record_start(WorkerHandle *worker);
#define record_stop worker_stop

int play_start(WorkerHandle *worker);
#define play_stop worker_stop
int play_pause(WorkerHandle *worker);
int play_continue(WorkerHandle *worker);
int play_stop(WorkerHandle *worker);

int mixer_start(WorkerHandle *worker);
int mixer_get_play_vol(WorkerHandle *worker, int *left, int *right);
int mixer_set_play_vol(WorkerHandle *worker, int *precent);
#define mixer_stop worker_stop

#ifdef __cplusplus
}
#endif

#endif /* __SOUNDIO_DEMO_H__ */
