本文整理汇总了C++中DB_output_t类的典型用法代码示例。如果您正苦于以下问题:C++ DB_output_t类的具体用法?C++ DB_output_t怎么用?C++ DB_output_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB_output_t类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: action_skip_to_next_artist_handler
int
action_skip_to_next_artist_handler (DB_plugin_action_t *act, int ctx)
{
deadbeef->pl_lock ();
DB_output_t *output = deadbeef->get_output ();
if (output->state () == OUTPUT_STATE_STOPPED) {
deadbeef->pl_unlock ();
return 0;
}
DB_playItem_t *it = skip_to_get_track_helper ();
if (!it) {
deadbeef->pl_unlock ();
return 0;
}
const char *cur_artist = deadbeef->pl_find_meta_raw (it, "band");
if (!cur_artist) {
cur_artist = deadbeef->pl_find_meta_raw (it, "album artist");
}
if (!cur_artist) {
cur_artist = deadbeef->pl_find_meta_raw (it, "albumartist");
}
if (!cur_artist) {
cur_artist = deadbeef->pl_find_meta_raw (it, "artist");
}
while (it) {
DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
if (!next) {
deadbeef->pl_item_unref (it);
break;
}
const char *next_artist = deadbeef->pl_find_meta_raw (next, "band");
if (!next_artist) {
next_artist = deadbeef->pl_find_meta_raw (next, "album artist");
}
if (!next_artist) {
next_artist = deadbeef->pl_find_meta_raw (next, "albumartist");
}
if (!next_artist) {
next_artist = deadbeef->pl_find_meta_raw (next, "artist");
}
if (cur_artist != next_artist) {
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (next), 0);
deadbeef->pl_item_unref (it);
deadbeef->pl_item_unref (next);
break;
}
deadbeef->pl_item_unref (it);
it = next;
}
deadbeef->pl_unlock ();
return 0;
}
示例2: skip_to_prev_helper
static void
skip_to_prev_helper (const char *meta)
{
if (!meta) {
return;
}
deadbeef->pl_lock ();
DB_output_t *output = deadbeef->get_output ();
if (output->state () == OUTPUT_STATE_STOPPED) {
deadbeef->pl_unlock ();
return;
}
DB_playItem_t *it = skip_to_get_track_helper ();
if (!it) {
deadbeef->pl_unlock ();
return;
}
const char *cur_meta = deadbeef->pl_find_meta_raw (it, meta);
int c = 0;
while (it) {
DB_playItem_t *prev = deadbeef->pl_get_prev (it, PL_MAIN);
if (!prev) {
if (c == 1) {
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (it), 0);
}
deadbeef->pl_item_unref (it);
break;
}
const char *prev_meta = deadbeef->pl_find_meta_raw (prev, meta);
if (cur_meta != prev_meta) {
if (c == 0) {
cur_meta = prev_meta;
c = 1;
}
else {
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (it), 0);
deadbeef->pl_item_unref (it);
deadbeef->pl_item_unref (prev);
break;
}
}
deadbeef->pl_item_unref (it);
it = prev;
}
deadbeef->pl_unlock ();
}
示例3: deadbeef_toggle_play_pause
void
deadbeef_toggle_play_pause (void) {
DB_output_t *output;
output = deadbeef->get_output ();
if (output) {
switch (output->state ()) {
case OUTPUT_STATE_PLAYING:
deadbeef->sendmessage (DB_EV_TOGGLE_PAUSE, 0, 0, 0);
return;
case OUTPUT_STATE_PAUSED:
deadbeef->sendmessage (DB_EV_TOGGLE_PAUSE, 0, 0, 0);
return;
}
}
deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
}
示例4: restore_resume_state
void
restore_resume_state (void) {
DB_output_t *output = plug_get_output ();
if (conf_get_int ("resume_last_session", 0) && output->state () == OUTPUT_STATE_STOPPED) {
int plt = conf_get_int ("resume.playlist", -1);
int track = conf_get_int ("resume.track", -1);
float pos = conf_get_float ("resume.position", -1);
int paused = conf_get_int ("resume.paused", 0);
trace ("resume: track %d pos %f playlist %d\n", track, pos, plt);
if (plt >= 0 && track >= 0 && pos >= 0) {
streamer_lock (); // need to hold streamer thread to make the resume operation atomic
streamer_set_current_playlist (plt);
streamer_set_nextsong (track, paused ? 2 : 3);
streamer_set_seek (pos);
streamer_unlock ();
}
}
}
示例5:
void
on_playbtn_clicked (GtkButton *button,
gpointer user_data)
{
// NOTE: this function is a copy of action_play_cb
DB_output_t *output = deadbeef->get_output ();
if (output->state () == OUTPUT_STATE_PAUSED) {
ddb_playlist_t *plt = deadbeef->plt_get_curr ();
int cur = deadbeef->plt_get_cursor (plt, PL_MAIN);
if (cur != -1) {
ddb_playItem_t *it = deadbeef->plt_get_item_for_idx (plt, cur, PL_MAIN);
ddb_playItem_t *it_playing = deadbeef->streamer_get_playing_track ();
if (it) {
deadbeef->pl_item_unref (it);
}
if (it_playing) {
deadbeef->pl_item_unref (it_playing);
}
if (it != it_playing) {
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, cur, 0);
}
else {
deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
}
}
else {
deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
}
deadbeef->plt_unref (plt);
}
else {
ddb_playlist_t *plt = deadbeef->plt_get_curr ();
int cur = -1;
if (plt) {
cur = deadbeef->plt_get_cursor (plt, PL_MAIN);
deadbeef->plt_unref (plt);
}
if (cur == -1) {
cur = 0;
}
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, cur, 0);
}
}
示例6: save_resume_state
void
save_resume_state (void) {
playItem_t *trk = streamer_get_playing_track ();
DB_output_t *output = plug_get_output ();
float playpos = -1;
int playtrack = -1;
int playlist = streamer_get_current_playlist ();
int paused = (output->state () == OUTPUT_STATE_PAUSED);
if (trk && playlist >= 0) {
playtrack = str_get_idx_of (trk);
playpos = streamer_get_playpos ();
pl_item_unref (trk);
}
conf_set_float ("resume.position", playpos);
conf_set_int ("resume.track", playtrack);
conf_set_int ("resume.playlist", playlist);
conf_set_int ("resume.paused", paused);
}
示例7: action_play_cb
int
action_play_cb (struct DB_plugin_action_s *action, int ctx) {
// NOTE: this function is copied as on_playbtn_clicked in gtkui
DB_output_t *output = deadbeef->get_output ();
if (output->state () == OUTPUT_STATE_PAUSED) {
ddb_playlist_t *plt = deadbeef->plt_get_curr ();
int cur = deadbeef->plt_get_cursor (plt, PL_MAIN);
if (cur != -1) {
ddb_playItem_t *it = deadbeef->plt_get_item_for_idx (plt, cur, PL_MAIN);
ddb_playItem_t *it_playing = deadbeef->streamer_get_playing_track ();
if (it) {
deadbeef->pl_item_unref (it);
}
if (it_playing) {
deadbeef->pl_item_unref (it_playing);
}
if (it != it_playing) {
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, cur, 0);
}
else {
deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
}
}
else {
deadbeef->sendmessage (DB_EV_PLAY_CURRENT, 0, 0, 0);
}
deadbeef->plt_unref (plt);
}
else {
ddb_playlist_t *plt = deadbeef->plt_get_curr ();
int cur = -1;
if (plt) {
cur = deadbeef->plt_get_cursor (plt, PL_MAIN);
deadbeef->plt_unref (plt);
}
if (cur == -1) {
cur = 0;
}
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, cur, 0);
}
return 0;
}
示例8: sni_update_status
void
sni_update_status (int state) {
g_debug("sni_update_status, status: %d", state);
DB_output_t *output;
DbusmenuMenuitem *stop_item;
if (!icon)
return;
output = deadbeef->get_output ();
if (output) {
if (state < 0)
state = output->state ();
switch (state) {
case OUTPUT_STATE_PLAYING:
status_notifier_set_from_icon_name (icon, STATUS_NOTIFIER_OVERLAY_ICON, "media-playback-start");
stop_item = get_context_menu_item (SNI_MENU_ITEM_STOP);
dbusmenu_menuitem_property_set_bool (stop_item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
sni_toggle_play_pause (0);
break;
case OUTPUT_STATE_PAUSED:
status_notifier_set_from_icon_name (icon, STATUS_NOTIFIER_OVERLAY_ICON, "media-playback-pause");
sni_toggle_play_pause (1);
break;
case OUTPUT_STATE_STOPPED:
status_notifier_set_from_icon_name (icon, STATUS_NOTIFIER_OVERLAY_ICON, NULL);
stop_item = get_context_menu_item (SNI_MENU_ITEM_STOP);
dbusmenu_menuitem_property_set_bool (stop_item, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
sni_toggle_play_pause (1);
break;
}
}
sni_update_tooltip (state);
}
示例9: skip_to_next_helper
static void
skip_to_next_helper (const char *meta)
{
if (!meta) {
return;
}
deadbeef->pl_lock ();
DB_output_t *output = deadbeef->get_output ();
if (output->state () == OUTPUT_STATE_STOPPED) {
deadbeef->pl_unlock ();
return;
}
DB_playItem_t *it = skip_to_get_track_helper ();
if (!it) {
deadbeef->pl_unlock ();
return;
}
const char *cur_meta = deadbeef->pl_find_meta_raw (it, meta);
while (it) {
DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
if (!next) {
deadbeef->pl_item_unref (it);
break;
}
const char *next_meta = deadbeef->pl_find_meta_raw (next, meta);
if (cur_meta != next_meta) {
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (next), 0);
deadbeef->pl_item_unref (it);
deadbeef->pl_item_unref (next);
break;
}
deadbeef->pl_item_unref (it);
it = next;
}
deadbeef->pl_unlock ();
}
示例10: action_skip_to_prev_artist_handler
int
action_skip_to_prev_artist_handler (DB_plugin_action_t *act, int ctx)
{
deadbeef->pl_lock ();
DB_output_t *output = deadbeef->get_output ();
if (output->state () == OUTPUT_STATE_STOPPED) {
deadbeef->pl_unlock ();
return 0;
}
DB_playItem_t *it = skip_to_get_track_helper ();
if (!it) {
deadbeef->pl_unlock ();
return 0;
}
const char *cur_artist = deadbeef->pl_find_meta_raw (it, "band");
if (!cur_artist) {
cur_artist = deadbeef->pl_find_meta_raw (it, "album artist");
}
if (!cur_artist) {
cur_artist = deadbeef->pl_find_meta_raw (it, "albumartist");
}
if (!cur_artist) {
cur_artist = deadbeef->pl_find_meta_raw (it, "artist");
}
int c = 0;
while (it) {
DB_playItem_t *prev = deadbeef->pl_get_prev (it, PL_MAIN);
if (!prev) {
if (c == 1) {
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (it), 0);
}
deadbeef->pl_item_unref (it);
break;
}
const char *prev_artist = deadbeef->pl_find_meta_raw (prev, "band");
if (!prev_artist) {
prev_artist = deadbeef->pl_find_meta_raw (prev, "album artist");
}
if (!prev_artist) {
prev_artist = deadbeef->pl_find_meta_raw (prev, "albumartist");
}
if (!prev_artist) {
prev_artist = deadbeef->pl_find_meta_raw (prev, "artist");
}
if (cur_artist != prev_artist) {
if (c == 0) {
cur_artist = prev_artist;
c = 1;
}
else {
deadbeef->sendmessage (DB_EV_PLAY_NUM, 0, deadbeef->pl_get_idx_of (it), 0);
deadbeef->pl_item_unref (it);
deadbeef->pl_item_unref (prev);
break;
}
}
deadbeef->pl_item_unref (it);
it = prev;
}
deadbeef->pl_unlock ();
return 0;
}
示例11: sni_update_tooltip
void
sni_update_tooltip (int state) {
if (!icon)
return;
g_debug("sni_update_tooltip, status: %d", state);
DB_output_t *output;
output = deadbeef->get_output ();
if (output) {
if (state < 0)
state = output->state ();
switch (state) {
case OUTPUT_STATE_STOPPED:
status_notifier_set_tooltip (icon, "deadbeef", "DeaDBeeF", _("Playback stopped"));
break;
case OUTPUT_STATE_PAUSED:
case OUTPUT_STATE_PLAYING:
{
DB_playItem_t *track = deadbeef->streamer_get_playing_track ();
static gchar *ns = NULL;
if (!ns)
ns = _("not specified");
if (!track) {
status_notifier_set_tooltip (icon, "deadbeef", "DeaDBeeF", _("Playing"));
break;
}
int64_t duration = (int64_t)deadbeef->pl_get_item_duration (track) * 1000000;
const char *album = deadbeef->pl_find_meta (track, "album");
const char *albumArtist = deadbeef->pl_find_meta (track, "albumartist");
if (albumArtist == NULL)
albumArtist = deadbeef->pl_find_meta (track, "album artist");
if (albumArtist == NULL)
albumArtist = deadbeef->pl_find_meta (track, "band");
const char *artist = deadbeef->pl_find_meta (track, "artist");
const char *date = deadbeef->pl_find_meta_raw (track, "year");
const char *title = deadbeef->pl_find_meta (track, "title");
const char *trackNumber = deadbeef->pl_find_meta (track, "track");
gchar *escaped_title = title ? g_markup_escape_text (title, -1) : NULL;
gchar *escaped_artist = (artist ? artist : albumArtist) ? g_markup_escape_text (artist ? artist : albumArtist, -1) : NULL;
gchar *escaped_album = album ? g_markup_escape_text (album, -1) : NULL;
gchar *escaped_date = date ? g_markup_escape_text (date, -1) : NULL;
gchar title_body[TOOLTIP_MAX_LENGTH];
date ?
g_snprintf (title_body, TOOLTIP_MAX_LENGTH, _(TOOLTIP_FORMAT), state == OUTPUT_STATE_PAUSED ? _("Playback paused<br>\n") : "",
escaped_title ? escaped_title : ns,
escaped_artist ? escaped_artist : ns,
escaped_album ? escaped_album : ns,
escaped_date) :
g_snprintf (title_body, TOOLTIP_MAX_LENGTH, _(TOOLTIP_FORMAT_WO_YEAR), state == OUTPUT_STATE_PAUSED ? _("Playback paused<br>\n") : "",
escaped_title ? escaped_title : ns,
escaped_artist ? escaped_artist : ns,
escaped_album ? escaped_album : ns);
g_free (escaped_title);
g_free (escaped_artist);
g_free (escaped_album);
g_free (escaped_date);
g_debug("Going to query coverart");
#if (DDB_GTKUI_API_LEVEL >= 202)
GdkPixbuf * buf = gtkui_plugin->get_cover_art_primary (deadbeef->pl_find_meta (track, ":URI"), artist, album, 128, NULL, NULL);
#else
GdkPixbuf * buf = gtkui_plugin->get_cover_art_pixbuf (deadbeef->pl_find_meta (track, ":URI"), artist, album, 128, NULL, NULL);
#endif
g_debug("Got GdbPixbuf: %d", buf);
if (!buf) {
buf = gtkui_plugin->cover_get_default_pixbuf ();
if (buf)
status_notifier_set_from_pixbuf (icon, STATUS_NOTIFIER_TOOLTIP_ICON, buf);
else
status_notifier_set_from_icon_name (icon, STATUS_NOTIFIER_TOOLTIP_ICON, "deadbeef");
}
else
status_notifier_set_from_pixbuf (icon, STATUS_NOTIFIER_TOOLTIP_ICON, buf);
status_notifier_set_tooltip_body (icon, title_body);
deadbeef->pl_item_unref (track);
break;
}
}
}
else {
status_notifier_set_tooltip (icon, "deadbeef", "DeaDBeeF", NULL);
}
}
示例12: player_mainloop
void
player_mainloop (void) {
for (;;) {
uint32_t msg;
uintptr_t ctx;
uint32_t p1;
uint32_t p2;
int term = 0;
while (messagepump_pop(&msg, &ctx, &p1, &p2) != -1) {
// broadcast to all plugins
DB_plugin_t **plugs = plug_get_list ();
for (int n = 0; plugs[n]; n++) {
if (plugs[n]->message) {
plugs[n]->message (msg, ctx, p1, p2);
}
}
if (!term) {
DB_output_t *output = plug_get_output ();
switch (msg) {
case DB_EV_REINIT_SOUND:
plug_reinit_sound ();
streamer_reset (1);
conf_save ();
break;
case DB_EV_TERMINATE:
{
save_resume_state ();
pl_playqueue_clear ();
// stop streaming and playback before unloading plugins
DB_output_t *output = plug_get_output ();
output->stop ();
streamer_free ();
output->free ();
term = 1;
}
break;
case DB_EV_PLAY_CURRENT:
streamer_play_current_track ();
break;
case DB_EV_PLAY_NUM:
pl_playqueue_clear ();
streamer_set_nextsong (p1, 4);
break;
case DB_EV_STOP:
streamer_set_nextsong (-2, 0);
break;
case DB_EV_NEXT:
streamer_move_to_nextsong (1);
break;
case DB_EV_PREV:
streamer_move_to_prevsong (1);
break;
case DB_EV_PAUSE:
if (output->state () != OUTPUT_STATE_PAUSED) {
output->pause ();
messagepump_push (DB_EV_PAUSED, 0, 1, 0);
}
break;
case DB_EV_TOGGLE_PAUSE:
if (output->state () == OUTPUT_STATE_PAUSED) {
streamer_play_current_track ();
}
else {
output->pause ();
messagepump_push (DB_EV_PAUSED, 0, 1, 0);
}
break;
case DB_EV_PLAY_RANDOM:
streamer_move_to_randomsong (1);
break;
case DB_EV_PLAYLIST_REFRESH:
pl_save_current ();
messagepump_push (DB_EV_PLAYLISTCHANGED, 0, 0, 0);
break;
case DB_EV_CONFIGCHANGED:
conf_save ();
streamer_configchanged ();
junk_configchanged ();
break;
case DB_EV_SEEK:
streamer_set_seek (p1 / 1000.f);
break;
}
}
if (msg >= DB_EV_FIRST && ctx) {
messagepump_event_free ((ddb_event_t *)ctx);
}
}
if (term) {
return;
}
messagepump_wait ();
}
}
示例13: trace
static int
oss_init (void) {
trace ("oss_init\n");
state = OUTPUT_STATE_STOPPED;
oss_terminate = 0;
mutex = 0;
// prepare oss for playback
fd = open (oss_device, O_WRONLY);
if (fd == -1) {
fprintf (stderr, "oss: failed to open file %s\n", oss_device);
perror (oss_device);
plugin.free ();
return -1;
}
oss_set_hwparams (&plugin.fmt);
mutex = deadbeef->mutex_create ();
oss_tid = deadbeef->thread_start (oss_thread, NULL);
return 0;
}