Mercurial > audlegacy-plugins
comparison src/madplug/decoder.c @ 807:0f9c8d4d3ac4 trunk
[svn] - make use of new millisecond seek API.
| author | yaz |
|---|---|
| date | Mon, 12 Mar 2007 11:03:24 -0700 |
| parents | 93dbfe1f0cd0 |
| children | f0846bdd9de6 |
comparison
equal
deleted
inserted
replaced
| 806:74abcb9cafae | 807:0f9c8d4d3ac4 |
|---|---|
| 507 if (info->seek != -1 && info->size > 0) { | 507 if (info->seek != -1 && info->size > 0) { |
| 508 #ifdef DEBUG | 508 #ifdef DEBUG |
| 509 g_message("seeking: %d", info->seek); | 509 g_message("seeking: %d", info->seek); |
| 510 #endif | 510 #endif |
| 511 int new_position; | 511 int new_position; |
| 512 int seconds = | 512 gulong milliseconds = |
| 513 mad_timer_count(info->duration, MAD_UNITS_SECONDS); | 513 mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS); |
| 514 if (info->seek >= seconds) | 514 if (info->seek >= milliseconds) |
| 515 info->seek = seconds; | 515 info->seek = milliseconds; |
| 516 | 516 |
| 517 mad_timer_set(&info->pos, info->seek, 0, 0); | 517 mad_timer_set(&info->pos, 0, info->seek, 1000); // in millisecond |
| 518 new_position = | 518 new_position = |
| 519 ((double) info->seek / (double) seconds) * info->size; | 519 ((double) info->seek / (double) milliseconds) * info->size; |
| 520 | 520 |
| 521 if(new_position < 0) | 521 if(new_position < 0) |
| 522 new_position = 0; | 522 new_position = 0; |
| 523 #ifdef DEBUG | 523 #ifdef DEBUG |
| 524 g_message("seeking to: %d bytes", new_position); | 524 g_message("seeking to: %d bytes", new_position); |
| 642 #ifdef DEBUG | 642 #ifdef DEBUG |
| 643 g_message("f: buffer_playing=%d", | 643 g_message("f: buffer_playing=%d", |
| 644 info->playback->output->buffer_playing()); | 644 info->playback->output->buffer_playing()); |
| 645 #endif | 645 #endif |
| 646 g_get_current_time(&sleeptime); | 646 g_get_current_time(&sleeptime); |
| 647 sleeptime.tv_usec += 500000; | 647 g_time_val_add(&sleeptime, 500000); |
| 648 if(sleeptime.tv_usec >= 1000000) { | 648 |
| 649 sleeptime.tv_sec += 1; | |
| 650 sleeptime.tv_usec -= 1000000; | |
| 651 } | |
| 652 | |
| 653 g_mutex_lock(mad_mutex); | 649 g_mutex_lock(mad_mutex); |
| 654 g_cond_timed_wait(mad_cond, mad_mutex, &sleeptime); | 650 g_cond_timed_wait(mad_cond, mad_mutex, &sleeptime); |
| 655 if (!info->playback->playing) { | 651 if (!info->playback->playing) { |
| 656 g_mutex_unlock(mad_mutex); | 652 g_mutex_unlock(mad_mutex); |
| 657 break; | 653 break; |
