void sms_Free( sms_stream_t *sms ) { if( sms->qlevels ) { for( int n = 0; n < vlc_array_count( sms->qlevels ); n++ ) { quality_level_t *qlevel = (quality_level_t *)vlc_array_item_at_index( sms->qlevels, n ); // sunqueen modify if( qlevel ) ql_Free( qlevel ); } vlc_array_destroy( sms->qlevels ); } if( sms->chunks ) { for( int n = 0; n < vlc_array_count( sms->chunks ); n++ ) { chunk_t *chunk = (chunk_t *)vlc_array_item_at_index( sms->chunks, n ); // sunqueen modify if( chunk) chunk_Free( chunk ); } vlc_array_destroy( sms->chunks ); } free( sms->name ); free( sms->url_template ); free( sms ); sms = NULL; }
/***************************************************************************** * Close: *****************************************************************************/ static void Close(vlc_object_t *p_this) { fingerprinter_thread_t *p_fingerprinter = (fingerprinter_thread_t*) p_this; fingerprinter_sys_t *p_sys = p_fingerprinter->p_sys; vlc_cancel( p_sys->thread ); vlc_join( p_sys->thread, NULL ); vlc_mutex_destroy( &p_sys->condwait.lock ); vlc_cond_destroy( &p_sys->condwait.wait ); for ( int i = 0; i < vlc_array_count( p_sys->incoming.queue ); i++ ) fingerprint_request_Delete( vlc_array_item_at_index( p_sys->incoming.queue, i ) ); vlc_array_destroy( p_sys->incoming.queue ); vlc_mutex_destroy( &p_sys->incoming.lock ); vlc_cond_destroy( &p_sys->incoming_queue_filled ); for ( int i = 0; i < vlc_array_count( p_sys->processing.queue ); i++ ) fingerprint_request_Delete( vlc_array_item_at_index( p_sys->processing.queue, i ) ); vlc_array_destroy( p_sys->processing.queue ); vlc_mutex_destroy( &p_sys->processing.lock ); for ( int i = 0; i < vlc_array_count( p_sys->results.queue ); i++ ) fingerprint_request_Delete( vlc_array_item_at_index( p_sys->results.queue, i ) ); vlc_array_destroy( p_sys->results.queue ); vlc_mutex_destroy( &p_sys->results.lock ); free( p_sys ); }
int stream_extractor_AttachParsed( stream_t** source, char const* data, char const** out_extra ) { vlc_array_t identifiers; if( mrl_FragmentSplit( &identifiers, out_extra, data ) ) return VLC_EGENERIC; size_t count = vlc_array_count( &identifiers ); size_t idx = 0; while( idx < count ) { char* id = vlc_array_item_at_index( &identifiers, idx ); if( vlc_stream_extractor_Attach( source, id, NULL ) ) break; ++idx; } for( size_t i = 0; i < count; ++i ) free( vlc_array_item_at_index( &identifiers, i ) ); vlc_array_clear( &identifiers ); return idx == count ? VLC_SUCCESS : VLC_EGENERIC; }
/************************************************************************** * libvlc_event_detach (public) : * * Remove a callback for an event. **************************************************************************/ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager, libvlc_event_type_t event_type, libvlc_callback_t pf_callback, void *p_user_data ) { libvlc_event_listeners_group_t * listeners_group; libvlc_event_listener_t * listener; int i, j; bool found = false; vlc_mutex_lock( &p_event_manager->event_sending_lock ); vlc_mutex_lock( &p_event_manager->object_lock ); for( i = 0; i < vlc_array_count(&p_event_manager->listeners_groups); i++) { listeners_group = vlc_array_item_at_index(&p_event_manager->listeners_groups, i); if( listeners_group->event_type == event_type ) { for( j = 0; j < vlc_array_count(&listeners_group->listeners); j++) { listener = vlc_array_item_at_index(&listeners_group->listeners, j); if( listener->event_type == event_type && listener->pf_callback == pf_callback && listener->p_user_data == p_user_data ) { /* that's our listener */ /* Mark this group as edited so that libvlc_event_send * will recheck what listener to call */ listeners_group->b_sublistener_removed = true; free( listener ); vlc_array_remove( &listeners_group->listeners, j ); found = true; break; } } } } vlc_mutex_unlock( &p_event_manager->object_lock ); vlc_mutex_unlock( &p_event_manager->event_sending_lock ); /* Now make sure any pending async event won't get fired after that point */ libvlc_event_listener_t listener_to_remove; listener_to_remove.event_type = event_type; listener_to_remove.pf_callback = pf_callback; listener_to_remove.p_user_data = p_user_data; listener_to_remove.is_asynchronous = true; libvlc_event_async_ensure_listener_removal(p_event_manager, &listener_to_remove); assert(found); }
static void BackgroundWorkerCancel( struct background_worker* worker, void* id) { vlc_mutex_lock( &worker->lock ); for( size_t i = 0; i < vlc_array_count( &worker->tail.data ); ) { struct bg_queued_item* item = vlc_array_item_at_index( &worker->tail.data, i ); if( id == NULL || item->id == id ) { vlc_array_remove( &worker->tail.data, i ); worker->conf.pf_release( item->entity ); free( item ); continue; } ++i; } while( ( id == NULL && worker->head.active ) || ( id != NULL && worker->head.id == id ) ) { worker->head.deadline = VLC_TS_0; vlc_cond_signal( &worker->head.worker_wait ); vlc_cond_signal( &worker->tail.wait ); vlc_cond_wait( &worker->head.wait, &worker->lock ); } vlc_mutex_unlock( &worker->lock ); }
/** * @brief Remove a directory to monitor * @param p_ml A media library object * @param psz_dir the directory to remove * @return VLC_SUCCESS or VLC_EGENERIC */ int RemoveDirToMonitor( media_library_t *p_ml, const char *psz_dir ) { assert( p_ml ); char **pp_results = NULL; int i_cols = 0, i_rows = 0, i_ret = VLC_SUCCESS; int i; bool b_recursive = var_CreateGetBool( p_ml, "ml-recursive-scan" ); if( b_recursive ) { i_ret = Query( p_ml, &pp_results, &i_rows, &i_cols, "SELECT media.id FROM media JOIN directories ON " "(media.directory_id = directories.id) WHERE " "directories.uri LIKE '%q%%'", psz_dir ); if( i_ret != VLC_SUCCESS ) { msg_Err( p_ml, "Error occured while making a query to the database" ); return i_ret; } QuerySimple( p_ml, "DELETE FROM directories WHERE uri LIKE '%q%%'", psz_dir ); } else { i_ret = Query( p_ml, &pp_results, &i_rows, &i_cols, "SELECT media.id FROM media JOIN directories ON " "(media.directory_id = directories.id) WHERE " "directories.uri = %Q", psz_dir ); if( i_ret != VLC_SUCCESS ) { msg_Err( p_ml, "Error occured while making a query to the database" ); return i_ret; } QuerySimple( p_ml, "DELETE FROM directories WHERE uri = %Q", psz_dir ); } vlc_array_t *p_where = vlc_array_new(); for( i = 1; i <= i_rows; i++ ) { int id = atoi( pp_results[i*i_cols] ); ml_element_t* p_find = ( ml_element_t * ) calloc( 1, sizeof( ml_element_t ) ); p_find->criteria = ML_ID; p_find->value.i = id; vlc_array_append( p_where, p_find ); } Delete( p_ml, p_where ); FreeSQLResult( p_ml, pp_results ); for( i = 0; i < vlc_array_count( p_where ); i++ ) { free( vlc_array_item_at_index( p_where, i ) ); } vlc_array_destroy( p_where ); return VLC_SUCCESS; }
void bdsm_SdClose (vlc_object_t *p_this) { services_discovery_t *sd = (services_discovery_t *)p_this; services_discovery_sys_t *p_sys = sd->p_sys; if( p_sys == NULL ) return; if( p_sys->p_ns ) { netbios_ns_discover_stop( p_sys->p_ns ); netbios_ns_destroy( p_sys->p_ns ); } if( p_sys->p_entry_item_list ) { for ( int i = 0; i < vlc_array_count( p_sys->p_entry_item_list ); i++ ) { struct entry_item *p_entry_item; p_entry_item = vlc_array_item_at_index( p_sys->p_entry_item_list, i ); vlc_gc_decref( p_entry_item->p_item ); free( p_entry_item ); } vlc_array_destroy( p_sys->p_entry_item_list ); } free( p_sys ); }
/** * Computes the time until the next timeout expiration. * @note Interface lock must be held. * @return The time in milliseconds until the next expiration, * or -1 if there are no pending timeouts. */ static int next_timeout(intf_thread_t *intf) { intf_sys_t *sys = intf->p_sys; mtime_t next_timeout = LAST_MDATE; unsigned count = vlc_array_count(sys->p_timeouts); for (unsigned i = 0; i < count; i++) { DBusTimeout *to = vlc_array_item_at_index(sys->p_timeouts, i); if (!dbus_timeout_get_enabled(to)) continue; mtime_t *expiry = dbus_timeout_get_data(to); if (next_timeout > *expiry) next_timeout = *expiry; } if (next_timeout >= LAST_MDATE) return -1; next_timeout /= 1000; if (next_timeout > INT_MAX) return INT_MAX; return (int)next_timeout; }
static void Close ( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t*) p_this; playlist_t *p_playlist = pl_Hold( p_intf );; input_thread_t *p_input; var_DelCallback( p_playlist, "item-current", AllCallback, p_intf ); var_DelCallback( p_playlist, "intf-change", AllCallback, p_intf ); var_DelCallback( p_playlist, "playlist-item-append", AllCallback, p_intf ); var_DelCallback( p_playlist, "playlist-item-deleted", AllCallback, p_intf ); var_DelCallback( p_playlist, "random", AllCallback, p_intf ); var_DelCallback( p_playlist, "repeat", AllCallback, p_intf ); var_DelCallback( p_playlist, "loop", AllCallback, p_intf ); p_input = playlist_CurrentInput( p_playlist ); if ( p_input ) { var_DelCallback( p_input, "state", AllCallback, p_intf ); vlc_object_release( p_input ); } pl_Release( p_intf ); dbus_connection_unref( p_intf->p_sys->p_conn ); // Free the events array for( int i = 0; i < vlc_array_count( p_intf->p_sys->p_events ); i++ ) { callback_info_t* info = vlc_array_item_at_index( p_intf->p_sys->p_events, i ); free( info ); } vlc_mutex_destroy( &p_intf->p_sys->lock ); vlc_array_destroy( p_intf->p_sys->p_events ); free( p_intf->p_sys ); }
/** * @brief Insert all medias from a result array to the model * @param p_result_array the medias to append * @return see insertMedia * @note if bSignal==true, then it signals only once * not media or NULL items are skipped */ int MLModel::insertResultArray( vlc_array_t *p_result_array, int row, bool bSignal ) { int i_ok = VLC_SUCCESS; int count = vlc_array_count( p_result_array ); if( !count ) return i_ok; if( row == -1 ) row = rowCount(); // Signal Qt that we will insert rows if( bSignal ) beginInsertRows( createIndex( -1, -1 ), row, row + count-1 ); // Loop and insert for( int i = 0; i < count; ++i ) { ml_result_t *p_result = (ml_result_t*) vlc_array_item_at_index( p_result_array, i ); if( !p_result || p_result->type != ML_TYPE_MEDIA ) continue; i_ok = insertMedia( p_result->value.p_media, row + i, false ); if( i_ok != VLC_SUCCESS ) break; } // Signal we're done if( bSignal ) endInsertRows(); return i_ok; }
/** * GetPollFds() fills an array of pollfd data structures with : * - the set of enabled dbus watches * - the unix pipe which we use to manually wake up the main loop * * This function must be called with p_sys->lock locked * * @return The number of file descriptors * * @param intf_thread_t *p_intf this interface thread's state * @param struct pollfd *p_fds a pointer to a pollfd array large enough to * contain all the returned data (number of enabled dbus watches + 1) */ static int GetPollFds( intf_thread_t *p_intf, struct pollfd *p_fds ) { intf_sys_t *p_sys = p_intf->p_sys; int i_fds = 1, i_watches = vlc_array_count( p_sys->p_watches ); p_fds[0].fd = p_sys->p_pipe_fds[PIPE_OUT]; p_fds[0].events = POLLIN | POLLPRI; for( int i = 0; i < i_watches; i++ ) { DBusWatch *p_watch = NULL; p_watch = vlc_array_item_at_index( p_sys->p_watches, i ); if( !dbus_watch_get_enabled( p_watch ) ) continue; p_fds[i_fds].fd = dbus_watch_get_unix_fd( p_watch ); int i_flags = dbus_watch_get_flags( p_watch ); if( i_flags & DBUS_WATCH_READABLE ) p_fds[i_fds].events |= POLLIN | POLLPRI; if( i_flags & DBUS_WATCH_WRITABLE ) p_fds[i_fds].events |= POLLOUT; i_fds++; } return i_fds; }
/** * UpdateTimeouts() updates the remaining time for each timeout and * returns how much time is left until the next timeout. * * This function must be called with p_sys->lock locked * * @return int The time remaining until the next timeout, in milliseconds * or -1 if there are no timeouts * * @param intf_thread_t *p_intf This interface thread's state * @param mtime_t i_loop_interval The time which has elapsed since the last * call to this function */ static int UpdateTimeouts( intf_thread_t *p_intf, mtime_t i_loop_interval ) { intf_sys_t *p_sys = p_intf->p_sys; mtime_t i_next_timeout = LAST_MDATE; unsigned int i_timeouts = vlc_array_count( p_sys->p_timeouts ); if( 0 == i_timeouts ) return -1; for( unsigned int i = 0; i < i_timeouts; i++ ) { timeout_info_t *p_info = NULL; DBusTimeout *p_timeout = NULL; mtime_t i_interval = 0; p_timeout = vlc_array_item_at_index( p_sys->p_timeouts, i ); i_interval = dbus_timeout_get_interval( p_timeout ) * 1000; /* µs */ p_info = (timeout_info_t*) dbus_timeout_get_data( p_timeout ); p_info->i_remaining -= __MAX( 0, i_loop_interval ) % i_interval; if( !dbus_timeout_get_enabled( p_timeout ) ) continue; /* The correct poll timeout value is the shortest one * in the dbus timeouts list */ i_next_timeout = __MIN( i_next_timeout, __MAX( 0, p_info->i_remaining ) ); } /* next timeout in milliseconds */ return i_next_timeout / 1000; }
/** * @brief Insert all medias from an array to the model * @param p_media_array the medias to append * @return see insertMedia * @note if bSignal==true, then it signals only once */ int MLModel::insertMediaArray( vlc_array_t *p_media_array, int row, bool bSignal ) { int i_ok = VLC_SUCCESS; int count = vlc_array_count( p_media_array ); if( !count ) return i_ok; if( row == -1 ) row = rowCount(); // Signal Qt that we will insert rows if( bSignal ) beginInsertRows( createIndex( -1, -1 ), row, row + count-1 ); // Loop for( int i = 0; i < count; ++i ) { i_ok = insertMedia( (ml_media_t*) vlc_array_item_at_index( p_media_array, i ), row + i, false ); if( i_ok != VLC_SUCCESS ) break; } if( bSignal ) endInsertRows(); return i_ok; }
char *vlc_http_cookies_fetch(vlc_http_cookie_jar_t *p_jar, bool secure, const char *host, const char *path) { int i; char *psz_cookiebuf = NULL; vlc_mutex_lock( &p_jar->lock ); for( i = 0; i < vlc_array_count( &p_jar->cookies ); i++ ) { const http_cookie_t * cookie = vlc_array_item_at_index( &p_jar->cookies, i ); if (cookie_should_be_sent(cookie, secure, host, path)) { char *psz_updated_buf = NULL; if ( asprintf(&psz_updated_buf, "%s%s%s=%s", psz_cookiebuf ? psz_cookiebuf : "", psz_cookiebuf ? "; " : "", cookie->psz_name ? cookie->psz_name : "", cookie->psz_value ? cookie->psz_value : "") == -1 ) { // TODO: report error free( psz_cookiebuf ); vlc_mutex_unlock( &p_jar->lock ); return NULL; } free( psz_cookiebuf ); psz_cookiebuf = psz_updated_buf; } } vlc_mutex_unlock( &p_jar->lock ); return psz_cookiebuf; }
/************************************************************************** * libvlc_media_list_release (Public) * * Release an object. **************************************************************************/ void libvlc_media_list_release( libvlc_media_list_t * p_mlist ) { libvlc_media_t * p_md; int i; vlc_mutex_lock( &p_mlist->refcount_lock ); p_mlist->i_refcount--; if( p_mlist->i_refcount > 0 ) { vlc_mutex_unlock( &p_mlist->refcount_lock ); return; } vlc_mutex_unlock( &p_mlist->refcount_lock ); /* Refcount null, time to free */ libvlc_event_manager_release( p_mlist->p_event_manager ); libvlc_media_release( p_mlist->p_md ); for ( i = 0; i < vlc_array_count( &p_mlist->items ); i++ ) { p_md = vlc_array_item_at_index( &p_mlist->items, i ); libvlc_media_release( p_md ); } vlc_mutex_destroy( &p_mlist->object_lock ); vlc_array_clear( &p_mlist->items ); free( p_mlist ); }
static void Run ( intf_thread_t *p_intf ) { for( ;; ) { if( dbus_connection_get_dispatch_status(p_intf->p_sys->p_conn) == DBUS_DISPATCH_COMPLETE ) msleep( INTF_IDLE_SLEEP ); int canc = vlc_savecancel(); dbus_connection_read_write_dispatch( p_intf->p_sys->p_conn, 0 ); /* Get the list of events to process * * We can't keep the lock on p_intf->p_sys->p_events, else we risk a * deadlock: * The signal functions could lock mutex X while p_events is locked; * While some other function in vlc (playlist) might lock mutex X * and then set a variable which would call AllCallback(), which itself * needs to lock p_events to add a new event. */ vlc_mutex_lock( &p_intf->p_sys->lock ); int i_events = vlc_array_count( p_intf->p_sys->p_events ); callback_info_t* info[i_events]; for( int i = i_events - 1; i >= 0; i-- ) { info[i] = vlc_array_item_at_index( p_intf->p_sys->p_events, i ); vlc_array_remove( p_intf->p_sys->p_events, i ); } vlc_mutex_unlock( &p_intf->p_sys->lock ); for( int i = 0; i < i_events; i++ ) { switch( info[i]->signal ) { case SIGNAL_ITEM_CURRENT: TrackChange( p_intf ); break; case SIGNAL_INTF_CHANGE: case SIGNAL_PLAYLIST_ITEM_APPEND: case SIGNAL_PLAYLIST_ITEM_DELETED: TrackListChangeEmit( p_intf, info[i]->signal, info[i]->i_node ); break; case SIGNAL_RANDOM: case SIGNAL_REPEAT: case SIGNAL_LOOP: StatusChangeEmit( p_intf ); break; case SIGNAL_STATE: StateChange( p_intf, info[i]->i_input_state ); break; default: assert(0); } free( info[i] ); } vlc_restorecancel( canc ); } }
static void CleanSys( fingerprinter_sys_t *p_sys ) { for ( size_t i = 0; i < vlc_array_count( &p_sys->incoming.queue ); i++ ) fingerprint_request_Delete( vlc_array_item_at_index( &p_sys->incoming.queue, i ) ); vlc_array_clear( &p_sys->incoming.queue ); vlc_mutex_destroy( &p_sys->incoming.lock ); for ( size_t i = 0; i < vlc_array_count( &p_sys->processing.queue ); i++ ) fingerprint_request_Delete( vlc_array_item_at_index( &p_sys->processing.queue, i ) ); vlc_array_clear( &p_sys->processing.queue ); vlc_mutex_destroy( &p_sys->processing.lock ); vlc_cond_destroy( &p_sys->processing.cond ); for ( size_t i = 0; i < vlc_array_count( &p_sys->results.queue ); i++ ) fingerprint_request_Delete( vlc_array_item_at_index( &p_sys->results.queue, i ) ); vlc_array_clear( &p_sys->results.queue ); vlc_mutex_destroy( &p_sys->results.lock ); }
void libvlc_event_manager_destroy(libvlc_event_manager_t *em) { vlc_mutex_destroy(&em->lock); for (size_t i = 0; i < vlc_array_count(&em->listeners); i++) free(vlc_array_item_at_index(&em->listeners, i)); vlc_array_clear(&em->listeners); }
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 } }
static void dialog_clear_all_locked(vlc_dialog_provider *p_provider) { for (size_t i = 0; i < vlc_array_count(&p_provider->dialog_array); ++i) { vlc_dialog_id *p_id = vlc_array_item_at_index(&p_provider->dialog_array, i); dialog_cancel_locked(p_provider, p_id); } }
static void Close( vlc_object_t *p_this ) { stream_t *s = (stream_t*)p_this; stream_sys_t *p_sys = s->p_sys; vlc_mutex_lock( &p_sys->download.lock_wait ); p_sys->b_close = true; /* Negate the condition variable's predicate */ for( int i = 0; i < 3; i++ ) p_sys->download.lead[i] = 0; p_sys->playback.toffset = 0; vlc_cond_signal(&p_sys->download.wait); vlc_mutex_unlock( &p_sys->download.lock_wait ); vlc_join( p_sys->thread, NULL ); vlc_mutex_destroy( &p_sys->download.lock_wait ); vlc_cond_destroy( &p_sys->download.wait ); /* Free sms streams */ sms_stream_t *sms; for( int i = 0; i < vlc_array_count( p_sys->sms_streams ); i++ ) { sms = vlc_array_item_at_index( p_sys->sms_streams, i ); if( sms ) sms_Free( sms ); } /* Free downloaded chunks */ chunk_t *chunk; for( int i = 0; i < vlc_array_count( p_sys->init_chunks ); i++ ) { chunk = vlc_array_item_at_index( p_sys->init_chunks, i ); chunk_Free( chunk ); } sms_queue_free( p_sys->bws ); vlc_array_destroy( p_sys->sms_streams ); vlc_array_destroy( p_sys->selected_st ); vlc_array_destroy( p_sys->download.chunks ); vlc_array_destroy( p_sys->init_chunks ); free( p_sys->base_url ); free( p_sys ); }
/************************************************************************** * libvlc_event_manager_release (internal) : * * Release an object's event manager. **************************************************************************/ void libvlc_event_manager_release( libvlc_event_manager_t * p_em ) { vlc_mutex_destroy(&p_em->lock); for (int i = 0; i < vlc_array_count(&p_em->listeners); i++) free(vlc_array_item_at_index(&p_em->listeners, i)); vlc_array_clear(&p_em->listeners); free( p_em ); }
/************************************************************************** * flat_media_list_view_item_at_index (private) * (called by flat_media_list_view_item_at_index) **************************************************************************/ static libvlc_media_t * flat_media_list_view_item_at_index( libvlc_media_list_view_t * p_mlv, int index, libvlc_exception_t * p_e ) { libvlc_media_t * p_md; (void)p_e; p_md = vlc_array_item_at_index( &p_mlv->p_this_view_data->array, index ); libvlc_media_retain( p_md ); return p_md; }
static void ApplyResult( fingerprint_request_t *p_r, size_t i_resultid ) { if ( i_resultid >= vlc_array_count( & p_r->results.metas_array ) ) return; vlc_meta_t *p_meta = (vlc_meta_t *) vlc_array_item_at_index( & p_r->results.metas_array, i_resultid ); input_item_t *p_item = p_r->p_item; vlc_mutex_lock( &p_item->lock ); vlc_meta_Merge( p_item->p_meta, p_meta ); vlc_mutex_unlock( &p_item->lock ); }
static void QueueIncomingRequests( fingerprinter_sys_t *p_sys ) { vlc_mutex_lock( &p_sys->incoming.lock ); size_t i = vlc_array_count( &p_sys->incoming.queue ); while( i ) vlc_array_append( &p_sys->processing.queue, vlc_array_item_at_index( &p_sys->incoming.queue, --i ) ); vlc_array_clear( &p_sys->incoming.queue ); vlc_mutex_unlock(&p_sys->incoming.lock); }
quality_level_t *get_qlevel( sms_stream_t *sms, const unsigned qid ) { quality_level_t *qlevel = NULL; for( unsigned i = 0; i < sms->qlevel_nb; i++ ) { qlevel = (quality_level_t *)vlc_array_item_at_index( sms->qlevels, i ); // sunqueen modify if( qlevel->id == qid ) return qlevel; } return NULL; }
static bool group_contains_listener( libvlc_event_listeners_group_t * group, libvlc_event_listener_t * searched_listener ) { int i; for( i = 0; i < vlc_array_count(&group->listeners); i++ ) { if( listeners_are_equal(searched_listener, vlc_array_item_at_index(&group->listeners, i)) ) return true; } return false; }
static fingerprint_request_t * GetResult( fingerprinter_thread_t *f ) { fingerprint_request_t *r = NULL; fingerprinter_sys_t *p_sys = f->p_sys; vlc_mutex_lock( &p_sys->results.lock ); if ( vlc_array_count( &p_sys->results.queue ) ) { r = vlc_array_item_at_index( &p_sys->results.queue, 0 ); vlc_array_remove( &p_sys->results.queue, 0 ); } vlc_mutex_unlock( &p_sys->results.lock ); return r; }
bool no_more_chunks( unsigned *indexes, vlc_array_t *streams ) { sms_stream_t *sms = NULL; int count = vlc_array_count( streams ); unsigned ck_index; for( int i = 0; i < count; i++ ) { sms = (sms_stream_t *)vlc_array_item_at_index( streams, i ); // sunqueen modify ck_index = indexes[es_cat_to_index( sms->type )]; if( ck_index < sms->vod_chunks_nb - 1 ) return false; } return true; }
/************************************************************************** * libvlc_media_list_index_of_item (Public) * * Lock should be held when entering. * Warning: this function returns the first matching item. **************************************************************************/ int libvlc_media_list_index_of_item( libvlc_media_list_t * p_mlist, libvlc_media_t * p_searched_md ) { libvlc_media_t * p_md; int i; for ( i = 0; i < vlc_array_count( &p_mlist->items ); i++ ) { p_md = vlc_array_item_at_index( &p_mlist->items, i ); if( p_searched_md == p_md ) return i; } libvlc_printerr( "Media not found" ); return -1; }