diff options
-rw-r--r-- | README.icecast | 89 | ||||
-rwxr-xr-x | configure | 20 | ||||
-rwxr-xr-x | configure.ac | 2 | ||||
-rw-r--r-- | src/alsa/Makefile | 4 | ||||
-rwxr-xr-x | src/alsa/alsa.c | 122 | ||||
-rw-r--r-- | src/alsa/alsa.h | 5 | ||||
-rw-r--r-- | src/alsa/config.c | 2 | ||||
-rw-r--r-- | src/gtkui/ui_gtk.c | 4 | ||||
-rw-r--r-- | src/gtkui/ui_infoarea.c | 4 | ||||
-rw-r--r-- | src/hotkey/plugin.c | 1 | ||||
-rw-r--r-- | src/resample/plugin.c | 4 |
11 files changed, 90 insertions, 167 deletions
diff --git a/README.icecast b/README.icecast deleted file mode 100644 index bf7512a..0000000 --- a/README.icecast +++ /dev/null @@ -1,89 +0,0 @@ -Icecast plugin notes --------------------- - -0. Build-time requirements -========================== - -To build Icecast plugin successfully, you need at least: - - * Audacious development files (audacious-dev package) - - * Audacious plugins sources themselves - and all their build-time dependencies - - * libshout development files (libshout3-dev package) - -Please note that Icecast plugin must be compiled *after* FileWriter plugin, -as they share some pieces of code (namely, encoding backends and format -conversion routines). If you build all plugins, this is done automagically. - - -1. Run-time requirements -======================== - -To run Icecast plugin, you need: - - * Icecast 2 server running somewhere, maybe at your local host, - to which you have "source" access - - * libshout version 2.0+ (libshout3 package) - - -2. Usage recommendations -======================== - -The plugin is implemented as both output and effect. This means that you can -set it as the only Audacious output, if you don't need to hear anything, or -you can listen to music and send the same audio data to Icecast server. - -Please note that using plugin as effect is recommended. If you want to turn off -your speakers, just use Null audio output plugin. - -The next thing you need to do is to decide what kind of stream do you want. You -can use MPEG Layer 3 or Ogg Vorbis encoder. Currently supported are LAME and -vorbisenc. Depending on your system configuration you may or may not have LAME, -as it has patent problems with Fraunhofer IIS, and Debian doesn't provide -packages for it. - -If you are Debian user and want to use LAME anyway, refer to debian-multimedia -project. - - -3. Configuration -================ - -First of all, you need to set up Icecast 2 properly. Note: previous versions of -Icecast as well as any versions of Shoutcast were not tested and are not -guaranteed to work at all. - -Usually, if you have single-user Icecast 2 setup, you should use user name -"source" and appropriate password. In either case, refer to Icecast 2 manual -for details. - -Mount point is a path on Icecast server, where your stream will be available. -I.e., if you have server at your local machine on default port, and mountpoint -is "/test", the whole URL of your stream would be - - http://127.0.0.1:8000/test - -If you don't specify mount point, mount point is set to "/". But this path -cannot be used for streaming, as server places status pages there. Don't do this. - -The connection timeout option is treated differently when plugin is in output -or effect mode. When being used as output plugin, this setting specifies the -time between last song ends (or "Stop" button click) and actual disconnect. -When being used as effect plugin, this setting specifies maximum time between -sequential portions of audio data sent to server. - -Plugin has internal buffer which collects audio data being sent to server. You -can fine tune size of this buffer. If buffer is too small, data will be sent -directly to the server bypassing this buffer. If buffer is too big, there can -be large pauses in audio data. - -You can set some information about your stream. First of all, you can provide -stream name, its description, music genre (or genres), URL of site where -listeners can read more about your radio. Also, you can ask server to list -the stream in any directories it knows about. Please refer to Icecast 2 -documentation for more details about this. - - -- Andrew O. Shadoura <bugzilla@tut.by>
\ No newline at end of file @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for audacious-plugins 2.4-rc1. +# Generated by GNU Autoconf 2.65 for audacious-plugins 2.4-rc2. # # Report bugs to <bugs+audacious-plugins@atheme.org>. # @@ -552,8 +552,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='audacious-plugins' PACKAGE_TARNAME='audacious-plugins' -PACKAGE_VERSION='2.4-rc1' -PACKAGE_STRING='audacious-plugins 2.4-rc1' +PACKAGE_VERSION='2.4-rc2' +PACKAGE_STRING='audacious-plugins 2.4-rc2' PACKAGE_BUGREPORT='bugs+audacious-plugins@atheme.org' PACKAGE_URL='' @@ -1569,7 +1569,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures audacious-plugins 2.4-rc1 to adapt to many kinds of systems. +\`configure' configures audacious-plugins 2.4-rc2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1636,7 +1636,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of audacious-plugins 2.4-rc1:";; + short | recursive ) echo "Configuration of audacious-plugins 2.4-rc2:";; esac cat <<\_ACEOF @@ -1927,7 +1927,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -audacious-plugins configure 2.4-rc1 +audacious-plugins configure 2.4-rc2 generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. @@ -2458,7 +2458,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by audacious-plugins $as_me 2.4-rc1, which was +It was created by audacious-plugins $as_me 2.4-rc2, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -2955,7 +2955,7 @@ fi PACKAGE=audacious-plugins -VERSION=2.4-rc1 +VERSION=2.4-rc2 @@ -13944,7 +13944,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by audacious-plugins $as_me 2.4-rc1, which was +This file was extended by audacious-plugins $as_me 2.4-rc2, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14010,7 +14010,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -audacious-plugins config.status 2.4-rc1 +audacious-plugins config.status 2.4-rc2 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 911f9c8..e455cb1 100755 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([audacious-plugins], [2.4-rc1], [bugs+audacious-plugins@atheme.org]) +AC_INIT([audacious-plugins], [2.4-rc2], [bugs+audacious-plugins@atheme.org]) AC_PREREQ([2.59]) AC_CANONICAL_HOST diff --git a/src/alsa/Makefile b/src/alsa/Makefile index 10485dc..2a97887 100644 --- a/src/alsa/Makefile +++ b/src/alsa/Makefile @@ -9,6 +9,6 @@ include ../../extra.mk plugindir := ${plugindir}/${OUTPUT_PLUGIN_DIR} -CFLAGS += ${PLUGIN_CFLAGS} ${GLIB_CFLAGS} ${GTK_CFLAGS} ${ALSA_CFLAGS} +CFLAGS += -std=gnu99 ${PLUGIN_CFLAGS} ${GTK_CFLAGS} ${ALSA_CFLAGS} CPPFLAGS += -I../.. -LIBS += ${GLIB_LIBS} ${GTK_LIBS} ${ALSA_LIBS} +LIBS += ${GTK_LIBS} ${ALSA_LIBS} diff --git a/src/alsa/alsa.c b/src/alsa/alsa.c index b407a9e..867ad8c 100755 --- a/src/alsa/alsa.c +++ b/src/alsa/alsa.c @@ -40,6 +40,7 @@ #include <assert.h> #include <errno.h> #include <poll.h> +#include <pthread.h> #include <stdint.h> #include <time.h> #include <unistd.h> @@ -69,8 +70,8 @@ do { \ static snd_pcm_t * alsa_handle; static char alsa_initted; -pthread_mutex_t alsa_mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t alsa_cond = PTHREAD_COND_INITIALIZER; +static pthread_mutex_t alsa_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t alsa_cond = PTHREAD_COND_INITIALIZER; static snd_pcm_format_t alsa_format; static int alsa_channels, alsa_rate; @@ -78,9 +79,9 @@ static int alsa_channels, alsa_rate; static void * alsa_buffer; static int alsa_buffer_length, alsa_buffer_data_start, alsa_buffer_data_length; -static int64_t alsa_time; /* microseconds */ +static int64_t alsa_written; /* frames */ static char alsa_prebuffer, alsa_paused; -static int alsa_paused_time; +static int alsa_paused_time; /* milliseconds */ static int poll_pipe[2]; static int poll_count; @@ -120,12 +121,15 @@ static char poll_setup (void) static void poll_sleep (void) { - char c; - - poll (poll_handles, poll_count, -1); + if (poll (poll_handles, poll_count, -1) < 0) + { + ERROR ("Failed to poll: %s.\n", strerror (errno)); + return; + } if (poll_handles[0].revents & POLLIN) { + char c; while (read (poll_pipe[0], & c, 1) == 1) ; } @@ -134,7 +138,6 @@ static void poll_sleep (void) static void poll_wake (void) { const char c = 0; - write (poll_pipe[1], & c, 1); } @@ -147,8 +150,6 @@ static void poll_cleanup (void) static void * pump (void * unused) { - int length, written; - pthread_mutex_lock (& alsa_mutex); pthread_cond_broadcast (& alsa_cond); /* signal thread started */ @@ -160,6 +161,7 @@ static void * pump (void * unused) continue; } + int length; CHECK_VAL_RECOVER (length, snd_pcm_avail_update, alsa_handle); if (! length) @@ -170,8 +172,10 @@ static void * pump (void * unused) length = MIN (length, alsa_buffer_length - alsa_buffer_data_start); length = snd_pcm_bytes_to_frames (alsa_handle, length); + int written; CHECK_VAL_RECOVER (written, snd_pcm_writei, alsa_handle, (char *) alsa_buffer + alsa_buffer_data_start, length); + written = snd_pcm_frames_to_bytes (alsa_handle, written); alsa_buffer_data_start += written; alsa_buffer_data_length -= written; @@ -236,20 +240,21 @@ FAILED: static int get_output_time (void) { - return (alsa_time - (int64_t) (snd_pcm_bytes_to_frames (alsa_handle, - alsa_buffer_data_length) + get_delay ()) * 1000000 / alsa_rate) / 1000; + return (int64_t) (alsa_written - snd_pcm_bytes_to_frames (alsa_handle, + alsa_buffer_data_length) - get_delay ()) * 1000 / alsa_rate; } OutputPluginInitStatus alsa_init (void) { alsa_handle = NULL; alsa_initted = 0; - return OUTPUT_PLUGIN_INIT_FOUND_DEVICES; } void alsa_soft_init (void) { + pthread_mutex_lock (& alsa_mutex); + if (! alsa_initted) { AUDDBG ("Initialize.\n"); @@ -257,6 +262,8 @@ void alsa_soft_init (void) alsa_open_mixer (); alsa_initted = 1; } + + pthread_mutex_unlock (& alsa_mutex); } void alsa_cleanup (void) @@ -294,57 +301,62 @@ static int convert_aud_format (int aud_format) {FMT_U32_BE, SND_PCM_FORMAT_U32_BE}, }; - int count; - - for (count = 0; count < G_N_ELEMENTS (table); count ++) + for (int count = 0; count < G_N_ELEMENTS (table); count ++) { - if (table[count].aud_format == aud_format) - return table[count].format; + if (table[count].aud_format == aud_format) + return table[count].format; } return SND_PCM_FORMAT_UNKNOWN; } -int alsa_open_audio (gint aud_format, int rate, int channels) +int alsa_open_audio (int aud_format, int rate, int channels) { - int format = convert_aud_format (aud_format); - snd_pcm_hw_params_t * params; - unsigned int useconds; - int direction; - snd_pcm_uframes_t frames, period; - int hard_buffer, soft_buffer; - - pthread_mutex_lock (& alsa_mutex); alsa_soft_init (); + pthread_mutex_lock (& alsa_mutex); + + assert (alsa_handle == NULL); + int format = convert_aud_format (aud_format); AUDDBG ("Opening PCM device %s for %s, %d channels, %d Hz.\n", alsa_config_pcm, snd_pcm_format_name (format), channels, rate); CHECK_NOISY (snd_pcm_open, & alsa_handle, alsa_config_pcm, SND_PCM_STREAM_PLAYBACK, 0); + snd_pcm_hw_params_t * params; snd_pcm_hw_params_alloca (& params); CHECK_NOISY (snd_pcm_hw_params_any, alsa_handle, params); CHECK_NOISY (snd_pcm_hw_params_set_access, alsa_handle, params, SND_PCM_ACCESS_RW_INTERLEAVED); + CHECK_NOISY (snd_pcm_hw_params_set_format, alsa_handle, params, format); CHECK_NOISY (snd_pcm_hw_params_set_channels, alsa_handle, params, channels); CHECK_NOISY (snd_pcm_hw_params_set_rate, alsa_handle, params, rate, 0); - useconds = 1000 * aud_cfg->output_buffer_size / 2; - direction = 0; - CHECK_NOISY (snd_pcm_hw_params_set_buffer_time_max, alsa_handle, params, - & useconds, & direction); - CHECK_NOISY (snd_pcm_hw_params, alsa_handle, params); alsa_format = format; alsa_channels = channels; alsa_rate = rate; - CHECK_NOISY (snd_pcm_get_params, alsa_handle, & frames, & period); - hard_buffer = (int64_t) frames * 1000 / rate; - soft_buffer = MAX (aud_cfg->output_buffer_size / 2, + unsigned int useconds = 1000 * MIN (1000, aud_cfg->output_buffer_size / 2); + int direction = 0; + CHECK_NOISY (snd_pcm_hw_params_set_buffer_time_near, alsa_handle, params, + & useconds, & direction); + int hard_buffer = useconds / 1000; + + useconds = 1000 * (hard_buffer / 4); + direction = 0; + CHECK_NOISY (snd_pcm_hw_params_set_period_time_near, alsa_handle, params, + & useconds, & direction); +#ifdef DEBUG + int period = useconds / 1000; +#endif + + CHECK_NOISY (snd_pcm_hw_params, alsa_handle, params); + + int soft_buffer = MAX (aud_cfg->output_buffer_size / 2, aud_cfg->output_buffer_size - hard_buffer); - AUDDBG ("Hardware buffer %d ms, software buffer %d ms.\n", hard_buffer, - soft_buffer); + AUDDBG ("Buffer: hardware %d ms, software %d ms, period %d ms.\n", + hard_buffer, soft_buffer, period); alsa_buffer_length = snd_pcm_frames_to_bytes (alsa_handle, (int64_t) soft_buffer * rate / 1000); @@ -352,7 +364,7 @@ int alsa_open_audio (gint aud_format, int rate, int channels) alsa_buffer_data_start = 0; alsa_buffer_data_length = 0; - alsa_time = 0; + alsa_written = 0; alsa_prebuffer = 1; alsa_paused = 0; alsa_paused_time = 0; @@ -381,6 +393,8 @@ void alsa_close_audio (void) AUDDBG ("Closing audio.\n"); pthread_mutex_lock (& alsa_mutex); + assert (alsa_handle != NULL); + pump_stop (); CHECK (snd_pcm_drop, alsa_handle); @@ -421,8 +435,7 @@ void alsa_write_audio (void * data, int length) memcpy ((char *) alsa_buffer + start, data, length); alsa_buffer_data_length += length; - alsa_time += (int64_t) snd_pcm_bytes_to_frames (alsa_handle, length) * - 1000000 / alsa_rate; + alsa_written += snd_pcm_bytes_to_frames (alsa_handle, length); pthread_mutex_unlock (& alsa_mutex); } @@ -449,8 +462,6 @@ void alsa_period_wait (void) void alsa_drain (void) { - int state; - AUDDBG ("Drain.\n"); pthread_mutex_lock (& alsa_mutex); @@ -478,6 +489,7 @@ void alsa_drain (void) { while (1) { + int state; CHECK_VAL (state, snd_pcm_state, alsa_handle); if (state != SND_PCM_STATE_RUNNING && state != @@ -501,31 +513,23 @@ void alsa_set_written_time (int time) { AUDDBG ("Setting time counter to %d.\n", time); pthread_mutex_lock (& alsa_mutex); - alsa_time = 1000 * (int64_t) time; + alsa_written = (int64_t) time * alsa_rate / 1000; pthread_mutex_unlock (& alsa_mutex); } int alsa_written_time (void) { - int time; - pthread_mutex_lock (& alsa_mutex); - time = alsa_time / 1000; + int time = (int64_t) alsa_written * 1000 / alsa_rate; pthread_mutex_unlock (& alsa_mutex); return time; } int alsa_output_time (void) { - int time = 0; - pthread_mutex_lock (& alsa_mutex); - - if (alsa_prebuffer || alsa_paused) - time = alsa_paused_time; - else - time = get_output_time (); - + int time = (alsa_prebuffer || alsa_paused) ? alsa_paused_time : + get_output_time (); pthread_mutex_unlock (& alsa_mutex); return time; } @@ -542,7 +546,7 @@ FAILED: alsa_buffer_data_start = 0; alsa_buffer_data_length = 0; - alsa_time = (int64_t) time * 1000; + alsa_written = (int64_t) time * alsa_rate / 1000; alsa_prebuffer = 1; alsa_paused_time = time; @@ -617,10 +621,10 @@ void alsa_close_mixer (void) void alsa_get_volume (int * left, int * right) { - long left_l = 0, right_l = 0; - - pthread_mutex_lock (& alsa_mutex); alsa_soft_init (); + pthread_mutex_lock (& alsa_mutex); + + long left_l = 0, right_l = 0; if (alsa_mixer == NULL) goto FAILED; @@ -650,8 +654,8 @@ FAILED: void alsa_set_volume (int left, int right) { - pthread_mutex_lock (& alsa_mutex); alsa_soft_init (); + pthread_mutex_lock (& alsa_mutex); if (alsa_mixer == NULL) goto FAILED; diff --git a/src/alsa/alsa.h b/src/alsa/alsa.h index b522b3a..890a98f 100644 --- a/src/alsa/alsa.h +++ b/src/alsa/alsa.h @@ -1,6 +1,6 @@ /* * ALSA Output Plugin for Audacious - * Copyright 2009 John Lindgren + * Copyright 2009-2010 John Lindgren * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -22,7 +22,6 @@ #include "../../config.h" -#include <pthread.h> #include <stdio.h> #include <audacious/plugin.h> @@ -55,8 +54,6 @@ do { \ } while (0) /* alsa.c */ -extern pthread_mutex_t alsa_mutex; - OutputPluginInitStatus alsa_init (void); void alsa_soft_init (void); void alsa_cleanup (void); diff --git a/src/alsa/config.c b/src/alsa/config.c index a5c2231..20af5c1 100644 --- a/src/alsa/config.c +++ b/src/alsa/config.c @@ -536,9 +536,7 @@ static void connect_callbacks (void) void alsa_configure (void) { - pthread_mutex_lock (& alsa_mutex); alsa_soft_init (); - pthread_mutex_unlock (& alsa_mutex); if (window != NULL) { diff --git a/src/gtkui/ui_gtk.c b/src/gtkui/ui_gtk.c index fd1a625..bc44471 100644 --- a/src/gtkui/ui_gtk.c +++ b/src/gtkui/ui_gtk.c @@ -41,6 +41,10 @@ #include "actions-mainwin.h" #include "actions-playlist.h" +#if ! GTK_CHECK_VERSION (2, 18, 0) +#define gtk_widget_set_can_focus(w, t) do {if (t) GTK_WIDGET_SET_FLAGS ((w), GTK_CAN_FOCUS); else GTK_WIDGET_UNSET_FLAGS ((w), GTK_CAN_FOCUS);} while (0) +#endif + gboolean multi_column_view; static GtkWidget *label_time; diff --git a/src/gtkui/ui_infoarea.c b/src/gtkui/ui_infoarea.c index 5d7527c..64b6368 100644 --- a/src/gtkui/ui_infoarea.c +++ b/src/gtkui/ui_infoarea.c @@ -44,6 +44,10 @@ #define SPECT_BANDS 12 #define VIS_OFFSET (10 + 12 * SPECT_BANDS + 7) +#if ! GTK_CHECK_VERSION (2, 18, 0) +#define gtk_widget_get_allocation(w, ap) (* (ap) = (w)->allocation) +#endif + typedef struct { GtkWidget *parent; diff --git a/src/hotkey/plugin.c b/src/hotkey/plugin.c index c2c1bfb..1b42cfe 100644 --- a/src/hotkey/plugin.c +++ b/src/hotkey/plugin.c @@ -38,6 +38,7 @@ #include <stdio.h> #include <X11/XF86keysym.h> +#include <gdk/gdk.h> #include <gdk/gdkx.h> #include <audacious/configdb.h> diff --git a/src/resample/plugin.c b/src/resample/plugin.c index 8017f69..e2772b4 100644 --- a/src/resample/plugin.c +++ b/src/resample/plugin.c @@ -188,7 +188,11 @@ static void resample_configure (void) button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); gtk_box_pack_end ((GtkBox *) hbox, button, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION (2, 18, 0) gtk_widget_set_can_default (button, TRUE); +#else + GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); +#endif gtk_widget_grab_default (button); g_signal_connect_swapped (button, "clicked", (GCallback) gtk_widget_destroy, window); |