--- alsaplayer-0.99.81.old/app/CorePlayer.cpp +++ alsaplayer-0.99.81/app/CorePlayer.cpp @@ -59,6 +59,7 @@ extern void exit_sighandler(int); static char addon_dir[PATH_MAX]; +double initial_volume = -1.0; int CorePlayer::plugin_count = 0; int CorePlayer::plugins_loaded = 0; @@ -190,13 +191,19 @@ CorePlayer::CorePlayer(AlsaNode *the_node) { int i; + double x_volume = 1.0; /* Init mutexes */ pthread_mutex_init(&counter_mutex, NULL); pthread_mutex_init(&player_mutex, NULL); pthread_mutex_init(¬ifier_mutex, NULL); pthread_cond_init(&producer_ready, NULL); - + + if (initial_volume >= 0.0) + { + x_volume = initial_volume; + } + producer_thread = 0; total_frames = 0; streaming = false; @@ -214,7 +221,7 @@ input_rate = output_rate = 44100; SetSpeedMulti(1.0); SetSpeed(1.0); - SetVolume(1.0); + SetVolume (x_volume); SetPan(0.0); buffer = NULL; the_object = NULL; --- alsaplayer-0.99.81.old/app/Main.cpp +++ alsaplayer-0.99.81/app/Main.cpp @@ -387,6 +387,7 @@ int do_quit = 0; int do_status = 0; int do_speed = 0; + int used_start_vol = 0; float speed_val = 0.0; int use_freq = OUTPUT_RATE; @@ -398,6 +399,7 @@ const char *use_output = NULL; char *use_interface = NULL; char *use_config = NULL; + extern double initial_volume; int opt; int option_index; @@ -535,6 +537,8 @@ break; case 'l': start_vol = atof(optarg); + used_start_vol = 1; + if (start_vol < 0.0 || start_vol > 1.0) { alsaplayer_error("volume out of range: using 1.0"); start_vol = 1.0; @@ -693,6 +697,18 @@ } } + if (!used_start_vol) + { + double x_volume = ((double) prefs_get_int + (ap_prefs, "main", "volume", 1000)) / 1000.0; + + if (x_volume < 0.0) x_volume = 0.0; + if (x_volume > 1.0) x_volume = 1.0; + start_vol = x_volume; + } + + initial_volume = start_vol; + // Check if we're in remote control mode if (do_remote_control) { if (do_quit) { --- alsaplayer-0.99.81.old/interface/gtk2/PlaylistWindow.cpp +++ alsaplayer-0.99.81/interface/gtk2/PlaylistWindow.cpp @@ -347,6 +347,19 @@ } } +static void +proc_quit(GtkButton *button, gpointer user_data) +{ + extern void exit_cb(GtkWidget *, gpointer data); + + PlaylistWindow *playlist_window = (PlaylistWindow *) user_data; + if (playlist_window) { + stop_cb(NULL, (gpointer) playlist_window->GetPlaylist()); + } + + exit_cb (NULL, (gpointer) playlist_window->window); +} + void playlist_remove(GtkWidget *, gpointer user_data) { @@ -560,6 +573,7 @@ GtkWidget *load_button; GtkWidget *save_button; GtkWidget *clear_button; + GtkWidget *quit_button; GtkWidget *add_file; GtkWidget *load_list; GtkWidget *save_list; @@ -639,6 +653,10 @@ gtk_box_pack_start (GTK_BOX (pl_button_box), clear_button, FALSE, FALSE, 0); gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), clear_button, _("Remove the current playlist"), NULL); + quit_button = gtk_button_new_from_stock (GTK_STOCK_QUIT); + gtk_box_pack_start (GTK_BOX (pl_button_box), quit_button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), quit_button, _("Exit the program"), NULL); + gtk_drag_dest_set(list, GTK_DEST_DEFAULT_ALL, drag_types, n_drag_types, (GdkDragAction) (GDK_ACTION_MOVE | GDK_ACTION_COPY)); gtk_drag_source_set(list, GDK_BUTTON1_MASK, @@ -659,6 +677,7 @@ g_signal_connect(G_OBJECT(shuffle_button), "clicked", G_CALLBACK(shuffle_cb), (gpointer)playlist_window); g_signal_connect(G_OBJECT(add_button), "clicked", G_CALLBACK(dialog_popup), (gpointer)add_file); g_signal_connect(G_OBJECT(clear_button), "clicked", G_CALLBACK(clear_cb), (gpointer)playlist_window); + g_signal_connect(G_OBJECT(quit_button), "clicked", G_CALLBACK(proc_quit), (gpointer)playlist_window); g_signal_connect(G_OBJECT(del_button), "clicked", G_CALLBACK(playlist_remove), (gpointer)playlist_window); g_signal_connect(G_OBJECT(save_button), "clicked", G_CALLBACK(dialog_popup), (gpointer)save_list); g_signal_connect(G_OBJECT(load_button), "clicked", G_CALLBACK(dialog_popup), (gpointer)load_list); --- alsaplayer-0.99.81.old/interface/gtk2/PlaylistWindow.h +++ alsaplayer-0.99.81/interface/gtk2/PlaylistWindow.h @@ -29,12 +29,13 @@ private: playlist_interface pli; Playlist *playlist; - GtkWidget *window; GtkWidget *list; gint width; gint height; pthread_mutex_t playlist_list_mutex; public: + GtkWidget *window; + PlaylistWindow(Playlist *); ~PlaylistWindow(); --- alsaplayer-0.99.81.old/interface/gtk2/gtk_interface.cpp +++ alsaplayer-0.99.81/interface/gtk2/gtk_interface.cpp @@ -306,12 +306,18 @@ static gboolean main_window_delete(GtkWidget *widget, GdkEvent *event, gpointer user_data) { + int nv; global_update = -1; PlaylistWindow *playlist_window = (PlaylistWindow *) g_object_get_data(G_OBJECT(widget), "playlist_window"); prefs_set_int(ap_prefs, "gtk2_interface", "width", widget->allocation.width); prefs_set_int(ap_prefs, "gtk2_interface", "height", widget->allocation.height); + + nv = (int) (playlist->GetCorePlayer()->GetVolume() * 1000.0); + if (nv < 0) nv = 0; + if (nv > 1000) nv = 1000; + prefs_set_int (ap_prefs, "main", "volume", nv); // Remove notifier @@ -1613,7 +1619,9 @@ { GtkWidget *main_window; gint width, height, plheight; - + double x_volume; + extern double initial_volume; + main_window = create_main_window(pl); gtk_widget_show_all(main_window);