-
Notifications
You must be signed in to change notification settings - Fork 0
/
playback.h
71 lines (48 loc) · 1.21 KB
/
playback.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _PLAYBACK_H_
#define _PLAYBACK_H_
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <ao/ao.h>
#include <math.h>
#include <limits.h>
#include <time.h>
#include "enums.h"
#include "logger.h"
#define INBUF_SIZE 4096
#define AUDIO_INBUF_SIZE 20480
#define AUDIO_REFILL_THRESH 4096
typedef struct playback
{
AVFormatContext *ctx;
AVCodecContext *avctx;
ao_sample_format sformat;
ao_device *adevice;
AVPacket *pkt;
AVFrame *frame;
uint8_t buffer[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
uint8_t *samples[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
char first_try;
} playback;
typedef struct audio
{
playback *pb;
char playstate;
char threadstate;
char cycle;
} audio;
void playback_init (void);
audio *audio_create (void); // creates and initialzes audio
void audio_free (audio **a);
playback *playback_open_file (const char *path);
int playback_playback (playback *pb);
/*
* return
* 1 if file ist still playing
* -1 on error
* 0 at EOF
*/
void playback_seek_timestamp (playback *pb, const int time);
void playback_free_file (playback *pb);
void playback_shutdown (void);
#endif