diff options
Diffstat (limited to 'streamer.c')
-rw-r--r-- | streamer.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -40,6 +40,12 @@ //#define trace(...) { fprintf(stderr, __VA_ARGS__); } #define trace(fmt,...) +// #define WRITE_DUMP 1 + +#if WRITE_DUMP +FILE *out; +#endif + static intptr_t streamer_tid; static int src_quality; static SRC_STATE *src; @@ -500,7 +506,14 @@ streamer_move_to_randomsong (void) { trace ("empty playlist\n"); return -1; } + int curr = str_get_idx_of (playing_track); int r = rand () / (float)RAND_MAX * cnt; + if (r == curr) { + r++; + if (r >= cnt) { + r = 0; + } + } streamer_set_nextsong (r, 1); return 0; } @@ -805,6 +818,19 @@ streamer_start_new_song (void) { } } else if (pstate == 2) { + if (p_get_state () == OUTPUT_STATE_STOPPED) { + last_bitrate = -1; + avg_bitrate = -1; + streamer_reset (1); + if (fileinfo) { + plug_get_output ()->change_rate (fileinfo->samplerate); + } + if (p_play () < 0) { + fprintf (stderr, "streamer: failed to start playback; output plugin doesn't work\n"); + streamer_set_nextsong (-2, 0); + return; + } + } p_pause (); } } @@ -1083,6 +1109,9 @@ streamer_thread (void *ctx) { int streamer_init (void) { +#if WRITE_DUMP + out = fopen ("out.raw", "w+b"); +#endif mutex = mutex_create (); decodemutex = mutex_create (); srcmutex = mutex_create (); @@ -1099,6 +1128,9 @@ streamer_init (void) { void streamer_free (void) { +#if WRITE_DUMP + fclose (out); +#endif streamer_abort_files (); streaming_terminate = 1; thread_join (streamer_tid); @@ -1616,6 +1648,9 @@ streamer_read (char *bytes, int size) { int ms = (tm2.tv_sec*1000+tm2.tv_usec/1000) - (tm1.tv_sec*1000+tm1.tv_usec/1000); printf ("streamer_read took %d ms\n", ms); #endif +#if WRITE_DUMP + fwrite (bytes, 1, sz, out); +#endif return sz; } |