Example #1
0
static void *
audio_output_thread(void *aux)
{
  audio_mode_t *am;
  int r;
  audio_fifo_t *af = &af0;

  audio_fifo_init(af, 16000, 8000);
  thefifo = af;

  am = audio_mode_current;

  while(audio_run) {
    r = am->am_entry(am, af);
    am = audio_mode_current;

    if(r == -1) {
      /* Device error, sleep to avoid busy looping.
	 Hopefully the error will resolve itself (if another app
	 is blocking output, etc)
      */
      sleep(1);
    } else {
      if(am)
	notify_add(NULL, NOTIFY_INFO, NULL, 5, 
		   _("Switching audio output to %s"), 
		   am->am_title);
    }
  }
  return NULL;
}
Example #2
0
void
audio_init(void)
{
  audio_fifo_init(&af0, 16000, 8000);

  htsmsg_t *m = htsmsg_store_load("audio/current");
  if(m == NULL)
    m = htsmsg_create_map();

  audio_mastervol_init();

  audio_settings_root =
    settings_add_dir(NULL, _p("Audio output"), "sound", NULL,
		     _p("Select audio output device and related configurations"),
		     "settings:audio");
  
  audio_settings_current_device = 
    settings_create_multiopt(audio_settings_root, "currentdevice", 
			     _p("Current output device"), 0);
  
  TAILQ_INIT(&audio_modes);

#ifdef CONFIG_LIBOGC
  audio_wii_init();
#endif

#if PS3
  audio_ps3_init();
#endif

  int have_pulse_audio  __attribute__((unused)) = 0;

#ifdef CONFIG_LIBPULSE
  have_pulse_audio |= audio_pa_init();
#endif

#ifdef CONFIG_LIBASOUND
  audio_alsa_init(have_pulse_audio);
#endif

#ifdef CONFIG_COREAUDIO
  audio_coreaudio_init();
#endif

  audio_dummy_init();


  settings_multiopt_initiate(audio_settings_current_device,
			     audio_change_output_device, NULL, NULL,
			     m, settings_generic_save_settings,
			     (void *)"audio/current");

  audio_run = 1;
  hts_thread_create_joinable("audio output", &audio_thread_id, 
			     audio_output_thread, NULL, THREAD_PRIO_HIGH);
}
static void
impl_activate (RBPlugin *plugin,
               RBShell *shell)
{
//	rb_error_dialog (NULL, _("Spotify Plugin"), "Spotify plugin activated, with shell %p", shell);


    RBSpotifySource *source;
    RhythmDBEntryType type;
    RhythmDB *db;
    char *entry_type_name, *username, *password;
    int err;
    RBSpotifyPluginPrivate *pprivate = RB_SPOTIFY_PLUGIN_GET_PRIVATE(plugin);

    pthread_mutex_init(&g_notify_mutex, NULL);
    pthread_cond_init(&g_notify_cond, NULL);

    audio_fifo_init(&g_audio_fifo);

    spconfig.application_key_size = g_appkey_size;
    err = sp_session_init(&spconfig, &pprivate->sess);


    if (err != SP_ERROR_OK) {
        rb_error_dialog (NULL, _("Spotify Plugin"), "Error initialising spotify session");
        pprivate->sess = NULL;
        return;
    }
    fprintf(stderr, "err: %x", err);

    err = pthread_create(&pprivate->notify_thread, 0, notification_routine, pprivate->sess);
    fprintf(stderr, "Thread created");
    if (err != 0)
    {
        fprintf(stderr, "Error creating notification thread %x\n", err);
        return;
    }

    username = eel_gconf_get_string (CONF_SPOTIFY_USERNAME);
    password = eel_gconf_get_string (CONF_SPOTIFY_PASSWORD);
    if (username == NULL || password == NULL) {
        rb_error_dialog (NULL, _("Spotify Plugin"), "Username and password not set.");
        return;
    }

    err = sp_session_login(pprivate->sess, username, password);
    fprintf(stderr, "err: %x", err);

    rbspotifysrc_set_plugin(plugin);

    g_object_get (shell, "db", &db, NULL);
    entry_type_name = g_strdup_printf ("spotify");
    type = rhythmdb_entry_register_type (db, entry_type_name);
    g_free (entry_type_name);
    type->save_to_disk = FALSE;
    type->category = RHYTHMDB_ENTRY_NORMAL;
//	type->get_playback_uri = (RhythmDBEntryStringFunc) rb_daap_source_get_playback_uri;
    g_object_unref (db);

//	icon = rb_daap_plugin_get_icon (RB_DAAP_PLUGIN (plugin), password_protected, FALSE);
    source = (RBSpotifySource*)RB_SOURCE (g_object_new (RBSPOTIFYSOURCE_TYPE,
                                          "name", "spotify",
                                          "entry-type", type,
                                          "shell", shell,
                                          "visibility", TRUE,
//					  "sorting-key", CONF_STATE_SORTING,
                                          "source-group", RB_SOURCE_GROUP_SHARED,
                                          "plugin", RB_PLUGIN (plugin),
                                          NULL));

    source->priv->sess = pprivate->sess;
    source->priv->db = db;
    source->priv->type = type;

    rb_shell_register_entry_type_for_source (shell, (RBSource*)source,	 type);

    rb_shell_append_source (shell, (RBSource*)source, NULL);

//	return source;
}