Commit 29b488fe authored by Eric Petit's avatar Eric Petit

* AudioOutput.cpp: send zeros to BSoundPlayer if nothing comes from

    audio output;
 * VlcWrapper.cpp: handle volume using aout3 features.
parent e7453ce6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* AudioOutput.cpp: BeOS audio output * AudioOutput.cpp: BeOS audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: AudioOutput.cpp,v 1.18 2002/11/27 06:27:52 titer Exp $ * $Id: AudioOutput.cpp,v 1.19 2002/12/09 07:57:04 titer Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -138,8 +138,17 @@ static void Play( void *aout, void *p_buffer, size_t i_size, ...@@ -138,8 +138,17 @@ static void Play( void *aout, void *p_buffer, size_t i_size,
memcpy( (float*)p_buffer, memcpy( (float*)p_buffer,
p_aout_buffer->p_buffer, p_aout_buffer->p_buffer,
MIN( BUFFER_SIZE, p_aout_buffer->i_nb_bytes ) ); MIN( BUFFER_SIZE, p_aout_buffer->i_nb_bytes ) );
if( p_aout_buffer->i_nb_bytes < BUFFER_SIZE )
{
memset( (float*)p_buffer + p_aout_buffer->i_nb_bytes,
0, BUFFER_SIZE - p_aout_buffer->i_nb_bytes );
}
aout_BufferFree( p_aout_buffer ); aout_BufferFree( p_aout_buffer );
} }
else
{
memset( (float*)p_buffer, 0, BUFFER_SIZE );
}
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* InterfaceWindow.cpp: beos interface * InterfaceWindow.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: InterfaceWindow.cpp,v 1.11 2002/12/04 02:16:23 titer Exp $ * $Id: InterfaceWindow.cpp,v 1.12 2002/12/09 07:57:04 titer Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -264,7 +264,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -264,7 +264,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
// this currently stops playback not nicely // this currently stops playback not nicely
if (playback_status > UNDEF_S) if (playback_status > UNDEF_S)
{ {
p_wrapper->volume_mute();
snooze( 400000 ); snooze( 400000 );
p_wrapper->PlaylistStop(); p_wrapper->PlaylistStop();
p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE); p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
...@@ -281,13 +280,10 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -281,13 +280,10 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
/* pause if currently playing */ /* pause if currently playing */
if ( playback_status == PLAYING_S ) if ( playback_status == PLAYING_S )
{ {
p_wrapper->volume_mute();
snooze( 400000 );
p_wrapper->PlaylistPause(); p_wrapper->PlaylistPause();
} }
else else
{ {
p_wrapper->volume_restore();
p_wrapper->PlaylistPlay(); p_wrapper->PlaylistPlay();
} }
} }
...@@ -302,8 +298,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -302,8 +298,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
/* cycle the fast playback modes */ /* cycle the fast playback modes */
if (playback_status > UNDEF_S) if (playback_status > UNDEF_S)
{ {
p_wrapper->volume_mute();
snooze( 400000 );
p_wrapper->InputFaster(); p_wrapper->InputFaster();
} }
break; break;
...@@ -312,8 +306,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -312,8 +306,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
/* cycle the slow playback modes */ /* cycle the slow playback modes */
if (playback_status > UNDEF_S) if (playback_status > UNDEF_S)
{ {
p_wrapper->volume_mute();
snooze( 400000 );
p_wrapper->InputSlower(); p_wrapper->InputSlower();
} }
break; break;
...@@ -322,7 +314,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -322,7 +314,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
/* restore speed to normal if already playing */ /* restore speed to normal if already playing */
if (playback_status > UNDEF_S) if (playback_status > UNDEF_S)
{ {
p_wrapper->volume_restore();
p_wrapper->PlaylistPlay(); p_wrapper->PlaylistPlay();
} }
break; break;
...@@ -335,15 +326,18 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -335,15 +326,18 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
/* adjust the volume */ /* adjust the volume */
if (playback_status > UNDEF_S) if (playback_status > UNDEF_S)
{ {
p_wrapper->set_volume( p_mediaControl->GetVolume() ); p_wrapper->SetVolume( p_mediaControl->GetVolume() );
p_mediaControl->SetMuted( p_wrapper->is_muted() ); p_mediaControl->SetMuted( p_wrapper->IsMuted() );
} }
break; break;
case VOLUME_MUTE: case VOLUME_MUTE:
// toggle muting // toggle muting
p_wrapper->toggle_mute(); if( p_wrapper->IsMuted() )
p_mediaControl->SetMuted( p_wrapper->is_muted() ); p_wrapper->VolumeRestore();
else
p_wrapper->VolumeMute();
p_mediaControl->SetMuted( p_wrapper->IsMuted() );
break; break;
case SELECT_CHANNEL: case SELECT_CHANNEL:
...@@ -353,13 +347,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -353,13 +347,6 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
if ( p_message->FindInt32( "channel", &channel ) == B_OK ) if ( p_message->FindInt32( "channel", &channel ) == B_OK )
{ {
p_wrapper->toggleLanguage( channel ); p_wrapper->toggleLanguage( channel );
// vlc seems to remember the volume for every channel,
// but I would assume that to be somewhat annoying to the user
// the next call will also unmute the volume, which is probably
// desired as well, because if the user selects another language,
// he probably wants to hear the change as well
snooze( 400000 ); // we have to wait a bit, or the change will be reverted
p_wrapper->set_volume( p_mediaControl->GetVolume() );
} }
} }
break; break;
...@@ -510,10 +497,10 @@ void InterfaceWindow::updateInterface() ...@@ -510,10 +497,10 @@ void InterfaceWindow::updateInterface()
p_wrapper->getNavCapabilities( &canSkipPrev, &canSkipNext ); p_wrapper->getNavCapabilities( &canSkipPrev, &canSkipNext );
p_mediaControl->SetSkippable( canSkipPrev, canSkipNext ); p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );
if ( p_wrapper->has_audio() ) if ( p_wrapper->HasAudio() )
{ {
p_mediaControl->SetAudioEnabled( true ); p_mediaControl->SetAudioEnabled( true );
p_mediaControl->SetMuted( p_wrapper->is_muted() ); p_mediaControl->SetMuted( p_wrapper->IsMuted() );
} else } else
p_mediaControl->SetAudioEnabled( false ); p_mediaControl->SetAudioEnabled( false );
...@@ -633,7 +620,7 @@ InterfaceWindow::_InputStreamChanged() ...@@ -633,7 +620,7 @@ InterfaceWindow::_InputStreamChanged()
//printf("InterfaceWindow::_InputStreamChanged()\n"); //printf("InterfaceWindow::_InputStreamChanged()\n");
// TODO: move more stuff from updateInterface() here! // TODO: move more stuff from updateInterface() here!
snooze( 400000 ); snooze( 400000 );
p_wrapper->set_volume( p_mediaControl->GetVolume() ); p_wrapper->SetVolume( p_mediaControl->GetVolume() );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* PlayListWindow.cpp: beos interface * PlayListWindow.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PlayListWindow.cpp,v 1.4 2002/11/26 01:06:08 titer Exp $ * $Id: PlayListWindow.cpp,v 1.5 2002/12/09 07:57:04 titer Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -246,5 +246,5 @@ PlayListWindow::UpdatePlaylist( bool rebuild ) ...@@ -246,5 +246,5 @@ PlayListWindow::UpdatePlaylist( bool rebuild )
fListView->AddItem( new PlaylistItem( p_wrapper->PlaylistItemName( i ) ) ); fListView->AddItem( new PlaylistItem( p_wrapper->PlaylistItemName( i ) ) );
} }
fListView->SetCurrent( p_wrapper->PlaylistCurrent() ); fListView->SetCurrent( p_wrapper->PlaylistCurrent() );
fListView->SetPlaying( p_wrapper->is_playing() ); fListView->SetPlaying( p_wrapper->IsPlaying() );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port) * VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port)
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: VlcWrapper.cpp,v 1.12 2002/11/27 05:36:41 titer Exp $ * $Id: VlcWrapper.cpp,v 1.13 2002/12/09 07:57:04 titer Exp $
* *
* Authors: Florian G. Pflug <fgp@phlo.org> * Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net> * Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -144,14 +144,7 @@ void VlcWrapper::InputSlower() ...@@ -144,14 +144,7 @@ void VlcWrapper::InputSlower()
{ {
input_SetStatus( p_input, INPUT_STATUS_SLOWER ); input_SetStatus( p_input, INPUT_STATUS_SLOWER );
} }
if( p_input->stream.control.i_rate == DEFAULT_RATE) //VolumeMute();
{
toggle_mute();
}
else
{
toggle_mute();
}
} }
void VlcWrapper::InputFaster() void VlcWrapper::InputFaster()
...@@ -160,14 +153,7 @@ void VlcWrapper::InputFaster() ...@@ -160,14 +153,7 @@ void VlcWrapper::InputFaster()
{ {
input_SetStatus( p_input, INPUT_STATUS_FASTER ); input_SetStatus( p_input, INPUT_STATUS_FASTER );
} }
if( p_input->stream.control.i_rate == DEFAULT_RATE) //VolumeMute();
{
toggle_mute();
}
else
{
toggle_mute();
}
} }
void VlcWrapper::openFiles( BList* o_files, bool replace ) void VlcWrapper::openFiles( BList* o_files, bool replace )
...@@ -201,7 +187,7 @@ void VlcWrapper::toggleLanguage(int i_language) ...@@ -201,7 +187,7 @@ void VlcWrapper::toggleLanguage(int i_language)
int i_cat = AUDIO_ES; int i_cat = AUDIO_ES;
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
for( int i = 0; i < p_input->stream.i_selected_es_number ; i++ ) for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
{ {
if( p_input->stream.pp_selected_es[i]->i_cat == i_cat ) if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
{ {
...@@ -233,7 +219,7 @@ void VlcWrapper::toggleSubtitle(int i_subtitle) ...@@ -233,7 +219,7 @@ void VlcWrapper::toggleSubtitle(int i_subtitle)
int i_cat = SPU_ES; int i_cat = SPU_ES;
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
for( int i = 0; i < p_input->stream.i_selected_es_number ; i++ ) for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
{ {
if( p_input->stream.pp_selected_es[i]->i_cat == i_cat ) if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
{ {
...@@ -302,6 +288,30 @@ void VlcWrapper::setTimeAsFloat(float f_position) ...@@ -302,6 +288,30 @@ void VlcWrapper::setTimeAsFloat(float f_position)
} }
} }
bool VlcWrapper::IsPlaying()
{
bool playing = false;
if ( p_input )
{
switch ( p_input->stream.control.i_status )
{
case PLAYING_S:
case FORWARD_S:
case BACKWARD_S:
case START_S:
playing = true;
break;
case PAUSE_S:
case UNDEF_S:
case NOT_STARTED_S:
default:
break;
}
}
return playing;
}
/****************************** /******************************
* playlist infos and control * * playlist infos and control *
...@@ -334,13 +344,13 @@ bool VlcWrapper::PlaylistPlay() ...@@ -334,13 +344,13 @@ bool VlcWrapper::PlaylistPlay()
if( PlaylistSize() ) if( PlaylistSize() )
{ {
playlist_Play( p_playlist ); playlist_Play( p_playlist );
//VolumeRestore();
} }
return( true ); return( true );
} }
void VlcWrapper::PlaylistPause() void VlcWrapper::PlaylistPause()
{ {
toggle_mute();
if( p_input ) if( p_input )
{ {
input_SetStatus( p_input, INPUT_STATUS_PAUSE ); input_SetStatus( p_input, INPUT_STATUS_PAUSE );
...@@ -349,7 +359,6 @@ void VlcWrapper::PlaylistPause() ...@@ -349,7 +359,6 @@ void VlcWrapper::PlaylistPause()
void VlcWrapper::PlaylistStop() void VlcWrapper::PlaylistStop()
{ {
volume_mute();
playlist_Stop( p_playlist ); playlist_Stop( p_playlist );
} }
...@@ -590,125 +599,43 @@ void VlcWrapper::navigateNext() ...@@ -590,125 +599,43 @@ void VlcWrapper::navigateNext()
* audio infos and control * * audio infos and control *
***************************/ ***************************/
void VlcWrapper::volume_mute() void VlcWrapper::SetVolume(int value)
{
if( p_aout != NULL )
{
if( !p_intf->p_sys->b_mute )
{
p_intf->p_sys->i_saved_volume = p_aout->output.i_volume;
p_aout->output.i_volume = 0;
p_intf->p_sys->b_mute = 1;
}
}
}
void VlcWrapper::volume_restore()
{ {
if( p_aout != NULL ) if( p_aout != NULL )
{ {
p_aout->output.i_volume = p_intf->p_sys->i_saved_volume;
p_intf->p_sys->i_saved_volume = 0;
p_intf->p_sys->b_mute = 0;
}
}
void VlcWrapper::set_volume(int value)
{
if( p_aout != NULL )
{
// make sure value is within bounds
if (value < 0)
value = 0;
if (value > AOUT_VOLUME_MAX)
value = AOUT_VOLUME_MAX;
vlc_mutex_lock( &p_aout->mixer_lock );
// unmute volume if muted
if ( p_intf->p_sys->b_mute ) if ( p_intf->p_sys->b_mute )
{ {
p_intf->p_sys->b_mute = 0; p_intf->p_sys->b_mute = 0;
p_aout->output.i_volume = value;
} }
vlc_mutex_unlock( &p_aout->mixer_lock ); aout_VolumeSet( p_aout, value );
} }
} }
void VlcWrapper::toggle_mute() void VlcWrapper::VolumeMute()
{ {
if( p_aout != NULL ) if( p_aout != NULL )
{ {
if ( p_intf->p_sys->b_mute ) aout_VolumeGet( p_aout, &p_intf->p_sys->i_saved_volume );
{ aout_VolumeMute( p_aout, NULL );
volume_restore(); p_intf->p_sys->b_mute = 1;
}
else
{
volume_mute();
}
} }
} }
bool VlcWrapper::is_muted() void VlcWrapper::VolumeRestore()
{ {
bool muted = true;
if( p_aout != NULL ) if( p_aout != NULL )
{ {
vlc_mutex_lock( &p_aout->mixer_lock ); aout_VolumeSet( p_aout, p_intf->p_sys->i_saved_volume );
if( p_aout->output.i_volume > 0 ) p_intf->p_sys->b_mute = 0;
{
muted = false;
}
vlc_mutex_unlock( &p_aout->mixer_lock );
// unfortunately, this is not reliable!
// return p_main->p_intf->p_sys->b_mute;
}
return muted;
}
bool VlcWrapper::is_playing()
{
bool playing = false;
if ( p_input )
{
switch ( p_input->stream.control.i_status )
{
case PLAYING_S:
case FORWARD_S:
case BACKWARD_S:
case START_S:
playing = true;
break;
case PAUSE_S:
case UNDEF_S:
case NOT_STARTED_S:
default:
break;
}
} }
return playing;
} }
void VlcWrapper::maxvolume() bool VlcWrapper::IsMuted()
{ {
if( p_aout != NULL ) return p_intf->p_sys->b_mute;
{
if( p_intf->p_sys->b_mute )
{
p_intf->p_sys->i_saved_volume = AOUT_VOLUME_MAX;
}
else
{
p_aout->output.i_volume = AOUT_VOLUME_MAX;
}
}
} }
bool VlcWrapper::has_audio() bool VlcWrapper::HasAudio()
{ {
return( p_aout != NULL ); return( p_aout != NULL );
} }
...@@ -737,7 +664,7 @@ void VlcWrapper::PrevTitle() ...@@ -737,7 +664,7 @@ void VlcWrapper::PrevTitle()
void VlcWrapper::NextTitle() void VlcWrapper::NextTitle()
{ {
int i_id; unsigned int i_id;
i_id = p_input->stream.p_selected_area->i_id + 1; i_id = p_input->stream.p_selected_area->i_id + 1;
if( i_id < p_input->stream.i_area_nb ) if( i_id < p_input->stream.i_area_nb )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* VlcWrapper.h: BeOS plugin for vlc (derived from MacOS X port) * VlcWrapper.h: BeOS plugin for vlc (derived from MacOS X port)
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: VlcWrapper.h,v 1.8 2002/11/27 05:36:41 titer Exp $ * $Id: VlcWrapper.h,v 1.9 2002/12/09 07:57:04 titer Exp $
* *
* Authors: Florian G. Pflug <fgp@phlo.org> * Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net> * Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -41,7 +41,7 @@ struct intf_sys_t ...@@ -41,7 +41,7 @@ struct intf_sys_t
vlc_bool_t b_loop; vlc_bool_t b_loop;
vlc_bool_t b_mute; vlc_bool_t b_mute;
int i_part; int i_part;
int i_saved_volume; audio_volume_t i_saved_volume;
int i_channel; int i_channel;
VlcWrapper * p_wrapper; VlcWrapper * p_wrapper;
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
const char* getTimeAsString(); const char* getTimeAsString();
float getTimeAsFloat(); float getTimeAsFloat();
void setTimeAsFloat( float i_offset ); void setTimeAsFloat( float i_offset );
bool IsPlaying();
/* Playlist */ /* Playlist */
int PlaylistSize(); int PlaylistSize();
...@@ -103,14 +103,11 @@ public: ...@@ -103,14 +103,11 @@ public:
void navigateNext(); void navigateNext();
/* audio */ /* audio */
void volume_mute(); void SetVolume( int value );
void volume_restore(); void VolumeMute();
void set_volume(int value); void VolumeRestore();
void toggle_mute( ); bool IsMuted();
bool is_muted(); bool HasAudio();
bool is_playing();
void maxvolume();
bool has_audio();
/* DVD */ /* DVD */
bool HasTitles(); bool HasTitles();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment