reviewed by: George Lebl <jirka@5z.com>

2001-02-24  Gene Z. Ragan  <gzr@eazel.com>

	reviewed by: George Lebl <jirka@5z.com>

	Fixed bug 3546, Nautilus fails if MP3 previews in rapid succession

	Fixed bug 5105, Preview sound file during MP3 playback
	-> "/dev/dsp: Device or resource busy"

	* libnautilus-extensions/nautilus-global-preferences.h:
	Add a preference that that tracks the result of an intial
	audio output capability check during nautilus_sound_initialize().

	* libnautilus-extensions/nautilus-sound.c:
	(nautilus_sound_initialize):
	Check audio output capability and save the result of the check in
	a preference.

	(nautilus_sound_can_play_sound):
	Check saved preference instead of opening and closing esd as a
	way to check if sound output is available.  The constant opening
	and closing creating a latency problem withing esd and was
	affecting the audio preview mechanism.
This commit is contained in:
Gene Z. Ragan 2001-02-25 00:40:27 +00:00 committed by Gene Ragan
parent 8468f2f623
commit 8ff3209e1c
6 changed files with 82 additions and 24 deletions

View file

@ -1,3 +1,27 @@
2001-02-24 Gene Z. Ragan <gzr@eazel.com>
reviewed by: George Lebl <jirka@5z.com>
Fixed bug 3546, Nautilus fails if MP3 previews in rapid succession
Fixed bug 5105, Preview sound file during MP3 playback
-> "/dev/dsp: Device or resource busy"
* libnautilus-extensions/nautilus-global-preferences.h:
Add a preference that that tracks the result of an intial
audio output capability check during nautilus_sound_initialize().
* libnautilus-extensions/nautilus-sound.c:
(nautilus_sound_initialize):
Check audio output capability and save the result of the check in
a preference.
(nautilus_sound_can_play_sound):
Check saved preference instead of opening and closing esd as a
way to check if sound output is available. The constant opening
and closing creating a latency problem withing esd and was
affecting the audio preview mechanism.
2001-02-24 Gene Z. Ragan <gzr@eazel.com>
reviewed by: Seth Nickell <seth@eazel.com>

View file

@ -35,8 +35,11 @@ BEGIN_GNOME_DECLS
#define NAUTILUS_PREFERENCES_ICON_CAPTIONS "icon_view/captions"
/* How wide the sidebar is (or how wide it will be when expanded) */
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "preferences/sidebar_width"
/* Keep track of the sound playing process */
#define NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE "preferences/sound_state"
/* Does the system have audio output capability */
#define NAUTILUS_PREFERENCES_HAS_AUDIO_OUT "preferences/audio_out"
/* Window options */
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "preferences/window_always_new"

View file

@ -42,6 +42,7 @@ kill_sound_if_necessary (void)
/* fetch the sound state */
sound_process = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE);
/* if there was a sound playing, kill it */
if (sound_process > 0) {
kill (-sound_process, SIGTERM);
@ -54,7 +55,22 @@ kill_sound_if_necessary (void)
void
nautilus_sound_initialize (void)
{
int open_result;
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
/* Check and see if the system itself can play sound. We do this by attmepting
* to open esd. Save the result of this as a preference. This value only
* means that the system has audio out capabilities and should not be used as
* a way to check the current audio output state.
*/
open_result = esd_audio_open ();
if (open_result < 0) {
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_HAS_AUDIO_OUT, 0);
} else {
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_HAS_AUDIO_OUT, 1);
esd_audio_close ();
}
}
/* if there is a sound registered, kill it, and register the empty sound */
@ -79,23 +95,22 @@ nautilus_sound_register_sound (pid_t sound_process)
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, sound_process);
}
/* This function does two things. First it checks to see a sound is currently playing. If it is,
* it returns the process id of the external application playing the sound. If no sound is playing,
* it return the value set in nautilus_sound_initialize() when system audio output capabilites
* were queried.
*/
gboolean
nautilus_sound_can_play_sound (void)
{
int open_result, sound_process;
int sound_process;
/* first see if there's already one in progress; if so, return true */
sound_process = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE);
if (sound_process > 0) {
return TRUE;
}
open_result = esd_audio_open ();
if (open_result < 0) {
return FALSE;
}
esd_audio_close ();
return TRUE;
/* Now check and see if system has audio out capabilites */
return nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_HAS_AUDIO_OUT);
}

View file

@ -35,8 +35,11 @@ BEGIN_GNOME_DECLS
#define NAUTILUS_PREFERENCES_ICON_CAPTIONS "icon_view/captions"
/* How wide the sidebar is (or how wide it will be when expanded) */
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "preferences/sidebar_width"
/* Keep track of the sound playing process */
#define NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE "preferences/sound_state"
/* Does the system have audio output capability */
#define NAUTILUS_PREFERENCES_HAS_AUDIO_OUT "preferences/audio_out"
/* Window options */
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "preferences/window_always_new"

View file

@ -42,6 +42,7 @@ kill_sound_if_necessary (void)
/* fetch the sound state */
sound_process = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE);
/* if there was a sound playing, kill it */
if (sound_process > 0) {
kill (-sound_process, SIGTERM);
@ -54,7 +55,22 @@ kill_sound_if_necessary (void)
void
nautilus_sound_initialize (void)
{
int open_result;
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
/* Check and see if the system itself can play sound. We do this by attmepting
* to open esd. Save the result of this as a preference. This value only
* means that the system has audio out capabilities and should not be used as
* a way to check the current audio output state.
*/
open_result = esd_audio_open ();
if (open_result < 0) {
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_HAS_AUDIO_OUT, 0);
} else {
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_HAS_AUDIO_OUT, 1);
esd_audio_close ();
}
}
/* if there is a sound registered, kill it, and register the empty sound */
@ -79,23 +95,22 @@ nautilus_sound_register_sound (pid_t sound_process)
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, sound_process);
}
/* This function does two things. First it checks to see a sound is currently playing. If it is,
* it returns the process id of the external application playing the sound. If no sound is playing,
* it return the value set in nautilus_sound_initialize() when system audio output capabilites
* were queried.
*/
gboolean
nautilus_sound_can_play_sound (void)
{
int open_result, sound_process;
int sound_process;
/* first see if there's already one in progress; if so, return true */
sound_process = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE);
if (sound_process > 0) {
return TRUE;
}
open_result = esd_audio_open ();
if (open_result < 0) {
return FALSE;
}
esd_audio_close ();
return TRUE;
/* Now check and see if system has audio out capabilites */
return nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_HAS_AUDIO_OUT);
}

View file

@ -1327,7 +1327,6 @@ band_select_ended_callback (NautilusIconContainer *container,
/* here's the timer task that actually plays the file using mpg123. */
/* FIXME bugzilla.eazel.com 1258: we should get the application from our mime-type stuff */
static int
play_file (gpointer callback_data)
{
@ -1376,7 +1375,7 @@ play_file (gpointer callback_data)
/* this routine is invoked from the preview signal handler to preview a sound file. We
want to wait a suitable delay until we actually do it, so set up a timer task to actually
start playing. If we move out before the task files, we remove it. */
static void
preview_sound (NautilusFile *file, gboolean start_flag)
{
@ -1391,7 +1390,6 @@ preview_sound (NautilusFile *file, gboolean start_flag)
}
}
static gboolean
should_preview_sound (NautilusFile *file) {
int preview_mode;
@ -1401,7 +1399,7 @@ should_preview_sound (NautilusFile *file) {
if (preview_mode == NAUTILUS_SPEED_TRADEOFF_NEVER) {
return FALSE;
}
/* the followinf is disabled until we can preview remote sounds, which we currently can't do */
/* the following is disabled until we can preview remote sounds, which we currently can't do */
/*
if (preview_mode == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
return TRUE;