void vout_IntfReinit( vout_thread_t *p_vout ) { var_TriggerCallback( p_vout, "zoom" ); var_TriggerCallback( p_vout, "crop" ); var_TriggerCallback( p_vout, "aspect-ratio" ); var_TriggerCallback( p_vout, "video-on-top" ); var_TriggerCallback( p_vout, "video-wallpaper" ); var_TriggerCallback( p_vout, "video-filter" ); var_TriggerCallback( p_vout, "sub-source" ); var_TriggerCallback( p_vout, "sub-filter" ); var_TriggerCallback( p_vout, "sub-margin" ); var_TriggerCallback( p_vout, "viewpoint" ); }
/**************************************************************************** * DecodeBlock: the whole thing ****************************************************************************/ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = (decoder_sys_t*) p_dec->p_sys; picture_t *p_pic; if( pp_block == NULL || !*pp_block ) return NULL; p_pic = decoder_NewPicture( p_dec ); if( p_pic == NULL ) { msg_Err( p_dec, "cannot get picture" ); goto error; } if( p_sys->b_reload && (mdate() >= p_sys->i_next) ) { var_TriggerCallback( p_dec, "fake-file" ); /* next period */ p_sys->i_next = (mtime_t)(p_sys->i_reload + mdate()); } vlc_mutex_lock( &p_dec->p_sys->lock ); picture_Copy( p_pic, p_dec->p_sys->p_image ); vlc_mutex_unlock( &p_dec->p_sys->lock ); p_pic->date = (*pp_block)->i_pts; error: block_Release( *pp_block ); *pp_block = NULL; return p_pic; }
int libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num, const char *psz_filepath, unsigned int i_width, unsigned int i_height ) { assert( psz_filepath ); vout_thread_t *p_vout = GetVout (p_mi, num); if (p_vout == NULL) return -1; /* FIXME: This is not atomic. All parameters should be passed at once * (obviously _not_ with var_*()). Also, the libvlc object should not be * used for the callbacks: that breaks badly if there are concurrent * media players in the instance. */ var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER ); var_SetInteger( p_vout, "snapshot-width", i_width); var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER ); var_SetInteger( p_vout, "snapshot-height", i_height ); var_Create( p_vout, "snapshot-path", VLC_VAR_STRING ); var_SetString( p_vout, "snapshot-path", psz_filepath ); var_Create( p_vout, "snapshot-format", VLC_VAR_STRING ); var_SetString( p_vout, "snapshot-format", "png" ); var_TriggerCallback( p_vout, "video-snapshot" ); vlc_object_release( p_vout ); return 0; }
static int DeinterlaceCallback(vlc_object_t *object, char const *cmd, vlc_value_t oldval, vlc_value_t newval, void *data) { VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(data); vout_thread_t *vout = (vout_thread_t *)object; /* */ const int deinterlace_state = var_GetInteger(vout, "deinterlace"); char *mode = var_GetString(vout, "deinterlace-mode"); const bool is_needed = var_GetBool(vout, "deinterlace-needed"); if (!mode || !DeinterlaceIsModeValid(mode)) return VLC_EGENERIC; /* */ char *old = var_CreateGetString(vout, "sout-deinterlace-mode"); var_SetString(vout, "sout-deinterlace-mode", mode); msg_Dbg(vout, "deinterlace %d, mode %s, is_needed %d", deinterlace_state, mode, is_needed); if (deinterlace_state == 0 || (deinterlace_state == -1 && !is_needed)) DeinterlaceRemove(vout); else if (!DeinterlaceIsPresent(vout)) DeinterlaceAdd(vout); else if (old && strcmp(old, mode)) var_TriggerCallback(vout, "video-filter"); /* */ free(old); free(mode); return VLC_SUCCESS; }
static void test_callbacks( libvlc_int_t *p_libvlc ) { /* add the callbacks */ int i; for( i = 0; i < i_var_count; i++ ) { var_Create( p_libvlc, psz_var_name[i], VLC_VAR_INTEGER ); var_AddCallback( p_libvlc, psz_var_name[i], callback, psz_var_name ); } /* Set the variables and trigger the callbacks */ for( i = 0; i < i_var_count; i++ ) { int i_temp = rand(); var_SetInteger( p_libvlc, psz_var_name[i], i_temp ); assert( i_temp == var_value[i].i_int ); var_SetInteger( p_libvlc, psz_var_name[i], 0 ); assert( var_value[i].i_int == 0 ); var_value[i].i_int = 1; } /* Only trigger the callback: the value will be 0 again */ for( i = 0; i < i_var_count; i++ ) { var_TriggerCallback( p_libvlc, psz_var_name[i] ); assert( var_value[i].i_int == 0 ); } for( i = 0; i < i_var_count; i++ ) var_Destroy( p_libvlc, psz_var_name[i] ); }
static int vlclua_trigger_callback( lua_State *L ) { vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" ); const char *psz_var = luaL_checkstring( L, 2 ); return vlclua_push_ret( L, var_TriggerCallback( *pp_obj, psz_var ) ); }
void InputManager::sectionMenu() { if( hasInput() ) { var_TriggerCallback( p_input, "menu-title" ); } }
void InputManager::sectionNext() { if( hasInput() ) { int i_type = var_Type( p_input, "next-chapter" ); var_TriggerCallback( p_input, (i_type & VLC_VAR_TYPE) != 0 ? "next-chapter":"next-title" ); } }
void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi ); if( p_input_thread != NULL ) { var_TriggerCallback( p_input_thread, "frame-next" ); vlc_object_release( p_input_thread ); } }
static int WallPaperCallback( vlc_object_t *obj, char const *name, vlc_value_t prev, vlc_value_t cur, void *data ) { vout_thread_t *vout = (vout_thread_t *)obj; if( cur.b_bool ) { vout_ControlChangeWindowState( vout, VOUT_WINDOW_STATE_BELOW ); vout_ControlChangeFullscreen( vout, true ); } else { var_TriggerCallback( obj, "fullscreen" ); var_TriggerCallback( obj, "video-on-top" ); } (void) name; (void) prev; (void) data; return VLC_SUCCESS; }
/* Restart filter callback */ static int RestartFilterCallback( vlc_object_t *obj, char const *psz_name, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(obj); VLC_UNUSED(psz_name); VLC_UNUSED(oldval); VLC_UNUSED(newval); var_TriggerCallback( (vlc_object_t *)p_data, "video-filter" ); return VLC_SUCCESS; }
void ActionsManager::snapshot() { vout_thread_t *p_vout = THEMIM->getVout(); if( p_vout ) { var_TriggerCallback( p_vout, "video-snapshot" ); vlc_object_release( p_vout ); } }
static void Run( fingerprinter_thread_t *p_fingerprinter ) { fingerprinter_sys_t *p_sys = p_fingerprinter->p_sys; /* main loop */ for (;;) { vlc_mutex_lock( &p_sys->processing.lock ); mutex_cleanup_push( &p_sys->processing.lock ); vlc_cond_timedwait( &p_sys->incoming_queue_filled, &p_sys->processing.lock, mdate() + 1000000 ); vlc_cleanup_run(); QueueIncomingRequests( p_sys ); vlc_mutex_lock( &p_sys->processing.lock ); // L0 mutex_cleanup_push( &p_sys->processing.lock ); vlc_cleanup_push( cancelRun, p_sys ); // C1 //** for ( p_sys->i = 0 ; p_sys->i < vlc_array_count( p_sys->processing.queue ); p_sys->i++ ) { fingerprint_request_t *p_data = vlc_array_item_at_index( p_sys->processing.queue, p_sys->i ); acoustid_fingerprint_t acoustid_print; memset( &acoustid_print , 0, sizeof(acoustid_fingerprint_t) ); vlc_cleanup_push( clearPrint, &acoustid_print ); // C2 p_sys->psz_uri = input_item_GetURI( p_data->p_item ); if ( p_sys->psz_uri ) { /* overwrite with hint, as in this case, fingerprint's session will be truncated */ if ( p_data->i_duration ) acoustid_print.i_duration = p_data->i_duration; DoFingerprint( VLC_OBJECT(p_fingerprinter), p_sys, &acoustid_print ); DoAcoustIdWebRequest( VLC_OBJECT(p_fingerprinter), &acoustid_print ); fill_metas_with_results( p_data, &acoustid_print ); FREENULL( p_sys->psz_uri ); } vlc_cleanup_run( ); // C2 /* copy results */ vlc_mutex_lock( &p_sys->results.lock ); vlc_array_append( p_sys->results.queue, p_data ); vlc_mutex_unlock( &p_sys->results.lock ); vlc_testcancel(); } if ( vlc_array_count( p_sys->processing.queue ) ) { var_TriggerCallback( p_fingerprinter, "results-available" ); vlc_array_clear( p_sys->processing.queue ); } vlc_cleanup_pop( ); // C1 //** vlc_cleanup_run(); // L0 } }
/** * Supply or update the current custom ("hardware") volume. * @note This only makes sense after calling aout_VolumeHardInit(). * @param setter volume setter callback * @param volume current custom volume * @param mute current mute flag * * @warning The caller (i.e. the audio output plug-in) is responsible for * interlocking and synchronizing call to this function and to the * audio_output_t.pf_volume_set callback. This ensures that VLC gets correct * volume information (possibly with a latency). */ void aout_VolumeHardSet (audio_output_t *aout, float volume, bool mute) { audio_volume_t vol = lroundf (volume * (float)AOUT_VOLUME_DEFAULT); /* We cannot acquire the volume lock as this gets called from the audio * output plug-in (it would cause a lock inversion). */ var_SetInteger (aout, "volume", vol); var_SetBool (aout, "mute", mute); var_TriggerCallback (aout, "intf-change"); }
void CmdFaster::execute() { playlist_t *pPlaylist = getIntf()->p_sys->p_playlist; input_thread_t *pInput = playlist_CurrentInput( pPlaylist ); if( pInput ) { var_TriggerCallback( pPlaylist, "rate-faster" ); vlc_object_release( pInput ); } }
/** * Start the input for an item * * \param p_playlist the playlist object * \param p_item the item to play * \return nothing */ static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item ) { playlist_private_t *p_sys = pl_priv(p_playlist); input_item_t *p_input = p_item->p_input; PL_ASSERT_LOCKED; msg_Dbg( p_playlist, "creating new input thread" ); p_item->i_nb_played++; set_current_status_item( p_playlist, p_item ); p_sys->status.i_status = PLAYLIST_RUNNING; assert( p_sys->p_input == NULL ); PL_UNLOCK; input_thread_t *p_input_thread = input_Create( p_playlist, p_input, NULL, p_sys->p_input_resource ); if( likely(p_input_thread != NULL) ) { var_AddCallback( p_input_thread, "intf-event", InputEvent, p_playlist ); if( input_Start( p_input_thread ) ) { var_DelCallback( p_input_thread, "intf-event", InputEvent, p_playlist ); vlc_object_release( p_input_thread ); p_input_thread = NULL; } } var_SetAddress( p_playlist, "input-current", p_input_thread ); /* TODO store art policy in playlist private data */ char *psz_arturl = input_item_GetArtURL( p_input ); /* p_input->p_meta should not be null after a successful CreateThread */ bool b_has_art = !EMPTY_STR( psz_arturl ); if( !b_has_art || strncmp( psz_arturl, "attachment://", 13 ) ) { PL_DEBUG( "requesting art for new input thread" ); libvlc_ArtRequest( p_playlist->p_libvlc, p_input, META_REQUEST_OPTION_NONE ); } free( psz_arturl ); var_TriggerCallback( p_playlist, "activity" ); PL_LOCK; p_sys->p_input = p_input_thread; }
void CmdSnapshot::execute() { if( getIntf()->p_sys->p_input == NULL ) return; vout_thread_t *pVout = input_GetVout( getIntf()->p_sys->p_input ); if( pVout ) { // Take a snapshot var_TriggerCallback( pVout, "video-snapshot" ); vlc_object_release( pVout ); } }
void libvlc_media_player_previous_chapter( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return; int i_type = var_Type( p_input_thread, "next-chapter" ); var_TriggerCallback( p_input_thread, (i_type & VLC_VAR_TYPE) != 0 ? "prev-chapter":"prev-title" ); vlc_object_release( p_input_thread ); }
/** * Initializes list of devices. */ static void Probe (vlc_object_t *obj) { /* Due to design bug in audio output core, this hack is required: */ if (var_Type (obj, "audio-device")) return; /* The variable does not exist - first call. */ vlc_value_t text; var_Create (obj, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE); text.psz_string = _("Audio Device"); var_Change (obj, "audio-device", VLC_VAR_SETTEXT, &text, NULL); GetDevices (obj, NULL); var_AddCallback (obj, "audio-device", aout_ChannelsRestart, NULL); var_TriggerCallback (obj, "intf-change"); }
static void LoopInput( playlist_t *p_playlist ) { playlist_private_t *p_sys = pl_priv(p_playlist); input_thread_t *p_input = p_sys->p_input; assert( p_input != NULL ); if( p_sys->request.b_request || p_sys->killed ) { PL_DEBUG( "incoming request - stopping current input" ); input_Stop( p_input, true ); } #warning Unsynchronized access to *p_input flags... /* This input is dead. Remove it ! */ if( p_input->b_dead ) { p_sys->p_input = NULL; PL_DEBUG( "dead input" ); PL_UNLOCK; var_SetAddress( p_playlist, "input-current", NULL ); /* WARNING: Input resource manipulation and callback deletion are * incompatible with the playlist lock. */ if( !var_InheritBool( p_input, "sout-keep" ) ) input_resource_TerminateSout( p_sys->p_input_resource ); var_DelCallback( p_input, "intf-event", InputEvent, p_playlist ); input_Close( p_input ); var_TriggerCallback( p_playlist, "activity" ); PL_LOCK; return; } /* This input has finished, ask it to die ! */ else if( p_input->b_error || p_input->b_eof ) { PL_DEBUG( "finished input" ); input_Stop( p_input, false ); } vlc_cond_wait( &p_sys->signal, &p_sys->lock ); }
int libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num, const char *psz_filepath, unsigned int i_width, unsigned int i_height ) { assert( psz_filepath ); vout_thread_t *p_vout = GetVout (p_mi, num); if (p_vout == NULL) return -1; /* FIXME: This is not atomic. Someone else could change the values, * at least in theory. */ var_SetInteger( p_vout, "snapshot-width", i_width); var_SetInteger( p_vout, "snapshot-height", i_height ); var_SetString( p_vout, "snapshot-path", psz_filepath ); var_SetString( p_vout, "snapshot-format", "png" ); var_TriggerCallback (p_vout, "video-snapshot" ); return 0; }
int CommonInit( vout_thread_t *p_vout ) { vout_sys_t *p_sys = p_vout->p_sys; p_sys->hwnd = NULL; p_sys->hvideownd = NULL; p_sys->hparent = NULL; p_sys->hfswnd = NULL; p_sys->i_changes = 0; SetRectEmpty( &p_sys->rect_display ); SetRectEmpty( &p_sys->rect_parent ); vlc_mutex_init( &p_sys->lock ); var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); /* Set main window's size */ p_sys->i_window_width = p_vout->i_window_width; p_sys->i_window_height = p_vout->i_window_height; p_sys->p_event = EventThreadCreate( p_vout ); if( !p_sys->p_event ) return VLC_EGENERIC; if( EventThreadStart( p_sys->p_event ) ) return VLC_EGENERIC; /* Variable to indicate if the window should be on top of others */ /* Trigger a callback right now */ var_TriggerCallback( p_vout, "video-on-top" ); /* Why not with glwin32 */ #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32) var_Create( p_vout, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); DisableScreensaver ( p_vout ); #endif return VLC_SUCCESS; }
/** * Creates a software amplifier. */ aout_volume_t *aout_volume_New(vlc_object_t *parent, const audio_replay_gain_t *gain) { aout_volume_t *vol = vlc_custom_create(parent, sizeof (aout_volume_t), "volume"); if (unlikely(vol == NULL)) return NULL; vol->module = NULL; vol->output_factor = 1.f; //audio_volume_t *obj = &vol->object; /* Gain */ if (gain != NULL) memcpy(&vol->replay_gain, gain, sizeof (vol->replay_gain)); else memset(&vol->replay_gain, 0, sizeof (vol->replay_gain)); var_AddCallback(parent, "audio-replay-gain-mode", ReplayGainCallback, vol); var_TriggerCallback(parent, "audio-replay-gain-mode"); return vol; }
/***************************************************************************** * InterfaceWindow::MessageReceived *****************************************************************************/ void InterfaceWindow::MessageReceived( BMessage * p_message ) { switch( p_message->what ) { case B_ABOUT_REQUESTED: { BAlert * alert; alert = new BAlert( "VLC media player" VERSION, "VLC media player" VERSION " (BeOS interface)\n\n" "The VideoLAN team <*****@*****.**>\n" "http://www.videolan.org/", _("OK") ); alert->Go(); break; } case TOGGLE_ON_TOP: break; case OPEN_FILE: _ShowFilePanel( B_REFS_RECEIVED, _("VLC media player: Open Media Files") ); break; case LOAD_SUBFILE: _ShowFilePanel( SUBFILE_RECEIVED, _("VLC media player: Open Subtitle File") ); break; #if 0 case OPEN_PLAYLIST: if (fPlaylistWindow->Lock()) { if (fPlaylistWindow->IsHidden()) fPlaylistWindow->Show(); else fPlaylistWindow->Activate(); fPlaylistWindow->Unlock(); } break; #endif case OPEN_DVD: { const char * psz_device; if( p_playlist && p_message->FindString( "device", &psz_device ) == B_OK ) { char psz_uri[1024]; memset( psz_uri, 0, 1024 ); snprintf( psz_uri, 1024, "dvdnav:%s", psz_device ); playlist_Add( p_playlist, psz_uri, psz_device, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true ); } UpdatePlaylist(); } break; case SUBFILE_RECEIVED: { entry_ref ref; if( p_message->FindRef( "refs", 0, &ref ) == B_OK ) { BPath path( &ref ); if ( path.InitCheck() == B_OK ) config_PutPsz( p_intf, "sub-file", path.Path() ); } break; } case STOP_PLAYBACK: if( p_playlist ) { playlist_Stop( p_playlist ); } p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT); break; case START_PLAYBACK: case PAUSE_PLAYBACK: { vlc_value_t val; val.i_int = PLAYING_S; if( p_input ) { var_Get( p_input, "state", &val ); } if( p_input && val.i_int != PAUSE_S ) { val.i_int = PAUSE_S; var_Set( p_input, "state", val ); } else { playlist_Play( p_playlist ); } break; } case HEIGHTH_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 8 ); } break; case QUARTER_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 4 ); } break; case HALF_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 2 ); } break; case NORMAL_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT ); } break; case TWICE_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 2 ); } break; case FOUR_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 4 ); } break; case HEIGHT_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 8 ); } break; case SEEK_PLAYBACK: /* handled by semaphores */ break; case VOLUME_CHG: aout_VolumeSet( p_intf, p_mediaControl->GetVolume() ); break; case VOLUME_MUTE: aout_ToggleMute( p_intf, NULL ); break; case SELECT_CHANNEL: { int32 channel; if( p_input ) { if( p_message->FindInt32( "audio-es", &channel ) == B_OK ) { var_SetInteger( p_input, "audio-es", channel ); } else if( p_message->FindInt32( "spu-es", &channel ) == B_OK ) { var_SetInteger( p_input, "spu-es", channel ); } } break; } case PREV_TITLE: if( p_input ) { var_TriggerCallback( p_input, "prev-title" ); } break; case NEXT_TITLE: if( p_input ) { var_TriggerCallback( p_input, "next-title" ); } break; case TOGGLE_TITLE: { int32 index; if( p_input && p_message->FindInt32( "index", &index ) == B_OK ) { var_SetInteger( p_input, "title", index ); } break; } case PREV_CHAPTER: if( p_input ) { var_TriggerCallback( p_input, "prev-chapter" ); } break; case NEXT_CHAPTER: if( p_input ) { var_TriggerCallback( p_input, "next-chapter" ); } break; case TOGGLE_CHAPTER: { int32 index; if( p_input && p_message->FindInt32( "index", &index ) == B_OK ) { var_SetInteger( p_input, "chapter", index ); } break; } case PREV_FILE: if( p_playlist ) { playlist_Prev( p_playlist ); } break; case NEXT_FILE: if( p_playlist ) { playlist_Next( p_playlist ); } break; case NAVIGATE_PREV: if( p_input ) { vlc_value_t val; /* First try to go to previous chapter */ if( !var_Get( p_input, "chapter", &val ) ) { if( val.i_int > 1 ) { var_TriggerCallback( p_input, "prev-chapter" ); break; } } /* Try to go to previous title */ if( !var_Get( p_input, "title", &val ) ) { if( val.i_int > 1 ) { var_TriggerCallback( p_input, "prev-title" ); break; } } /* Try to go to previous file */ if( p_playlist ) { playlist_Prev( p_playlist ); } } break; case NAVIGATE_NEXT: if( p_input ) { /* First try to go to next chapter */ if( !var_Get( p_input, "chapter", &val ) ) { int i_chapter_count = var_CountChoices( p_input, "chapter" ); if( i_chapter_count > val.i_int ) { var_TriggerCallback( p_input, "next-chapter" ); break; } } /* Try to go to next title */ if( !var_Get( p_input, "title", &val ) ) { int i_title_count = var_CountChoices( p_input, "title" ); if( i_title_count > val.i_int ) { var_TriggerCallback( p_input, "next-title" ); break; } } /* Try to go to next file */ if( p_playlist ) { playlist_Next( p_playlist ); } } break; // drag'n'drop and system messages case MSG_SOUNDPLAY: // convert soundplay drag'n'drop message (containing paths) // to normal message (containing refs) { const char* path; for ( int32 i = 0; p_message->FindString( "path", i, &path ) == B_OK; i++ ) { entry_ref ref; if ( get_ref_for_path( path, &ref ) == B_OK ) p_message->AddRef( "refs", &ref ); } } // fall through case B_REFS_RECEIVED: case B_SIMPLE_DATA: { /* file(s) opened by the File menu -> append to the playlist; file(s) opened by drag & drop -> replace playlist; file(s) opened by 'shift' + drag & drop -> append */ int32 count; type_code dummy; if( p_message->GetInfo( "refs", &dummy, &count ) != B_OK || count < 1 ) { break; } bool b_remove = ( p_message->WasDropped() && !( modifiers() & B_SHIFT_KEY ) ); if( b_remove && p_playlist ) { playlist_Clear( p_playlist, true ); } entry_ref ref; for( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ ) { BPath path( &ref ); /* TODO: find out if this is a DVD icon */ if( p_playlist ) { playlist_Add( p_playlist, path.Path(), NULL, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true ); } } UpdatePlaylist(); break; } case OPEN_PREFERENCES: { if( fPreferencesWindow->Lock() ) { if (fPreferencesWindow->IsHidden()) fPreferencesWindow->Show(); else fPreferencesWindow->Activate(); fPreferencesWindow->Unlock(); } break; } case OPEN_MESSAGES: { if( fMessagesWindow->Lock() ) { if (fMessagesWindow->IsHidden()) fMessagesWindow->Show(); else fMessagesWindow->Activate(); fMessagesWindow->Unlock(); } break; } case MSG_UPDATE: UpdateInterface(); break; default: BWindow::MessageReceived( p_message ); break; } }
/***************************************************************************** * Open: open the audio device *****************************************************************************/ static int Open ( vlc_object_t *p_this ) { aout_instance_t *p_aout = (aout_instance_t *)p_this; SDL_AudioSpec desired, obtained; int i_nb_channels; vlc_value_t val, text; /* Check that no one uses the DSP. */ uint32_t i_flags = SDL_INIT_AUDIO; if( SDL_WasInit( i_flags ) ) { return VLC_EGENERIC; } i_flags |= SDL_INIT_EVENTTHREAD; #ifndef NDEBUG /* In debug mode you may want vlc to dump a core instead of staying * stuck */ i_flags |= SDL_INIT_NOPARACHUTE; #endif /* Initialize library */ if( SDL_Init( i_flags ) < 0 ) { msg_Err( p_aout, "cannot initialize SDL (%s)", SDL_GetError() ); return VLC_EGENERIC; } if( var_Get( p_aout, "audio-device", &val ) != VLC_ENOVAR ) { /* The user has selected an audio device. */ if ( val.i_int == AOUT_VAR_STEREO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } else if ( val.i_int == AOUT_VAR_MONO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; } } i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); if ( i_nb_channels > 2 ) { /* SDL doesn't support more than two channels. */ i_nb_channels = 2; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } desired.freq = p_aout->output.output.i_rate; desired.format = AUDIO_S16SYS; desired.channels = i_nb_channels; desired.callback = SDLCallback; desired.userdata = p_aout; desired.samples = FRAME_SIZE; /* Open the sound device. */ if( SDL_OpenAudio( &desired, &obtained ) < 0 ) { return VLC_EGENERIC; } SDL_PauseAudio( 0 ); /* Now have a look at what we got. */ switch ( obtained.format ) { case AUDIO_S16LSB: p_aout->output.output.i_format = VLC_CODEC_S16L; break; case AUDIO_S16MSB: p_aout->output.output.i_format = VLC_CODEC_S16B; break; case AUDIO_U16LSB: p_aout->output.output.i_format = VLC_CODEC_U16L; break; case AUDIO_U16MSB: p_aout->output.output.i_format = VLC_CODEC_U16B; break; case AUDIO_S8: p_aout->output.output.i_format = VLC_CODEC_S8; break; case AUDIO_U8: p_aout->output.output.i_format = VLC_CODEC_U8; break; } /* Volume is entirely done in software. */ aout_VolumeSoftInit( p_aout ); if ( obtained.channels != i_nb_channels ) { p_aout->output.output.i_physical_channels = (obtained.channels == 2 ? AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT : AOUT_CHAN_CENTER); if ( var_Type( p_aout, "audio-device" ) == 0 ) { var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); text.psz_string = _("Audio Device"); var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); val.i_int = (obtained.channels == 2) ? AOUT_VAR_STEREO : AOUT_VAR_MONO; text.psz_string = (obtained.channels == 2) ? _("Stereo") : _("Mono"); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); } } else if ( var_Type( p_aout, "audio-device" ) == 0 ) { /* First launch. */ var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); text.psz_string = _("Audio Device"); var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); val.i_int = AOUT_VAR_STEREO; text.psz_string = _("Stereo"); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_MONO; text.psz_string = _("Mono"); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); if ( i_nb_channels == 2 ) { val.i_int = AOUT_VAR_STEREO; } else { val.i_int = AOUT_VAR_MONO; } var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); } var_TriggerCallback( p_aout, "intf-change" ); p_aout->output.output.i_rate = obtained.freq; p_aout->output.i_nb_samples = obtained.samples; p_aout->output.pf_play = Play; return VLC_SUCCESS; }
static void ProcessGesture( intf_thread_t *p_intf ) { intf_sys_t *p_sys = p_intf->p_sys; playlist_t *p_playlist = pl_Get( p_intf ); /* Do something */ /* If you modify this, please try to follow this convention: Start with LEFT, RIGHT for playback related commands and UP, DOWN, for other commands */ switch( p_sys->i_pattern ) { case LEFT: { msg_Dbg( p_intf, "Go backward in the movie!" ); input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; int it = var_InheritInteger( p_intf , "short-jump-size" ); if( it > 0 ) var_SetTime( p_input, "time-offset", -CLOCK_FREQ * it ); vlc_object_release( p_input ); break; } case RIGHT: { msg_Dbg( p_intf, "Go forward in the movie!" ); input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; int it = var_InheritInteger( p_intf , "short-jump-size" ); if( it > 0 ) var_SetTime( p_input, "time-offset", CLOCK_FREQ * it ); vlc_object_release( p_input ); break; } case GESTURE(LEFT,UP,NONE,NONE): msg_Dbg( p_intf, "Going slower." ); var_TriggerCallback( p_playlist, "rate-slower" ); break; case GESTURE(RIGHT,UP,NONE,NONE): msg_Dbg( p_intf, "Going faster." ); var_TriggerCallback( p_playlist, "rate-faster" ); break; case GESTURE(LEFT,RIGHT,NONE,NONE): case GESTURE(RIGHT,LEFT,NONE,NONE): { msg_Dbg( p_intf, "Play/Pause" ); input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; int i_state = var_GetInteger( p_input, "state" ); i_state = (i_state == PLAYING_S) ? PAUSE_S : PLAYING_S; var_SetInteger( p_input, "state", i_state ); vlc_object_release( p_input ); break; } case GESTURE(LEFT,DOWN,NONE,NONE): playlist_Prev( p_playlist ); break; case GESTURE(RIGHT,DOWN,NONE,NONE): playlist_Next( p_playlist ); break; case UP: msg_Dbg(p_intf, "Louder"); playlist_VolumeUp( p_playlist, 1, NULL ); break; case DOWN: msg_Dbg(p_intf, "Quieter"); playlist_VolumeDown( p_playlist, 1, NULL ); break; case GESTURE(UP,DOWN,NONE,NONE): case GESTURE(DOWN,UP,NONE,NONE): msg_Dbg( p_intf, "Mute sound" ); playlist_MuteToggle( p_playlist ); break; case GESTURE(UP,RIGHT,NONE,NONE): { input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; vlc_value_t list, list2; var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES, &list, &list2 ); if( list.p_list->i_count > 1 ) { int i_audio_es = var_GetInteger( p_input, "audio-es" ); int i; for( i = 0; i < list.p_list->i_count; i++ ) if( i_audio_es == list.p_list->p_values[i].i_int ) break; /* value of audio-es was not in choices list */ if( i == list.p_list->i_count ) { msg_Warn( p_input, "invalid current audio track, selecting 0" ); i = 0; } else if( i == list.p_list->i_count - 1 ) i = 1; else i++; var_SetInteger( p_input, "audio-es", list.p_list->p_values[i].i_int ); } var_FreeList( &list, &list2 ); vlc_object_release( p_input ); break; } case GESTURE(DOWN,RIGHT,NONE,NONE): { input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; vlc_value_t list, list2; var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES, &list, &list2 ); if( list.p_list->i_count > 1 ) { int i_audio_es = var_GetInteger( p_input, "spu-es" ); int i; for( i = 0; i < list.p_list->i_count; i++ ) if( i_audio_es == list.p_list->p_values[i].i_int ) break; /* value of audio-es was not in choices list */ if( i == list.p_list->i_count ) { msg_Warn( p_input, "invalid current subtitle track, selecting 0" ); i = 0; } else if( i == list.p_list->i_count - 1 ) i = 1; else i++; var_SetInteger( p_input, "audio-es", list.p_list->p_values[i].i_int ); } var_FreeList( &list, &list2 ); vlc_object_release( p_input ); break; } case GESTURE(UP,LEFT,NONE,NONE): { bool val = var_ToggleBool( pl_Get( p_intf ), "fullscreen" ); if( p_sys->p_vout ) var_SetBool( p_sys->p_vout, "fullscreen", val ); break; } case GESTURE(DOWN,LEFT,NONE,NONE): /* FIXME: Should close the vout!"*/ libvlc_Quit( p_intf->p_libvlc ); break; case GESTURE(DOWN,LEFT,UP,RIGHT): case GESTURE(UP,RIGHT,DOWN,LEFT): msg_Dbg( p_intf, "a square was drawn!" ); break; } p_sys->i_num_gestures = 0; p_sys->i_pattern = 0; }
void InputManager::slower() { var_TriggerCallback( THEPL, "rate-slower" ); }
/***************************************************************************** * Open: open the audio device (the digital sound processor) ***************************************************************************** * This function opens the DSP as a usual non-blocking write-only file, and * modifies the p_aout->p_sys->i_fd with the file's descriptor. *****************************************************************************/ static int Open( vlc_object_t *p_this ) { audio_output_t * p_aout = (audio_output_t *)p_this; struct aout_sys_t * p_sys; char * psz_device; vlc_value_t val; /* Allocate structure */ p_aout->sys = p_sys = malloc( sizeof( aout_sys_t ) ); if( p_sys == NULL ) return VLC_ENOMEM; /* Get device name */ if( (psz_device = var_InheritString( p_aout, "oss-audio-device" )) == NULL ) { msg_Err( p_aout, "no audio device specified (maybe /dev/dsp?)" ); free( p_sys ); return VLC_EGENERIC; } /* Open the sound device in non-blocking mode, because ALSA's OSS * emulation and some broken OSS drivers would make a blocking call * wait forever until the device is available. Since this breaks the * OSS spec, we immediately put it back to blocking mode if the * operation was successful. */ p_sys->i_fd = vlc_open( psz_device, O_WRONLY | O_NDELAY ); if( p_sys->i_fd < 0 ) { msg_Err( p_aout, "cannot open audio device (%s)", psz_device ); free( psz_device ); free( p_sys ); return VLC_EGENERIC; } /* if the opening was ok, put the device back in blocking mode */ fcntl( p_sys->i_fd, F_SETFL, fcntl( p_sys->i_fd, F_GETFL ) &~ FNDELAY ); free( psz_device ); p_aout->pf_play = aout_PacketPlay; p_aout->pf_pause = aout_PacketPause; p_aout->pf_flush = aout_PacketFlush; if ( var_Type( p_aout, "audio-device" ) == 0 ) Probe( p_aout ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); if ( var_Get( p_aout, "audio-device", &val ) < 0 ) /* Probe() has failed. */ goto error; if ( val.i_int == AOUT_VAR_SPDIF ) { p_aout->format.i_format = VLC_CODEC_SPDIFL; } else if ( val.i_int == AOUT_VAR_5_1 ) { p_aout->format.i_format = VLC_CODEC_S16N; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE; } else if ( val.i_int == AOUT_VAR_2F2R ) { p_aout->format.i_format = VLC_CODEC_S16N; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; } else if ( val.i_int == AOUT_VAR_STEREO ) { p_aout->format.i_format = VLC_CODEC_S16N; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } else if ( val.i_int == AOUT_VAR_MONO ) { p_aout->format.i_format = VLC_CODEC_S16N; p_aout->format.i_physical_channels = AOUT_CHAN_CENTER; } else { /* This should not happen ! */ msg_Err( p_aout, "internal: can't find audio-device (%"PRId64")", val.i_int ); goto error; } var_TriggerCallback( p_aout, "intf-change" ); /* Reset the DSP device */ if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 ) { msg_Err( p_aout, "cannot reset OSS audio device" ); goto error; } /* Set the output format */ if ( AOUT_FMT_SPDIF( &p_aout->format ) ) { int i_format = AFMT_AC3; if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 || i_format != AFMT_AC3 ) { msg_Err( p_aout, "cannot reset OSS audio device" ); goto error; } p_aout->format.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_frame_length = A52_FRAME_NB; aout_PacketInit( p_aout, &p_sys->packet, A52_FRAME_NB ); aout_VolumeNoneInit( p_aout ); } else { unsigned int i_format = AFMT_S16_NE; unsigned int i_frame_size, i_fragments; unsigned int i_rate; unsigned int i_nb_channels; audio_buf_info audio_buf; if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 ) { msg_Err( p_aout, "cannot set audio output format" ); goto error; } switch ( i_format ) { case AFMT_U8: p_aout->format.i_format = VLC_CODEC_U8; break; case AFMT_S8: p_aout->format.i_format = VLC_CODEC_S8; break; case AFMT_U16_LE: p_aout->format.i_format = VLC_CODEC_U16L; break; case AFMT_S16_LE: p_aout->format.i_format = VLC_CODEC_S16L; break; case AFMT_U16_BE: p_aout->format.i_format = VLC_CODEC_U16B; break; case AFMT_S16_BE: p_aout->format.i_format = VLC_CODEC_S16B; break; default: msg_Err( p_aout, "OSS fell back to an unknown format (%d)", i_format ); goto error; } i_nb_channels = aout_FormatNbChannels( &p_aout->format ); /* Set the number of channels */ if( ioctl( p_sys->i_fd, SNDCTL_DSP_CHANNELS, &i_nb_channels ) < 0 || i_nb_channels != aout_FormatNbChannels( &p_aout->format ) ) { msg_Err( p_aout, "cannot set number of audio channels (%s)", aout_FormatPrintChannels( &p_aout->format) ); goto error; } /* Set the output rate */ i_rate = p_aout->format.i_rate; if( ioctl( p_sys->i_fd, SNDCTL_DSP_SPEED, &i_rate ) < 0 ) { msg_Err( p_aout, "cannot set audio output rate (%i)", p_aout->format.i_rate ); goto error; } if( i_rate != p_aout->format.i_rate ) { p_aout->format.i_rate = i_rate; } /* Set the fragment size */ aout_FormatPrepare( &p_aout->format ); /* i_fragment = xxxxyyyy where: xxxx is fragtotal * 1 << yyyy is fragsize */ i_frame_size = ((uint64_t)p_aout->format.i_bytes_per_frame * p_aout->format.i_rate * 65536) / (48000 * 2 * 2) / FRAME_COUNT; i_fragments = 4; while( i_fragments < 12 && (1U << i_fragments) < i_frame_size ) { ++i_fragments; } i_fragments |= FRAME_COUNT << 16; if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFRAGMENT, &i_fragments ) < 0 ) { msg_Warn( p_aout, "cannot set fragment size (%.8x)", i_fragments ); } if( ioctl( p_sys->i_fd, SNDCTL_DSP_GETOSPACE, &audio_buf ) < 0 ) { msg_Err( p_aout, "cannot get fragment size" ); goto error; } /* Number of fragments actually allocated */ p_aout->sys->i_fragstotal = audio_buf.fragstotal; /* Maximum duration the soundcard's buffer can hold */ p_aout->sys->max_buffer_duration = (mtime_t)audio_buf.fragstotal * audio_buf.fragsize * 1000000 / p_aout->format.i_bytes_per_frame / p_aout->format.i_rate * p_aout->format.i_frame_length; aout_PacketInit( p_aout, &p_sys->packet, audio_buf.fragsize/p_aout->format.i_bytes_per_frame ); aout_VolumeSoftInit( p_aout ); } /* Create OSS thread and wait for its readiness. */ if( vlc_clone( &p_sys->thread, OSSThread, p_aout, VLC_THREAD_PRIORITY_OUTPUT ) ) { msg_Err( p_aout, "cannot create OSS thread (%m)" ); aout_PacketDestroy( p_aout ); goto error; } return VLC_SUCCESS; error: var_DelCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); close( p_sys->i_fd ); free( p_sys ); return VLC_EGENERIC; }
void InputManager::faster() { var_TriggerCallback( THEPL, "rate-faster" ); }
/** * Start the input for an item * * \param p_playlist the playlist object * \param p_item the item to play * \return nothing */ static int PlayItem( playlist_t *p_playlist, playlist_item_t *p_item ) { playlist_private_t *p_sys = pl_priv(p_playlist); input_item_t *p_input = p_item->p_input; PL_ASSERT_LOCKED; msg_Dbg( p_playlist, "creating new input thread" ); p_input->i_nb_played++; set_current_status_item( p_playlist, p_item ); p_sys->status.i_status = PLAYLIST_RUNNING; assert( p_sys->p_input == NULL ); input_thread_t *p_input_thread = input_Create( p_playlist, p_input, NULL, p_sys->p_input_resource ); if( p_input_thread ) { p_sys->p_input = p_input_thread; var_AddCallback( p_input_thread, "intf-event", InputEvent, p_playlist ); var_SetAddress( p_playlist, "input-current", p_input_thread ); if( input_Start( p_sys->p_input ) ) { vlc_object_release( p_input_thread ); p_sys->p_input = p_input_thread = NULL; } } bool b_find_art = var_GetInteger( p_playlist, "album-art" ) == ALBUM_ART_WHEN_PLAYED; if( b_find_art ) { char *psz_uri = input_item_GetURI( p_item->p_input ); if( psz_uri != NULL && (!strncmp( psz_uri, "directory:", 10 ) || !strncmp( psz_uri, "vlc:", 4 )) ) b_find_art = false; free( psz_uri ); } /* TODO store art policy in playlist private data */ if( b_find_art ) { char *psz_arturl = input_item_GetArtURL( p_input ); char *psz_name = input_item_GetName( p_input ); /* p_input->p_meta should not be null after a successful CreateThread */ bool b_has_art = !EMPTY_STR( psz_arturl ); if( !b_has_art || strncmp( psz_arturl, "attachment://", 13 ) ) { PL_DEBUG( "requesting art for %s", psz_name ); playlist_AskForArtEnqueue( p_playlist, p_input ); } free( psz_arturl ); free( psz_name ); } PL_UNLOCK; var_TriggerCallback( p_playlist, "activity" ); PL_LOCK; return VLC_SUCCESS; }