forked from DeaDBeeF-Player/deadbeef
-
Notifications
You must be signed in to change notification settings - Fork 5
/
deadbeef.h
2360 lines (1931 loc) · 89.7 KB
/
deadbeef.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
deadbeef.h -- plugin API of the DeaDBeeF audio player
http://deadbeef.sourceforge.net
Copyright (C) 2009-2022 Oleksiy Yakovenko
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef __DEADBEEF_H
#define __DEADBEEF_H
#include <stdint.h>
#include <time.h>
#include <stdio.h>
#include <dirent.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
// every plugin must define the following entry-point:
// extern "C" DB_plugin_t* $MODULENAME_load (DB_functions_t *api);
// where $MODULENAME is a name of module
// e.g. if your plugin is called "myplugin.so", $MODULENAME is "myplugin"
// this function should return pointer to DB_plugin_t structure
// that is enough for both static and dynamic modules
// backwards compatibility is supported since API version 1.0
// that means that the plugins which use the API 1.0 will work without recompiling until API 2.0.
//
// increments in the major version number mean that there are API breaks, and
// plugins must be recompiled to be compatible.
//
// add DDB_REQUIRE_API_VERSION(x,y) macro when you define the plugin structure
// like this:
// static DB_decoder_t plugin = {
// DDB_REQUIRE_API_VERSION(1,0)
// ............
// }
// this is required for versioning
// if you don't do it -- no version checking will be done (useful for debugging/development)
//
// please DON'T release plugins without version requirement
//
// to ensure compatibility, use the following before including deadbeef.h:
// #define DDB_API_LEVEL x
// where x is the minor API version number.
// that way, you'll get errors or warnings when using incompatible stuff.
//
// if you also want to get the deprecation warnings, use the following:
// #define DDB_WARN_DEPRECATED 1
//
// NOTE: deprecation doesn't mean the API is going to be removed, it just means
// that there's a better replacement in the newer deadbeef versions.
// API version history:
// 1.15 -- deadbeef-1.9.0
// 1.14 -- deadbeef-1.8.8
// 1.12 -- deadbeef-1.8.4
// 1.11 -- deadbeef-1.8.3
// 1.10 -- deadbeef-1.8.0
// 1.9 -- deadbeef-0.7.2
// 1.8 -- deadbeef-0.7.0
// 1.7 -- deadbeef-0.6.2
// 1.6 -- deadbeef-0.6.1
// 1.5 -- deadbeef-0.6
// 1.4 -- deadbeef-0.5.5
// 1.3 -- deadbeef-0.5.3
// 1.2 -- deadbeef-0.5.2
// 1.1 -- deadbeef-0.5.1
// adds pass_through method to dsp plugins for optimization purposes
// 1.0 -- deadbeef-0.5.0
// 0.10 -- deadbeef-0.4.4-portable-r1 (note: 0.4.4 uses api v0.9)
// 0.9 -- deadbeef-0.4.3-portable-build3
// 0.8 -- deadbeef-0.4.2
// 0.7 -- deabdeef-0.4.0
// 0.6 -- deadbeef-0.3.3
// 0.5 -- deadbeef-0.3.2
// 0.4 -- deadbeef-0.3.0
// 0.3 -- deadbeef-0.2.3.2
// 0.2 -- deadbeef-0.2.3
// 0.1 -- deadbeef-0.2.0
#define DB_API_VERSION_MAJOR 1
#define DB_API_VERSION_MINOR 15
#if defined(__clang__)
# define DDB_DEPRECATED(x) __attribute__ ((deprecated(x)))
#elif defined(__GNUC__)
#if !defined(__GNUC_PREREQ)
// avoid including glibc headers, this is not very portable
#if defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
# define __GNUC_PREREQ(maj, min) 0
#endif
#endif
// Deprecating of enum values requires GCC 6+.
// Older GCC can still be used to build.
#if __GNUC_PREREQ(6,0)
# define DDB_DEPRECATED(x) __attribute__ ((deprecated(x)))
#else
# define DDB_DEPRECATED(x)
#endif
#else
#define DDB_DEPRECATED(x)
#endif
#ifndef DDB_API_LEVEL
#define DDB_API_LEVEL DB_API_VERSION_MINOR
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 15)
#define DEPRECATED_115 DDB_DEPRECATED("since deadbeef API 1.15")
#else
#define DEPRECATED_115
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 14)
#define DEPRECATED_114 DDB_DEPRECATED("since deadbeef API 1.14")
#else
#define DEPRECATED_114
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 13)
#define DEPRECATED_113 DDB_DEPRECATED("since deadbeef API 1.13")
#else
#define DEPRECATED_113
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 12)
#define DEPRECATED_112 DDB_DEPRECATED("since deadbeef API 1.12")
#else
#define DEPRECATED_112
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 11)
#define DEPRECATED_111 DDB_DEPRECATED("since deadbeef API 1.11")
#else
#define DEPRECATED_111
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 10)
#define DEPRECATED_110 DDB_DEPRECATED("since deadbeef API 1.10")
#else
#define DEPRECATED_110
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 9)
#define DEPRECATED_19 DDB_DEPRECATED("since deadbeef API 1.9")
#else
#define DEPRECATED_19
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 8)
#define DEPRECATED_18 DDB_DEPRECATED("since deadbeef API 1.8")
#else
#define DEPRECATED_18
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 7)
#define DEPRECATED_17 DDB_DEPRECATED("since deadbeef API 1.7")
#else
#define DEPRECATED_17
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 6)
#define DEPRECATED_16 DDB_DEPRECATED("since deadbeef API 1.6")
#else
#define DEPRECATED_16
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 5)
#define DEPRECATED_15 DDB_DEPRECATED("since deadbeef API 1.5")
#else
#define DEPRECATED_15
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 4)
#define DEPRECATED_14 DDB_DEPRECATED("since deadbeef API 1.4")
#else
#define DEPRECATED_14
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 3)
#define DEPRECATED_13 DDB_DEPRECATED("since deadbeef API 1.3")
#else
#define DEPRECATED_13
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 2)
#define DEPRECATED_12 DDB_DEPRECATED("since deadbeef API 1.2")
#else
#define DEPRECATED_12
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 1)
#define DEPRECATED_11 DDB_DEPRECATED("since deadbeef API 1.1")
#else
#define DEPRECATED_11
#endif
#if (DDB_WARN_DEPRECATED && DDB_API_LEVEL >= 0)
#define DEPRECATED DDB_DEPRECATED("since deadbeef API 1.0")
#else
#define DEPRECATED
#endif
#define DDB_PLUGIN_SET_API_VERSION\
.plugin.api_vmajor = DB_API_VERSION_MAJOR,\
.plugin.api_vminor = DB_API_VERSION_MINOR,
// backwards compat macro
#define DB_PLUGIN_SET_API_VERSION DDB_PLUGIN_SET_API_VERSION
#define PLUG_TEST_COMPAT(plug,x,y) ((plug)->version_major == (x) && (plug)->version_minor >= (y))
#define DDB_REQUIRE_API_VERSION(x,y)\
.plugin.api_vmajor = x,\
.plugin.api_vminor = y,
////////////////////////////
// default values for some common config variables should go here
// network.ctmapping : content-type to plugin mapping
#define DDB_DEFAULT_CTMAPPING "audio/mpeg {stdmpg ffmpeg} audio/x-mpeg {stdmpg ffmpeg} application/ogg {stdogg opus ffmpeg} audio/ogg {stdogg opus ffmpeg} audio/aac {aac ffmpeg} audio/aacp {aac ffmpeg} audio/x-m4a {aac ffmpeg} audio/wma {wma ffmpeg}"
////////////////////////////
// playlist structures
// that's a good candidate for redesign
// short explanation: PL_MAIN and PL_SEARCH are used as "iter" argument in
// playlist functions, to reference main or search playlist, respectively
#define PL_MAIN 0
#define PL_SEARCH 1
enum {
DDB_IS_SUBTRACK = (1<<0), // file is not single-track, might have metainfo in external file
DDB_IS_READONLY = (1<<1), // check this flag to block tag writing (e.g. in iso.wv)
DDB_HAS_EMBEDDED_CUESHEET = (1<<2),
DDB_TAG_ID3V1 = (1<<8),
DDB_TAG_ID3V22 = (1<<9),
DDB_TAG_ID3V23 = (1<<10),
DDB_TAG_ID3V24 = (1<<11),
DDB_TAG_APEV2 = (1<<12),
DDB_TAG_VORBISCOMMENTS = (1<<13),
DDB_TAG_CUESHEET = (1<<14),
DDB_TAG_ICY = (1<<15),
DDB_TAG_ITUNES = (1<<16),
DDB_TAG_MASK = 0x000fff00
};
// playlist item
// these are "public" fields, available to plugins
typedef struct DB_playItem_s {
// NOTE: the startsample and endsample fields are 32 bit, and are kept for
// compatibility. Please use pl_item_get_startsample and friends instead.
int32_t startsample DEPRECATED_110;
int32_t endsample DEPRECATED_110;
int32_t shufflerating; // sort order for shuffle mode
} ddb_playItem_t;
typedef ddb_playItem_t DB_playItem_t;
typedef struct {
char unused; // to shut up C++ warning
} ddb_playlist_t;
typedef struct DB_metaInfo_s {
struct DB_metaInfo_s *next;
const char *key;
const char *value;
#if (DDB_API_LEVEL >= 10)
int valuesize;
#endif
} DB_metaInfo_t;
/// These flags should be used with `junk_rewrite_tags`
#define JUNK_STRIP_ID3V2 1
#define JUNK_STRIP_APEV2 2
#define JUNK_STRIP_ID3V1 4
#define JUNK_WRITE_ID3V2 8
#define JUNK_WRITE_APEV2 16
#define JUNK_WRITE_ID3V1 32
typedef struct DB_id3v2_frame_s {
struct DB_id3v2_frame_s *next;
char id[5];
uint32_t size;
uint8_t flags[2];
uint8_t data[0];
} DB_id3v2_frame_t;
typedef struct DB_id3v2_tag_s {
uint8_t version[2];
uint8_t flags;
DB_id3v2_frame_t *frames;
} DB_id3v2_tag_t;
typedef struct DB_apev2_frame_s {
struct DB_apev2_frame_s *next;
uint32_t flags;
char key[256];
uint32_t size; // size of data
uint8_t data[0];
} DB_apev2_frame_t;
typedef struct DB_apev2_tag_s {
uint32_t version;
uint32_t flags;
DB_apev2_frame_t *frames;
} DB_apev2_tag_t;
// plugin types
enum {
DB_PLUGIN_DECODER = 1,
DB_PLUGIN_OUTPUT = 2,
DB_PLUGIN_DSP = 3,
DB_PLUGIN_MISC = 4,
DB_PLUGIN_VFS = 5,
DB_PLUGIN_PLAYLIST = 6,
DB_PLUGIN_GUI = 7,
#if (DDB_API_LEVEL >= 15)
DB_PLUGIN_MEDIASOURCE = 8,
#endif
};
// output plugin states
enum output_state_t {
OUTPUT_STATE_STOPPED DEPRECATED_111 = 0,
OUTPUT_STATE_PLAYING DEPRECATED_111 = 1,
OUTPUT_STATE_PAUSED DEPRECATED_111 = 2,
};
#if (DDB_API_LEVEL >= 11)
typedef enum ddb_playback_state_e {
DDB_PLAYBACK_STATE_STOPPED = 0,
DDB_PLAYBACK_STATE_PLAYING = 1,
DDB_PLAYBACK_STATE_PAUSED = 2,
} ddb_playback_state_t;
#endif
// playback order
enum playback_order_t {
PLAYBACK_ORDER_LINEAR DEPRECATED_111 = 0,
PLAYBACK_ORDER_SHUFFLE_TRACKS DEPRECATED_111 = 1,
PLAYBACK_ORDER_RANDOM DEPRECATED_111 = 2,
PLAYBACK_ORDER_SHUFFLE_ALBUMS DEPRECATED_111 = 3,
};
// playback modes
enum playback_mode_t {
PLAYBACK_MODE_LOOP_ALL DEPRECATED_111 = 0, // loop playlist
PLAYBACK_MODE_NOLOOP DEPRECATED_111 = 1, // don't loop
PLAYBACK_MODE_LOOP_SINGLE DEPRECATED_111 = 2, // loop single track
};
#if (DDB_API_LEVEL >= 11)
typedef enum ddb_shuffle_e {
DDB_SHUFFLE_OFF = 0,
DDB_SHUFFLE_TRACKS = 1,
DDB_SHUFFLE_RANDOM = 2,
DDB_SHUFFLE_ALBUMS = 3,
} ddb_shuffle_t;
typedef enum ddb_repeat_e {
DDB_REPEAT_ALL = 0,
DDB_REPEAT_OFF = 1,
DDB_REPEAT_SINGLE = 2,
} ddb_repeat_t;
#endif
#if (DDB_API_LEVEL >= 8)
// playlist change info, used in the DB_EV_PLAYLISTCHANGED p1 argument
// NOTE: these events can only be sent individually, and can't be ORed.
enum ddb_playlist_change_t {
DDB_PLAYLIST_CHANGE_CONTENT, // this is the most generic one, will work for the cases when p1 was omitted (0)
DDB_PLAYLIST_CHANGE_CREATED,
DDB_PLAYLIST_CHANGE_DELETED,
DDB_PLAYLIST_CHANGE_POSITION,
DDB_PLAYLIST_CHANGE_TITLE,
// When handling DDB_PLAYLIST_CHANGE_SELECTION,
// `ctx` is assumed to be a unique ID of the event sender,
// for example a UI view pointer which caused the selection change,
// but it should not be expected to point to a specific type.
// This is used to filter the events when they hit the same
// view which sent them.
DDB_PLAYLIST_CHANGE_SELECTION,
DDB_PLAYLIST_CHANGE_SEARCHRESULT,
DDB_PLAYLIST_CHANGE_PLAYQUEUE,
};
#endif
typedef struct {
int event;
int size;
} ddb_event_t;
typedef struct {
ddb_event_t ev;
DB_playItem_t *track;
float playtime; // for SONGFINISHED event -- for how many seconds track was playing
time_t started_timestamp; // time when "track" started playing
} ddb_event_track_t;
typedef struct {
ddb_event_t ev;
DB_playItem_t *from;
DB_playItem_t *to;
float playtime; // for SONGCHANGED event -- for how many seconds prev track was playing
time_t started_timestamp; // time when "from" started playing
} ddb_event_trackchange_t;
typedef struct {
ddb_event_t ev;
int state;
} ddb_event_state_t;
typedef struct {
ddb_event_t ev;
DB_playItem_t *track;
float playpos;
} ddb_event_playpos_t;
typedef struct DB_conf_item_s {
char *key;
char *value;
struct DB_conf_item_s *next;
} DB_conf_item_t;
// event callback type
typedef int (*DB_callback_t)(ddb_event_t *, uintptr_t data);
// events
enum {
DB_EV_NEXT = 1, // switch to next track
DB_EV_PREV = 2, // switch to prev track
DB_EV_PLAY_CURRENT = 3, // play current track (will start/unpause if stopped or paused)
DB_EV_PLAY_NUM = 4, // play track nr. p1
DB_EV_STOP = 5, // stop current track
DB_EV_PAUSE = 6, // pause playback
DB_EV_PLAY_RANDOM = 7, // play random track
DB_EV_TERMINATE = 8, // must be sent to player thread to terminate
DB_EV_PLAYLIST_REFRESH DEPRECATED_18 = 9, // [use DB_EV_PLAYLISTCHANGED instead]
DB_EV_REINIT_SOUND = 10, // reinitialize sound output with current output_plugin config value
DB_EV_CONFIGCHANGED = 11, // one or more config options were changed
DB_EV_TOGGLE_PAUSE = 12,
DB_EV_ACTIVATED = 13, // will be fired every time player is activated
DB_EV_PAUSED = 14, // player was paused (p1=1) or unpaused (p1=0)
DB_EV_PLAYLISTCHANGED = 15, // playlist contents were changed (e.g. metadata in any track)
// DB_EV_PLAYLISTCHANGED NOTE: it's usually sent on LARGE changes,
// when multiple tracks are affected, while for single tracks
// the DB_EV_TRACKINFOCHANGED is preferred
// added in API level 8:
// p1 is one of ddb_playlist_change_t enum values, detailing what exactly has been changed.
DB_EV_VOLUMECHANGED = 16, // volume was changed
DB_EV_OUTPUTCHANGED = 17, // sound output plugin changed
DB_EV_PLAYLISTSWITCHED = 18, // playlist switch occurred
DB_EV_SEEK = 19, // seek current track to position p1 (ms)
DB_EV_ACTIONSCHANGED = 20, // plugin actions were changed, e.g. for reinitializing gui
DB_EV_DSPCHAINCHANGED = 21, // emitted when any parameter of the main dsp chain has been changed
// since 1.5
#if (DDB_API_LEVEL >= 5)
// DB_EV_SELCHANGED is obsolete and isn't emitted; DB_EV_PLAYLISTCHANGED with DDB_PLAYLIST_CHANGE_SELECTION should be used instead.
DB_EV_SELCHANGED = 22,
DB_EV_PLUGINSLOADED = 23, // after all plugins have been loaded and connected
#endif
#if (DDB_API_LEVEL >= 8)
// A caller sends this event, to ask playlist viewer(s) to focus on selected track.
DB_EV_FOCUS_SELECTION = 24,
#endif
// -----------------
// structured events
DB_EV_FIRST = 1000, // this is not an event id by itself, but used for checking which events are structured (>=DB_EV_FIRST)
DB_EV_SONGCHANGED = 1000, // current song changed from one to another, ctx=ddb_event_trackchange_t
DB_EV_SONGSTARTED = 1001, // song started playing, ctx=ddb_event_track_t
DB_EV_SONGFINISHED = 1002, // song finished playing, ctx=ddb_event_track_t
DB_EV_TRACKINFOCHANGED = 1004, // trackinfo was changed (included medatata, playback status, playqueue state, etc), ctx=ddb_event_track_t
// DB_EV_TRACKINFOCHANGED NOTE: when multiple tracks change, DB_EV_PLAYLISTCHANGED may be sent instead,
// for speed reasons, so always handle both events.
DB_EV_SEEKED = 1005, // seek happened, ctx=ddb_event_playpos_t
// since 1.5
#if (DDB_API_LEVEL >= 5)
// NOTE: this is not a structured event, but too late to fix, needs to stay here for backwards compat
DB_EV_TRACKFOCUSCURRENT = 1006, // user wants to highlight/find the current playing track
#endif
#if (DDB_API_LEVEL >= 10)
DB_EV_CURSOR_MOVED = 1007, // used for syncing cursor position between playlist views, p1 = PL_MAIN or PL_SEARCH, ctx is a ddb_event_track_t, containing the new track under cursor
#endif
DB_EV_MAX
};
// preset columns, working using IDs
// DON'T add new ids in range 2-7, they are reserved for backwards compatibility
enum pl_column_t {
#if (DDB_API_LEVEL >= 10)
DB_COLUMN_STANDARD = -1,
#endif
DB_COLUMN_FILENUMBER = 0,
DB_COLUMN_PLAYING = 1,
DB_COLUMN_ALBUM_ART = 8,
#if (DDB_API_LEVEL >= 10)
DB_COLUMN_CUSTOM = 9
#endif
};
// replaygain constants
enum {
DDB_REPLAYGAIN_ALBUMGAIN,
DDB_REPLAYGAIN_ALBUMPEAK,
DDB_REPLAYGAIN_TRACKGAIN,
DDB_REPLAYGAIN_TRACKPEAK,
};
#if (DDB_API_LEVEL >= 10)
#if (DDB_API_LEVEL >= 11)
typedef enum ddb_rg_source_mode_e {
#else
enum {
#endif
DDB_RG_SOURCE_MODE_PLAYBACK_ORDER = 0,
DDB_RG_SOURCE_MODE_TRACK = 1,
DDB_RG_SOURCE_MODE_ALBUM = 2,
#if (DDB_API_LEVEL >= 11)
} ddb_rg_source_mode_t;
#else
};
#endif
#if (DDB_API_LEVEL >= 11)
typedef enum ddb_rg_processing_e {
#else
enum {
#endif
DDB_RG_PROCESSING_NONE = 0,
DDB_RG_PROCESSING_GAIN = 1,
DDB_RG_PROCESSING_PREVENT_CLIPPING = 2,
#if (DDB_API_LEVEL >= 11)
} ddb_rg_processing_t;
#else
};
#endif
typedef struct {
int _size;
int source_mode;
uint32_t processing_flags;
float preamp_with_rg;
float preamp_without_rg;
int has_album_gain;
int has_track_gain;
float albumgain;
float albumpeak;
float trackgain;
float trackpeak;
} ddb_replaygain_settings_t;
#endif
// sort order constants
enum ddb_sort_order_t {
DDB_SORT_DESCENDING,
DDB_SORT_ASCENDING,
// since 1.3
#if (DDB_API_LEVEL >= 3)
DDB_SORT_RANDOM,
#endif
};
enum ddb_sys_directory_t {
DDB_SYS_DIR_CONFIG = 1,
DDB_SYS_DIR_PREFIX = 2,
DDB_SYS_DIR_DOC = 3,
DDB_SYS_DIR_PLUGIN = 4,
DDB_SYS_DIR_PIXMAP = 5,
DDB_SYS_DIR_CACHE = 6,
#if (DDB_API_LEVEL >= 13)
DDB_SYS_DIR_PLUGIN_RESOURCES = 7,
#endif
};
// typecasting macros
#define DB_PLUGIN(x) ((DB_plugin_t *)(x))
#define DB_CALLBACK(x) ((DB_callback_t)(x))
#define DB_EVENT(x) ((ddb_event_t *)(x))
#define DB_PLAYITEM(x) ((DB_playItem_t *)(x))
// FILE object wrapper for vfs access
typedef struct {
struct DB_vfs_s *vfs;
} DB_FILE;
// md5 calc control structure (see md5/md5.h)
typedef struct DB_md5_s {
char data[88];
} DB_md5_t;
typedef struct {
int bps;
int channels;
int samplerate;
uint32_t channelmask;
int is_float; // bps must be 32 if this is true
int is_bigendian;
} ddb_waveformat_t;
// since 1.5
#if (DDB_API_LEVEL >= 5)
/// NOTE: The @c DDB_FREQ_BANDS and the related @c vis_spectrum_listen is no longer used / supported.
/// They do not do anything, just allowing to build old code.
/// Use the nframes field instead. Your code should adapt to any
/// number of bands produced by the visualization engine.
static const int DDB_FREQ_BANDS DEPRECATED_115 = 256;
/// Max number of channels allowed in the ddb_audio_data_t for frequency data
static const int DDB_FREQ_MAX_CHANNELS = 9;
typedef struct ddb_audio_data_s {
ddb_waveformat_t *fmt;
float *data;
int nframes;
} ddb_audio_data_t;
typedef struct ddb_fileadd_data_s {
int visibility;
ddb_playlist_t *plt;
ddb_playItem_t *track;
} ddb_fileadd_data_t;
#endif
// since 1.8
#if (DDB_API_LEVEL >= 8)
enum {
DDB_TF_CONTEXT_HAS_INDEX = 1,
DDB_TF_CONTEXT_HAS_ID = 2,
DDB_TF_CONTEXT_NO_DYNAMIC = 4, // skip dynamic fields (%playback_time%)
// since 1.9
#if (DDB_API_LEVEL >= 9)
// By default, non-printable characters will be replaced with underscores.
// In multiline mode, they stay as they are in the input.
DDB_TF_CONTEXT_MULTILINE = 8,
#endif
// since 1.10
#if (DDB_API_LEVEL >= 10)
// the caller supports text dimming functions
DDB_TF_CONTEXT_TEXT_DIM = 16,
#endif
// since 1.13
#if (DDB_API_LEVEL >= 13)
// the caller guarantees that metadata access is thread safe
DDB_TF_CONTEXT_NO_MUTEX_LOCK = 32,
#endif
};
// since 1.10
#if (DDB_API_LEVEL >= 10)
enum {
DDB_TF_ESC_DIM = 1,
#if DDB_API_LEVEL >= 14
DDB_TF_ESC_RGB = 2,
#endif
};
#endif
// since 1.10
#if (DDB_API_LEVEL >= 10)
typedef struct ddb_file_found_data_s {
ddb_playlist_t *plt;
const char *filename;
int is_dir;
} ddb_file_found_data_t;
#endif
// context for title formatting interpreter
typedef struct {
int _size; // must be set to sizeof(tf_context_t)
uint32_t flags; // DDB_TF_CONTEXT_ flags
ddb_playItem_t *it; // track to get information from, or NULL
ddb_playlist_t *plt; // playlist in which the track resides, or NULL
// NOTE: when plt is NULL, it means that the track is not in any playlist,
// that is -- playlist will never be automatically guessed, for performance
// reasons.
// index of the track in playlist the track belongs to
// if present, DDB_TF_CONTEXT_HAS_INDEX flag must be set
int idx;
// predefined column id, one of the DB_COLUMN_
// if present, DDB_TF_CONTEXT_HAS_ID flag must be set
int id;
int iter; // playlist iteration (PL_MAIN, PL_SEARCH)
// update is a returned value
// meaning:
// 0: no automatic updates
// <0: updates on every call
// >0: number of milliseconds between updates / until next update
int update;
#if (DDB_API_LEVEL >= 10)
// Return value, is set to non-zero if text was <<<dimmed>>> or >>>brightened<<<
// It's used to determine whether the text needs to be searched for the corresponding esc sequences
int dimmed;
#endif
} ddb_tf_context_t;
#endif
#if (DDB_API_LEVEL>=10)
enum {
// Layer 0 means it's always on, and important.
// This layer is suitable for critical error messages,
// but it's also useful for plugin-specific messages,
// which can be turned on and off in the settings.
// It is expected that the UI plugins will auto-show the Log View,
// when any message is logged on this layer
DDB_LOG_LAYER_DEFAULT = 0,
// Layer 1 should contain informational non-critical messages, like boot log.
// This layer is always on.
// UI should not auto-show the Log View for this layer.
DDB_LOG_LAYER_INFO = 1,
};
#endif
#if (DDB_API_LEVEL>=15)
typedef enum {
DDB_INSERT_FILE_RESULT_SUCCESS = 0,
DDB_INSERT_FILE_RESULT_UNRECOGNIZED_FILE = 1, // File was not unrecognized
DDB_INSERT_FILE_RESULT_RECOGNIZED_FAILED = 2, // File extension was recognized, but could not be loaded by decoder
DDB_INSERT_FILE_RESULT_RELATIVE_PATH = 3, // File path is relative: unsupported
DDB_INSERT_FILE_RESULT_NULL_FILENAME = 4, // File name is NULL
DDB_INSERT_FILE_RESULT_ESCAPE_CHARACTERS_IN_FILENAME = 5, // Escape characters are not allowed in filenames
DDB_INSERT_FILE_RESULT_NO_FILE_EXTENSION = 6, // File doesn't have an extension
DDB_INSERT_FILE_RESULT_CUESHEET_ERROR = 7, // Error while loading cuesheet
} ddb_insert_file_result_t;
typedef enum {
DDB_INSERT_FILE_FLAG_FOLLOW_SYMLINKS = 1<<0,
DDB_INSERT_FILE_FLAG_ENTER_ARCHIVES = 1<<1,
} ddb_insert_file_flags_t;
#endif
// forward decl for plugin struct
struct DB_plugin_s;
// player api definition
typedef struct {
// versioning
int vmajor;
int vminor;
// md5sum calc
void (*md5) (uint8_t sig[16], const char *in, int len);
void (*md5_to_str) (char *str, const uint8_t sig[16]);
void (*md5_init)(DB_md5_t *s);
void (*md5_append)(DB_md5_t *s, const uint8_t *data, int nbytes);
void (*md5_finish)(DB_md5_t *s, uint8_t digest[16]);
// playback control
struct DB_output_s* (*get_output) (void);
float (*playback_get_pos) (void); // [0..100]
void (*playback_set_pos) (float pos); // [0..100]
// streamer access
DB_playItem_t *(*streamer_get_playing_track) (void);
DB_playItem_t *(*streamer_get_streaming_track) (void);
float (*streamer_get_playpos) (void);
int (*streamer_ok_to_read) (int len);
void (*streamer_reset) (int full);
int (*streamer_read) (char *bytes, int size);
void (*streamer_set_bitrate) (int bitrate);
int (*streamer_get_apx_bitrate) (void);
struct DB_fileinfo_s *(*streamer_get_current_fileinfo) (void);
int (*streamer_get_current_playlist) (void);
struct ddb_dsp_context_s * (*streamer_get_dsp_chain) (void);
void (*streamer_set_dsp_chain) (struct ddb_dsp_context_s *chain);
void (*streamer_dsp_refresh) (void); // call after changing parameters
// system folders
// normally functions will return standard folders derived from --prefix
// portable version will return pathes specified in comments below
// DEPRECATED IN API LEVEL 8, use get_system_dir instead
const char *(*get_config_dir) (void) DEPRECATED_18; // installdir/config | $XDG_CONFIG_HOME/.config/deadbeef
const char *(*get_prefix) (void) DEPRECATED_18; // installdir | PREFIX
const char *(*get_doc_dir) (void) DEPRECATED_18; // installdir/doc | DOCDIR
const char *(*get_plugin_dir) (void) DEPRECATED_18; // installdir/plugins | LIBDIR/deadbeef
const char *(*get_pixmap_dir) (void) DEPRECATED_18; // installdir/pixmaps | PREFIX "/share/deadbeef/pixmaps"
// This function is not implemented, and should not be called. A remnant
// from old API before 0.5.0.
void (*do_not_call) (void) DEPRECATED;
// threading
intptr_t (*thread_start) (void (*fn)(void *ctx), void *ctx);
intptr_t (*thread_start_low_priority) (void (*fn)(void *ctx), void *ctx);
int (*thread_join) (intptr_t tid);
int (*thread_detach) (intptr_t tid);
void (*thread_exit) (void *retval);
uintptr_t (*mutex_create) (void);
uintptr_t (*mutex_create_nonrecursive) (void);
void (*mutex_free) (uintptr_t mtx);
int (*mutex_lock) (uintptr_t mtx);
int (*mutex_unlock) (uintptr_t mtx);
uintptr_t (*cond_create) (void);
void (*cond_free) (uintptr_t cond);
int (*cond_wait) (uintptr_t cond, uintptr_t mutex);
int (*cond_signal) (uintptr_t cond);
int (*cond_broadcast) (uintptr_t cond);
/////// playlist management //////
void (*plt_ref) (ddb_playlist_t *plt);
void (*plt_unref) (ddb_playlist_t *plt);
// total number of playlists
int (*plt_get_count) (void);
// 1st item in playlist nr. 'plt'
DB_playItem_t * (*plt_get_head) (int plt) DEPRECATED_113;
// nr. of selected items in playlist nr. 'plt'
int (*plt_get_sel_count) (int plt);
// add new playlist into position before nr. 'before', with title='title'
// returns index of new playlist
int (*plt_add) (int before, const char *title);
// remove playlist nr. plt
void (*plt_remove) (int plt);
// clear playlist
void (*plt_clear) (ddb_playlist_t *plt);
void (*pl_clear) (void);
// set current playlist
void (*plt_set_curr) (ddb_playlist_t *plt);
void (*plt_set_curr_idx) (int plt);
// get current playlist
// note: caller is responsible to call plt_unref after using pointer
// returned by plt_get_curr
ddb_playlist_t *(*plt_get_curr) (void);
int (*plt_get_curr_idx) (void);
// move playlist nr. 'from' into position before nr. 'before', where
// before=-1 means last position
void (*plt_move) (int from, int before);
// playlist saving and loading
DB_playItem_t * (*plt_load) (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data) DEPRECATED_15;
int (*plt_save) (ddb_playlist_t *plt, DB_playItem_t *first, DB_playItem_t *last, const char *fname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data);
ddb_playlist_t *(*plt_get_for_idx) (int idx);
int (*plt_get_title) (ddb_playlist_t *plt, char *buffer, int bufsize);
int (*plt_set_title) (ddb_playlist_t *plt, const char *title);
// Increments modification index.
// This would mark playlist as "dirty" -- meaning it needs to be saved when `pl_save_all` is called.
// The flag is reset as soon as playlist is saved.
// This is called automatically when playlists are created / cleared / removed, and when items are added/removed to them.
// However, other changes -- like changing track metadata -- would not call this function.
// You need to call it yourself, to make sure the playlist gets saved on exit.
// It doesn't need to be called if you save the playlist via direct call to `plt_save_*`, or `pl_save_current`
void (*plt_modified) (ddb_playlist_t *handle);
// returns modication index
// the index is incremented by 1 every time playlist changes
int (*plt_get_modification_idx) (ddb_playlist_t *handle);
// return index of an item in specified playlist, or -1 if not found
int (*plt_get_item_idx) (ddb_playlist_t *plt, DB_playItem_t *it, int iter);
// playlist metadata
// this kind of metadata is stored in playlist (dbpl) files
// that is, this is the properties of playlist itself,
// not of the tracks in the playlist.
// for example, playlist tab color can be stored there, etc
// add meta if it doesn't exist yet
void (*plt_add_meta) (ddb_playlist_t *handle, const char *key, const char *value);
// replace (or add) existing meta
void (*plt_replace_meta) (ddb_playlist_t *handle, const char *key, const char *value);
// append meta to existing one, or add if doesn't exist
void (*plt_append_meta) (ddb_playlist_t *handle, const char *key, const char *value);
// set integer meta (works same as replace)
void (*plt_set_meta_int) (ddb_playlist_t *handle, const char *key, int value);
// set float meta (works same as replace)
void (*plt_set_meta_float) (ddb_playlist_t *handle, const char *key, float value);
// plt_find_meta must always be used in the pl_lock/unlock block
const char *(*plt_find_meta) (ddb_playlist_t *handle, const char *key);
// returns head of metadata linked list, for direct access
// remember pl_lock/unlock
DB_metaInfo_t * (*plt_get_metadata_head) (ddb_playlist_t *handle);
// delete meta item from list
void (*plt_delete_metadata) (ddb_playlist_t *handle, DB_metaInfo_t *meta);
// returns integer value of requested meta, def is the default value if not found
int (*plt_find_meta_int) (ddb_playlist_t *handle, const char *key, int def);
// returns float value of requested meta, def is the default value if not found
float (*plt_find_meta_float) (ddb_playlist_t *handle, const char *key, float def);
// delete all metadata
void (*plt_delete_all_meta) (ddb_playlist_t *handle);
// operating on playlist items
DB_playItem_t * (*plt_insert_item) (ddb_playlist_t *playlist, DB_playItem_t *after, DB_playItem_t *it);
DB_playItem_t * (*plt_insert_file) (ddb_playlist_t *playlist, DB_playItem_t *after, const char *fname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data) DEPRECATED_15;
DB_playItem_t *(*plt_insert_dir) (ddb_playlist_t *plt, DB_playItem_t *after, const char *dirname, int *pabort, int (*cb)(DB_playItem_t *it, void *data), void *user_data) DEPRECATED_15;
void (*plt_set_item_duration) (ddb_playlist_t *plt, DB_playItem_t *it, float duration);
int (*plt_remove_item) (ddb_playlist_t *playlist, DB_playItem_t *it);
int (*plt_getselcount) (ddb_playlist_t *playlist);
float (*plt_get_totaltime) (ddb_playlist_t *plt);
int (*plt_get_item_count) (ddb_playlist_t *plt, int iter);
int (*plt_delete_selected) (ddb_playlist_t *plt);
void (*plt_set_cursor) (ddb_playlist_t *plt, int iter, int cursor);
int (*plt_get_cursor) (ddb_playlist_t *plt, int iter);
void (*plt_select_all) (ddb_playlist_t *plt);
void (*plt_crop_selected) (ddb_playlist_t *plt);
DB_playItem_t *(*plt_get_first) (ddb_playlist_t *plt, int iter);
DB_playItem_t *(*plt_get_last) (ddb_playlist_t *plt, int iter);
DB_playItem_t * (*plt_get_item_for_idx) (ddb_playlist_t *playlist, int idx, int iter);
void (*plt_move_items) (ddb_playlist_t *to, int iter, ddb_playlist_t *from, DB_playItem_t *drop_before, uint32_t *indexes, int count);
void (*plt_copy_items) (ddb_playlist_t *to, int iter, ddb_playlist_t * from, DB_playItem_t *before, uint32_t *indices, int cnt);
// Empty the PL_SEARCH list, and mark the previous results as unselected.
void (*plt_search_reset) (ddb_playlist_t *plt);
// Find the specified text in playlist, and populate the PL_SEARCH linked
// list. The results are also marked as selected.
void (*plt_search_process) (ddb_playlist_t *plt, const char *text);
// sort using the title formatting v1 (deprecated)
void (*plt_sort) (ddb_playlist_t *plt, int iter, int id, const char *format, int order) DEPRECATED_18;
// add files and folders to current playlist
int (*plt_add_file) (ddb_playlist_t *plt, const char *fname, int (*cb)(DB_playItem_t *it, void *data), void *user_data) DEPRECATED_15;
int (*plt_add_dir) (ddb_playlist_t *plt, const char *dirname, int (*cb)(DB_playItem_t *it, void *data), void *user_data) DEPRECATED_15;
// cuesheet support
DB_playItem_t *(*plt_insert_cue_from_buffer) (ddb_playlist_t *plt, DB_playItem_t *after, DB_playItem_t *origin, const uint8_t *buffer, int buffersize, int numsamples, int samplerate) DEPRECATED_110;
DB_playItem_t * (*plt_insert_cue) (ddb_playlist_t *plt, DB_playItem_t *after, DB_playItem_t *origin, int numsamples, int samplerate) DEPRECATED_110;