summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-11-10 20:33:29 -0800
committerVito Caputo <vcaputo@pengaru.com>2020-11-11 23:55:52 -0800
commit72a0ce71285034853c1720b738db348fdcec5228 (patch)
treea0a368319fad24d6757d7af458b8884f07c5f0f8
parent371ad8abf4494837a77ab6c443c0d534652e3dbd (diff)
*: add _us suffixes to {frame,period}time names
Make the names reflect their units of microseconds
-rw-r--r--src/rmd_capture_audio.c4
-rw-r--r--src/rmd_encode_audio_buffer.c2
-rw-r--r--src/rmd_encode_image_buffer.c2
-rw-r--r--src/rmd_initialize_data.c8
-rw-r--r--src/rmd_opendev.c6
-rw-r--r--src/rmd_opendev.h4
-rw-r--r--src/rmd_rescue.c2
-rw-r--r--src/rmd_timer.c10
-rw-r--r--src/rmd_types.h4
9 files changed, 21 insertions, 21 deletions
diff --git a/src/rmd_capture_audio.c b/src/rmd_capture_audio.c
index bfba547..f9f2ddb 100644
--- a/src/rmd_capture_audio.c
+++ b/src/rmd_capture_audio.c
@@ -51,7 +51,7 @@ void *rmdCaptureAudio(ProgData *pdata)
rmdThreadsSetName("rmdCaptureAudio");
//start capturing only after first frame is taken
- nanosleep(&(struct timespec){ .tv_nsec = pdata->frametime * 1000 }, NULL);
+ nanosleep(&(struct timespec){ .tv_nsec = pdata->frametime_us * 1000 }, NULL);
while (pdata->running) {
int sret = 0;
@@ -154,7 +154,7 @@ void *rmdCaptureAudio(ProgData *pdata)
* should get accounted for too FIXME TODO
*/
pthread_mutex_lock(&pdata->avd_mutex);
- pdata->avd -= pdata->periodtime;
+ pdata->avd -= pdata->periodtime_us;
pthread_mutex_unlock(&pdata->avd_mutex);
//queue the new buffer
diff --git a/src/rmd_encode_audio_buffer.c b/src/rmd_encode_audio_buffer.c
index 4e20a1c..db4629f 100644
--- a/src/rmd_encode_audio_buffer.c
+++ b/src/rmd_encode_audio_buffer.c
@@ -175,5 +175,5 @@ void rmdSyncEncodeAudioBuffer(ProgData *pdata, signed char *buff)
if (!pdata->running)
pdata->enc_data->m_ogg_vs.e_o_s = 1;
- pdata->avd -= pdata->periodtime;
+ pdata->avd -= pdata->periodtime_us;
}
diff --git a/src/rmd_encode_image_buffer.c b/src/rmd_encode_image_buffer.c
index cc819aa..a669155 100644
--- a/src/rmd_encode_image_buffer.c
+++ b/src/rmd_encode_image_buffer.c
@@ -119,5 +119,5 @@ void rmdSyncEncodeImageBuffer(ProgData *pdata, unsigned int n_frames)
pthread_mutex_unlock(&pdata->libogg_mutex);
}
- pdata->avd += pdata->frametime * n_frames;
+ pdata->avd += pdata->frametime_us * n_frames;
}
diff --git a/src/rmd_initialize_data.c b/src/rmd_initialize_data.c
index 6f2af89..19a91ee 100644
--- a/src/rmd_initialize_data.c
+++ b/src/rmd_initialize_data.c
@@ -112,7 +112,7 @@ int rmdInitializeData(ProgData *pdata, EncData *enc_data, CacheData *cache_data)
&pdata->args.frequency,
&pdata->args.buffsize,
&pdata->periodsize,
- &pdata->periodtime,
+ &pdata->periodtime_us,
&pdata->hard_pause);
pdata->sound_framesize=(snd_pcm_format_width(SND_PCM_FORMAT_S16_LE) / 8 *
@@ -124,7 +124,7 @@ int rmdInitializeData(ProgData *pdata, EncData *enc_data, CacheData *cache_data)
pdata->args.channels,
pdata->args.frequency);
- pdata->periodtime = (1000000 * pdata->args.buffsize) /
+ pdata->periodtime_us = (1000000 * pdata->args.buffsize) /
((pdata->args.channels<<1) * pdata->args.frequency);
//when using OSS periodsize serves as an alias of buffsize
pdata->periodsize = pdata->args.buffsize;
@@ -154,7 +154,7 @@ int rmdInitializeData(ProgData *pdata, EncData *enc_data, CacheData *cache_data)
pdata->periodsize = pdata->args.buffsize;
pdata->args.frequency = pdata->jdata->frequency;
pdata->args.channels = pdata->jdata->nports;
- pdata->periodtime = 1000000 * pdata->args.buffsize /
+ pdata->periodtime_us = 1000000 * pdata->args.buffsize /
pdata->args.frequency;
pdata->sound_framesize = sizeof(jack_default_audio_sample_t) *
pdata->jdata->nports;
@@ -183,7 +183,7 @@ int rmdInitializeData(ProgData *pdata, EncData *enc_data, CacheData *cache_data)
vblocks = malloc((pdata->enc_data->yuv.y_width / Y_UNIT_WIDTH) *
(pdata->enc_data->yuv.y_height / Y_UNIT_WIDTH));
- pdata->frametime = 1000000 / pdata->args.fps;
+ pdata->frametime_us = 1000000 / pdata->args.fps;
return 0;
diff --git a/src/rmd_opendev.c b/src/rmd_opendev.c
index 3bf9474..c8460d9 100644
--- a/src/rmd_opendev.c
+++ b/src/rmd_opendev.c
@@ -47,7 +47,7 @@ snd_pcm_t *rmdOpenDev( const char *pcm_dev,
unsigned int *frequency,
snd_pcm_uframes_t *buffsize,
snd_pcm_uframes_t *periodsize,
- unsigned int *periodtime,
+ unsigned int *periodtime_us,
int *hard_pause)
{
snd_pcm_t *mhandle;
@@ -126,8 +126,8 @@ snd_pcm_t *rmdOpenDev( const char *pcm_dev,
if (periodsize != NULL)
snd_pcm_hw_params_get_period_size(hwparams, periodsize, 0);
- if (periodtime != NULL)
- snd_pcm_hw_params_get_period_time(hwparams, periodtime, 0);
+ if (periodtime_us != NULL)
+ snd_pcm_hw_params_get_period_time(hwparams, periodtime_us, 0);
fprintf(stderr,
"Recording on device %s is set to:\n%d channels at %dHz\n",
diff --git a/src/rmd_opendev.h b/src/rmd_opendev.h
index 06dfc64..64ec8a5 100644
--- a/src/rmd_opendev.h
+++ b/src/rmd_opendev.h
@@ -46,7 +46,7 @@
*
* \param periodsize Size of a period(can be NULL)
*
-* \param periodtime Duration of a period(can be NULL)
+* \param periodtime_us Duration of a period(can be NULL)
*
* \param hardpause Set to 1 when the device has to be stopped during pause
* and to 0 when it supports pausing
@@ -59,7 +59,7 @@ snd_pcm_t *rmdOpenDev(const char *pcm_dev,
unsigned int *frequency,
snd_pcm_uframes_t *buffsize,
snd_pcm_uframes_t *periodsize,
- unsigned int *periodtime,
+ unsigned int *periodtime_us,
int *hardpause);
#else
/**
diff --git a/src/rmd_rescue.c b/src/rmd_rescue.c
index 82bb8df..dc5ca33 100644
--- a/src/rmd_rescue.c
+++ b/src/rmd_rescue.c
@@ -99,7 +99,7 @@ int rmdRescue(const char *path)
vblocks = malloc(sizeof(*vblocks) * (enc_data.yuv.y_width / Y_UNIT_WIDTH) *
(enc_data.yuv.y_height / Y_UNIT_WIDTH));
- pdata.frametime = 1000000 / pdata.args.fps;
+ pdata.frametime_us = 1000000 / pdata.args.fps;
pthread_mutex_init(&pdata.theora_lib_mutex, NULL);
pthread_mutex_init(&pdata.vorbis_lib_mutex, NULL);
diff --git a/src/rmd_timer.c b/src/rmd_timer.c
index 9936860..8b2e076 100644
--- a/src/rmd_timer.c
+++ b/src/rmd_timer.c
@@ -52,7 +52,7 @@ static void sync_streams(ProgData *pdata, unsigned int *frame_step, struct times
int avd;
pthread_mutex_lock(&pdata->avd_mutex);
- avd = pdata->avd + pdata->frametime;
+ avd = pdata->avd + pdata->frametime_us;
/* There are two knobs available for keeping the video synchronized with the audio:
* 1. frame_step; how many frames to encode from this frame (aka dropping frames if > 1)
@@ -67,20 +67,20 @@ static void sync_streams(ProgData *pdata, unsigned int *frame_step, struct times
*/
if (avd < 0) {
- int frames_behind = -avd / pdata->frametime;
+ int frames_behind = -avd / pdata->frametime_us;
if (frames_behind > 0) {
/* more than a whole frame behind, drop frames to catch up */
*frame_step += frames_behind;
- avd += frames_behind * pdata->frametime;
+ avd += frames_behind * pdata->frametime_us;
} else {
/* less than a whole frame behind, just sleep less */
- *delay = us_to_timespec(pdata->frametime + avd);
+ *delay = us_to_timespec(pdata->frametime_us + avd);
}
} else if (avd > 0) {
/* sleep longer */
- *delay = us_to_timespec(pdata->frametime + avd);
+ *delay = us_to_timespec(pdata->frametime_us + avd);
}
pdata->avd = avd;
diff --git a/src/rmd_types.h b/src/rmd_types.h
index 9be5ca7..6d1f1ba 100644
--- a/src/rmd_types.h
+++ b/src/rmd_types.h
@@ -314,8 +314,8 @@ struct _ProgData {
//later use in YUV buffer
npxl; //this is the no pixel convention
//when drawing the dummy pointer
- unsigned int periodtime,//time that a sound buffer lasts (microsecs)
- frametime; //time that a frame lasts (microsecs)
+ unsigned int periodtime_us, //time that a sound buffer lasts (microsecs)
+ frametime_us; //time that a frame lasts (microsecs)
Window shaped_w; //frame
int damage_event, //damage event base code
damage_error, //damage error base code
© All Rights Reserved