Squeezebox Radio -- Alarm Occasionally Plays Alarm.mp3 Backup Instead Of Correct Audio --- Simple Fix In Player/Source.pm

by ADMIN 122 views

Introduction

Squeezebox radio users have been experiencing an issue where the alarm occasionally plays the backup alarm instead of the specified audio. This problem arises due to the player being in a "paused" state, causing the server to resume the player instead of starting it. As a result, the device does not receive the "strm" command, and playback is not initiated.

Understanding the Issue

The root cause of this problem lies in the Player/Source.pm file, specifically in the _returnPlayMode function. This function returns 'stop' if the player is not powered on, which is not a reliable method. When the player is paused, it is considered "stopped," and the server does not send a "strm" command to the device. Consequently, the device does not start playback, leading to the backup alarm being played instead of the specified audio.

The Simple Fix

To resolve this issue, a simple modification can be made to the Player/Source.pm file. Line 59, which returns 'stop' if the player is not powered on, should be removed. This change ensures that the server uses the isStopped and isPaused methods to determine the correct state of the player. By doing so, the server will always learn the correct state, and the alarm problem will be resolved.

The Code Change

The modified code in Player/Source.pm should look like this:

sub _returnPlayMode {
    my ($self, $client, $mode) = @_;
    return $mode if $mode;
    return 'play' if $self->isPlaying;
    return 'pause' if $self->isPaused;
    return 'stop' if $self->isStopped;
    return 'unknown';
}

Alternative Solutions

If calling isStopped and isPaused is deemed too expensive, an alternative solution can be implemented in Control/Commands.pm. The playControlCommand function can be modified to always call Slim::Player::Source::playmode if the $wantmode is 'stop'. This change ensures that the server will always initiate playback, even if the player is paused.

The Modified Code

The modified code in Control/Commands.pm should look like this:

sub playControlCommand {
    my ($self, $client, $wantmode, $fadeIn) = @_;
    # do we need to do anything?
    if ($wantmode eq 'stop') {
        Slim::Player::Source::playmode($client, $wantmode, undef, undef, $fadeIn);
    } else {
        # existing code
    }
}

Conclusion

Q: What is the Squeezebox radio alarm issue?

A: The Squeezebox radio alarm issue is a problem where the alarm occasionally plays the backup alarm instead of the specified audio. This issue arises due to the player being in a "paused" state, causing the server to resume the player instead of starting it.

Q: Why is the player in a "paused" state?

A: The player is in a "paused" state because the server returns 'stop' if the player is not powered on, which is not a reliable method. When the player is paused, it is considered "stopped," and the server does not send a "strm" command to the device. Consequently, the device does not start playback, leading to the backup alarm being played instead of the specified audio.

Q: How can I fix the Squeezebox radio alarm issue?

A: To fix the Squeezebox radio alarm issue, you can make a simple change to the Player/Source.pm file. Remove line 59, which returns 'stop' if the player is not powered on. This change ensures that the server uses the isStopped and isPaused methods to determine the correct state of the player.

Q: What is the modified code in Player/Source.pm?

A: The modified code in Player/Source.pm should look like this:

sub _returnPlayMode {
    my ($self, $client, $mode) = @_;
    return $mode if $mode;
    return 'play' if $self->isPlaying;
    return 'pause' if $self->isPaused;
    return 'stop' if $self->isStopped;
    return 'unknown';
}

Q: What is an alternative solution to fix the Squeezebox radio alarm issue?

A: An alternative solution is to modify the Control/Commands.pm file to always call Slim::Player::Source::playmode if the $wantmode is 'stop'. This change ensures that the server will always initiate playback, even if the player is paused.

Q: What is the modified code in Control/Commands.pm?

A: The modified code in Control/Commands.pm should look like this:

sub playControlCommand {
    my ($self, $client, $wantmode, $fadeIn) = @_;
    # do we need to do anything?
    if ($wantmode eq 'stop') {
        Slim::Player::Source::playmode($client, $wantmode, undef, undef, $fadeIn);
    } else {
        # existing code
    }
}

Q: Why is this solution better than a firmware hack?

A: This solution is better than a firmware hack because it provides a straightforward and reliable fix to the Squeezebox radio alarm issue. By modifying the Player/Source.pm and Control/Commands.pm files, you can ensure that the server always learns the correct state of the player and initiates playback correctly.

Q: Can I test this solution before implementing it?

A: Yes, you can test this solution before implementing it. Simply make the modifications to the Player/Source.pm and Control/Commands.pm files, and then test the Squeezebox radio alarm functionality to ensure that it is working correctly.