From e0c2c77c2ab1fcd65b18a4c8c71b34b2b8652900 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 22 Mar 2013 07:05:00 +0100 Subject: ffmpeg decoder plugin: do not allocate an AVFrame on stack. AVFrame must be allocated with avcodec_alloc_frame(). --- src/decoder/ffmpeg_decoder_plugin.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 4c4cb2b81..fcf7507f4 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -318,20 +318,33 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, cmd == DECODE_COMMAND_NONE) { int audio_size = buffer_size; #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0) - AVFrame frame; + + AVFrame *frame = avcodec_alloc_frame(); + if (frame == NULL) { + g_warning("Could not allocate frame"); + break; + } + int got_frame = 0; int len = avcodec_decode_audio4(codec_context, - &frame, &got_frame, + frame, &got_frame, &packet2); if (len >= 0 && got_frame) { audio_size = copy_interleave_frame(codec_context, - &frame, + frame, aligned_buffer, buffer_size); if (audio_size < 0) len = audio_size; } else if (len >= 0) len = -1; + +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0) + avcodec_free_frame(&frame); +#else + av_freep(&frame); +#endif + #elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0) int len = avcodec_decode_audio3(codec_context, aligned_buffer, &audio_size, -- cgit v1.2.3 From a30eb194d5c5188a0e824e72ce959677d5801c0a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 8 Apr 2013 21:30:32 +0200 Subject: command: don't print undefined audio_format Check audio_format_defined(). --- src/command.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/command.c b/src/command.c index c405925f2..472571006 100644 --- a/src/command.c +++ b/src/command.c @@ -381,18 +381,21 @@ handle_status(struct client *client, song, playlist_get_song_id(&g_playlist, song)); } - if (player_status.state != PLAYER_STATE_STOP) { - struct audio_format_string af_string; - + if (player_status.state != PLAYER_STATE_STOP) client_printf(client, COMMAND_STATUS_TIME ": %i:%i\n" "elapsed: %1.3f\n" - COMMAND_STATUS_BITRATE ": %u\n" - COMMAND_STATUS_AUDIO ": %s\n", + COMMAND_STATUS_BITRATE ": %u\n", (int)(player_status.elapsed_time + 0.5), (int)(player_status.total_time + 0.5), player_status.elapsed_time, - player_status.bit_rate, + player_status.bit_rate); + + if (audio_format_defined(&player_status.audio_format)) { + struct audio_format_string af_string; + + client_printf(client, + COMMAND_STATUS_AUDIO ": %s\n", audio_format_to_string(&player_status.audio_format, &af_string)); } -- cgit v1.2.3 From 436335e9a3251cbfe42848843e1acea33d22177c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 8 Apr 2013 21:22:06 +0200 Subject: player_control: don't emit IDLE_PLAYER before audio format is known Eliminates one IDLE_PLAYER call in playlist_control, and add two new ones to player_thread. Fixes Mantis bug 3636. --- src/player_control.c | 2 -- src/player_thread.c | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/player_control.c b/src/player_control.c index 90f616d77..b18639087 100644 --- a/src/player_control.c +++ b/src/player_control.c @@ -127,8 +127,6 @@ pc_play(struct player_control *pc, struct song *song) assert(pc->next_song == NULL); player_unlock(pc); - - idle_add(IDLE_PLAYER); } void diff --git a/src/player_thread.c b/src/player_thread.c index 593788caf..ac0b0579e 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -313,6 +313,8 @@ player_open_output(struct player *player) pc->state = PLAYER_STATE_PLAY; player_unlock(pc); + idle_add(IDLE_PLAYER); + return true; } else { player->output_open = false; @@ -375,6 +377,8 @@ player_check_decoder_startup(struct player *player) pc->audio_format = dc->in_audio_format; player_unlock(pc); + idle_add(IDLE_PLAYER); + player->play_audio_format = dc->out_audio_format; player->decoder_starting = false; -- cgit v1.2.3 From cd71038655677878205a9532dd91667c5ac8b1b8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 8 Apr 2013 22:00:35 +0200 Subject: command: don't check audio_format if not playing Fixes valgrind warning. --- src/command.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/command.c b/src/command.c index 472571006..34ec87247 100644 --- a/src/command.c +++ b/src/command.c @@ -381,7 +381,7 @@ handle_status(struct client *client, song, playlist_get_song_id(&g_playlist, song)); } - if (player_status.state != PLAYER_STATE_STOP) + if (player_status.state != PLAYER_STATE_STOP) { client_printf(client, COMMAND_STATUS_TIME ": %i:%i\n" "elapsed: %1.3f\n" @@ -391,13 +391,14 @@ handle_status(struct client *client, player_status.elapsed_time, player_status.bit_rate); - if (audio_format_defined(&player_status.audio_format)) { - struct audio_format_string af_string; + if (audio_format_defined(&player_status.audio_format)) { + struct audio_format_string af_string; - client_printf(client, - COMMAND_STATUS_AUDIO ": %s\n", - audio_format_to_string(&player_status.audio_format, - &af_string)); + client_printf(client, + COMMAND_STATUS_AUDIO ": %s\n", + audio_format_to_string(&player_status.audio_format, + &af_string)); + } } if ((updateJobId = isUpdatingDB())) { -- cgit v1.2.3