本文整理汇总了C++中DB_output_t::state方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_output_t::state方法的具体用法?C++ DB_output_t::state怎么用?C++ DB_output_t::state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_output_t
的用法示例。
在下文中一共展示了DB_output_t::state方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
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: switch
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);
}
示例3: trace
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 ();
}
}
}
示例4:
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);
}
}
示例5:
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);
}
示例6:
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;
}
示例7: while
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 ();
}
}