File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,8 @@ MP3 in most cases.
217217 The returned time only represents how long the music has been playing; it
218218 does not take into account any starting position offsets.
219219
220+ Returns -1 if ``get_pos `` failed due to music not playing.
221+
220222 .. ## pygame.mixer.music.get_pos ##
221223
222224 .. function :: queue
Original file line number Diff line number Diff line change @@ -252,12 +252,13 @@ music_get_pos(PyObject *self, PyObject *_null)
252252
253253 MIXER_INIT_CHECK ();
254254
255- if (music_pos_time < 0 )
255+ Uint16 intermediate_step = (music_format & 0xff ) >> 3 ;
256+ long denominator = music_channels * music_frequency * intermediate_step ;
257+ if (music_pos_time < 0 || denominator == 0 ) {
256258 return PyLong_FromLong (-1 );
259+ }
257260
258- ticks = (long )(1000 * music_pos /
259- (music_channels * music_frequency *
260- ((music_format & 0xff ) >> 3 )));
261+ ticks = (long )(1000 * music_pos / denominator );
261262 if (!Mix_PausedMusic ())
262263 ticks += PG_GetTicks () - music_pos_time ;
263264
You can’t perform that action at this time.
0 commit comments