Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cubeb_opensl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct cubeb_stream {
uint32_t framesize;
/* Total number of played frames.
* Synchronized by stream::mutex lock. */
long written;
int64_t written;
/* Flag indicating draining. Synchronized
* by stream::mutex lock. */
int draining;
Expand Down Expand Up @@ -1856,12 +1856,12 @@ opensl_stream_get_position(cubeb_stream * stm, uint64_t * position)
uint64_t samplerate = stm->user_output_rate;
uint32_t output_latency = stm->output_latency_ms;

XASSERT(stm->written >= 0);
XASSERT(stm->user_output_rate > 0);
XASSERT(stm->output_configured_rate > 0);
pthread_mutex_lock(&stm->mutex);
int64_t maximum_position = stm->written * (int64_t)stm->user_output_rate /
stm->output_configured_rate;
XASSERT(stm->written >= 0);
int64_t maximum_position =
stm->written * stm->user_output_rate / stm->output_configured_rate;
Comment on lines +1863 to +1864
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By my calculation for a high rate (384kHz) stm->written * stm->user_output_rate will overflow after 723 days. At 768kHz I get 180 days. Should be ok.

pthread_mutex_unlock(&stm->mutex);
XASSERT(maximum_position >= 0);

Expand Down
Loading