~ubuntu-branches/ubuntu/utopic/rhythmbox/utopic

« back to all changes in this revision

Viewing changes to shell/rb-shell-player.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2014-04-03 17:23:01 UTC
  • mfrom: (1.3.5)
  • Revision ID: package-import@ubuntu.com-20140403172301-1fd16h8r1nr8ytno
Tags: 3.0.2-0ubuntu1
* New upstream bugfix version (lp: #1296334)
* Clean patches included in the update
* debian/librhythmbox-core8.symbols:
  - new version update

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
static void playing_stream_cb (RBPlayer *player, RhythmDBEntry *entry, RBShellPlayer *shell_player);
136
136
static void player_image_cb (RBPlayer *player, RhythmDBEntry *entry, GdkPixbuf *image, RBShellPlayer *shell_player);
137
137
static void rb_shell_player_error (RBShellPlayer *player, gboolean async, const GError *err);
 
138
static void rb_shell_player_error_idle (RBShellPlayer *player, gboolean async, const GError *err);
138
139
 
139
140
static void rb_shell_player_play_order_update_cb (RBPlayOrder *porder,
140
141
                                                  gboolean has_next,
232
233
        float volume;
233
234
 
234
235
        guint do_next_idle_id;
 
236
        GMutex error_idle_mutex;
 
237
        guint error_idle_id;
235
238
};
236
239
 
237
240
#define RB_SHELL_PLAYER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_SHELL_PLAYER, RBShellPlayerPrivate))
337
340
                rb_player_play (player->priv->mmplayer, play_type, player->priv->track_transition_time, &error);
338
341
 
339
342
        if (error) {
340
 
                GDK_THREADS_ENTER ();
341
 
                rb_shell_player_error (player, TRUE, error);
 
343
                rb_shell_player_error_idle (player, TRUE, error);
342
344
                g_error_free (error);
343
 
                GDK_THREADS_LEAVE ();
344
345
        }
345
346
}
346
347
 
499
500
                }
500
501
        }
501
502
 
502
 
        GDK_THREADS_ENTER ();
503
 
 
504
503
        location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
505
504
        if (entry != shell_player->priv->playing_entry) {
506
505
                rb_debug ("got unexpected eos for %s", location);
509
508
                /* don't allow playback to be stopped on early EOS notifications */
510
509
                rb_shell_player_handle_eos_unlocked (shell_player, entry, (early == FALSE));
511
510
        }
512
 
 
513
 
        GDK_THREADS_LEAVE ();
514
511
}
515
512
 
516
513
 
678
675
                        GError *error = g_error_new (RB_SHELL_PLAYER_ERROR,
679
676
                                                     RB_SHELL_PLAYER_ERROR_END_OF_PLAYLIST,
680
677
                                                     _("Playlist was empty"));
681
 
                        GDK_THREADS_ENTER ();
682
 
                        rb_shell_player_error (data->player, TRUE, error);
 
678
                        rb_shell_player_error_idle (data->player, TRUE, error);
683
679
                        g_error_free (error);
684
 
                        GDK_THREADS_LEAVE ();
685
680
                } else {
686
681
                        char *location;
687
682
 
2387
2382
        return FALSE;
2388
2383
}
2389
2384
 
 
2385
typedef struct {
 
2386
        RBShellPlayer *player;
 
2387
        gboolean async;
 
2388
        GError *error;
 
2389
} ErrorIdleData;
 
2390
 
 
2391
static void
 
2392
free_error_idle_data (ErrorIdleData *data)
 
2393
{
 
2394
        g_error_free (data->error);
 
2395
        g_free (data);
 
2396
}
 
2397
 
 
2398
static gboolean
 
2399
error_idle_cb (ErrorIdleData *data)
 
2400
{
 
2401
        rb_shell_player_error (data->player, data->async, data->error);
 
2402
        g_mutex_lock (&data->player->priv->error_idle_mutex);
 
2403
        data->player->priv->error_idle_id = 0;
 
2404
        g_mutex_unlock (&data->player->priv->error_idle_mutex);
 
2405
        return FALSE;
 
2406
}
 
2407
 
 
2408
static void
 
2409
rb_shell_player_error_idle (RBShellPlayer *player, gboolean async, const GError *error)
 
2410
{
 
2411
        ErrorIdleData *eid;
 
2412
 
 
2413
        eid = g_new0 (ErrorIdleData, 1);
 
2414
        eid->player = player;
 
2415
        eid->async = async;
 
2416
        eid->error = g_error_copy (error);
 
2417
 
 
2418
        g_mutex_lock (&player->priv->error_idle_mutex);
 
2419
        if (player->priv->error_idle_id != 0)
 
2420
                g_source_remove (player->priv->error_idle_id);
 
2421
 
 
2422
        player->priv->error_idle_id = g_idle_add_full (G_PRIORITY_DEFAULT,
 
2423
                                                       (GSourceFunc) error_idle_cb,
 
2424
                                                       eid,
 
2425
                                                       (GDestroyNotify) free_error_idle_data);
 
2426
        g_mutex_unlock (&player->priv->error_idle_mutex);
 
2427
}
 
2428
 
2390
2429
static void
2391
2430
rb_shell_player_error (RBShellPlayer *player,
2392
2431
                       gboolean async,
2458
2497
 
2459
2498
        g_return_if_fail (entry != NULL);
2460
2499
 
2461
 
        GDK_THREADS_ENTER ();
2462
 
 
2463
2500
        entry_changed = (player->priv->playing_entry != entry);
2464
2501
 
2465
2502
        /* update playing entry */
2485
2522
        rb_shell_player_sync_with_source (player);
2486
2523
        rb_shell_player_sync_buttons (player);
2487
2524
        g_object_notify (G_OBJECT (player), "playing");
2488
 
 
2489
 
        GDK_THREADS_LEAVE ();
2490
2525
}
2491
2526
 
2492
2527
static void
2505
2540
                return;
2506
2541
        }
2507
2542
 
2508
 
        GDK_THREADS_ENTER ();
2509
 
 
2510
2543
        if (entry != player->priv->playing_entry) {
2511
2544
                rb_debug ("got error for unexpected entry %p (expected %p)", entry, player->priv->playing_entry);
2512
2545
        } else {
2513
2546
                rb_shell_player_error (player, TRUE, err);
2514
2547
                rb_debug ("exiting error hander");
2515
2548
        }
2516
 
 
2517
 
        GDK_THREADS_LEAVE ();
2518
2549
}
2519
2550
 
2520
2551
static void
2530
2561
        const char *uri;
2531
2562
        long elapsed_sec;
2532
2563
 
2533
 
        GDK_THREADS_ENTER ();
2534
 
 
2535
2564
        if (player->priv->playing_entry != entry) {
2536
2565
                rb_debug ("got tick for unexpected entry %p (expected %p)", entry, player->priv->playing_entry);
2537
 
                GDK_THREADS_LEAVE ();
2538
2566
                return;
2539
2567
        }
2540
2568
 
2594
2622
                          remaining_check);
2595
2623
                rb_shell_player_handle_eos_unlocked (player, entry, FALSE);
2596
2624
        }
2597
 
 
2598
 
        GDK_THREADS_LEAVE ();
2599
2625
}
2600
2626
 
2601
2627
typedef struct {
3248
3274
 
3249
3275
        player->priv = RB_SHELL_PLAYER_GET_PRIVATE (player);
3250
3276
 
 
3277
        g_mutex_init (&player->priv->error_idle_mutex);
 
3278
 
3251
3279
        player->priv->settings = g_settings_new ("org.gnome.rhythmbox.player");
3252
3280
        player->priv->ui_settings = g_settings_new ("org.gnome.rhythmbox");
3253
3281
        g_signal_connect_object (player->priv->settings,
3387
3415
                g_source_remove (player->priv->do_next_idle_id);
3388
3416
                player->priv->do_next_idle_id = 0;
3389
3417
        }
 
3418
        if (player->priv->error_idle_id != 0) {
 
3419
                g_source_remove (player->priv->error_idle_id);
 
3420
                player->priv->error_idle_id = 0;
 
3421
        }
3390
3422
 
3391
3423
        G_OBJECT_CLASS (rb_shell_player_parent_class)->dispose (object);
3392
3424
}