diff options
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/apps/playback.c b/apps/playback.c index 80a0585b17..eba90f9a0a 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -334,17 +334,18 @@ enum audio_start_playback_flags | |||
334 | static void audio_start_playback(const struct audio_resume_info *resume_info, | 334 | static void audio_start_playback(const struct audio_resume_info *resume_info, |
335 | unsigned int flags); | 335 | unsigned int flags); |
336 | static void audio_stop_playback(void); | 336 | static void audio_stop_playback(void); |
337 | static void buffer_event_buffer_low_callback(void *data); | 337 | static void buffer_event_buffer_low_callback(unsigned short id, void *data, void *user_data); |
338 | static void buffer_event_rebuffer_callback(void *data); | 338 | static void buffer_event_rebuffer_callback(unsigned short id, void *data); |
339 | static void buffer_event_finished_callback(void *data); | 339 | static void buffer_event_finished_callback(unsigned short id, void *data); |
340 | void audio_pcmbuf_sync_position(void); | 340 | void audio_pcmbuf_sync_position(void); |
341 | 341 | ||
342 | 342 | ||
343 | /**************************************/ | 343 | /**************************************/ |
344 | 344 | ||
345 | /** --- voice event --- **/ | 345 | /** --- voice event --- **/ |
346 | void playback_voice_event(void *data) | 346 | void playback_voice_event(unsigned short id, void *data) |
347 | { | 347 | { |
348 | (void)id; | ||
348 | /* Make audio play softly while voice is speaking */ | 349 | /* Make audio play softly while voice is speaking */ |
349 | pcmbuf_soft_mode(*(bool *)data); | 350 | pcmbuf_soft_mode(*(bool *)data); |
350 | } | 351 | } |
@@ -1757,7 +1758,7 @@ static int audio_load_track(void) | |||
1757 | should have been cleared already */ | 1758 | should have been cleared already */ |
1758 | logf("%s(): finishing load: %d", __func__, info->id3_hid); | 1759 | logf("%s(): finishing load: %d", __func__, info->id3_hid); |
1759 | filling = STATE_FILLING; | 1760 | filling = STATE_FILLING; |
1760 | buffer_event_finished_callback(&info->id3_hid); | 1761 | buffer_event_finished_callback(BUFFER_EVENT_FINISHED, &info->id3_hid); |
1761 | return LOAD_TRACK_OK; | 1762 | return LOAD_TRACK_OK; |
1762 | } | 1763 | } |
1763 | } | 1764 | } |
@@ -2585,8 +2586,8 @@ static void audio_start_playback(const struct audio_resume_info *resume_info, | |||
2585 | 2586 | ||
2586 | /* Add these now - finish event for the first id3 will most likely be sent | 2587 | /* Add these now - finish event for the first id3 will most likely be sent |
2587 | immediately */ | 2588 | immediately */ |
2588 | add_event(BUFFER_EVENT_REBUFFER, false, buffer_event_rebuffer_callback); | 2589 | add_event(BUFFER_EVENT_REBUFFER, buffer_event_rebuffer_callback); |
2589 | add_event(BUFFER_EVENT_FINISHED, false, buffer_event_finished_callback); | 2590 | add_event(BUFFER_EVENT_FINISHED, buffer_event_finished_callback); |
2590 | 2591 | ||
2591 | if (old_status == PLAY_STOPPED) | 2592 | if (old_status == PLAY_STOPPED) |
2592 | { | 2593 | { |
@@ -2647,7 +2648,7 @@ static void audio_stop_playback(void) | |||
2647 | /* Close all tracks and mark them NULL */ | 2648 | /* Close all tracks and mark them NULL */ |
2648 | remove_event(BUFFER_EVENT_REBUFFER, buffer_event_rebuffer_callback); | 2649 | remove_event(BUFFER_EVENT_REBUFFER, buffer_event_rebuffer_callback); |
2649 | remove_event(BUFFER_EVENT_FINISHED, buffer_event_finished_callback); | 2650 | remove_event(BUFFER_EVENT_FINISHED, buffer_event_finished_callback); |
2650 | remove_event(BUFFER_EVENT_BUFFER_LOW, buffer_event_buffer_low_callback); | 2651 | remove_event_ex(BUFFER_EVENT_BUFFER_LOW, buffer_event_buffer_low_callback, NULL); |
2651 | 2652 | ||
2652 | track_list_clear(TRACK_LIST_CLEAR_ALL); | 2653 | track_list_clear(TRACK_LIST_CLEAR_ALL); |
2653 | 2654 | ||
@@ -3164,8 +3165,8 @@ void audio_playback_handler(struct queue_event *ev) | |||
3164 | /* End of buffering for now, let's calculate the watermark, | 3165 | /* End of buffering for now, let's calculate the watermark, |
3165 | register for a low buffer event and unboost */ | 3166 | register for a low buffer event and unboost */ |
3166 | audio_update_filebuf_watermark(0); | 3167 | audio_update_filebuf_watermark(0); |
3167 | add_event(BUFFER_EVENT_BUFFER_LOW, true, | 3168 | add_event_ex(BUFFER_EVENT_BUFFER_LOW, true, |
3168 | buffer_event_buffer_low_callback); | 3169 | buffer_event_buffer_low_callback, NULL); |
3169 | } | 3170 | } |
3170 | /* Fall-through */ | 3171 | /* Fall-through */ |
3171 | case STATE_FINISHED: | 3172 | case STATE_FINISHED: |
@@ -3200,27 +3201,31 @@ void audio_playback_handler(struct queue_event *ev) | |||
3200 | /* --- Buffering callbacks --- */ | 3201 | /* --- Buffering callbacks --- */ |
3201 | 3202 | ||
3202 | /* Called when fullness is below the watermark level */ | 3203 | /* Called when fullness is below the watermark level */ |
3203 | static void buffer_event_buffer_low_callback(void *data) | 3204 | static void buffer_event_buffer_low_callback(unsigned short id, void *ev_data, void *user_data) |
3204 | { | 3205 | { |
3205 | logf("low buffer callback"); | 3206 | logf("low buffer callback"); |
3206 | LOGFQUEUE("buffering > audio Q_AUDIO_BUFFERING: buffer low"); | 3207 | LOGFQUEUE("buffering > audio Q_AUDIO_BUFFERING: buffer low"); |
3207 | audio_queue_post(Q_AUDIO_BUFFERING, BUFFER_EVENT_BUFFER_LOW); | 3208 | audio_queue_post(Q_AUDIO_BUFFERING, BUFFER_EVENT_BUFFER_LOW); |
3208 | (void)data; | 3209 | (void)id; |
3210 | (void)ev_data; | ||
3211 | (void)user_data; | ||
3209 | } | 3212 | } |
3210 | 3213 | ||
3211 | /* Called when handles must be discarded in order to buffer new data */ | 3214 | /* Called when handles must be discarded in order to buffer new data */ |
3212 | static void buffer_event_rebuffer_callback(void *data) | 3215 | static void buffer_event_rebuffer_callback(unsigned short id, void *ev_data) |
3213 | { | 3216 | { |
3214 | logf("rebuffer callback"); | 3217 | logf("rebuffer callback"); |
3215 | LOGFQUEUE("buffering > audio Q_AUDIO_BUFFERING: rebuffer"); | 3218 | LOGFQUEUE("buffering > audio Q_AUDIO_BUFFERING: rebuffer"); |
3216 | audio_queue_post(Q_AUDIO_BUFFERING, BUFFER_EVENT_REBUFFER); | 3219 | audio_queue_post(Q_AUDIO_BUFFERING, BUFFER_EVENT_REBUFFER); |
3217 | (void)data; | 3220 | (void)id; |
3221 | (void)ev_data; | ||
3218 | } | 3222 | } |
3219 | 3223 | ||
3220 | /* A handle has completed buffering and all required data is available */ | 3224 | /* A handle has completed buffering and all required data is available */ |
3221 | static void buffer_event_finished_callback(void *data) | 3225 | static void buffer_event_finished_callback(unsigned short id, void *ev_data) |
3222 | { | 3226 | { |
3223 | int hid = *(const int *)data; | 3227 | (void)id; |
3228 | int hid = *(const int *)ev_data; | ||
3224 | const enum data_type htype = buf_handle_data_type(hid); | 3229 | const enum data_type htype = buf_handle_data_type(hid); |
3225 | 3230 | ||
3226 | logf("handle %d finished buffering (type:%u)", hid, (unsigned)htype); | 3231 | logf("handle %d finished buffering (type:%u)", hid, (unsigned)htype); |
@@ -3717,7 +3722,7 @@ void INIT_ATTR playback_init(void) | |||
3717 | track_list_init(); | 3722 | track_list_init(); |
3718 | buffering_init(); | 3723 | buffering_init(); |
3719 | pcmbuf_update_frequency(); | 3724 | pcmbuf_update_frequency(); |
3720 | add_event(PLAYBACK_EVENT_VOICE_PLAYING, false, playback_voice_event); | 3725 | add_event(PLAYBACK_EVENT_VOICE_PLAYING, playback_voice_event); |
3721 | #ifdef HAVE_CROSSFADE | 3726 | #ifdef HAVE_CROSSFADE |
3722 | /* Set crossfade setting for next buffer init which should be about... */ | 3727 | /* Set crossfade setting for next buffer init which should be about... */ |
3723 | pcmbuf_request_crossfade_enable(global_settings.crossfade); | 3728 | pcmbuf_request_crossfade_enable(global_settings.crossfade); |