Commit 331299dc authored by Felix Abecassis's avatar Felix Abecassis Committed by Rémi Denis-Courmont

Remove the deprecated vlc_atomic_t type.

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 418241e3
......@@ -387,65 +387,17 @@ typedef uintmax_t atomic_uintmax_t;
# endif
# endif
/**
* Memory storage space for an atom. Never access it directly.
*/
typedef union
{
atomic_uintptr_t u;
} vlc_atomic_t;
/** Static initializer for \ref vlc_atomic_t */
# define VLC_ATOMIC_INIT(val) { (val) }
/* All functions return the atom value _after_ the operation. */
static inline uintptr_t vlc_atomic_get(vlc_atomic_t *atom)
{
return atomic_load(&atom->u);
}
static inline uintptr_t vlc_atomic_set(vlc_atomic_t *atom, uintptr_t v)
{
atomic_store(&atom->u, v);
return v;
}
static inline uintptr_t vlc_atomic_add(vlc_atomic_t *atom, uintptr_t v)
{
return atomic_fetch_add(&atom->u, v) + v;
}
static inline uintptr_t vlc_atomic_sub (vlc_atomic_t *atom, uintptr_t v)
{
return atomic_fetch_sub (&atom->u, v) - v;
}
static inline uintptr_t vlc_atomic_inc (vlc_atomic_t *atom)
{
return vlc_atomic_add (atom, 1);
}
static inline uintptr_t vlc_atomic_dec (vlc_atomic_t *atom)
{
return vlc_atomic_sub (atom, 1);
}
static inline uintptr_t vlc_atomic_swap(vlc_atomic_t *atom, uintptr_t v)
{
return atomic_exchange(&atom->u, v);
}
typedef atomic_uint_least32_t vlc_atomic_float;
static inline uintptr_t vlc_atomic_compare_swap(vlc_atomic_t *atom,
uintptr_t u, uintptr_t v)
static inline void vlc_atomic_init_float(vlc_atomic_float *var, float f)
{
atomic_compare_exchange_strong(&atom->u, &u, v);
return u;
union { float f; uint32_t i; } u;
u.f = f;
atomic_init(var, u.i);
}
typedef atomic_uint_least32_t vlc_atomic_float;
/** Helper to retrieve a single precision from an atom. */
static inline float vlc_atomic_loadf(vlc_atomic_float *atom)
static inline float vlc_atomic_load_float(vlc_atomic_float *atom)
{
union { float f; uint32_t i; } u;
u.i = atomic_load(atom);
......@@ -453,7 +405,7 @@ static inline float vlc_atomic_loadf(vlc_atomic_float *atom)
}
/** Helper to store a single precision into an atom. */
static inline void vlc_atomic_storef(vlc_atomic_float *atom, float f)
static inline void vlc_atomic_store_float(vlc_atomic_float *atom, float f)
{
union { float f; uint32_t i; } u;
u.f = f;
......
......@@ -154,19 +154,19 @@ class DeckLinkCaptureDelegate : public IDeckLinkInputCallback
public:
DeckLinkCaptureDelegate(demux_t *demux) : demux_(demux)
{
vlc_atomic_set(&m_ref_, 1);
atomic_store(&m_ref, 1);
}
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID *) { return E_NOINTERFACE; }
virtual ULONG STDMETHODCALLTYPE AddRef(void)
{
return vlc_atomic_inc(&m_ref_);
return atomic_fetch_add(&m_ref, 1);
}
virtual ULONG STDMETHODCALLTYPE Release(void)
{
uintptr_t new_ref = vlc_atomic_dec(&m_ref_);
uintptr_t new_ref = atomic_fetch_sub(&m_ref_, 1);
if (new_ref == 0)
delete this;
return new_ref;
......@@ -181,7 +181,7 @@ public:
virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*);
private:
vlc_atomic_t m_ref_;
atomic_uint m_ref_;
demux_t *demux_;
};
......
......@@ -143,7 +143,7 @@ MessagesDialog::~MessagesDialog()
void MessagesDialog::changeVerbosity( int i_verbosity )
{
vlc_atomic_set( &this->verbosity, i_verbosity );
atomic_store( &this->verbosity, i_verbosity );
}
void MessagesDialog::updateConfig()
......@@ -337,7 +337,7 @@ void MessagesDialog::MsgCallback( void *self, int type, const vlc_log_t *item,
{
MessagesDialog *dialog = (MessagesDialog *)self;
char *str;
int verbosity = vlc_atomic_get( &dialog->verbosity );
int verbosity = atomic_load( &dialog->verbosity );
if( verbosity < 0 || verbosity < (type - VLC_MSG_ERR)
|| unlikely(vasprintf( &str, format, ap ) == -1) )
......
......@@ -55,7 +55,7 @@ private:
void sinkMessage( const MsgEvent * );
bool matchFilter( const QString& );
vlc_atomic_t verbosity;
atomic_uint verbosity;
static void MsgCallback( void *, int, const vlc_log_t *, const char *,
va_list );
......
......@@ -33,36 +33,12 @@
struct filter_sys_t
{
atomic_uint_fast32_t brightness;
atomic_uint_fast32_t contrast;
atomic_uint_fast32_t saturation;
atomic_uint_fast32_t hue;
vlc_atomic_float brightness;
vlc_atomic_float contrast;
vlc_atomic_float saturation;
vlc_atomic_float hue;
};
static inline void vlc_atomic_init_float(atomic_uint_fast32_t *var, float val)
{
union { uint32_t u; float f; } u;
u.f = val;
atomic_init(var, u.u);
}
static inline void vlc_atomic_store_float(atomic_uint_fast32_t *var, float val)
{
union { uint32_t u; float f; } u;
u.f = val;
atomic_store(var, u.u);
}
static inline float vlc_atomic_load_float(atomic_uint_fast32_t *var)
{
union { uint32_t u; float f; } u;
u.u = atomic_load(var);
return u.f;
}
static float vlc_to_vdp_brightness(float brightness)
{
brightness -= 1.f;
......
......@@ -703,7 +703,7 @@ typedef struct
{
filter_t *p_filter;
vlc_thread_t thread;
vlc_atomic_t abort;
atomic_bool abort;
/* tell the thread which color should be the target of fading */
uint8_t ui_red;
......@@ -1120,7 +1120,7 @@ static void Atmo_Shutdown(filter_t *p_filter)
p_sys->p_fadethread->i_steps = 1;
else
p_sys->p_fadethread->i_steps = p_sys->i_endfadesteps;
vlc_atomic_set(&p_sys->p_fadethread->abort, 0);
atomic_store(&p_sys->p_fadethread->abort, false);
if( vlc_clone( &p_sys->p_fadethread->thread,
FadeToColorThread,
......@@ -2390,7 +2390,7 @@ static void *FadeToColorThread(void *obj)
/* send the same pixel data again... to unlock the buffer! */
AtmoSendPixelData( p_fadethread->p_filter );
while( (!vlc_atomic_get (&p_fadethread->abort)) &&
while( (!atomic_load (&p_fadethread->abort)) &&
(i_steps_done < p_fadethread->i_steps))
{
p_transfer = AtmoLockTransferBuffer( p_fadethread->p_filter );
......@@ -2403,7 +2403,7 @@ static void *FadeToColorThread(void *obj)
thread improvements wellcome!
*/
for(i_index = 0;
(i_index < i_size) && (!vlc_atomic_get (&p_fadethread->abort));
(i_index < i_size) && (!atomic_load (&p_fadethread->abort));
i_index+=4)
{
i_src_blue = p_source[i_index+0];
......@@ -2459,7 +2459,7 @@ static void CheckAndStopFadeThread(filter_t *p_filter)
{
msg_Dbg(p_filter, "kill still running fadeing thread...");
vlc_atomic_set(&p_sys->p_fadethread->abort, 1);
atomic_store(&p_sys->p_fadethread->abort, true);
vlc_join(p_sys->p_fadethread->thread, NULL);
free(p_sys->p_fadethread);
......@@ -2507,7 +2507,7 @@ static int StateCallback( vlc_object_t *, char const *,
p_sys->p_fadethread->ui_green = p_sys->ui_pausecolor_green;
p_sys->p_fadethread->ui_blue = p_sys->ui_pausecolor_blue;
p_sys->p_fadethread->i_steps = p_sys->i_fadesteps;
vlc_atomic_set(&p_sys->p_fadethread->abort, 0);
atomic_store(&p_sys->p_fadethread->abort, false);
if( vlc_clone( &p_sys->p_fadethread->thread,
FadeToColorThread,
......
......@@ -170,7 +170,7 @@ struct vlc_thread
void *(*entry)(void*);
void *data;
vlc_atomic_t killed;
atomic_bool killed;
bool killable;
};
......@@ -374,7 +374,7 @@ static int vlc_clone_attr (vlc_thread_t *th, void *(*entry) (void *),
vlc_sem_init(&thread->finished, 0);
vlc_atomic_set(&thread->killed, false);
atomic_store(&thread->killed, false);
thread->killable = true;
thread->cond = NULL;
thread->entry = entry;
......@@ -434,7 +434,7 @@ void vlc_cancel (vlc_thread_t thread_id)
{
pthread_cond_t *cond;
vlc_atomic_set(&thread_id->killed, true);
atomic_store(&thread_id->killed, true);
vlc_mutex_lock(&thread_id->lock);
cond = thread_id->cond;
......@@ -467,7 +467,7 @@ void vlc_testcancel (void)
return;
if (!thread->killable)
return;
if (!vlc_atomic_get(&thread->killed))
if (!atomic_load(&thread->killed))
return;
pthread_exit(NULL);
......
......@@ -135,7 +135,7 @@ int aout_volume_Amplify(aout_volume_t *vol, block_t *block)
return -1;
float amp = vol->output_factor
* vlc_atomic_loadf (&vol->gain_factor);
* vlc_atomic_load_float (&vol->gain_factor);
vol->object.amplify(&vol->object, block, amp);
return 0;
......@@ -197,7 +197,7 @@ static int ReplayGainCallback (vlc_object_t *obj, char const *var,
aout_volume_t *vol = data;
float multiplier = aout_ReplayGainSelect(obj, val.psz_string,
&vol->replay_gain);
vlc_atomic_storef (&vol->gain_factor, multiplier);
vlc_atomic_store_float (&vol->gain_factor, multiplier);
VLC_UNUSED(var); VLC_UNUSED(oldval);
return VLC_SUCCESS;
}
......@@ -141,7 +141,7 @@ void update_Delete( update_t *p_update )
if( p_update->p_download )
{
vlc_atomic_set( &p_update->p_download->aborted, 1 );
atomic_store( &p_update->p_download->aborted, true );
vlc_join( p_update->p_download->thread, NULL );
vlc_object_release( p_update->p_download );
}
......@@ -494,7 +494,7 @@ void update_Download( update_t *p_update, const char *psz_destdir )
// If the object already exist, destroy it
if( p_update->p_download )
{
vlc_atomic_set( &p_update->p_download->aborted, 1 );
atomic_store( &p_update->p_download->aborted, true );
vlc_join( p_update->p_download->thread, NULL );
vlc_object_release( p_update->p_download );
}
......@@ -509,7 +509,7 @@ void update_Download( update_t *p_update, const char *psz_destdir )
p_update->p_download = p_udt;
p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
vlc_atomic_set(&p_udt->aborted, 0);
atomic_store(&p_udt->aborted, false);
vlc_clone( &p_udt->thread, update_DownloadReal, p_udt, VLC_THREAD_PRIORITY_LOW );
}
......@@ -590,7 +590,7 @@ static void* update_DownloadReal( void *obj )
if( p_progress == NULL )
goto end;
while( !vlc_atomic_get( &p_udt->aborted ) &&
while( !atomic_load( &p_udt->aborted ) &&
( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
!dialog_ProgressCancelled( p_progress ) )
{
......@@ -618,7 +618,7 @@ static void* update_DownloadReal( void *obj )
fclose( p_file );
p_file = NULL;
if( !vlc_atomic_get( &p_udt->aborted ) &&
if( !atomic_load( &p_udt->aborted ) &&
!dialog_ProgressCancelled( p_progress ) )
{
dialog_ProgressDestroy( p_progress );
......
......@@ -153,7 +153,7 @@ typedef struct
VLC_COMMON_MEMBERS
vlc_thread_t thread;
vlc_atomic_t aborted;
atomic_bool aborted;
update_t *p_update;
char *psz_destdir;
} update_download_thread_t;
......
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