File | Lines added | Lines deleted |
---|---|---|
src/command.cpp | 20 | 0 |
src/command.h | 1 | 0 |
src/pms.cpp | 9 | 11 |
File src/command.cpp changed (mode: 100644) (index 7443464..e3e029a) | |||
... | ... | Control::set_mpd_idle_events(enum mpd_idle idle_reply) | |
308 | 308 | pms->log(MSG_DEBUG, 0, "Set pending MPD IDLE events: %s\n", buffer); | pms->log(MSG_DEBUG, 0, "Set pending MPD IDLE events: %s\n", buffer); |
309 | 309 | } | } |
310 | 310 | ||
311 | /** | ||
312 | * Check if there are pending updates. | ||
313 | * | ||
314 | * Returns true if there are pending updates, false if not. | ||
315 | */ | ||
316 | bool | ||
317 | Control::has_pending_updates() | ||
318 | { | ||
319 | return (idle_events != 0); | ||
320 | } | ||
321 | |||
311 | 322 | /** | /** |
312 | 323 | * Run all pending updates. | * Run all pending updates. |
324 | * | ||
325 | * Returns true on success, false on failure. | ||
313 | 326 | */ | */ |
314 | 327 | bool | bool |
315 | 328 | Control::run_pending_updates() | Control::run_pending_updates() |
... | ... | Control::run_pending_updates() | |
349 | 362 | set_update_done(MPD_IDLE_DATABASE); | set_update_done(MPD_IDLE_DATABASE); |
350 | 363 | } | } |
351 | 364 | ||
365 | /* Hack to make has_pending_updates() work smoothly without too much | ||
366 | * effort. We don't care about the rest of the events, so we just | ||
367 | * pretend they never happened. */ | ||
368 | idle_events = 0; | ||
369 | |||
352 | 370 | return true; | return true; |
353 | 371 | } | } |
354 | 372 | ||
... | ... | Control::add(Songlist * list, Song * song) | |
787 | 805 | ||
788 | 806 | EXIT_IDLE; | EXIT_IDLE; |
789 | 807 | ||
808 | pms->log(MSG_DEBUG, 0, "Adding song %s to list %s\n", song->file.c_str(), list->filename.c_str()); | ||
809 | |||
790 | 810 | if (list == _playlist) { | if (list == _playlist) { |
791 | 811 | return mpd_run_add_id(conn->h(), song->file.c_str()); | return mpd_run_add_id(conn->h(), song->file.c_str()); |
792 | 812 | } else if (list != _library) { | } else if (list != _library) { |
File src/command.h changed (mode: 100644) (index 3c3c185..eabe977) | |||
... | ... | public: | |
247 | 247 | ||
248 | 248 | /* IDLE dispatcher */ | /* IDLE dispatcher */ |
249 | 249 | void set_mpd_idle_events(enum mpd_idle); | void set_mpd_idle_events(enum mpd_idle); |
250 | bool has_pending_updates(); | ||
250 | 251 | bool run_pending_updates(); | bool run_pending_updates(); |
251 | 252 | void set_update_done(enum mpd_idle); | void set_update_done(enum mpd_idle); |
252 | 253 | bool has_finished_update(enum mpd_idle); | bool has_finished_update(enum mpd_idle); |
File src/pms.cpp changed (mode: 100644) (index a0d9070..c7a4e36) | |||
... | ... | Pms::main() | |
426 | 426 | ||
427 | 427 | /* Run any pending updates */ | /* Run any pending updates */ |
428 | 428 | if (!comm->run_pending_updates()) { | if (!comm->run_pending_updates()) { |
429 | log(MSG_DEBUG, 0, "Failed running pending updates, MPD error follows:\n"); | ||
429 | log(MSG_DEBUG, 0, "Failed running pending updates, MPD error follows in next main loop iteration\n"); | ||
430 | 430 | continue; | continue; |
431 | 431 | } | } |
432 | 432 | ||
... | ... | Pms::main() | |
502 | 502 | disp->refresh(); | disp->refresh(); |
503 | 503 | ||
504 | 504 | ||
505 | |||
506 | |||
507 | 505 | /** | /** |
508 | 506 | * Start IDLE mode and polling. Keep this code at the end of | * Start IDLE mode and polling. Keep this code at the end of |
509 | 507 | * the main loop. | * the main loop. |
... | ... | Pms::main() | |
532 | 530 | } | } |
533 | 531 | } | } |
534 | 532 | ||
535 | continue; | ||
536 | |||
537 | |||
538 | /* Progress to next song? */ | ||
539 | progress_nextsong(); | ||
540 | |||
541 | 533 | /* Draw XTerm window title */ | /* Draw XTerm window title */ |
534 | /* FIXME: only draw when needed */ | ||
542 | 535 | disp->set_xterm_title(); | disp->set_xterm_title(); |
543 | 536 | ||
537 | /* Progress to next song if applicable, and make sure we are | ||
538 | * synched with IDLE events before doing it. */ | ||
539 | if (!comm->has_pending_updates()) { | ||
540 | progress_nextsong(); | ||
541 | } | ||
542 | |||
544 | 543 | /* Check out mediator events */ | /* Check out mediator events */ |
545 | /* FIXME: add these into their appropriate places */ | ||
544 | /* FIXME: implement this functionality with ZeroMQ */ | ||
546 | 545 | if (mediator->changed("setting.sort")) | if (mediator->changed("setting.sort")) |
547 | 546 | comm->library()->sort(options->get_string("sort")); | comm->library()->sort(options->get_string("sort")); |
548 | 547 | else if (mediator->changed("setting.ignorecase")) | else if (mediator->changed("setting.ignorecase")) |
... | ... | Pms::main() | |
566 | 565 | if (options->get_bool("topbarclear")) | if (options->get_bool("topbarclear")) |
567 | 566 | options->topbar.clear(); | options->topbar.clear(); |
568 | 567 | } | } |
569 | |||
570 | 568 | } | } |
571 | 569 | while (!_shutdown); | while (!_shutdown); |
572 | 570 |