File: ol_display_module.h

package info (click to toggle)
osdlyrics 0.5.5~rc2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,608 kB
  • sloc: ansic: 19,115; python: 4,837; sh: 563; makefile: 354; sed: 16
file content (121 lines) | stat: -rw-r--r-- 4,638 bytes parent folder | download | duplicates (3)
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
/* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
/*
 * Copyright (C) 2009-2011  Tiger Soldier <tigersoldier@gmail.com>
 *
 * This file is part of OSD Lyrics.
 * 
 * OSD Lyrics is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * OSD Lyrics is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OSD Lyrics.  If not, see <https://www.gnu.org/licenses/>. 
 */
#ifndef _OL_DISPLAY_MODULE_H_
#define _OL_DISPLAY_MODULE_H_

#include "ol_metadata.h"
#include "ol_lrc.h"
#include "ol_player.h"

struct OlLrc;
struct OlPlayer;
enum OlPlayerStatus;

struct OlDisplayModule
{
  const struct OlDisplayClass *klass;
  void *data;
};

typedef void* (*OlDisplayInitFunc) (struct OlDisplayModule *module,
                                    OlPlayer *player);
typedef void (*OlDisplayFreeFunc) (struct OlDisplayModule *module);

struct OlDisplayClass
{
  char *name;
  OlDisplayInitFunc init;
  OlDisplayFreeFunc free;
  void (*set_lrc) (struct OlDisplayModule *module,
                   OlLrc *lrc_file);
  void (*set_played_time) (struct OlDisplayModule *module,
                           guint64 played_time);
  void (*set_message) (struct OlDisplayModule *module,
                       const char *message,
                       int duration_ms);
  void (*search_message) (struct OlDisplayModule *module,
                          const char *message);
  void (*search_fail_message) (struct OlDisplayModule *module,
                               const char *message);
  void (*download_fail_message) (struct OlDisplayModule *module,
                                 const char *message);
  void (*clear_message) (struct OlDisplayModule *module);
};

/** functions for implementing concrete modules **/

/** 
 * @brief Create a new class for display module
 *
 * This should be used in ol_foo_moduel_get_class, where foo is the name of
 * the display module
 *
 * @param name The name of the new display module
 * @param init_func The function to initialize the private data
 * @param free_func The function to free the private data
 * 
 * @return A new class of display module, with all functions but init and free
 *         set to NULL
 */
struct OlDisplayClass* ol_display_class_new (const char *name,
                                             OlDisplayInitFunc init_func,
                                             OlDisplayFreeFunc free_func);

void* ol_display_module_get_data (struct OlDisplayModule *module);

/** functions for display module controlling **/

/** 
 * Initialize the display module.
 * 
 * This function must be called before any other functions
 */
void ol_display_module_init ();
void ol_display_module_unload ();
/** 
 * @brief Create a display module of given type
 * 
 * @param name The name of the type of display module, case insensitive
 * @param player The player proxy to use
 * 
 * @return The new display module. If the display module with the given name
 *         not exists, a default display module is returned. The returned module
 *         must be freed with ol_display_module_free.
 */
struct OlDisplayModule *ol_display_module_new (const char *name,
                                               OlPlayer *player);

void ol_display_module_free (struct OlDisplayModule *module);
void ol_display_module_set_played_time (struct OlDisplayModule *module,
                                        guint64 played_time);
void ol_display_module_set_lrc (struct OlDisplayModule *module,
                                OlLrc *lrc);
void ol_display_module_set_message (struct OlDisplayModule *module,
                                    const char *message,
                                    int duration_ms);
void ol_display_module_search_message (struct OlDisplayModule *module,
                                       const char *message);
void ol_display_module_search_fail_message (struct OlDisplayModule *module,
                                            const char *message);
void ol_display_module_download_fail_message (struct OlDisplayModule *module,
                                              const char *message);
void ol_display_module_clear_message (struct OlDisplayModule *module);

#endif /* _OL_DISPLAY_MODULE_H_ */